summaryrefslogtreecommitdiffstats
path: root/client_examples
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2012-03-29 13:21:34 -0500
committerJohannes Schindelin <johannes.schindelin@gmx.de>2012-03-29 13:21:39 -0500
commitf11e49b4e7faa78730a4125de3c6b8b56965e48a (patch)
tree390278d1a40230652fd1a3bf4e5e242ac92f51d1 /client_examples
parent1078e8a8b050b5b4ebbcb011750f5dd2d8eacc37 (diff)
downloadlibvncserver-f11e49b4e7faa78730a4125de3c6b8b56965e48a.zip
libvncserver-f11e49b4e7faa78730a4125de3c6b8b56965e48a.tar.gz
SDLvncviewer: fix the SDL_KEYUP issue
Keys got stuck because unicode is 0 upon SDL_KEYUP events, even if the same key event sets unicode correctly in SDL_KEYDOWN events. Work around that for the common case (ASCII) using the fact that both SDL and X11 keysyms were created with ASCII compatibility in mind. So as long as we type ASCII symbols, we can map things trivially. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'client_examples')
-rw-r--r--client_examples/SDLvncviewer.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index 5fa8f2c..f704ccc 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -78,7 +78,9 @@ static rfbBool resize(rfbClient* client) {
static rfbKeySym SDL_key2rfbKeySym(SDL_KeyboardEvent* e) {
rfbKeySym k = 0;
- switch(e->keysym.sym) {
+ SDLKey sym = e->keysym.sym;
+
+ switch (sym) {
case SDLK_BACKSPACE: k = XK_BackSpace; break;
case SDLK_TAB: k = XK_Tab; break;
case SDLK_CLEAR: k = XK_Clear; break;
@@ -152,16 +154,21 @@ static rfbKeySym SDL_key2rfbKeySym(SDL_KeyboardEvent* e) {
case SDLK_BREAK: k = XK_Break; break;
default: break;
}
- if (k == 0 && e->keysym.sym >= SDLK_a && e->keysym.sym <= SDLK_z) {
- k = XK_a + e->keysym.sym - SDLK_a;
- if (e->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))
- k &= ~0x20;
+ /* both SDL and X11 keysyms match ASCII in the range 0x01-0x7f */
+ if (k == 0 && sym > 0x0 && sym < 0x100) {
+ k = sym;
+ if (e->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) {
+ if (k >= '1' && k <= '9')
+ k &= ~0x10;
+ else if (k >= 'a' && k <= 'f')
+ k &= ~0x20;
+ }
}
if (k == 0) {
if (e->keysym.unicode < 0x100)
k = e->keysym.unicode;
else
- rfbClientLog("Unknown keysym: %d\n",e->keysym.sym);
+ rfbClientLog("Unknown keysym: %d\n", sym);
}
return k;
OpenPOWER on IntegriCloud