From fa62bc3ec2852e5744c49e42d4c64df65cfe3af8 Mon Sep 17 00:00:00 2001 From: mfranz <mfranz> Date: Wed, 17 May 2006 21:21:38 +0000 Subject: [PATCH] SDL 1.2.10 (released today!) doesn't report unicode on key release. Now we have to ourselves which unicode code a key release even should fire. (Tested with 1.2.9 and an 1.2.10. Please report any new keyboard problems.) --- src/Main/fg_os_sdl.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Main/fg_os_sdl.cxx b/src/Main/fg_os_sdl.cxx index 58602a884..dcb9c6541 100644 --- a/src/Main/fg_os_sdl.cxx +++ b/src/Main/fg_os_sdl.cxx @@ -112,6 +112,14 @@ void fgOSOpenWindow(int w, int h, int bpp, // int realh = screen->h; } + +struct keydata { + keydata() : unicode(0), mod(0) {}; + Uint16 unicode; + unsigned int mod; +} keys[SDLK_LAST]; + + static void handleKey(int key, int raw, int keyup) { int modmask = 0; @@ -173,8 +181,19 @@ static void handleKey(int key, int raw, int keyup) CurrentModifiers |= modmask; keymod = CurrentModifiers & ~KEYMOD_RELEASED; } - if(modmask == 0 && KeyHandler) + + if(modmask == 0 && KeyHandler) { + if (keymod & KEYMOD_RELEASED) { + if (keys[raw].mod) { + key = keys[raw].unicode; + keys[raw].mod = 0; + } + } else { + keys[raw].mod = keymod; + keys[raw].unicode = key; + } (*KeyHandler)(key, keymod, CurrentMouseX, CurrentMouseY); + } } // FIXME: Integrate with existing fgExit() in util.cxx.