src/video/windib/SDL_dibevents.c
branchSDL-1.2
changeset 4162 3b7fc3416601
parent 4159 a1b03ba2fcd0
child 4167 a6f635e5eaa6
     1.1 --- a/src/video/windib/SDL_dibevents.c	Fri Jan 30 01:40:44 2009 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Mon Feb 16 22:32:34 2009 +0000
     1.3 @@ -30,8 +30,16 @@
     1.4  #include "../../events/SDL_sysevents.h"
     1.5  #include "../../events/SDL_events_c.h"
     1.6  #include "../wincommon/SDL_lowvideo.h"
     1.7 +#include "SDL_gapidibvideo.h"
     1.8 +#include "SDL_vkeys.h"
     1.9 +
    1.10 +#ifdef SDL_VIDEO_DRIVER_GAPI
    1.11 +#include "../gapi/SDL_gapivideo.h"
    1.12 +#endif
    1.13 +
    1.14 +#ifdef SDL_VIDEO_DRIVER_WINDIB
    1.15  #include "SDL_dibvideo.h"
    1.16 -#include "SDL_vkeys.h"
    1.17 +#endif
    1.18  
    1.19  #ifndef WM_APP
    1.20  #define WM_APP	0x8000
    1.21 @@ -44,6 +52,7 @@
    1.22  /* The translation table from a Microsoft VK keysym to a SDL keysym */
    1.23  static SDLKey VK_keymap[SDLK_LAST];
    1.24  static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed);
    1.25 +static SDLKey Arrows_keymap[4];
    1.26  
    1.27  /* Masks for processing the windows KEYDOWN and KEYUP messages */
    1.28  #define REPEATED_KEYMASK	(1<<30)
    1.29 @@ -59,22 +68,21 @@
    1.30  static WNDPROCTYPE userWindowProc = NULL;
    1.31  
    1.32  
    1.33 -#ifdef _WIN32_WCE
    1.34 +#ifdef SDL_VIDEO_DRIVER_GAPI
    1.35  
    1.36 -WPARAM rotateKey(WPARAM key,SDL_ScreenOrientation direction) 
    1.37 +WPARAM rotateKey(WPARAM key,int direction) 
    1.38  {
    1.39 -	if (direction != SDL_ORIENTATION_LEFT)
    1.40 -		return key;
    1.41 -
    1.42 +	if(direction ==0 ) return key;
    1.43 +	
    1.44  	switch (key) {
    1.45  		case 0x26: /* up */
    1.46 -			return 0x27;
    1.47 +			return Arrows_keymap[(2 + direction) % 4];
    1.48  		case 0x27: /* right */
    1.49 -			return 0x28;
    1.50 +			return Arrows_keymap[(1 + direction) % 4];
    1.51  		case 0x28: /* down */
    1.52 -			return 0x25;
    1.53 +			return Arrows_keymap[direction % 4];
    1.54  		case 0x25: /* left */
    1.55 -			return 0x26;
    1.56 +			return Arrows_keymap[(3 + direction) % 4];
    1.57  	}
    1.58  
    1.59  	return key;
    1.60 @@ -93,14 +101,15 @@
    1.61  		case WM_KEYDOWN: {
    1.62  			SDL_keysym keysym;
    1.63  
    1.64 -#ifdef _WIN32_WCE
    1.65 -			// Drop GAPI artefacts
    1.66 -			if (wParam == 0x84 || wParam == 0x5B)
    1.67 -				return 0;
    1.68 +#ifdef SDL_VIDEO_DRIVER_GAPI
    1.69 +			if(this->hidden->gapiInfo)
    1.70 +			{
    1.71 +				// Drop GAPI artefacts
    1.72 +				if (wParam == 0x84 || wParam == 0x5B)
    1.73 +					return 0;
    1.74  
    1.75 -			// Rotate key if necessary
    1.76 -			if (this->hidden->orientation != SDL_ORIENTATION_UP)
    1.77 -				wParam = rotateKey(wParam, this->hidden->orientation);	
    1.78 +				wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
    1.79 +			}
    1.80  #endif 
    1.81  			/* Ignore repeated keys */
    1.82  			if ( lParam&REPEATED_KEYMASK ) {
    1.83 @@ -167,14 +176,15 @@
    1.84  		case WM_KEYUP: {
    1.85  			SDL_keysym keysym;
    1.86  
    1.87 -#ifdef _WIN32_WCE
    1.88 -			// Drop GAPI artifacts
    1.89 -			if (wParam == 0x84 || wParam == 0x5B)
    1.90 -				return 0;
    1.91 -
    1.92 -			// Rotate key if necessary
    1.93 -			if (this->hidden->orientation != SDL_ORIENTATION_UP)
    1.94 -				wParam = rotateKey(wParam, this->hidden->orientation);	
    1.95 +#ifdef SDL_VIDEO_DRIVER_GAPI
    1.96 +			if(this->hidden->gapiInfo)
    1.97 +			{
    1.98 +				// Drop GAPI artifacts
    1.99 +				if (wParam == 0x84 || wParam == 0x5B)
   1.100 +					return 0;
   1.101 +	
   1.102 +				wParam = rotateKey(wParam, this->hidden->gapiInfo->coordinateTransform);
   1.103 +			}
   1.104  #endif
   1.105  
   1.106  			switch (wParam) {
   1.107 @@ -222,12 +232,11 @@
   1.108  				TranslateKey(wParam,HIWORD(lParam),&keysym,0));
   1.109  		}
   1.110  		return(0);
   1.111 -
   1.112  #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
   1.113  		case WM_SYSCOMMAND: {
   1.114  			const DWORD val = (DWORD) (wParam & 0xFFF0);
   1.115  			if ((val == SC_SCREENSAVE) || (val == SC_MONITORPOWER)) {
   1.116 -				if (!allow_screensaver) {
   1.117 +				if (this->hidden->dibInfo && !allow_screensaver) {
   1.118  					/* Note that this doesn't stop anything on Vista
   1.119  					   if the screensaver has a password. */
   1.120  					return(0);
   1.121 @@ -430,6 +439,11 @@
   1.122  	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   1.123  	VK_keymap[VK_CANCEL] = SDLK_BREAK;
   1.124  	VK_keymap[VK_APPS] = SDLK_MENU;
   1.125 +
   1.126 +	Arrows_keymap[3] = 0x25;
   1.127 +	Arrows_keymap[2] = 0x26;
   1.128 +	Arrows_keymap[1] = 0x27;
   1.129 +	Arrows_keymap[0] = 0x28;
   1.130  }
   1.131  
   1.132  #define EXTKEYPAD(keypad) ((scancode & 0x100)?(mvke):(keypad))
   1.133 @@ -485,9 +499,19 @@
   1.134  	keysym->scancode = (unsigned char) scancode;
   1.135  	keysym->mod = KMOD_NONE;
   1.136  	keysym->unicode = 0;
   1.137 +	
   1.138 +	if ((vkey == VK_RETURN) && (scancode & 0x100)) {
   1.139 +		/* No VK_ code for the keypad enter key */
   1.140 +		keysym->sym = SDLK_KP_ENTER;
   1.141 +	}
   1.142 +	else {
   1.143 +		keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
   1.144 +	}
   1.145 +
   1.146  	if ( pressed && SDL_TranslateUNICODE ) {
   1.147  #ifdef NO_GETKEYBOARDSTATE
   1.148  		/* Uh oh, better hope the vkey is close enough.. */
   1.149 +		if((keysym->sym == vkey) || (vkey > 0x7f))
   1.150  		keysym->unicode = vkey;
   1.151  #else
   1.152  		BYTE	keystate[256];
   1.153 @@ -501,14 +525,6 @@
   1.154  #endif /* NO_GETKEYBOARDSTATE */
   1.155  	}
   1.156  
   1.157 -	if ((vkey == VK_RETURN) && (scancode & 0x100)) {
   1.158 -		/* No VK_ code for the keypad enter key */
   1.159 -		keysym->sym = SDLK_KP_ENTER;
   1.160 -	}
   1.161 -	else {
   1.162 -		keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
   1.163 -	}
   1.164 -
   1.165  #if 0
   1.166  	{
   1.167  		HKL     hLayoutCurrent = GetKeyboardLayout(0);