src/video/windib/SDL_dibevents.c
changeset 1282 217f5d5a49e5
parent 1280 f61f045343d3
child 1288 ea3888b472bf
equal deleted inserted replaced
1281:644b39bf7253 1282:217f5d5a49e5
    47 #endif
    47 #endif
    48 
    48 
    49 /* The translation table from a Microsoft VK keysym to a SDL keysym */
    49 /* The translation table from a Microsoft VK keysym to a SDL keysym */
    50 static SDLKey VK_keymap[SDLK_LAST];
    50 static SDLKey VK_keymap[SDLK_LAST];
    51 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed);
    51 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed);
    52 static BOOL prev_shiftstates[2];
       
    53 
    52 
    54 /* Masks for processing the windows KEYDOWN and KEYUP messages */
    53 /* Masks for processing the windows KEYDOWN and KEYUP messages */
    55 #define REPEATED_KEYMASK	(1<<30)
    54 #define REPEATED_KEYMASK	(1<<30)
    56 #define EXTENDED_KEYMASK	(1<<24)
    55 #define EXTENDED_KEYMASK	(1<<24)
    57 
    56 
   115 					else
   114 					else
   116 						wParam = VK_LCONTROL;
   115 						wParam = VK_LCONTROL;
   117 					break;
   116 					break;
   118 				case VK_SHIFT:
   117 				case VK_SHIFT:
   119 					/* EXTENDED trick doesn't work here */
   118 					/* EXTENDED trick doesn't work here */
   120 					if (!prev_shiftstates[0] && (GetKeyState(VK_LSHIFT) & 0x8000)) {
   119 					{
       
   120 					Uint8 *state = SDL_GetKeyState(NULL);
       
   121 					if (state[SDLK_LSHIFT] == SDL_RELEASED && (GetKeyState(VK_LSHIFT) & 0x8000)) {
   121 						wParam = VK_LSHIFT;
   122 						wParam = VK_LSHIFT;
   122 						prev_shiftstates[0] = TRUE;
   123 					} else if (state[SDLK_RSHIFT] == SDL_RELEASED && (GetKeyState(VK_RSHIFT) & 0x8000)) {
   123 					} else if (!prev_shiftstates[1] && (GetKeyState(VK_RSHIFT) & 0x8000)) {
       
   124 						wParam = VK_RSHIFT;
   124 						wParam = VK_RSHIFT;
   125 						prev_shiftstates[1] = TRUE;
       
   126 					} else {
   125 					} else {
   127 						/* Huh? */
   126 						/* Probably a key repeat */
       
   127 						return(0);
       
   128 					}
   128 					}
   129 					}
   129 					break;
   130 					break;
   130 				case VK_MENU:
   131 				case VK_MENU:
   131 					if ( lParam&EXTENDED_KEYMASK )
   132 					if ( lParam&EXTENDED_KEYMASK )
   132 						wParam = VK_RMENU;
   133 						wParam = VK_RMENU;
   176 					else
   177 					else
   177 						wParam = VK_LCONTROL;
   178 						wParam = VK_LCONTROL;
   178 					break;
   179 					break;
   179 				case VK_SHIFT:
   180 				case VK_SHIFT:
   180 					/* EXTENDED trick doesn't work here */
   181 					/* EXTENDED trick doesn't work here */
   181 					if (prev_shiftstates[0] && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
   182 					{
       
   183 					Uint8 *state = SDL_GetKeyState(NULL);
       
   184 					if (state[SDLK_LSHIFT] == SDL_PRESSED && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
   182 						wParam = VK_LSHIFT;
   185 						wParam = VK_LSHIFT;
   183 						prev_shiftstates[0] = FALSE;
   186 					} else if (state[SDLK_RSHIFT] == SDL_PRESSED && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
   184 					} else if (prev_shiftstates[1] && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
       
   185 						wParam = VK_RSHIFT;
   187 						wParam = VK_RSHIFT;
   186 						prev_shiftstates[1] = FALSE;
       
   187 					} else {
   188 					} else {
   188 						/* Huh? */
   189 						/* Probably a key repeat */
       
   190 						return(0);
       
   191 					}
   189 					}
   192 					}
   190 					break;
   193 					break;
   191 				case VK_MENU:
   194 				case VK_MENU:
   192 					if ( lParam&EXTENDED_KEYMASK )
   195 					if ( lParam&EXTENDED_KEYMASK )
   193 						wParam = VK_RMENU;
   196 						wParam = VK_RMENU;
   370 	VK_keymap[VK_PRINT] = SDLK_PRINT;
   373 	VK_keymap[VK_PRINT] = SDLK_PRINT;
   371 #endif
   374 #endif
   372 	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   375 	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   373 	VK_keymap[VK_CANCEL] = SDLK_BREAK;
   376 	VK_keymap[VK_CANCEL] = SDLK_BREAK;
   374 	VK_keymap[VK_APPS] = SDLK_MENU;
   377 	VK_keymap[VK_APPS] = SDLK_MENU;
   375 
       
   376 	prev_shiftstates[0] = FALSE;
       
   377 	prev_shiftstates[1] = FALSE;
       
   378 }
   378 }
   379 
   379 
   380 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
   380 static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
   381 {
   381 {
   382 	/* Set the keysym information */
   382 	/* Set the keysym information */