aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorLionel Ulmer2002-11-02 17:44:06 +0000
committerLionel Ulmer2002-11-02 17:44:06 +0000
commit6c4cb7346c873823a476eddf5ebf233becc1121b (patch)
treee4ea5c0f7480a7d64a04974a15110ab3c59b8394 /backends
parentcc0f8c4fb5f2933df4f5faa9dac5bbdea546ea2b (diff)
downloadscummvm-rg350-6c4cb7346c873823a476eddf5ebf233becc1121b.tar.gz
scummvm-rg350-6c4cb7346c873823a476eddf5ebf233becc1121b.tar.bz2
scummvm-rg350-6c4cb7346c873823a476eddf5ebf233becc1121b.zip
Fix key repeat in the GUI.
svn-id: r5385
Diffstat (limited to 'backends')
-rw-r--r--backends/x11/x11.cpp59
1 files changed, 45 insertions, 14 deletions
diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp
index a1a9ee3858..75308f06e4 100644
--- a/backends/x11/x11.cpp
+++ b/backends/x11/x11.cpp
@@ -842,19 +842,7 @@ bool OSystem_X11::poll_event(Event *scumm_event)
}
break;
- case KeyPress:
- switch (event.xkey.keycode) {
- case 132:
- report_presses = 0;
- break;
-
- case 133:
- fake_right_mouse = 1;
- break;
- }
- break;
-
- case KeyRelease:{
+ case KeyPress:{
/* I am using keycodes here and NOT keysyms to be sure that even if the user
remaps his iPAQ's keyboard, it will still work.
*/
@@ -869,6 +857,7 @@ bool OSystem_X11::poll_event(Event *scumm_event)
if (event.xkey.state & 0x08)
mode |= KBD_ALT;
switch (event.xkey.keycode) {
+
case 9: /* Escape on my PC */
case 130: /* Calendar on the iPAQ */
keycode = 27;
@@ -884,6 +873,48 @@ bool OSystem_X11::poll_event(Event *scumm_event)
keycode = 32;
break;
+ case 132:
+ report_presses = 0;
+ break;
+
+ case 133:
+ fake_right_mouse = 1;
+ break;
+
+ default:{
+ KeySym xsym;
+ xsym = XKeycodeToKeysym(display, event.xkey.keycode, 0);
+ keycode = xsym;
+ if ((xsym >= 'a') && (xsym <= 'z') && (event.xkey.state & 0x01))
+ xsym &= ~0x20; /* Handle shifted keys */
+ ascii = xsym;
+ }
+ }
+ if (keycode != -1) {
+ scumm_event->event_code = EVENT_KEYDOWN;
+ scumm_event->kbd.keycode = keycode;
+ scumm_event->kbd.ascii = (ascii != -1 ? ascii : keycode);
+ scumm_event->kbd.flags = mode;
+ return true;
+ }
+ }
+ break;
+
+ case KeyRelease:{
+ /* I am using keycodes here and NOT keysyms to be sure that even if the user
+ remaps his iPAQ's keyboard, it will still work.
+ */
+ int keycode = -1;
+ int ascii = -1;
+ byte mode = 0;
+
+ if (event.xkey.state & 0x01)
+ mode |= KBD_SHIFT;
+ if (event.xkey.state & 0x04)
+ mode |= KBD_CTRL;
+ if (event.xkey.state & 0x08)
+ mode |= KBD_ALT;
+ switch (event.xkey.keycode) {
case 132: /* 'Q' on the iPAQ */
report_presses = 1;
break;
@@ -902,7 +933,7 @@ bool OSystem_X11::poll_event(Event *scumm_event)
}
}
if (keycode != -1) {
- scumm_event->event_code = EVENT_KEYDOWN;
+ scumm_event->event_code = EVENT_KEYUP;
scumm_event->kbd.keycode = keycode;
scumm_event->kbd.ascii = (ascii != -1 ? ascii : keycode);
scumm_event->kbd.flags = mode;