diff src/video/windib/SDL_dibevents.c @ 1253:7c7ddaf195bf

Implemented ToUnicode() support on Windows 95/98/ME/NT/2000/XP This is a collaborative effort between Alex Volkov and John Popplewell. Thanks guys! (Fixes bug #39)
author Sam Lantinga <slouken@libsdl.org>
date Thu, 19 Jan 2006 09:09:32 +0000
parents 86d0d01290ea
children f3a3f1890b91
line wrap: on
line diff
--- a/src/video/windib/SDL_dibevents.c	Thu Jan 19 08:53:12 2006 +0000
+++ b/src/video/windib/SDL_dibevents.c	Thu Jan 19 09:09:32 2006 +0000
@@ -281,6 +281,7 @@
 	VK_keymap[VK_EQUALS] = SDLK_EQUALS;
 	VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
 	VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
+	VK_keymap[VK_OEM_102] = SDLK_LESS;
 	VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
 	VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
 	VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
@@ -385,17 +386,18 @@
 	keysym->sym = VK_keymap[vkey];
 	keysym->mod = KMOD_NONE;
 	keysym->unicode = 0;
-	if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
+	if ( pressed && SDL_TranslateUNICODE ) {
 #ifdef NO_GETKEYBOARDSTATE
 		/* Uh oh, better hope the vkey is close enough.. */
 		keysym->unicode = vkey;
 #else
-		BYTE keystate[256];
-		BYTE chars[2];
+		BYTE	keystate[256];
+		Uint16	wchars[2];
 
 		GetKeyboardState(keystate);
-		if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
-			keysym->unicode = chars[0];
+		if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1)
+		{
+			keysym->unicode = wchars[0];
 		}
 #endif /* NO_GETKEYBOARDSTATE */
 	}