-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Fix hardcode deviceId while inject touch event. #3758
base: master
Are you sure you want to change the base?
Conversation
Thank you for the PR. This is the alternative mentioned in 40febf4, so it's probably ok if it fixes the problem for some games. Could you mention the game(s) that you tested which is (are) fixed by this change? |
Thanks for you reply This is the download link of game i've tested: https://ugame.9game.cn/game/downloadGame?pack.cooperateModelId=235099&pack.id=47093428 |
I didn't see any issue in this game with Scrcpy 1.25. Plus I don't think it will work. In my touch event tester app the device id is still -1 This is because Android set device id of all injected events to -1, unless the event is from InputFilter (accessibility service). // For all injected events, set device id = VIRTUAL_KEYBOARD_ID. The only exception is events
// that have gone through the InputFilter. If the event passed through the InputFilter, assign
// the provided device id. If the InputFilter is accessibility, and it modifies or synthesizes
// the injected event, it is responsible for setting POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY.
// For those events, we will set FLAG_IS_ACCESSIBILITY_EVENT to allow apps to distinguish them
// from events that originate from actual hardware.
int32_t resolvedDeviceId = VIRTUAL_KEYBOARD_ID;
if (policyFlags & POLICY_FLAG_FILTERED) {
resolvedDeviceId = event->getDeviceId();
} The only method to get real device id is using AOA HID or uinput. |
Thanks. I ran this app in a android in container,like redroid.I think maybe this is the difference Btw this issue only happend on main scene |
@baker915 Did you test that the change proposed in this MR actually works for the game you mentioned? |
I did,and i tested other apps,everything works fine. |
OK so without this MR, it does not work, with this MR, it works? If so, I think this could be merged. On which Android version? |
(But I'm a bit afraid that it could break other use cases…) |
Source code: https://github.com/yume-chan/android-motion-event-tester APK: com.companyname.AndroidApp1.zip Touch or click in the empty area, it will display properties of received events. |
on Android 10 |
Agreed!I'm going to test more devices and read the source code @yume-chan metioned to figure out this MR is necessary. |
Thanks. I will test it in my environment. |
AOSP:
https://android.googlesource.com/platform/frameworks/base.git/+/refs/heads/android10-release/cmds/input/src/com/android/commands/input/Input.java#359
fix touch events not working on some unity game