comparison src/video/windib/SDL_dibevents.c @ 4162:3b7fc3416601 SDL-1.2

GAPI fixes from Stefan Klug
author Sam Lantinga <slouken@libsdl.org>
date Mon, 16 Feb 2009 22:32:34 +0000
parents a1b03ba2fcd0
children a6f635e5eaa6
comparison
equal deleted inserted replaced
4161:bd91db0b0b5d 4162:3b7fc3416601
28 #include "SDL_events.h" 28 #include "SDL_events.h"
29 #include "SDL_syswm.h" 29 #include "SDL_syswm.h"
30 #include "../../events/SDL_sysevents.h" 30 #include "../../events/SDL_sysevents.h"
31 #include "../../events/SDL_events_c.h" 31 #include "../../events/SDL_events_c.h"
32 #include "../wincommon/SDL_lowvideo.h" 32 #include "../wincommon/SDL_lowvideo.h"
33 #include "SDL_gapidibvideo.h"
34 #include "SDL_vkeys.h"
35
36 #ifdef SDL_VIDEO_DRIVER_GAPI
37 #include "../gapi/SDL_gapivideo.h"
38 #endif
39
40 #ifdef SDL_VIDEO_DRIVER_WINDIB
33 #include "SDL_dibvideo.h" 41 #include "SDL_dibvideo.h"
34 #include "SDL_vkeys.h" 42 #endif
35 43
36 #ifndef WM_APP 44 #ifndef WM_APP
37 #define WM_APP 0x8000 45 #define WM_APP 0x8000
38 #endif 46 #endif
39 47
42 #endif 50 #endif
43 51
44 /* The translation table from a Microsoft VK keysym to a SDL keysym */ 52 /* The translation table from a Microsoft VK keysym to a SDL keysym */
45 static SDLKey VK_keymap[SDLK_LAST]; 53 static SDLKey VK_keymap[SDLK_LAST];
46 static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed); 54 static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed);
55 static SDLKey Arrows_keymap[4];
47 56
48 /* Masks for processing the windows KEYDOWN and KEYUP messages */ 57 /* Masks for processing the windows KEYDOWN and KEYUP messages */
49 #define REPEATED_KEYMASK (1<<30) 58 #define REPEATED_KEYMASK (1<<30)
50 #define EXTENDED_KEYMASK (1<<24) 59 #define EXTENDED_KEYMASK (1<<24)
51 60
57 #define WNDPROCTYPE FARPROC 66 #define WNDPROCTYPE FARPROC
58 #endif 67 #endif
59 static WNDPROCTYPE userWindowProc = NULL; 68 static WNDPROCTYPE userWindowProc = NULL;
60 69
61 70
62 #ifdef _WIN32_WCE 71 #ifdef SDL_VIDEO_DRIVER_GAPI
63 72
64 WPARAM rotateKey(WPARAM key,SDL_ScreenOrientation direction) 73 WPARAM rotateKey(WPARAM key,int direction)
65 { 74 {
66 if (direction != SDL_ORIENTATION_LEFT) 75 if(direction ==0 ) return key;
67 return key; 76
68
69 switch (key) { 77 switch (key) {
70 case 0x26: /* up */ 78 case 0x26: /* up */
71 return 0x27; 79 return Arrows_keymap[(2 + direction) % 4];
72 case 0x27: /* right */ 80 case 0x27: /* right */
73 return 0x28; 81 return Arrows_keymap[(1 + direction) % 4];
74 case 0x28: /* down */ 82 case 0x28: /* down */
75 return 0x25; 83 return Arrows_keymap[direction % 4];
76 case 0x25: /* left */ 84 case 0x25: /* left */
77 return 0x26; 85 return Arrows_keymap[(3 + direction) % 4];
78 } 86 }
79 87
80 return key; 88 return key;
81 } 89 }
82 90
91 switch (msg) { 99 switch (msg) {
92 case WM_SYSKEYDOWN: 100 case WM_SYSKEYDOWN:
93 case WM_KEYDOWN: { 101 case WM_KEYDOWN: {
94 SDL_keysym keysym; 102 SDL_keysym keysym;
95 103
96 #ifdef _WIN32_WCE 104 #ifdef SDL_VIDEO_DRIVER_GAPI
97 // Drop GAPI artefacts 105 if(this->hidden->gapiInfo)
98 if (wParam == 0x84 || wParam == 0x5B) 106 {
99 return 0; 107 // Drop GAPI artefacts
100 108 if (wParam == 0x84 || wParam == 0x5B)
101 // Rotate key if necessary 109 return 0;
102 if (this->hidden->orientation != SDL_ORIENTATION_UP) 110
103 wParam = rotateKey(wParam, this->hidden->orientation); 111 wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
112 }
104 #endif 113 #endif
105 /* Ignore repeated keys */ 114 /* Ignore repeated keys */
106 if ( lParam&REPEATED_KEYMASK ) { 115 if ( lParam&REPEATED_KEYMASK ) {
107 return(0); 116 return(0);
108 } 117 }
165 174
166 case WM_SYSKEYUP: 175 case WM_SYSKEYUP:
167 case WM_KEYUP: { 176 case WM_KEYUP: {
168 SDL_keysym keysym; 177 SDL_keysym keysym;
169 178
170 #ifdef _WIN32_WCE 179 #ifdef SDL_VIDEO_DRIVER_GAPI
171 // Drop GAPI artifacts 180 if(this->hidden->gapiInfo)
172 if (wParam == 0x84 || wParam == 0x5B) 181 {
173 return 0; 182 // Drop GAPI artifacts
174 183 if (wParam == 0x84 || wParam == 0x5B)
175 // Rotate key if necessary 184 return 0;
176 if (this->hidden->orientation != SDL_ORIENTATION_UP) 185
177 wParam = rotateKey(wParam, this->hidden->orientation); 186 wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
187 }
178 #endif 188 #endif
179 189
180 switch (wParam) { 190 switch (wParam) {
181 case VK_CONTROL: 191 case VK_CONTROL:
182 if ( lParam&EXTENDED_KEYMASK ) 192 if ( lParam&EXTENDED_KEYMASK )
220 } 230 }
221 posted = SDL_PrivateKeyboard(SDL_RELEASED, 231 posted = SDL_PrivateKeyboard(SDL_RELEASED,
222 TranslateKey(wParam,HIWORD(lParam),&keysym,0)); 232 TranslateKey(wParam,HIWORD(lParam),&keysym,0));
223 } 233 }
224 return(0); 234 return(0);
225
226 #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER) 235 #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
227 case WM_SYSCOMMAND: { 236 case WM_SYSCOMMAND: {
228 const DWORD val = (DWORD) (wParam & 0xFFF0); 237 const DWORD val = (DWORD) (wParam & 0xFFF0);
229 if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) { 238 if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
230 if (!allow_screensaver) { 239 if (this->hidden->dibInfo && !allow_screensaver) {
231 /* Note that this doesn't stop anything on Vista 240 /* Note that this doesn't stop anything on Vista
232 if the screensaver has a password. */ 241 if the screensaver has a password. */
233 return(0); 242 return(0);
234 } 243 }
235 } 244 }
428 VK_keymap[VK_PRINT] = SDLK_PRINT; 437 VK_keymap[VK_PRINT] = SDLK_PRINT;
429 #endif 438 #endif
430 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT; 439 VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
431 VK_keymap[VK_CANCEL] = SDLK_BREAK; 440 VK_keymap[VK_CANCEL] = SDLK_BREAK;
432 VK_keymap[VK_APPS] = SDLK_MENU; 441 VK_keymap[VK_APPS] = SDLK_MENU;
442
443 Arrows_keymap[3] = 0x25;
444 Arrows_keymap[2] = 0x26;
445 Arrows_keymap[1] = 0x27;
446 Arrows_keymap[0] = 0x28;
433 } 447 }
434 448
435 #define EXTKEYPAD(keypad) ((scancode & 0x100)?(mvke):(keypad)) 449 #define EXTKEYPAD(keypad) ((scancode & 0x100)?(mvke):(keypad))
436 450
437 static int SDL_MapVirtualKey(int scancode, int vkey) 451 static int SDL_MapVirtualKey(int scancode, int vkey)
483 { 497 {
484 /* Set the keysym information */ 498 /* Set the keysym information */
485 keysym->scancode = (unsigned char) scancode; 499 keysym->scancode = (unsigned char) scancode;
486 keysym->mod = KMOD_NONE; 500 keysym->mod = KMOD_NONE;
487 keysym->unicode = 0; 501 keysym->unicode = 0;
502
503 if ((vkey == VK_RETURN) && (scancode & 0x100)) {
504 /* No VK_ code for the keypad enter key */
505 keysym->sym = SDLK_KP_ENTER;
506 }
507 else {
508 keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
509 }
510
488 if ( pressed && SDL_TranslateUNICODE ) { 511 if ( pressed && SDL_TranslateUNICODE ) {
489 #ifdef NO_GETKEYBOARDSTATE 512 #ifdef NO_GETKEYBOARDSTATE
490 /* Uh oh, better hope the vkey is close enough.. */ 513 /* Uh oh, better hope the vkey is close enough.. */
514 if((keysym->sym == vkey) || (vkey > 0x7f))
491 keysym->unicode = vkey; 515 keysym->unicode = vkey;
492 #else 516 #else
493 BYTE keystate[256]; 517 BYTE keystate[256];
494 Uint16 wchars[2]; 518 Uint16 wchars[2];
495 519
497 if (SDL_ToUnicode((UINT)vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1) 521 if (SDL_ToUnicode((UINT)vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1)
498 { 522 {
499 keysym->unicode = wchars[0]; 523 keysym->unicode = wchars[0];
500 } 524 }
501 #endif /* NO_GETKEYBOARDSTATE */ 525 #endif /* NO_GETKEYBOARDSTATE */
502 }
503
504 if ((vkey == VK_RETURN) && (scancode & 0x100)) {
505 /* No VK_ code for the keypad enter key */
506 keysym->sym = SDLK_KP_ENTER;
507 }
508 else {
509 keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
510 } 526 }
511 527
512 #if 0 528 #if 0
513 { 529 {
514 HKL hLayoutCurrent = GetKeyboardLayout(0); 530 HKL hLayoutCurrent = GetKeyboardLayout(0);