File tree Expand file tree Collapse file tree
app/src/main/java/io/github/sds100/keymapper/shizuku Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ import timber.log.Timber
1616class ShizukuInputEventInjector : InputEventInjector {
1717
1818 companion object {
19- private const val INJECT_INPUT_EVENT_MODE_ASYNC = 0
19+ // private const val INJECT_INPUT_EVENT_MODE_ASYNC = 0
20+
21+ private const val INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = 2
2022 }
2123
2224 private val iInputManager: IInputManager by lazy {
@@ -46,12 +48,15 @@ class ShizukuInputEventInjector : InputEventInjector {
4648 model.scanCode,
4749 )
4850
49- iInputManager.injectInputEvent(keyEvent, INJECT_INPUT_EVENT_MODE_ASYNC )
51+ // MUST wait for the application to finish processing the event before sending the next one.
52+ // Otherwise, rapidly repeating input events will go in a big queue and all inputs
53+ // into the application will be delayed or overloaded.
54+ iInputManager.injectInputEvent(keyEvent, INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH )
5055
5156 if (model.inputType == InputEventType .DOWN_UP ) {
5257 val upEvent = KeyEvent .changeAction(keyEvent, KeyEvent .ACTION_UP )
5358
54- iInputManager.injectInputEvent(upEvent, INJECT_INPUT_EVENT_MODE_ASYNC )
59+ iInputManager.injectInputEvent(upEvent, INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH )
5560 }
5661 }
5762}
You can’t perform that action at this time.
0 commit comments