Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android support #330

Closed
wants to merge 3 commits into from
Closed

Conversation

enfipy
Copy link

@enfipy enfipy commented Jan 18, 2022

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
Copy link
Author

enfipy commented Jan 18, 2022

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
Copy link
Member

orhun commented Jan 18, 2022

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
Copy link
Author

enfipy commented Jan 18, 2022

@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
Copy link
Member

orhun commented Jan 18, 2022

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

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

@enfipy
Copy link
Author

enfipy commented Jan 18, 2022

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
Copy link
Member

orhun commented Jan 18, 2022

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

@olefasting
Copy link
Member

olefasting commented Jan 21, 2022

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