Skip to content

Add android support#330

Closed
enfipy wants to merge 3 commits into
fishfolk:main_borkedfrom
enfipy:add-crossbundle
Closed

Add android support#330
enfipy wants to merge 3 commits into
fishfolk:main_borkedfrom
enfipy:add-crossbundle

Conversation

@enfipy

@enfipy enfipy commented Jan 18, 2022

Copy link
Copy Markdown

This draft pull request is a quick try to add android support to FishFight. Currently, blocked by the following error:

01-18 21:12:43.619 10287 10287 I SAPP    : NativeActivity onInputQueueCreated()
01-18 21:12:43.639 10287 10287 I SAPP    : NativeActivity onNativeWindowCreated()
01-18 21:12:43.639 10287 10310 I SAPP    : Creating egl surface
01-18 21:12:43.788 10287 10310 I SAPP    : ... ok!
01-18 21:12:44.110 10287 10287 I SAPP    : NativeActivity onFocusChange()
01-18 21:12:55.938 10287 10310 E SAPP    : PanicInfo { payload: Any { .. }, message: Some(called `Result::unwrap()` on an `Err` value: "Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"), location: Location { file: "src/__mainxZRTw7", line: 125, col: 65 } }

Also, as a temporary workaround, I changed assets dir in main.rs as I couldn't fastly set ASSETS_DIR_ENV_VAR.

To reproduce this error - you will need to build sdl2 (this helped me) from source with this command: ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_PLATFORM=android-18 (if you are on m1 mac - see this), and place libs/arm64-v8a/libSDL2.so in your target/aarch64-linux-android/<PROFILE>/tools/libSDL2.so. Then install crossbundle (or cargo-quad-apk, I think it will work too right now) and run crossbundle run android --quad.

Currently, crashing on this stage:
Screenshot 2022-01-18 at 21 36 44

@erlend-sh 👋

@enfipy

enfipy commented Jan 18, 2022

Copy link
Copy Markdown
Author

I just checked that sdl2 is only used for gamepad controlling - maybe it's easier to replace it with gilrs in fishsticks and FishFight.

Update: No, gilrs doesn't support android -_-

@orhun

orhun commented Jan 18, 2022

Copy link
Copy Markdown
Member

I just checked that sdl2 is only used for gamepad controlling - maybe it's easier to replace it with gilrs in fishsticks and FishFight.

We could do this:

fishsticks = { version = "0.2.0", default-features = false, features = ["gilrs"] }

However, this will require some refactoring due to regression:

133 | ...                   && (gamepad.analog_inputs.digital_value(Axis::LeftX) < 0.0
    |                                                                     ^^^^^
    |                                                                     |
    |                                                                     variant or associated item not found in `Axis`
    |                                                                     help: there is a variant with a similar name: `LeftZ`

Also, gilrs not seems to support Android as well. Do you think we will be able to build fine even if we make the switch?

Edit: Just saw the update on your message. I guess the answer is no 😄

@enfipy

enfipy commented Jan 18, 2022

Copy link
Copy Markdown
Author

@orhun Funny, but I already fixed those errors and got the following error:

01-18 22:03:25.556 12026 12069 E SAPP    : PanicInfo { payload: Any { .. }, message: Some(called `Result::unwrap()` on an `Err` value: "Gilrs does not support current platform."), location: Location { file: "src/_mainCgin7I", line: 125, col: 65 } }
01-18 22:03:27.085 12026 12026 I SAPP    : NativeActivity onFocusChange()

@orhun

orhun commented Jan 18, 2022

Copy link
Copy Markdown
Member

Definitely interesting... 🤔 Maybe it is worth reporting to upstream?

Either way, if it's not supported then it is not supported. 🤷🏼

@enfipy

enfipy commented Jan 18, 2022

Copy link
Copy Markdown
Author

Patched with gilrs that doesn't throw an error on an unsupported platform and got this:

Screenshot 2022-01-18 at 22 22 10

I think this is not really how the game should look, but it rendered something and has no errors.

@orhun

orhun commented Jan 18, 2022

Copy link
Copy Markdown
Member

It looks like the menu items are gone. I assume nothing happens when you click on the area, right?

@olefasting

olefasting commented Jan 21, 2022

Copy link
Copy Markdown
Member

Patched with gilrs that doesn't throw an error on an unsupported platform and got this:

I think this is not really how the game should look, but it rendered something and has no errors.

Do you know if the game freezes/locks up when this happens? Seems to me like it has issues with building the menu and it is probably connected to input (menus use gamepad input for navigation), after transition to gilrs. I implemented the menu builder and the menu elements, so if you need any assistance to integrate them with gilrs, give me a shout

@erlend-sh

Copy link
Copy Markdown
Member

Due to the #466 Bevy Rewrite this work is defunct, but the contribution is recognized and remains appreciated! 🙏

@erlend-sh erlend-sh closed this Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants