Index: wincommon/SDL_lowvideo.h =================================================================== RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/wincommon/SDL_lowvideo.h,v retrieving revision 1.14 diff -c -r1.14 SDL_lowvideo.h *** wincommon/SDL_lowvideo.h 16 Feb 2004 21:09:23 -0000 1.14 --- wincommon/SDL_lowvideo.h 16 Jan 2006 12:04:08 -0000 *************** *** 108,111 **** --- 108,116 ---- GDL_CreateWindow as well */ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + /* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ + typedef int (WINAPI *ToUnicodeFN)(UINT, UINT, PBYTE, LPWSTR, int, UINT); + + extern ToUnicodeFN SDL_ToUnicode; + #endif /* SDL_lowvideo_h */ Index: wincommon/SDL_sysevents.c =================================================================== RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/wincommon/SDL_sysevents.c,v retrieving revision 1.28 diff -c -r1.28 SDL_sysevents.c *** wincommon/SDL_sysevents.c 29 Sep 2005 09:43:00 -0000 1.28 --- wincommon/SDL_sysevents.c 16 Jan 2006 12:04:09 -0000 *************** *** 78,83 **** --- 78,92 ---- void (*WIN_WinPAINT)(_THIS, HDC hdc); extern void DIB_SwapGamma(_THIS); + /* Variables and support functions for SDL_ToUnicode() */ + static int codepage; + static int Is9xME(); + static int GetCodePage(); + static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, BYTE *keystate, Uint16 *wchars, int wsize, UINT flags); + + ToUnicodeFN SDL_ToUnicode = ToUnicode9xME; + + #if defined(_WIN32_WCE) // dynamically load aygshell dll because we want SDL to work on HPC and be300 *************** *** 581,586 **** --- 590,600 ---- } return(0); + case WM_INPUTLANGCHANGE: { + codepage = GetCodePage(); + } + return(TRUE); + default: { /* Special handling by the video driver */ if (HandleMessage) { *************** *** 687,692 **** --- 701,710 ---- /* Check for SDL_WINDOWID hack */ SDL_windowid = getenv("SDL_WINDOWID"); + /* Initialise variables for SDL_ToUnicode() */ + codepage = GetCodePage(); + SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; + app_registered = 1; return(0); } *************** *** 710,712 **** --- 728,766 ---- app_registered = 0; } + /* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ + + static int Is9xME() + { + OSVERSIONINFO info; + + memset(&info, 0, sizeof(info)); + info.dwOSVersionInfoSize = sizeof(info); + if (!GetVersionEx(&info)) { + return 0; + } + return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); + } + + static int GetCodePage() + { + char buff[8]; + int lcid = MAKELCID(LOWORD(GetKeyboardLayout(0)), SORT_DEFAULT); + int cp = GetACP(); + + if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { + cp = atoi(buff); + } + return cp; + } + + static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, PBYTE keystate, LPWSTR wchars, int wsize, UINT flags) + { + BYTE chars[2]; + + if (ToAsciiEx(vkey, scancode, keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) { + return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize); + } + return 0; + } + Index: windib/SDL_dibevents.c =================================================================== RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/windib/SDL_dibevents.c,v retrieving revision 1.25 diff -c -r1.25 SDL_dibevents.c *** windib/SDL_dibevents.c 29 Sep 2005 09:43:00 -0000 1.25 --- windib/SDL_dibevents.c 16 Jan 2006 12:04:09 -0000 *************** *** 237,242 **** --- 237,243 ---- 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; *************** *** 341,357 **** keysym->sym = VK_keymap[vkey]; keysym->mod = KMOD_NONE; keysym->unicode = 0; ! if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ #ifdef NO_GETKEYBOARDSTATE /* Uh oh, better hope the vkey is close enough.. */ keysym->unicode = vkey; #else ! BYTE keystate[256]; ! BYTE chars[2]; GetKeyboardState(keystate); ! if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { ! keysym->unicode = chars[0]; } #endif /* NO_GETKEYBOARDSTATE */ } --- 342,359 ---- keysym->sym = VK_keymap[vkey]; keysym->mod = KMOD_NONE; keysym->unicode = 0; ! if ( pressed && SDL_TranslateUNICODE ) { #ifdef NO_GETKEYBOARDSTATE /* Uh oh, better hope the vkey is close enough.. */ keysym->unicode = vkey; #else ! BYTE keystate[256]; ! Uint16 wchars[2]; GetKeyboardState(keystate); ! if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1) ! { ! keysym->unicode = wchars[0]; } #endif /* NO_GETKEYBOARDSTATE */ } Index: windib/SDL_vkeys.h =================================================================== RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/windib/SDL_vkeys.h,v retrieving revision 1.6 diff -c -r1.6 SDL_vkeys.h *** windib/SDL_vkeys.h 4 Jan 2004 16:49:27 -0000 1.6 --- windib/SDL_vkeys.h 16 Jan 2006 12:04:09 -0000 *************** *** 77,79 **** --- 77,80 ---- #define VK_RBRACKET 0xDD #define VK_APOSTROPHE 0xDE #define VK_BACKTICK 0xDF + #define VK_OEM_102 0xE2 Index: windx5/SDL_dx5events.c =================================================================== RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/windx5/SDL_dx5events.c,v retrieving revision 1.25 diff -c -r1.25 SDL_dx5events.c *** windx5/SDL_dx5events.c 11 Aug 2005 05:08:28 -0000 1.25 --- windx5/SDL_dx5events.c 16 Jan 2006 12:04:10 -0000 *************** *** 824,834 **** keysym->sym = DIK_keymap[scancode]; keysym->mod = KMOD_NONE; keysym->unicode = 0; ! if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ UINT vkey; #ifndef NO_GETKEYBOARDSTATE ! BYTE keystate[256]; ! BYTE chars[2]; #endif vkey = MapVirtualKey(scancode, 1); --- 824,834 ---- keysym->sym = DIK_keymap[scancode]; keysym->mod = KMOD_NONE; keysym->unicode = 0; ! if ( pressed && SDL_TranslateUNICODE ) { UINT vkey; #ifndef NO_GETKEYBOARDSTATE ! BYTE keystate[256]; ! Uint16 wchars[2]; #endif vkey = MapVirtualKey(scancode, 1); *************** *** 837,846 **** keysym->unicode = vkey; #else GetKeyboardState(keystate); ! if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { ! keysym->unicode = chars[0]; } ! #endif } return(keysym); } --- 837,847 ---- keysym->unicode = vkey; #else GetKeyboardState(keystate); ! if (SDL_ToUnicode(vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1) ! { ! keysym->unicode = wchars[0]; } ! #endif /* NO_GETKEYBOARDSTATE */ } return(keysym); }