touchHLE
touchHLE copied to clipboard
Accelerometer not working on Android on some phones
It feels like version v0.2.0 is not very complete, some games like some games are not compatible and only some games are in the active list and there are a few versions that don't work, can't tilt the phone left or right to play racing and play games that require tilting and shaking the phone. Hopefully v0.3.0 will fix these 2 bugs
gotta name it v0.0.0.0.2 to get the point across some people apparently
some games are not compatible and only some games are in the active list
This emulator will never work with all early iPhone OS titles, and supporting a large number of them requires a huge amount of work. If someone told you that this emulator can run any iOS game, then please complain to them, not me. Obviously, I want to support more titles, but it's not like I can just snap my fingers and suddenly the entire library is available. Emulator development is not fast or easy.
can't tilt the phone left or right to play racing
The accelerometer is supposed to work, and it does for me. Can you tell me what phone you have, and what version of Android it's running?
Apparently someone has this issue on the “Redmi Note 9 4GB/128GB, running Android 12 and MIUI 13”. The highest Android version I've tested myself was Android 11, so perhaps that could be the problem.
Apparently someone has this issue on the “Redmi Note 9 4GB/128GB, running Android 12 and MIUI 13”. The highest Android version I've tested myself was Android 11, so perhaps that could be the problem.
I was about to open an issue myself and found this, and yes accelerometer doesn't work on Redmi Note 12, Android 13 MIUI 14. I'm starting to think it's a Xiaomi issue but it does work in other apps. Please let me know if there's any way I could help. Great job on the emulator btw, nice progress y'all
Seems like a MIUI issue because it doesnt work for me as well (MIUI 14 with Android 12, Mi10T with Snapdragon 865), please let me know as well if there's any way I can help
If anyone can test on an older MIUI version, that'd be helpful.
It seems to be a specific issue with MIUI 14. My phone is a Redmi Note 8 with MIUI 11 and accelerometer works flawlessly in touchHLE.
Accelerometer doesn't work for me as well (Redmi 10C, MIUI 14, Android 13)
Someone with “Android 10 on Redmi Note 7” also had problems. Very consistent Xiaomi pattern here…
Someone with a “ZTE A7040” reported the same issue. That's the first non-Xiaomi, non-MIUI device. Huh.
Based on the logs obtained by some of MIUI user on Android I think the problem is that a fingerprint device is detected as a controller and take a precedence over accelerometer (same issue as https://github.com/libgdx/libgdx/issues/5596)
I think filtering out uinput-fpc device from list of controllers reported by SDL may solve accelerometer issue on some Android phones
Log file from that user: log.txt
Apparently someone has this issue on the “Redmi Note 9 4GB/128GB, running Android 12 and MIUI 13”. The highest Android version I've tested myself was Android 11, so perhaps that could be the problem.
If i could test i could test the android 12 version, but i cant use the app since it crashes
Can confirm this issue still exists on 0.2.2 on HyperOS (miui) 1.0.4.0 (android 14) Poco F5
On a Redmi Note 11 Pro+, with MIUI 14.0.7 and Android 13, the accelerometer won't work either. It might just be broken on models with fingerprint sensors on the power button.
I managed to fix the problem, at least partially on some devices.
modifying the file in
touchHLE/vendor/SDL/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
I added a filter to check that the fingerprint sensor is not a jostick:
// Check if a given device is considered a possible SDL joystick
public static boolean isDeviceSDLJoystick(int deviceId) {
InputDevice device = InputDevice.getDevice(deviceId);
String deviceName = device.getName();
// We cannot use InputDevice.isVirtual before API 16, so let's accept
// only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
if ((device == null) || (deviceId < 0) || deviceName.equals("uinput-fpc") || deviceName.equals("uinput-fortsense")) {
return false;
}
Or Alternatively
// Check if a given device is considered a possible SDL joystick
public static boolean isDeviceSDLJoystick(int deviceId) {
InputDevice device = InputDevice.getDevice(deviceId);
String deviceName = device.getName();
// We cannot use InputDevice.isVirtual before API 16, so let's accept
// only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
if ((device == null) || (deviceId < 0) || deviceName.matches("uinput-.*")) {
return false;
}
The problem is not only on android but also on steam os (steam deck)
Steam deck doesn't use the same implementation, it would need to be custom for it.
I have hidden the comments about Steam Deck, it does not run Android so that's off-topic.
I managed to fix the problem, at least partially on some devices.
modifying the file in
touchHLE/vendor/SDL/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
I added a filter to check that the fingerprint sensor is not a jostick:
// Check if a given device is considered a possible SDL joystick public static boolean isDeviceSDLJoystick(int deviceId) { InputDevice device = InputDevice.getDevice(deviceId); String deviceName = device.getName(); // We cannot use InputDevice.isVirtual before API 16, so let's accept // only nonnegative device ids (VIRTUAL_KEYBOARD equals -1) if ((device == null) || (deviceId < 0) || deviceName.equals("uinput-fpc") || deviceName.equals("uinput-fortsense")) { return false; }Or Alternatively
// Check if a given device is considered a possible SDL joystick public static boolean isDeviceSDLJoystick(int deviceId) { InputDevice device = InputDevice.getDevice(deviceId); String deviceName = device.getName(); // We cannot use InputDevice.isVirtual before API 16, so let's accept // only nonnegative device ids (VIRTUAL_KEYBOARD equals -1) if ((device == null) || (deviceId < 0) || deviceName.matches("uinput-.*")) { return false; }
I do not have an affected device to confirm if it's working.
Regardless, I think we would prefer to not modify SDL Android code as it's currently just symlinked to the repo. Can the same changes be implemented on the touchHLE side? Maybe inside controller_added() method of window.rs?
@ciciplusplus My device is a Redmi 12c with Android 12 which is affected by this problem and the solution I proposed works
modify the controller_added() method in the window.rs file for not touch the SDL files as you suggested.
fn controller_added(&mut self, joystick_idx: u32) {
let Ok(controller) = self.controller_ctx.open(joystick_idx) else {
log!("Warning: A new controller was connected, but it couldn't be accessed!");
return;
};
let controller_name = controller.name();
if env::consts::OS == "android" {
if controller_name.starts_with("uinput-") {
return;
}
}
log!(
"New controller connected: {}. Left stick = device tilt. Right stick = touch input (press the stick or shoulder button to tap/hold).",
controller_name
);
self.controllers.push(controller);
}
@ciciplusplus My device is a Redmi 12c with Android 12 which is affected by this problem and the solution I proposed works
modify the controller_added() method in the window.rs file for not touch the SDL files as you suggested.
fn controller_added(&mut self, joystick_idx: u32) { let Ok(controller) = self.controller_ctx.open(joystick_idx) else { log!("Warning: A new controller was connected, but it couldn't be accessed!"); return; }; let controller_name = controller.name(); if env::consts::OS == "android" { if controller_name.starts_with("uinput-") { return; } } log!( "New controller connected: {}. Left stick = device tilt. Right stick = touch input (press the stick or shoulder button to tap/hold).", controller_name ); self.controllers.push(controller); }
@Oscar1640 Nice! Please follow https://github.com/touchHLE/touchHLE/blob/trunk/CONTRIBUTING.md to submit your patch set if you want it to be merged.
Hello, please, touchscreen works perfectly on my phone, but why does Hero of Sparta 2 doom resistance residence evil crash?
Hello, please, touchscreen works perfectly on my phone, but why does Hero of Sparta 2 doom resistance residence evil crash?
you already have your answer here https://github.com/touchHLE/touchHLE/issues/311#issuecomment-2124538826, but you continue to produce off-topic messages. i'm blocking you from repo for 7 days, if you continue to produce off-topic messages and noise after that, you'll be blocked permanently
A fix by @Oscar1640 has being merged here https://github.com/touchHLE/touchHLE/commit/a5e501c92eec00a634f00e4ccf8096d0d5f97e51 Many thanks for that!
Could someone with an impacted device confirm that problem is indeed fixed in the last trunk Android build? Once confirmed, we can close this issue.
A fix by @Oscar1640 has being merged here a5e501c Many thanks for that!
Could someone with an impacted device confirm that problem is indeed fixed in the last trunk Android build? Once confirmed, we can close this issue.
I can confirm this build fixed the accelerometer issue
Thanks for confirmation!
@ciciplusplus Will this be added to the changelog? I think it is the headline feature for a lot of Android users.
@hikari-no-yume yes, it should be there. will do chanelog update later
I have a Xiaomi 10c MIUI 13 And it's sadly not working Touch works well only issue is with the Accelerometer
I have a Xiaomi 10c MIUI 13 And it's sadly not working Touch works well only issue is with the Accelerometer
what is the version of touchHLE that you're using?