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

SDL2 and SDL example from action not detecting controller in Android 14 #9831

Open
ikhoeyZX opened this issue May 18, 2024 · 18 comments
Open
Milestone

Comments

@ikhoeyZX
Copy link

Hello

it seems like Android 14 broken any USB controller in SDL
i did tried in amdroid 13 or lower and my controller working
only in Android 14 are not detecting
Screenshot_20240518_221118_testcontroller

@slouken
Copy link
Collaborator

slouken commented May 18, 2024

@AntTheAlchemist, are you seeing this as well?

@slouken slouken added this to the 2.32.0 milestone May 18, 2024
@AntTheAlchemist
Copy link
Contributor

I don't have a physical Android 14 device (and emulators don't have USB), but if there was an issue with SDL on a specific version of Android, it would reflect on the feedback on my Game Controller Tester app which is live on Google Play. No one has reported any issues and the ratings don't show a specific version problem (4.8 stars on Android 14, 4.3 Android 13, 4.8 Android 12...). It may be a problem with the test app? Rendering issue?

@ikhoeyZX
Copy link
Author

btw other emulator like vita3k have same problem (and it using SDL2)
Only in Android 14 usb not detected

i did tried merge from example SDL android HIDManager, but still same result

@ikhoeyZX
Copy link
Author

ikhoeyZX commented May 19, 2024

I don't have a physical Android 14 device (and emulators don't have USB), but if there was an issue with SDL on a specific version of Android, it would reflect on the feedback on my Game Controller Tester app which is live on Google Play. No one has reported any issues and the ratings don't show a specific version problem (4.8 stars on Android 14, 4.3 Android 13, 4.8 Android 12...). It may be a problem with the test app? Rendering issue?

intent issue maybe, because i did test your app and it firing USB intent
it should be popup this menu

Screenshot_20240519_171354

@madebr
Copy link
Contributor

madebr commented May 19, 2024

This is the manifest used for the tests built on actions: https://github.com/libsdl-org/SDL/blob/main/test/android/cmake/AndroidManifest.xml.cmake
Can you please give it a sanity test?

@AntTheAlchemist
Copy link
Contributor

@ikhoeyZX, the pop-up that asks "Allow ... to access Wireless Controller" is caused by the BLUETOOTH & BLUETOOTH_CONNECT manifest entries. They are only needed for Steam Controllers and are not required. I added them to my app very recently, and it was working before I added them.

I think it might be a setting in the project.

@ikhoeyZX
Copy link
Author

@ikhoeyZX, the pop-up that asks "Allow ... to access Wireless Controller" is caused by the BLUETOOTH & BLUETOOTH_CONNECT manifest entries. They are only needed for Steam Controllers and are not required. I added them to my app very recently, and it was working before I added them.

I think it might be a setting in the project.

still same result

@AntTheAlchemist
Copy link
Contributor

still same result

@ikhoeyZX Yes, them manifest entries won't be the problem.

I don't understand how you're using USB on an emulator though? Nothing I plug into my PC is transferred over to the emulator...

@ikhoeyZX
Copy link
Author

ikhoeyZX commented May 20, 2024

still same result

@ikhoeyZX Yes, them manifest entries won't be the problem.

I don't understand how you're using USB on an emulator though? Nothing I plug into my PC is transferred over to the emulator...

not in android emulator (because my pc cant run android studio)
but real hardware (samsung m33)
sdl app are used in vita3k emulator.
this is bug what i encounter : Vita3K/Vita3K-Android#625
i did ask dev and they still dont know how to fix it since he doesnt have android 14

@AntTheAlchemist
Copy link
Contributor

Please note that prompt isn't the reason why my app is working on Android 14. That prompt is only needed for Steam controllers.

So, my SDL3 app can see game controllers on Android 14, but other apps can't, but they can on other Android versions? Including SDL3's test app?

Which version of SDL are you using to test?

I don't think I'm doing anything special to get this working. The test app's manifest looks fine. It looks like it's something else in the project setting, but there are too many options to guess. If you have the time, you can try to get your project to match my settings as closely as possible (I'll just cut-paste some relevant settings from my project):

- gradle-8.7-bin
-     compileSdk 34
-         minSdkVersion 16
-         targetSdkVersion 34
- com.android.tools.build:gradle:8.2.2
-     <uses-feature android:name="android.hardware.bluetooth" android:required="false" />
-     <uses-feature android:name="android.hardware.gamepad" android:required="false" />
-     <uses-feature android:name="android.hardware.type.pc" android:required="false" />
-     <uses-feature android:name="android.hardware.usb.host" android:required="false" />
-                 <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />

@madebr
Copy link
Contributor

madebr commented May 20, 2024

The manifest of the action apks contains the same items, so that shouldn't be it.

However, they have a target sdk version of 31, but don't set a minimum sdk version.

TARGET_SDK_VERSION 31

@ikhoeyZX
Replace TARGET_SDK_VERSION 31 with TARGET_SDK_VERSION 34 MIN_SDK_VERSION 16 to reproduce ant's configuration (ignoring gradle).

@ikhoeyZX
Copy link
Author

like this?

  minSdk 16
  targetSdk 34

in build.gradle ?

@AntTheAlchemist
Copy link
Contributor

AntTheAlchemist commented May 20, 2024

In case hints might affect it, here are the relevant hints I'm using:

	SDL_SetHint(SDL_HINT_TV_REMOTE_AS_JOYSTICK, "0");
	SDL_SetHint(SDL_HINT_GAMECONTROLLER_SENSOR_FUSION, "0");
	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "0");
	SDL_SetHint(SDL_HINT_JOYSTICK_ROG_CHAKRAM, "1");
	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "1");
	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3_SIXAXIS_DRIVER, "1");
	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_STEAM, "1");
	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
	SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1");
	SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, SDL_FALSE);
	SDL_SetEventEnabled(SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, SDL_FALSE);

@AntTheAlchemist
Copy link
Contributor

@ikhoeyZX, this is my build.gradle, but yours may look different:

android {
    compileSdk 34
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 34

@ikhoeyZX
Copy link
Author

@ikhoeyZX, this is my build.gradle, but yours may look different:

android {
    compileSdk 34
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 34

okay, i'm gonna test compile with minsdk 16 (before was 28)

@AntTheAlchemist
Copy link
Contributor

okay, i'm gonna test compile with minsdk 16 (before was 28)

You may struggle to get it to compile with min 16 if there are dependencies that have a higher minimum. I've had to limit myself to older versions of some, to retain min 16:

    implementation 'com.android.billingclient:billing:6.0.1' // do not update beyond 6.0.1
    implementation 'com.google.android.gms:play-services-ads-lite:20.6.0' // do not update beyond 20.6.0

The minimumSdkVersion is not important - it shouldn't affect the problem, I should think.

@ikhoeyZX
Copy link
Author

nothing works with all suggestion
seems like SDL2 problem
I will wait until vita3k dev upgrade to SDL3

@AntTheAlchemist
Copy link
Contributor

AntTheAlchemist commented May 22, 2024

It's still a problem if it's SDL2, because it shares a lot of code with SDL3. It's likely the problem will still persist when they upgrade to SDL3.

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

No branches or pull requests

4 participants