diff options
Diffstat (limited to 'backends/x11/x11.cpp')
-rw-r--r-- | backends/x11/x11.cpp | 59 |
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; |