jumpy icon indicating copy to clipboard operation
jumpy copied to clipboard

Add android support

Open enfipy opened this issue 3 years ago • 7 comments

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 avatar Jan 18 '22 19:01 enfipy

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 -_-

enfipy avatar Jan 18 '22 19:01 enfipy

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 😄

orhun avatar Jan 18 '22 20:01 orhun

@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()

enfipy avatar Jan 18 '22 20:01 enfipy

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

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

orhun avatar Jan 18 '22 20:01 orhun

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.

enfipy avatar Jan 18 '22 20:01 enfipy

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

orhun avatar Jan 18 '22 20:01 orhun

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

olefasting avatar Jan 21 '22 12:01 olefasting

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

erlend-sh avatar Nov 20 '22 20:11 erlend-sh