[Scummvm-git-logs] scummvm master -> 9f4a32f88be3256aa28909deba345b8a1097727b
antoniou79
noreply at scummvm.org
Tue Aug 29 01:45:58 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9f4a32f88b ANDROID: Remove hack for virtual keyboard arrow key repeats
Commit: 9f4a32f88be3256aa28909deba345b8a1097727b
https://github.com/scummvm/scummvm/commit/9f4a32f88be3256aa28909deba345b8a1097727b
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-08-29T04:30:00+03:00
Commit Message:
ANDROID: Remove hack for virtual keyboard arrow key repeats
This hack was simulating repeated key presses (EVENT_KEYDOWN, then EVENT_KEYUP) for the arrow keys like the ones a physical keyboard sends
The hack could potentially cause further issues like spamming the events queue with many unnecessary events, and sending the events too quickly for some engines to handle
(thus missing some of them). We're now making use of the allowKbdRepeats() for the Up/Down/Left/Right event actions in the gui-manager, which will handle the case of a key
being kept pressed, sending an initial EVENT_KEYDOWN event and then subsequent EVENT_KEYDOWN events with the kbdRepeat flag set, and finally a single EVENT_KEYUP in the end.
Android itself handles repeated key events similarily (instead of a kbdRepeat flag, it updates a counter for the key repeats, which we translate to a simple flag).
This (and the hack that this replaces) affect things like moving the selection in the GUI lists (like the added games list) upwards or downwards continuously
while keeping the respective arrow key from the Android virtual keyboard pressed down.
Changed paths:
backends/platform/android/events.cpp
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 8190f44a666..5da67906c4a 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -417,6 +417,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
ev0.kbd.keycode = Common::KEYCODE_INVALID;
}
} else {
+// LOGD("Received JE_KEY keycode: %d", arg3);
ev0.kbd.keycode = jkeymap[arg2];
}
@@ -424,25 +425,41 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
ev0.kbdRepeat = true;
}
- // Special case for when the arrow keys on the virtual keyboard are pressed and held down
- // This emulates what happens when the arrow keys on a physical keyboard are pressed and held down
- // In the case of the physical keyboard Android keeps sending successive EVENT_KEYDOWN, EVENT_KEYUP events, non-"repeated"
- if (ev0.kbdRepeat
- && ev0.type == Common::EVENT_KEYDOWN
- && (ev0.kbd.keycode == Common::KEYCODE_UP
- || ev0.kbd.keycode == Common::KEYCODE_DOWN
- || ev0.kbd.keycode == Common::KEYCODE_LEFT
- || ev0.kbd.keycode == Common::KEYCODE_RIGHT)) {
- ev0.kbd.ascii = 0;
- // TODO Maybe only handle 1 every X such events to lower the spam on the queue of these very fast up/down events?
- ev0.kbdRepeat = false;
- Common::Event ev1 = ev0;
- ev1.type = Common::EVENT_KEYUP;
-// LOGD("JE_KEY pushing rep event type: %d kbdcode: %d ascii: %d flags: %d repeats: %d", ev1.type, ev1.kbd.keycode, ev1.kbd.ascii, ev1.kbd.flags, ev1.kbdRepeat? 1: 0);
-// LOGD("JE_KEY pushing rep event type: %d kbdcode: %d ascii: %d flags: %d repeats: %d", ev0.type, ev0.kbd.keycode, ev0.kbd.ascii, ev0.kbd.flags, ev0.kbdRepeat? 1: 0);
- pushEvent(ev1, ev0);
- return;
- }
+// // HACK: Special case for when the arrow keys on the virtual keyboard are pressed and held down
+// // This emulates what happens when the arrow keys on a physical keyboard are pressed and held down
+// // In the case of the physical keyboard Android keeps sending successive EVENT_KEYDOWN, EVENT_KEYUP events, non-"repeated"
+// if (ev0.kbdRepeat
+// && ev0.type == Common::EVENT_KEYDOWN
+// && (ev0.kbd.keycode == Common::KEYCODE_UP
+// || ev0.kbd.keycode == Common::KEYCODE_DOWN
+// || ev0.kbd.keycode == Common::KEYCODE_LEFT
+// || ev0.kbd.keycode == Common::KEYCODE_RIGHT)) {
+// switch (ev0.kbd.keycode) {
+// case Common::KEYCODE_UP:
+// ev0.kbd.ascii = Common::KEYCODE_UP;
+// break;
+//
+// case Common::KEYCODE_DOWN:
+// ev0.kbd.ascii = Common::KEYCODE_DOWN;
+// break;
+//
+// case Common::KEYCODE_RIGHT:
+// ev0.kbd.ascii = Common::KEYCODE_RIGHT;
+// break;
+//
+// case Common::KEYCODE_LEFT:
+// ev0.kbd.ascii = Common::KEYCODE_LEFT;
+// break;
+// }
+// // TODO Maybe only handle 1 every X such events to lower the spam on the queue of these very fast up/down events?
+// ev0.kbdRepeat = false;
+// Common::Event ev1 = ev0;
+// ev1.type = Common::EVENT_KEYUP;
+//// LOGD("JE_KEY pushing rep event type: %d kbdcode: %d ascii: %d flags: %d repeats: %d", ev1.type, ev1.kbd.keycode, ev1.kbd.ascii, ev1.kbd.flags, ev1.kbdRepeat? 1: 0);
+//// LOGD("JE_KEY pushing rep event type: %d kbdcode: %d ascii: %d flags: %d repeats: %d", ev0.type, ev0.kbd.keycode, ev0.kbd.ascii, ev0.kbd.flags, ev0.kbdRepeat? 1: 0);
+// pushEvent(ev1, ev0);
+// return;
+// }
// map special keys to 'our' ascii codes
switch (ev0.kbd.keycode) {
@@ -515,6 +532,26 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
ev0.kbd.ascii = Common::ASCII_F12;
break;
+ case Common::KEYCODE_UP:
+ // Set to match what a physical keyboard sends as ascii code for the arrow keys
+ ev0.kbd.ascii = Common::KEYCODE_UP;
+ break;
+
+ case Common::KEYCODE_DOWN:
+ // Set to match what a physical keyboard sends as ascii code for the arrow keys
+ ev0.kbd.ascii = Common::KEYCODE_DOWN;
+ break;
+
+ case Common::KEYCODE_RIGHT:
+ // Set to match what a physical keyboard sends as ascii code for the arrow keys
+ ev0.kbd.ascii = Common::KEYCODE_RIGHT;
+ break;
+
+ case Common::KEYCODE_LEFT:
+ // Set to match what a physical keyboard sends as ascii code for the arrow keys
+ ev0.kbd.ascii = Common::KEYCODE_LEFT;
+ break;
+
default:
ev0.kbd.ascii = arg3;
break;
More information about the Scummvm-git-logs
mailing list