src/video/windib/SDL_dibevents.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1526 89f90f32f6c0
child 1668 4da1ee79c9af
     1.1 --- a/src/video/windib/SDL_dibevents.c	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -43,7 +43,8 @@
     1.4  
     1.5  /* The translation table from a Microsoft VK keysym to a SDL keysym */
     1.6  static SDLKey VK_keymap[SDLK_LAST];
     1.7 -static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed);
     1.8 +static SDL_keysym *TranslateKey (WPARAM vkey, UINT scancode,
     1.9 +                                 SDL_keysym * keysym, int pressed);
    1.10  
    1.11  /* Masks for processing the windows KEYDOWN and KEYUP messages */
    1.12  #define REPEATED_KEYMASK	(1<<30)
    1.13 @@ -61,410 +62,445 @@
    1.14  
    1.15  #ifdef _WIN32_WCE
    1.16  
    1.17 -WPARAM rotateKey(WPARAM key,SDL_ScreenOrientation direction) 
    1.18 +WPARAM
    1.19 +rotateKey (WPARAM key, SDL_ScreenOrientation direction)
    1.20  {
    1.21 -	if (direction != SDL_ORIENTATION_LEFT)
    1.22 -		return key;
    1.23 +    if (direction != SDL_ORIENTATION_LEFT)
    1.24 +        return key;
    1.25  
    1.26 -	switch (key) {
    1.27 -		case 0x26: /* up */
    1.28 -			return 0x27;
    1.29 -		case 0x27: /* right */
    1.30 -			return 0x28;
    1.31 -		case 0x28: /* down */
    1.32 -			return 0x25;
    1.33 -		case 0x25: /* left */
    1.34 -			return 0x26;
    1.35 -	}
    1.36 +    switch (key) {
    1.37 +    case 0x26:                 /* up */
    1.38 +        return 0x27;
    1.39 +    case 0x27:                 /* right */
    1.40 +        return 0x28;
    1.41 +    case 0x28:                 /* down */
    1.42 +        return 0x25;
    1.43 +    case 0x25:                 /* left */
    1.44 +        return 0x26;
    1.45 +    }
    1.46  
    1.47 -	return key;
    1.48 +    return key;
    1.49  }
    1.50  
    1.51 -#endif 
    1.52 +#endif
    1.53  
    1.54  
    1.55  /* The main Win32 event handler */
    1.56 -LRESULT DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    1.57 +LRESULT
    1.58 +DIB_HandleMessage (_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    1.59  {
    1.60 -	extern int posted;
    1.61 +    extern int posted;
    1.62  
    1.63 -	switch (msg) {
    1.64 -		case WM_SYSKEYDOWN:
    1.65 -		case WM_KEYDOWN: {
    1.66 -			SDL_keysym keysym;
    1.67 +    switch (msg) {
    1.68 +    case WM_SYSKEYDOWN:
    1.69 +    case WM_KEYDOWN:
    1.70 +        {
    1.71 +            SDL_keysym keysym;
    1.72  
    1.73  #ifdef _WIN32_WCE
    1.74 -			// Drop GAPI artefacts
    1.75 -			if (wParam == 0x84 || wParam == 0x5B)
    1.76 -				return 0;
    1.77 +            // Drop GAPI artefacts
    1.78 +            if (wParam == 0x84 || wParam == 0x5B)
    1.79 +                return 0;
    1.80  
    1.81 -			// Rotate key if necessary
    1.82 -			if (this->hidden->orientation != SDL_ORIENTATION_UP)
    1.83 -				wParam = rotateKey(wParam, this->hidden->orientation);	
    1.84 -#endif 
    1.85 -			/* Ignore repeated keys */
    1.86 -			if ( lParam&REPEATED_KEYMASK ) {
    1.87 -				return(0);
    1.88 -			}
    1.89 -			switch (wParam) {
    1.90 -				case VK_CONTROL:
    1.91 -					if ( lParam&EXTENDED_KEYMASK )
    1.92 -						wParam = VK_RCONTROL;
    1.93 -					else
    1.94 -						wParam = VK_LCONTROL;
    1.95 -					break;
    1.96 -				case VK_SHIFT:
    1.97 -					/* EXTENDED trick doesn't work here */
    1.98 -					{
    1.99 -					Uint8 *state = SDL_GetKeyState(NULL);
   1.100 -					if (state[SDLK_LSHIFT] == SDL_RELEASED && (GetKeyState(VK_LSHIFT) & 0x8000)) {
   1.101 -						wParam = VK_LSHIFT;
   1.102 -					} else if (state[SDLK_RSHIFT] == SDL_RELEASED && (GetKeyState(VK_RSHIFT) & 0x8000)) {
   1.103 -						wParam = VK_RSHIFT;
   1.104 -					} else {
   1.105 -						/* Probably a key repeat */
   1.106 -						return(0);
   1.107 -					}
   1.108 -					}
   1.109 -					break;
   1.110 -				case VK_MENU:
   1.111 -					if ( lParam&EXTENDED_KEYMASK )
   1.112 -						wParam = VK_RMENU;
   1.113 -					else
   1.114 -						wParam = VK_LMENU;
   1.115 -					break;
   1.116 -			}
   1.117 +            // Rotate key if necessary
   1.118 +            if (this->hidden->orientation != SDL_ORIENTATION_UP)
   1.119 +                wParam = rotateKey (wParam, this->hidden->orientation);
   1.120 +#endif
   1.121 +            /* Ignore repeated keys */
   1.122 +            if (lParam & REPEATED_KEYMASK) {
   1.123 +                return (0);
   1.124 +            }
   1.125 +            switch (wParam) {
   1.126 +            case VK_CONTROL:
   1.127 +                if (lParam & EXTENDED_KEYMASK)
   1.128 +                    wParam = VK_RCONTROL;
   1.129 +                else
   1.130 +                    wParam = VK_LCONTROL;
   1.131 +                break;
   1.132 +            case VK_SHIFT:
   1.133 +                /* EXTENDED trick doesn't work here */
   1.134 +                {
   1.135 +                    Uint8 *state = SDL_GetKeyState (NULL);
   1.136 +                    if (state[SDLK_LSHIFT] == SDL_RELEASED
   1.137 +                        && (GetKeyState (VK_LSHIFT) & 0x8000)) {
   1.138 +                        wParam = VK_LSHIFT;
   1.139 +                    } else if (state[SDLK_RSHIFT] == SDL_RELEASED
   1.140 +                               && (GetKeyState (VK_RSHIFT) & 0x8000)) {
   1.141 +                        wParam = VK_RSHIFT;
   1.142 +                    } else {
   1.143 +                        /* Probably a key repeat */
   1.144 +                        return (0);
   1.145 +                    }
   1.146 +                }
   1.147 +                break;
   1.148 +            case VK_MENU:
   1.149 +                if (lParam & EXTENDED_KEYMASK)
   1.150 +                    wParam = VK_RMENU;
   1.151 +                else
   1.152 +                    wParam = VK_LMENU;
   1.153 +                break;
   1.154 +            }
   1.155  #ifdef NO_GETKEYBOARDSTATE
   1.156 -			/* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */
   1.157 -			if ( SDL_TranslateUNICODE ) {
   1.158 -				MSG m;
   1.159 +            /* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */
   1.160 +            if (SDL_TranslateUNICODE) {
   1.161 +                MSG m;
   1.162  
   1.163 -				m.hwnd = hwnd;
   1.164 -				m.message = msg;
   1.165 -				m.wParam = wParam;
   1.166 -				m.lParam = lParam;
   1.167 -				m.time = 0;
   1.168 -				if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) {
   1.169 -					GetMessage(&m, hwnd, 0, WM_USER);
   1.170 -			    		wParam = m.wParam;
   1.171 -				}
   1.172 -			}
   1.173 +                m.hwnd = hwnd;
   1.174 +                m.message = msg;
   1.175 +                m.wParam = wParam;
   1.176 +                m.lParam = lParam;
   1.177 +                m.time = 0;
   1.178 +                if (TranslateMessage (&m)
   1.179 +                    && PeekMessage (&m, hwnd, 0, WM_USER, PM_NOREMOVE)
   1.180 +                    && (m.message == WM_CHAR)) {
   1.181 +                    GetMessage (&m, hwnd, 0, WM_USER);
   1.182 +                    wParam = m.wParam;
   1.183 +                }
   1.184 +            }
   1.185  #endif /* NO_GETKEYBOARDSTATE */
   1.186 -			posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.187 -				TranslateKey(wParam,HIWORD(lParam),&keysym,1));
   1.188 -		}
   1.189 -		return(0);
   1.190 +            posted = SDL_PrivateKeyboard (SDL_PRESSED,
   1.191 +                                          TranslateKey (wParam,
   1.192 +                                                        HIWORD (lParam),
   1.193 +                                                        &keysym, 1));
   1.194 +        }
   1.195 +        return (0);
   1.196  
   1.197 -		case WM_SYSKEYUP:
   1.198 -		case WM_KEYUP: {
   1.199 -			SDL_keysym keysym;
   1.200 +    case WM_SYSKEYUP:
   1.201 +    case WM_KEYUP:
   1.202 +        {
   1.203 +            SDL_keysym keysym;
   1.204  
   1.205  #ifdef _WIN32_WCE
   1.206 -			// Drop GAPI artifacts
   1.207 -			if (wParam == 0x84 || wParam == 0x5B)
   1.208 -				return 0;
   1.209 +            // Drop GAPI artifacts
   1.210 +            if (wParam == 0x84 || wParam == 0x5B)
   1.211 +                return 0;
   1.212  
   1.213 -			// Rotate key if necessary
   1.214 -			if (this->hidden->orientation != SDL_ORIENTATION_UP)
   1.215 -				wParam = rotateKey(wParam, this->hidden->orientation);	
   1.216 +            // Rotate key if necessary
   1.217 +            if (this->hidden->orientation != SDL_ORIENTATION_UP)
   1.218 +                wParam = rotateKey (wParam, this->hidden->orientation);
   1.219  #endif
   1.220  
   1.221 -			switch (wParam) {
   1.222 -				case VK_CONTROL:
   1.223 -					if ( lParam&EXTENDED_KEYMASK )
   1.224 -						wParam = VK_RCONTROL;
   1.225 -					else
   1.226 -						wParam = VK_LCONTROL;
   1.227 -					break;
   1.228 -				case VK_SHIFT:
   1.229 -					/* EXTENDED trick doesn't work here */
   1.230 -					{
   1.231 -					Uint8 *state = SDL_GetKeyState(NULL);
   1.232 -					if (state[SDLK_LSHIFT] == SDL_PRESSED && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
   1.233 -						wParam = VK_LSHIFT;
   1.234 -					} else if (state[SDLK_RSHIFT] == SDL_PRESSED && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
   1.235 -						wParam = VK_RSHIFT;
   1.236 -					} else {
   1.237 -						/* Probably a key repeat */
   1.238 -						return(0);
   1.239 -					}
   1.240 -					}
   1.241 -					break;
   1.242 -				case VK_MENU:
   1.243 -					if ( lParam&EXTENDED_KEYMASK )
   1.244 -						wParam = VK_RMENU;
   1.245 -					else
   1.246 -						wParam = VK_LMENU;
   1.247 -					break;
   1.248 -			}
   1.249 -			/* Windows only reports keyup for print screen */
   1.250 -			if ( wParam == VK_SNAPSHOT && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED ) {
   1.251 -				posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.252 -					TranslateKey(wParam,HIWORD(lParam),&keysym,1));
   1.253 -			}
   1.254 -			posted = SDL_PrivateKeyboard(SDL_RELEASED,
   1.255 -				TranslateKey(wParam,HIWORD(lParam),&keysym,0));
   1.256 -		}
   1.257 -		return(0);
   1.258 +            switch (wParam) {
   1.259 +            case VK_CONTROL:
   1.260 +                if (lParam & EXTENDED_KEYMASK)
   1.261 +                    wParam = VK_RCONTROL;
   1.262 +                else
   1.263 +                    wParam = VK_LCONTROL;
   1.264 +                break;
   1.265 +            case VK_SHIFT:
   1.266 +                /* EXTENDED trick doesn't work here */
   1.267 +                {
   1.268 +                    Uint8 *state = SDL_GetKeyState (NULL);
   1.269 +                    if (state[SDLK_LSHIFT] == SDL_PRESSED
   1.270 +                        && !(GetKeyState (VK_LSHIFT) & 0x8000)) {
   1.271 +                        wParam = VK_LSHIFT;
   1.272 +                    } else if (state[SDLK_RSHIFT] == SDL_PRESSED
   1.273 +                               && !(GetKeyState (VK_RSHIFT) & 0x8000)) {
   1.274 +                        wParam = VK_RSHIFT;
   1.275 +                    } else {
   1.276 +                        /* Probably a key repeat */
   1.277 +                        return (0);
   1.278 +                    }
   1.279 +                }
   1.280 +                break;
   1.281 +            case VK_MENU:
   1.282 +                if (lParam & EXTENDED_KEYMASK)
   1.283 +                    wParam = VK_RMENU;
   1.284 +                else
   1.285 +                    wParam = VK_LMENU;
   1.286 +                break;
   1.287 +            }
   1.288 +            /* Windows only reports keyup for print screen */
   1.289 +            if (wParam == VK_SNAPSHOT
   1.290 +                && SDL_GetKeyState (NULL)[SDLK_PRINT] == SDL_RELEASED) {
   1.291 +                posted = SDL_PrivateKeyboard (SDL_PRESSED,
   1.292 +                                              TranslateKey (wParam,
   1.293 +                                                            HIWORD
   1.294 +                                                            (lParam),
   1.295 +                                                            &keysym, 1));
   1.296 +            }
   1.297 +            posted = SDL_PrivateKeyboard (SDL_RELEASED,
   1.298 +                                          TranslateKey (wParam,
   1.299 +                                                        HIWORD (lParam),
   1.300 +                                                        &keysym, 0));
   1.301 +        }
   1.302 +        return (0);
   1.303  
   1.304  #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
   1.305 -		case WM_SYSCOMMAND: {
   1.306 -			if ((wParam&0xFFF0)==SC_SCREENSAVE ||
   1.307 -				(wParam&0xFFF0)==SC_MONITORPOWER)
   1.308 -					return(0);
   1.309 -		}
   1.310 -		/* Fall through to default processing */
   1.311 +    case WM_SYSCOMMAND:
   1.312 +        {
   1.313 +            if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
   1.314 +                (wParam & 0xFFF0) == SC_MONITORPOWER)
   1.315 +                return (0);
   1.316 +        }
   1.317 +        /* Fall through to default processing */
   1.318  #endif /* SC_SCREENSAVE && SC_MONITORPOWER */
   1.319  
   1.320 -		default: {
   1.321 -			/* Only post the event if we're watching for it */
   1.322 -			if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
   1.323 -			        SDL_SysWMmsg wmmsg;
   1.324 +    default:
   1.325 +        {
   1.326 +            /* Only post the event if we're watching for it */
   1.327 +            if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
   1.328 +                SDL_SysWMmsg wmmsg;
   1.329  
   1.330 -				SDL_VERSION(&wmmsg.version);
   1.331 -				wmmsg.hwnd = hwnd;
   1.332 -				wmmsg.msg = msg;
   1.333 -				wmmsg.wParam = wParam;
   1.334 -				wmmsg.lParam = lParam;
   1.335 -				posted = SDL_PrivateSysWMEvent(&wmmsg);
   1.336 +                SDL_VERSION (&wmmsg.version);
   1.337 +                wmmsg.hwnd = hwnd;
   1.338 +                wmmsg.msg = msg;
   1.339 +                wmmsg.wParam = wParam;
   1.340 +                wmmsg.lParam = lParam;
   1.341 +                posted = SDL_PrivateSysWMEvent (&wmmsg);
   1.342  
   1.343 -			/* DJM: If the user isn't watching for private
   1.344 -				messages in her SDL event loop, then pass it
   1.345 -				along to any win32 specific window proc.
   1.346 -			 */
   1.347 -			} else if (userWindowProc) {
   1.348 -				return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam);
   1.349 -			}
   1.350 -		}
   1.351 -		break;
   1.352 -	}
   1.353 -	return(DefWindowProc(hwnd, msg, wParam, lParam));
   1.354 +                /* DJM: If the user isn't watching for private
   1.355 +                   messages in her SDL event loop, then pass it
   1.356 +                   along to any win32 specific window proc.
   1.357 +                 */
   1.358 +            } else if (userWindowProc) {
   1.359 +                return CallWindowProc (userWindowProc, hwnd, msg, wParam,
   1.360 +                                       lParam);
   1.361 +            }
   1.362 +        }
   1.363 +        break;
   1.364 +    }
   1.365 +    return (DefWindowProc (hwnd, msg, wParam, lParam));
   1.366  }
   1.367  
   1.368 -void DIB_PumpEvents(_THIS)
   1.369 +void
   1.370 +DIB_PumpEvents (_THIS)
   1.371  {
   1.372 -	MSG msg;
   1.373 +    MSG msg;
   1.374  
   1.375 -	while ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) {
   1.376 -		if ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
   1.377 -			DispatchMessage(&msg);
   1.378 -		}
   1.379 -	}
   1.380 +    while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) {
   1.381 +        if (GetMessage (&msg, NULL, 0, 0) > 0) {
   1.382 +            DispatchMessage (&msg);
   1.383 +        }
   1.384 +    }
   1.385  }
   1.386  
   1.387 -void DIB_InitOSKeymap(_THIS)
   1.388 +void
   1.389 +DIB_InitOSKeymap (_THIS)
   1.390  {
   1.391 -	int i;
   1.392 +    int i;
   1.393  
   1.394 -	/* Map the VK keysyms */
   1.395 -	for ( i=0; i<SDL_arraysize(VK_keymap); ++i )
   1.396 -		VK_keymap[i] = SDLK_UNKNOWN;
   1.397 +    /* Map the VK keysyms */
   1.398 +    for (i = 0; i < SDL_arraysize (VK_keymap); ++i)
   1.399 +        VK_keymap[i] = SDLK_UNKNOWN;
   1.400  
   1.401 -	VK_keymap[VK_BACK] = SDLK_BACKSPACE;
   1.402 -	VK_keymap[VK_TAB] = SDLK_TAB;
   1.403 -	VK_keymap[VK_CLEAR] = SDLK_CLEAR;
   1.404 -	VK_keymap[VK_RETURN] = SDLK_RETURN;
   1.405 -	VK_keymap[VK_PAUSE] = SDLK_PAUSE;
   1.406 -	VK_keymap[VK_ESCAPE] = SDLK_ESCAPE;
   1.407 -	VK_keymap[VK_SPACE] = SDLK_SPACE;
   1.408 -	VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE;
   1.409 -	VK_keymap[VK_COMMA] = SDLK_COMMA;
   1.410 -	VK_keymap[VK_MINUS] = SDLK_MINUS;
   1.411 -	VK_keymap[VK_PERIOD] = SDLK_PERIOD;
   1.412 -	VK_keymap[VK_SLASH] = SDLK_SLASH;
   1.413 -	VK_keymap[VK_0] = SDLK_0;
   1.414 -	VK_keymap[VK_1] = SDLK_1;
   1.415 -	VK_keymap[VK_2] = SDLK_2;
   1.416 -	VK_keymap[VK_3] = SDLK_3;
   1.417 -	VK_keymap[VK_4] = SDLK_4;
   1.418 -	VK_keymap[VK_5] = SDLK_5;
   1.419 -	VK_keymap[VK_6] = SDLK_6;
   1.420 -	VK_keymap[VK_7] = SDLK_7;
   1.421 -	VK_keymap[VK_8] = SDLK_8;
   1.422 -	VK_keymap[VK_9] = SDLK_9;
   1.423 -	VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON;
   1.424 -	VK_keymap[VK_EQUALS] = SDLK_EQUALS;
   1.425 -	VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
   1.426 -	VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
   1.427 -	VK_keymap[VK_OEM_102] = SDLK_LESS;
   1.428 -	VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
   1.429 -	VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
   1.430 -	VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
   1.431 -	VK_keymap[VK_A] = SDLK_a;
   1.432 -	VK_keymap[VK_B] = SDLK_b;
   1.433 -	VK_keymap[VK_C] = SDLK_c;
   1.434 -	VK_keymap[VK_D] = SDLK_d;
   1.435 -	VK_keymap[VK_E] = SDLK_e;
   1.436 -	VK_keymap[VK_F] = SDLK_f;
   1.437 -	VK_keymap[VK_G] = SDLK_g;
   1.438 -	VK_keymap[VK_H] = SDLK_h;
   1.439 -	VK_keymap[VK_I] = SDLK_i;
   1.440 -	VK_keymap[VK_J] = SDLK_j;
   1.441 -	VK_keymap[VK_K] = SDLK_k;
   1.442 -	VK_keymap[VK_L] = SDLK_l;
   1.443 -	VK_keymap[VK_M] = SDLK_m;
   1.444 -	VK_keymap[VK_N] = SDLK_n;
   1.445 -	VK_keymap[VK_O] = SDLK_o;
   1.446 -	VK_keymap[VK_P] = SDLK_p;
   1.447 -	VK_keymap[VK_Q] = SDLK_q;
   1.448 -	VK_keymap[VK_R] = SDLK_r;
   1.449 -	VK_keymap[VK_S] = SDLK_s;
   1.450 -	VK_keymap[VK_T] = SDLK_t;
   1.451 -	VK_keymap[VK_U] = SDLK_u;
   1.452 -	VK_keymap[VK_V] = SDLK_v;
   1.453 -	VK_keymap[VK_W] = SDLK_w;
   1.454 -	VK_keymap[VK_X] = SDLK_x;
   1.455 -	VK_keymap[VK_Y] = SDLK_y;
   1.456 -	VK_keymap[VK_Z] = SDLK_z;
   1.457 -	VK_keymap[VK_DELETE] = SDLK_DELETE;
   1.458 +    VK_keymap[VK_BACK] = SDLK_BACKSPACE;
   1.459 +    VK_keymap[VK_TAB] = SDLK_TAB;
   1.460 +    VK_keymap[VK_CLEAR] = SDLK_CLEAR;
   1.461 +    VK_keymap[VK_RETURN] = SDLK_RETURN;
   1.462 +    VK_keymap[VK_PAUSE] = SDLK_PAUSE;
   1.463 +    VK_keymap[VK_ESCAPE] = SDLK_ESCAPE;
   1.464 +    VK_keymap[VK_SPACE] = SDLK_SPACE;
   1.465 +    VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE;
   1.466 +    VK_keymap[VK_COMMA] = SDLK_COMMA;
   1.467 +    VK_keymap[VK_MINUS] = SDLK_MINUS;
   1.468 +    VK_keymap[VK_PERIOD] = SDLK_PERIOD;
   1.469 +    VK_keymap[VK_SLASH] = SDLK_SLASH;
   1.470 +    VK_keymap[VK_0] = SDLK_0;
   1.471 +    VK_keymap[VK_1] = SDLK_1;
   1.472 +    VK_keymap[VK_2] = SDLK_2;
   1.473 +    VK_keymap[VK_3] = SDLK_3;
   1.474 +    VK_keymap[VK_4] = SDLK_4;
   1.475 +    VK_keymap[VK_5] = SDLK_5;
   1.476 +    VK_keymap[VK_6] = SDLK_6;
   1.477 +    VK_keymap[VK_7] = SDLK_7;
   1.478 +    VK_keymap[VK_8] = SDLK_8;
   1.479 +    VK_keymap[VK_9] = SDLK_9;
   1.480 +    VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON;
   1.481 +    VK_keymap[VK_EQUALS] = SDLK_EQUALS;
   1.482 +    VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
   1.483 +    VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
   1.484 +    VK_keymap[VK_OEM_102] = SDLK_LESS;
   1.485 +    VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
   1.486 +    VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
   1.487 +    VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
   1.488 +    VK_keymap[VK_A] = SDLK_a;
   1.489 +    VK_keymap[VK_B] = SDLK_b;
   1.490 +    VK_keymap[VK_C] = SDLK_c;
   1.491 +    VK_keymap[VK_D] = SDLK_d;
   1.492 +    VK_keymap[VK_E] = SDLK_e;
   1.493 +    VK_keymap[VK_F] = SDLK_f;
   1.494 +    VK_keymap[VK_G] = SDLK_g;
   1.495 +    VK_keymap[VK_H] = SDLK_h;
   1.496 +    VK_keymap[VK_I] = SDLK_i;
   1.497 +    VK_keymap[VK_J] = SDLK_j;
   1.498 +    VK_keymap[VK_K] = SDLK_k;
   1.499 +    VK_keymap[VK_L] = SDLK_l;
   1.500 +    VK_keymap[VK_M] = SDLK_m;
   1.501 +    VK_keymap[VK_N] = SDLK_n;
   1.502 +    VK_keymap[VK_O] = SDLK_o;
   1.503 +    VK_keymap[VK_P] = SDLK_p;
   1.504 +    VK_keymap[VK_Q] = SDLK_q;
   1.505 +    VK_keymap[VK_R] = SDLK_r;
   1.506 +    VK_keymap[VK_S] = SDLK_s;
   1.507 +    VK_keymap[VK_T] = SDLK_t;
   1.508 +    VK_keymap[VK_U] = SDLK_u;
   1.509 +    VK_keymap[VK_V] = SDLK_v;
   1.510 +    VK_keymap[VK_W] = SDLK_w;
   1.511 +    VK_keymap[VK_X] = SDLK_x;
   1.512 +    VK_keymap[VK_Y] = SDLK_y;
   1.513 +    VK_keymap[VK_Z] = SDLK_z;
   1.514 +    VK_keymap[VK_DELETE] = SDLK_DELETE;
   1.515  
   1.516 -	VK_keymap[VK_NUMPAD0] = SDLK_KP0;
   1.517 -	VK_keymap[VK_NUMPAD1] = SDLK_KP1;
   1.518 -	VK_keymap[VK_NUMPAD2] = SDLK_KP2;
   1.519 -	VK_keymap[VK_NUMPAD3] = SDLK_KP3;
   1.520 -	VK_keymap[VK_NUMPAD4] = SDLK_KP4;
   1.521 -	VK_keymap[VK_NUMPAD5] = SDLK_KP5;
   1.522 -	VK_keymap[VK_NUMPAD6] = SDLK_KP6;
   1.523 -	VK_keymap[VK_NUMPAD7] = SDLK_KP7;
   1.524 -	VK_keymap[VK_NUMPAD8] = SDLK_KP8;
   1.525 -	VK_keymap[VK_NUMPAD9] = SDLK_KP9;
   1.526 -	VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD;
   1.527 -	VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE;
   1.528 -	VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY;
   1.529 -	VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS;
   1.530 -	VK_keymap[VK_ADD] = SDLK_KP_PLUS;
   1.531 +    VK_keymap[VK_NUMPAD0] = SDLK_KP0;
   1.532 +    VK_keymap[VK_NUMPAD1] = SDLK_KP1;
   1.533 +    VK_keymap[VK_NUMPAD2] = SDLK_KP2;
   1.534 +    VK_keymap[VK_NUMPAD3] = SDLK_KP3;
   1.535 +    VK_keymap[VK_NUMPAD4] = SDLK_KP4;
   1.536 +    VK_keymap[VK_NUMPAD5] = SDLK_KP5;
   1.537 +    VK_keymap[VK_NUMPAD6] = SDLK_KP6;
   1.538 +    VK_keymap[VK_NUMPAD7] = SDLK_KP7;
   1.539 +    VK_keymap[VK_NUMPAD8] = SDLK_KP8;
   1.540 +    VK_keymap[VK_NUMPAD9] = SDLK_KP9;
   1.541 +    VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD;
   1.542 +    VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE;
   1.543 +    VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY;
   1.544 +    VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS;
   1.545 +    VK_keymap[VK_ADD] = SDLK_KP_PLUS;
   1.546  
   1.547 -	VK_keymap[VK_UP] = SDLK_UP;
   1.548 -	VK_keymap[VK_DOWN] = SDLK_DOWN;
   1.549 -	VK_keymap[VK_RIGHT] = SDLK_RIGHT;
   1.550 -	VK_keymap[VK_LEFT] = SDLK_LEFT;
   1.551 -	VK_keymap[VK_INSERT] = SDLK_INSERT;
   1.552 -	VK_keymap[VK_HOME] = SDLK_HOME;
   1.553 -	VK_keymap[VK_END] = SDLK_END;
   1.554 -	VK_keymap[VK_PRIOR] = SDLK_PAGEUP;
   1.555 -	VK_keymap[VK_NEXT] = SDLK_PAGEDOWN;
   1.556 +    VK_keymap[VK_UP] = SDLK_UP;
   1.557 +    VK_keymap[VK_DOWN] = SDLK_DOWN;
   1.558 +    VK_keymap[VK_RIGHT] = SDLK_RIGHT;
   1.559 +    VK_keymap[VK_LEFT] = SDLK_LEFT;
   1.560 +    VK_keymap[VK_INSERT] = SDLK_INSERT;
   1.561 +    VK_keymap[VK_HOME] = SDLK_HOME;
   1.562 +    VK_keymap[VK_END] = SDLK_END;
   1.563 +    VK_keymap[VK_PRIOR] = SDLK_PAGEUP;
   1.564 +    VK_keymap[VK_NEXT] = SDLK_PAGEDOWN;
   1.565  
   1.566 -	VK_keymap[VK_F1] = SDLK_F1;
   1.567 -	VK_keymap[VK_F2] = SDLK_F2;
   1.568 -	VK_keymap[VK_F3] = SDLK_F3;
   1.569 -	VK_keymap[VK_F4] = SDLK_F4;
   1.570 -	VK_keymap[VK_F5] = SDLK_F5;
   1.571 -	VK_keymap[VK_F6] = SDLK_F6;
   1.572 -	VK_keymap[VK_F7] = SDLK_F7;
   1.573 -	VK_keymap[VK_F8] = SDLK_F8;
   1.574 -	VK_keymap[VK_F9] = SDLK_F9;
   1.575 -	VK_keymap[VK_F10] = SDLK_F10;
   1.576 -	VK_keymap[VK_F11] = SDLK_F11;
   1.577 -	VK_keymap[VK_F12] = SDLK_F12;
   1.578 -	VK_keymap[VK_F13] = SDLK_F13;
   1.579 -	VK_keymap[VK_F14] = SDLK_F14;
   1.580 -	VK_keymap[VK_F15] = SDLK_F15;
   1.581 +    VK_keymap[VK_F1] = SDLK_F1;
   1.582 +    VK_keymap[VK_F2] = SDLK_F2;
   1.583 +    VK_keymap[VK_F3] = SDLK_F3;
   1.584 +    VK_keymap[VK_F4] = SDLK_F4;
   1.585 +    VK_keymap[VK_F5] = SDLK_F5;
   1.586 +    VK_keymap[VK_F6] = SDLK_F6;
   1.587 +    VK_keymap[VK_F7] = SDLK_F7;
   1.588 +    VK_keymap[VK_F8] = SDLK_F8;
   1.589 +    VK_keymap[VK_F9] = SDLK_F9;
   1.590 +    VK_keymap[VK_F10] = SDLK_F10;
   1.591 +    VK_keymap[VK_F11] = SDLK_F11;
   1.592 +    VK_keymap[VK_F12] = SDLK_F12;
   1.593 +    VK_keymap[VK_F13] = SDLK_F13;
   1.594 +    VK_keymap[VK_F14] = SDLK_F14;
   1.595 +    VK_keymap[VK_F15] = SDLK_F15;
   1.596  
   1.597 -	VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
   1.598 -	VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
   1.599 -	VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK;
   1.600 -	VK_keymap[VK_RSHIFT] = SDLK_RSHIFT;
   1.601 -	VK_keymap[VK_LSHIFT] = SDLK_LSHIFT;
   1.602 -	VK_keymap[VK_RCONTROL] = SDLK_RCTRL;
   1.603 -	VK_keymap[VK_LCONTROL] = SDLK_LCTRL;
   1.604 -	VK_keymap[VK_RMENU] = SDLK_RALT;
   1.605 -	VK_keymap[VK_LMENU] = SDLK_LALT;
   1.606 -	VK_keymap[VK_RWIN] = SDLK_RSUPER;
   1.607 -	VK_keymap[VK_LWIN] = SDLK_LSUPER;
   1.608 +    VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
   1.609 +    VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
   1.610 +    VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK;
   1.611 +    VK_keymap[VK_RSHIFT] = SDLK_RSHIFT;
   1.612 +    VK_keymap[VK_LSHIFT] = SDLK_LSHIFT;
   1.613 +    VK_keymap[VK_RCONTROL] = SDLK_RCTRL;
   1.614 +    VK_keymap[VK_LCONTROL] = SDLK_LCTRL;
   1.615 +    VK_keymap[VK_RMENU] = SDLK_RALT;
   1.616 +    VK_keymap[VK_LMENU] = SDLK_LALT;
   1.617 +    VK_keymap[VK_RWIN] = SDLK_RSUPER;
   1.618 +    VK_keymap[VK_LWIN] = SDLK_LSUPER;
   1.619  
   1.620 -	VK_keymap[VK_HELP] = SDLK_HELP;
   1.621 +    VK_keymap[VK_HELP] = SDLK_HELP;
   1.622  #ifdef VK_PRINT
   1.623 -	VK_keymap[VK_PRINT] = SDLK_PRINT;
   1.624 +    VK_keymap[VK_PRINT] = SDLK_PRINT;
   1.625  #endif
   1.626 -	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   1.627 -	VK_keymap[VK_CANCEL] = SDLK_BREAK;
   1.628 -	VK_keymap[VK_APPS] = SDLK_MENU;
   1.629 +    VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   1.630 +    VK_keymap[VK_CANCEL] = SDLK_BREAK;
   1.631 +    VK_keymap[VK_APPS] = SDLK_MENU;
   1.632  }
   1.633  
   1.634 -static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed)
   1.635 +static SDL_keysym *
   1.636 +TranslateKey (WPARAM vkey, UINT scancode, SDL_keysym * keysym, int pressed)
   1.637  {
   1.638 -	/* Set the keysym information */
   1.639 -	keysym->scancode = (unsigned char) scancode;
   1.640 -	keysym->sym = VK_keymap[vkey];
   1.641 -	keysym->mod = KMOD_NONE;
   1.642 -	keysym->unicode = 0;
   1.643 -	if ( pressed && SDL_TranslateUNICODE ) {
   1.644 +    /* Set the keysym information */
   1.645 +    keysym->scancode = (unsigned char) scancode;
   1.646 +    keysym->sym = VK_keymap[vkey];
   1.647 +    keysym->mod = KMOD_NONE;
   1.648 +    keysym->unicode = 0;
   1.649 +    if (pressed && SDL_TranslateUNICODE) {
   1.650  #ifdef NO_GETKEYBOARDSTATE
   1.651 -		/* Uh oh, better hope the vkey is close enough.. */
   1.652 -		keysym->unicode = vkey;
   1.653 +        /* Uh oh, better hope the vkey is close enough.. */
   1.654 +        keysym->unicode = vkey;
   1.655  #else
   1.656 -		BYTE	keystate[256];
   1.657 -		Uint16	wchars[2];
   1.658 +        BYTE keystate[256];
   1.659 +        Uint16 wchars[2];
   1.660  
   1.661 -		GetKeyboardState(keystate);
   1.662 -		if (SDL_ToUnicode((UINT)vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1)
   1.663 -		{
   1.664 -			keysym->unicode = wchars[0];
   1.665 -		}
   1.666 +        GetKeyboardState (keystate);
   1.667 +        if (SDL_ToUnicode
   1.668 +            ((UINT) vkey, scancode, keystate, wchars,
   1.669 +             sizeof (wchars) / sizeof (wchars[0]), 0) == 1) {
   1.670 +            keysym->unicode = wchars[0];
   1.671 +        }
   1.672  #endif /* NO_GETKEYBOARDSTATE */
   1.673 -	}
   1.674 -	return(keysym);
   1.675 +    }
   1.676 +    return (keysym);
   1.677  }
   1.678  
   1.679 -int DIB_CreateWindow(_THIS)
   1.680 +int
   1.681 +DIB_CreateWindow (_THIS)
   1.682  {
   1.683 -	char *windowid = SDL_getenv("SDL_WINDOWID");
   1.684 +    char *windowid = SDL_getenv ("SDL_WINDOWID");
   1.685  
   1.686 -	SDL_RegisterApp(NULL, 0, 0);
   1.687 +    SDL_RegisterApp (NULL, 0, 0);
   1.688  
   1.689 -	SDL_windowid = (windowid != NULL);
   1.690 -	if ( SDL_windowid ) {
   1.691 +    SDL_windowid = (windowid != NULL);
   1.692 +    if (SDL_windowid) {
   1.693  #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
   1.694 -		/* wince 2.1 does not have strtol */
   1.695 -		wchar_t *windowid_t = SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t));
   1.696 -		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, SDL_strlen(windowid) + 1);
   1.697 -		SDL_Window = (HWND)wcstol(windowid_t, NULL, 0);
   1.698 -		SDL_free(windowid_t);
   1.699 +        /* wince 2.1 does not have strtol */
   1.700 +        wchar_t *windowid_t =
   1.701 +            SDL_malloc ((SDL_strlen (windowid) + 1) * sizeof (wchar_t));
   1.702 +        MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, windowid, -1,
   1.703 +                             windowid_t, SDL_strlen (windowid) + 1);
   1.704 +        SDL_Window = (HWND) wcstol (windowid_t, NULL, 0);
   1.705 +        SDL_free (windowid_t);
   1.706  #else
   1.707 -		SDL_Window = (HWND)SDL_strtoull(windowid, NULL, 0);
   1.708 +        SDL_Window = (HWND) SDL_strtoull (windowid, NULL, 0);
   1.709  #endif
   1.710 -		if ( SDL_Window == NULL ) {
   1.711 -			SDL_SetError("Couldn't get user specified window");
   1.712 -			return(-1);
   1.713 -		}
   1.714 +        if (SDL_Window == NULL) {
   1.715 +            SDL_SetError ("Couldn't get user specified window");
   1.716 +            return (-1);
   1.717 +        }
   1.718  
   1.719 -		/* DJM: we want all event's for the user specified
   1.720 -			window to be handled by SDL.
   1.721 -		 */
   1.722 -		userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
   1.723 -		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)WinMessage);
   1.724 -	} else {
   1.725 -		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
   1.726 -                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
   1.727 -                        CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
   1.728 -		if ( SDL_Window == NULL ) {
   1.729 -			SDL_SetError("Couldn't create window");
   1.730 -			return(-1);
   1.731 -		}
   1.732 -		ShowWindow(SDL_Window, SW_HIDE);
   1.733 -	}
   1.734 +        /* DJM: we want all event's for the user specified
   1.735 +           window to be handled by SDL.
   1.736 +         */
   1.737 +        userWindowProc =
   1.738 +            (WNDPROCTYPE) GetWindowLongPtr (SDL_Window, GWLP_WNDPROC);
   1.739 +        SetWindowLongPtr (SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage);
   1.740 +    } else {
   1.741 +        SDL_Window = CreateWindow (SDL_Appname, SDL_Appname,
   1.742 +                                   (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
   1.743 +                                    | WS_MINIMIZEBOX), CW_USEDEFAULT,
   1.744 +                                   CW_USEDEFAULT, 0, 0, NULL, NULL,
   1.745 +                                   SDL_Instance, NULL);
   1.746 +        if (SDL_Window == NULL) {
   1.747 +            SDL_SetError ("Couldn't create window");
   1.748 +            return (-1);
   1.749 +        }
   1.750 +        ShowWindow (SDL_Window, SW_HIDE);
   1.751 +    }
   1.752  
   1.753 -	/* JC 14 Mar 2006
   1.754 -		Flush the message loop or this can cause big problems later
   1.755 -		Especially if the user decides to use dialog boxes or assert()!
   1.756 -	*/
   1.757 -	WIN_FlushMessageQueue();
   1.758 +    /* JC 14 Mar 2006
   1.759 +       Flush the message loop or this can cause big problems later
   1.760 +       Especially if the user decides to use dialog boxes or assert()!
   1.761 +     */
   1.762 +    WIN_FlushMessageQueue ();
   1.763  
   1.764 -	return(0);
   1.765 +    return (0);
   1.766  }
   1.767  
   1.768 -void DIB_DestroyWindow(_THIS)
   1.769 +void
   1.770 +DIB_DestroyWindow (_THIS)
   1.771  {
   1.772 -	if ( SDL_windowid ) {
   1.773 -		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)userWindowProc);
   1.774 -	} else {
   1.775 -		DestroyWindow(SDL_Window);
   1.776 -	}
   1.777 -	SDL_UnregisterApp();
   1.778 +    if (SDL_windowid) {
   1.779 +        SetWindowLongPtr (SDL_Window, GWLP_WNDPROC,
   1.780 +                          (LONG_PTR) userWindowProc);
   1.781 +    } else {
   1.782 +        DestroyWindow (SDL_Window);
   1.783 +    }
   1.784 +    SDL_UnregisterApp ();
   1.785  
   1.786 -	/* JC 14 Mar 2006
   1.787 -		Flush the message loop or this can cause big problems later
   1.788 -		Especially if the user decides to use dialog boxes or assert()!
   1.789 -	*/
   1.790 -	WIN_FlushMessageQueue();
   1.791 +    /* JC 14 Mar 2006
   1.792 +       Flush the message loop or this can cause big problems later
   1.793 +       Especially if the user decides to use dialog boxes or assert()!
   1.794 +     */
   1.795 +    WIN_FlushMessageQueue ();
   1.796  }
   1.797 +
   1.798 +/* vi: set ts=4 sw=4 expandtab: */