src/video/windib/SDL_dibevents.c
changeset 1895 c121d94672cb
parent 1852 eb2d5480ae95
     1.1 --- a/src/video/windib/SDL_dibevents.c	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Mon Jul 10 21:04:37 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,505 +62,444 @@
    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 -						/* Win9x */
   1.106 -						int sc = HIWORD(lParam) & 0xFF;
   1.107 +            // Rotate key if necessary
   1.108 +            if (this->hidden->orientation != SDL_ORIENTATION_UP)
   1.109 +                wParam = rotateKey(wParam, this->hidden->orientation);
   1.110 +#endif
   1.111 +            /* Ignore repeated keys */
   1.112 +            if (lParam & REPEATED_KEYMASK) {
   1.113 +                return (0);
   1.114 +            }
   1.115 +            switch (wParam) {
   1.116 +            case VK_CONTROL:
   1.117 +                if (lParam & EXTENDED_KEYMASK)
   1.118 +                    wParam = VK_RCONTROL;
   1.119 +                else
   1.120 +                    wParam = VK_LCONTROL;
   1.121 +                break;
   1.122 +            case VK_SHIFT:
   1.123 +                /* EXTENDED trick doesn't work here */
   1.124 +                {
   1.125 +                    Uint8 *state = SDL_GetKeyState(NULL);
   1.126 +                    if (state[SDLK_LSHIFT] == SDL_RELEASED
   1.127 +                        && (GetKeyState(VK_LSHIFT) & 0x8000)) {
   1.128 +                        wParam = VK_LSHIFT;
   1.129 +                    } else if (state[SDLK_RSHIFT] == SDL_RELEASED
   1.130 +                               && (GetKeyState(VK_RSHIFT) & 0x8000)) {
   1.131 +                        wParam = VK_RSHIFT;
   1.132 +                    } else {
   1.133 +                        /* Probably a key repeat */
   1.134 +                        return (0);
   1.135 +                    }
   1.136 +                }
   1.137 +                break;
   1.138 +            case VK_MENU:
   1.139 +                if (lParam & EXTENDED_KEYMASK)
   1.140 +                    wParam = VK_RMENU;
   1.141 +                else
   1.142 +                    wParam = VK_LMENU;
   1.143 +                break;
   1.144 +            }
   1.145 +#ifdef NO_GETKEYBOARDSTATE
   1.146 +            /* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */
   1.147 +            if (SDL_TranslateUNICODE) {
   1.148 +                MSG m;
   1.149  
   1.150 -						if (sc == 0x2A)
   1.151 -							wParam = VK_LSHIFT;
   1.152 -						else
   1.153 -						if (sc == 0x36)
   1.154 -							wParam = VK_RSHIFT;
   1.155 -						else
   1.156 -							wParam = VK_LSHIFT;
   1.157 -					}
   1.158 -					}
   1.159 -					break;
   1.160 -				case VK_MENU:
   1.161 -					if ( lParam&EXTENDED_KEYMASK )
   1.162 -						wParam = VK_RMENU;
   1.163 -					else
   1.164 -						wParam = VK_LMENU;
   1.165 -					break;
   1.166 -			}
   1.167 -#ifdef NO_GETKEYBOARDSTATE
   1.168 -			/* this is the workaround for the missing ToAscii() and ToUnicode() in CE (not necessary at KEYUP!) */
   1.169 -			if ( SDL_TranslateUNICODE ) {
   1.170 -				MSG m;
   1.171 +                m.hwnd = hwnd;
   1.172 +                m.message = msg;
   1.173 +                m.wParam = wParam;
   1.174 +                m.lParam = lParam;
   1.175 +                m.time = 0;
   1.176 +                if (TranslateMessage(&m)
   1.177 +                    && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE)
   1.178 +                    && (m.message == WM_CHAR)) {
   1.179 +                    GetMessage(&m, hwnd, 0, WM_USER);
   1.180 +                    wParam = m.wParam;
   1.181 +                }
   1.182 +            }
   1.183 +#endif /* NO_GETKEYBOARDSTATE */
   1.184 +            posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.185 +                                         TranslateKey(wParam,
   1.186 +                                                      HIWORD(lParam),
   1.187 +                                                      &keysym, 1));
   1.188 +        }
   1.189 +        return (0);
   1.190  
   1.191 -				m.hwnd = hwnd;
   1.192 -				m.message = msg;
   1.193 -				m.wParam = wParam;
   1.194 -				m.lParam = lParam;
   1.195 -				m.time = 0;
   1.196 -				if ( TranslateMessage(&m) && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR) ) {
   1.197 -					GetMessage(&m, hwnd, 0, WM_USER);
   1.198 -			    		wParam = m.wParam;
   1.199 -				}
   1.200 -			}
   1.201 -#endif /* NO_GETKEYBOARDSTATE */
   1.202 -			posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.203 -				TranslateKey(wParam,HIWORD(lParam),&keysym,1));
   1.204 -		}
   1.205 -		return(0);
   1.206 -
   1.207 -		case WM_SYSKEYUP:
   1.208 -		case WM_KEYUP: {
   1.209 -			SDL_keysym keysym;
   1.210 +    case WM_SYSKEYUP:
   1.211 +    case WM_KEYUP:
   1.212 +        {
   1.213 +            SDL_keysym keysym;
   1.214  
   1.215  #ifdef _WIN32_WCE
   1.216 -			// Drop GAPI artifacts
   1.217 -			if (wParam == 0x84 || wParam == 0x5B)
   1.218 -				return 0;
   1.219 +            // Drop GAPI artifacts
   1.220 +            if (wParam == 0x84 || wParam == 0x5B)
   1.221 +                return 0;
   1.222  
   1.223 -			// Rotate key if necessary
   1.224 -			if (this->hidden->orientation != SDL_ORIENTATION_UP)
   1.225 -				wParam = rotateKey(wParam, this->hidden->orientation);	
   1.226 +            // Rotate key if necessary
   1.227 +            if (this->hidden->orientation != SDL_ORIENTATION_UP)
   1.228 +                wParam = rotateKey(wParam, this->hidden->orientation);
   1.229  #endif
   1.230  
   1.231 -			switch (wParam) {
   1.232 -				case VK_CONTROL:
   1.233 -					if ( lParam&EXTENDED_KEYMASK )
   1.234 -						wParam = VK_RCONTROL;
   1.235 -					else
   1.236 -						wParam = VK_LCONTROL;
   1.237 -					break;
   1.238 -				case VK_SHIFT:
   1.239 -					/* EXTENDED trick doesn't work here */
   1.240 -					{
   1.241 -					Uint8 *state = SDL_GetKeyState(NULL);
   1.242 -					if (state[SDLK_LSHIFT] == SDL_PRESSED && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
   1.243 -						wParam = VK_LSHIFT;
   1.244 -					} else if (state[SDLK_RSHIFT] == SDL_PRESSED && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
   1.245 -						wParam = VK_RSHIFT;
   1.246 -					} else {
   1.247 -						/* Win9x */
   1.248 -						int sc = HIWORD(lParam) & 0xFF;
   1.249 -
   1.250 -						if (sc == 0x2A)
   1.251 -							wParam = VK_LSHIFT;
   1.252 -						else
   1.253 -						if (sc == 0x36)
   1.254 -							wParam = VK_RSHIFT;
   1.255 -						else
   1.256 -							wParam = VK_LSHIFT;
   1.257 -					}
   1.258 -					}
   1.259 -					break;
   1.260 -				case VK_MENU:
   1.261 -					if ( lParam&EXTENDED_KEYMASK )
   1.262 -						wParam = VK_RMENU;
   1.263 -					else
   1.264 -						wParam = VK_LMENU;
   1.265 -					break;
   1.266 -			}
   1.267 -			/* Windows only reports keyup for print screen */
   1.268 -			if ( wParam == VK_SNAPSHOT && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED ) {
   1.269 -				posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.270 -					TranslateKey(wParam,HIWORD(lParam),&keysym,1));
   1.271 -			}
   1.272 -			posted = SDL_PrivateKeyboard(SDL_RELEASED,
   1.273 -				TranslateKey(wParam,HIWORD(lParam),&keysym,0));
   1.274 -		}
   1.275 -		return(0);
   1.276 +            switch (wParam) {
   1.277 +            case VK_CONTROL:
   1.278 +                if (lParam & EXTENDED_KEYMASK)
   1.279 +                    wParam = VK_RCONTROL;
   1.280 +                else
   1.281 +                    wParam = VK_LCONTROL;
   1.282 +                break;
   1.283 +            case VK_SHIFT:
   1.284 +                /* EXTENDED trick doesn't work here */
   1.285 +                {
   1.286 +                    Uint8 *state = SDL_GetKeyState(NULL);
   1.287 +                    if (state[SDLK_LSHIFT] == SDL_PRESSED
   1.288 +                        && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
   1.289 +                        wParam = VK_LSHIFT;
   1.290 +                    } else if (state[SDLK_RSHIFT] == SDL_PRESSED
   1.291 +                               && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
   1.292 +                        wParam = VK_RSHIFT;
   1.293 +                    } else {
   1.294 +                        /* Probably a key repeat */
   1.295 +                        return (0);
   1.296 +                    }
   1.297 +                }
   1.298 +                break;
   1.299 +            case VK_MENU:
   1.300 +                if (lParam & EXTENDED_KEYMASK)
   1.301 +                    wParam = VK_RMENU;
   1.302 +                else
   1.303 +                    wParam = VK_LMENU;
   1.304 +                break;
   1.305 +            }
   1.306 +            /* Windows only reports keyup for print screen */
   1.307 +            if (wParam == VK_SNAPSHOT
   1.308 +                && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED) {
   1.309 +                posted = SDL_PrivateKeyboard(SDL_PRESSED,
   1.310 +                                             TranslateKey(wParam,
   1.311 +                                                          HIWORD
   1.312 +                                                          (lParam),
   1.313 +                                                          &keysym, 1));
   1.314 +            }
   1.315 +            posted = SDL_PrivateKeyboard(SDL_RELEASED,
   1.316 +                                         TranslateKey(wParam,
   1.317 +                                                      HIWORD(lParam),
   1.318 +                                                      &keysym, 0));
   1.319 +        }
   1.320 +        return (0);
   1.321  
   1.322  #if defined(SC_SCREENSAVE) && defined(SC_MONITORPOWER)
   1.323 -		case WM_SYSCOMMAND: {
   1.324 -			if ((wParam&0xFFF0)==SC_SCREENSAVE ||
   1.325 -				(wParam&0xFFF0)==SC_MONITORPOWER)
   1.326 -					return(0);
   1.327 -		}
   1.328 -		/* Fall through to default processing */
   1.329 +    case WM_SYSCOMMAND:
   1.330 +        {
   1.331 +            if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
   1.332 +                (wParam & 0xFFF0) == SC_MONITORPOWER)
   1.333 +                return (0);
   1.334 +        }
   1.335 +        /* Fall through to default processing */
   1.336  #endif /* SC_SCREENSAVE && SC_MONITORPOWER */
   1.337  
   1.338 -		default: {
   1.339 -			/* Only post the event if we're watching for it */
   1.340 -			if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
   1.341 -			        SDL_SysWMmsg wmmsg;
   1.342 +    default:
   1.343 +        {
   1.344 +            /* Only post the event if we're watching for it */
   1.345 +            if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
   1.346 +                SDL_SysWMmsg wmmsg;
   1.347  
   1.348 -				SDL_VERSION(&wmmsg.version);
   1.349 -				wmmsg.hwnd = hwnd;
   1.350 -				wmmsg.msg = msg;
   1.351 -				wmmsg.wParam = wParam;
   1.352 -				wmmsg.lParam = lParam;
   1.353 -				posted = SDL_PrivateSysWMEvent(&wmmsg);
   1.354 +                SDL_VERSION(&wmmsg.version);
   1.355 +                wmmsg.hwnd = hwnd;
   1.356 +                wmmsg.msg = msg;
   1.357 +                wmmsg.wParam = wParam;
   1.358 +                wmmsg.lParam = lParam;
   1.359 +                posted = SDL_PrivateSysWMEvent(&wmmsg);
   1.360  
   1.361 -			/* DJM: If the user isn't watching for private
   1.362 -				messages in her SDL event loop, then pass it
   1.363 -				along to any win32 specific window proc.
   1.364 -			 */
   1.365 -			} else if (userWindowProc) {
   1.366 -				return CallWindowProc(userWindowProc, hwnd, msg, wParam, lParam);
   1.367 -			}
   1.368 -		}
   1.369 -		break;
   1.370 -	}
   1.371 -	return(DefWindowProc(hwnd, msg, wParam, lParam));
   1.372 +                /* DJM: If the user isn't watching for private
   1.373 +                   messages in her SDL event loop, then pass it
   1.374 +                   along to any win32 specific window proc.
   1.375 +                 */
   1.376 +            } else if (userWindowProc) {
   1.377 +                return CallWindowProc(userWindowProc, hwnd, msg, wParam,
   1.378 +                                      lParam);
   1.379 +            }
   1.380 +        }
   1.381 +        break;
   1.382 +    }
   1.383 +    return (DefWindowProc(hwnd, msg, wParam, lParam));
   1.384  }
   1.385  
   1.386 -void DIB_PumpEvents(_THIS)
   1.387 +void
   1.388 +DIB_PumpEvents(_THIS)
   1.389  {
   1.390 -	MSG msg;
   1.391 +    MSG msg;
   1.392  
   1.393 -	while ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) {
   1.394 -		if ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
   1.395 -			DispatchMessage(&msg);
   1.396 -		}
   1.397 -	}
   1.398 +    while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
   1.399 +        if (GetMessage(&msg, NULL, 0, 0) > 0) {
   1.400 +            DispatchMessage(&msg);
   1.401 +        }
   1.402 +    }
   1.403  }
   1.404  
   1.405 -static HKL hLayoutUS = NULL;
   1.406 +void
   1.407 +DIB_InitOSKeymap(_THIS)
   1.408 +{
   1.409 +    int i;
   1.410  
   1.411 -void DIB_InitOSKeymap(_THIS)
   1.412 -{
   1.413 -	int	i;
   1.414 -	char	current_layout[256];
   1.415 +    /* Map the VK keysyms */
   1.416 +    for (i = 0; i < SDL_arraysize(VK_keymap); ++i)
   1.417 +        VK_keymap[i] = SDLK_UNKNOWN;
   1.418  
   1.419 -	GetKeyboardLayoutName(current_layout);
   1.420 -	//printf("Initial Keyboard Layout Name: '%s'\n", current_layout);
   1.421 +    VK_keymap[VK_BACK] = SDLK_BACKSPACE;
   1.422 +    VK_keymap[VK_TAB] = SDLK_TAB;
   1.423 +    VK_keymap[VK_CLEAR] = SDLK_CLEAR;
   1.424 +    VK_keymap[VK_RETURN] = SDLK_RETURN;
   1.425 +    VK_keymap[VK_PAUSE] = SDLK_PAUSE;
   1.426 +    VK_keymap[VK_ESCAPE] = SDLK_ESCAPE;
   1.427 +    VK_keymap[VK_SPACE] = SDLK_SPACE;
   1.428 +    VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE;
   1.429 +    VK_keymap[VK_COMMA] = SDLK_COMMA;
   1.430 +    VK_keymap[VK_MINUS] = SDLK_MINUS;
   1.431 +    VK_keymap[VK_PERIOD] = SDLK_PERIOD;
   1.432 +    VK_keymap[VK_SLASH] = SDLK_SLASH;
   1.433 +    VK_keymap[VK_0] = SDLK_0;
   1.434 +    VK_keymap[VK_1] = SDLK_1;
   1.435 +    VK_keymap[VK_2] = SDLK_2;
   1.436 +    VK_keymap[VK_3] = SDLK_3;
   1.437 +    VK_keymap[VK_4] = SDLK_4;
   1.438 +    VK_keymap[VK_5] = SDLK_5;
   1.439 +    VK_keymap[VK_6] = SDLK_6;
   1.440 +    VK_keymap[VK_7] = SDLK_7;
   1.441 +    VK_keymap[VK_8] = SDLK_8;
   1.442 +    VK_keymap[VK_9] = SDLK_9;
   1.443 +    VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON;
   1.444 +    VK_keymap[VK_EQUALS] = SDLK_EQUALS;
   1.445 +    VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
   1.446 +    VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
   1.447 +    VK_keymap[VK_OEM_102] = SDLK_LESS;
   1.448 +    VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
   1.449 +    VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
   1.450 +    VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
   1.451 +    VK_keymap[VK_A] = SDLK_a;
   1.452 +    VK_keymap[VK_B] = SDLK_b;
   1.453 +    VK_keymap[VK_C] = SDLK_c;
   1.454 +    VK_keymap[VK_D] = SDLK_d;
   1.455 +    VK_keymap[VK_E] = SDLK_e;
   1.456 +    VK_keymap[VK_F] = SDLK_f;
   1.457 +    VK_keymap[VK_G] = SDLK_g;
   1.458 +    VK_keymap[VK_H] = SDLK_h;
   1.459 +    VK_keymap[VK_I] = SDLK_i;
   1.460 +    VK_keymap[VK_J] = SDLK_j;
   1.461 +    VK_keymap[VK_K] = SDLK_k;
   1.462 +    VK_keymap[VK_L] = SDLK_l;
   1.463 +    VK_keymap[VK_M] = SDLK_m;
   1.464 +    VK_keymap[VK_N] = SDLK_n;
   1.465 +    VK_keymap[VK_O] = SDLK_o;
   1.466 +    VK_keymap[VK_P] = SDLK_p;
   1.467 +    VK_keymap[VK_Q] = SDLK_q;
   1.468 +    VK_keymap[VK_R] = SDLK_r;
   1.469 +    VK_keymap[VK_S] = SDLK_s;
   1.470 +    VK_keymap[VK_T] = SDLK_t;
   1.471 +    VK_keymap[VK_U] = SDLK_u;
   1.472 +    VK_keymap[VK_V] = SDLK_v;
   1.473 +    VK_keymap[VK_W] = SDLK_w;
   1.474 +    VK_keymap[VK_X] = SDLK_x;
   1.475 +    VK_keymap[VK_Y] = SDLK_y;
   1.476 +    VK_keymap[VK_Z] = SDLK_z;
   1.477 +    VK_keymap[VK_DELETE] = SDLK_DELETE;
   1.478  
   1.479 -	hLayoutUS = LoadKeyboardLayout("00000409", KLF_NOTELLSHELL);
   1.480 -	if (!hLayoutUS) {
   1.481 -		//printf("Failed to load US keyboard layout. Using current.\n");
   1.482 -		hLayoutUS = GetKeyboardLayout(0);
   1.483 -	}
   1.484 -	LoadKeyboardLayout(current_layout, KLF_ACTIVATE);
   1.485 +    VK_keymap[VK_NUMPAD0] = SDLK_KP0;
   1.486 +    VK_keymap[VK_NUMPAD1] = SDLK_KP1;
   1.487 +    VK_keymap[VK_NUMPAD2] = SDLK_KP2;
   1.488 +    VK_keymap[VK_NUMPAD3] = SDLK_KP3;
   1.489 +    VK_keymap[VK_NUMPAD4] = SDLK_KP4;
   1.490 +    VK_keymap[VK_NUMPAD5] = SDLK_KP5;
   1.491 +    VK_keymap[VK_NUMPAD6] = SDLK_KP6;
   1.492 +    VK_keymap[VK_NUMPAD7] = SDLK_KP7;
   1.493 +    VK_keymap[VK_NUMPAD8] = SDLK_KP8;
   1.494 +    VK_keymap[VK_NUMPAD9] = SDLK_KP9;
   1.495 +    VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD;
   1.496 +    VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE;
   1.497 +    VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY;
   1.498 +    VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS;
   1.499 +    VK_keymap[VK_ADD] = SDLK_KP_PLUS;
   1.500  
   1.501 -	/* Map the VK keysyms */
   1.502 -	for ( i=0; i<SDL_arraysize(VK_keymap); ++i )
   1.503 -		VK_keymap[i] = SDLK_UNKNOWN;
   1.504 +    VK_keymap[VK_UP] = SDLK_UP;
   1.505 +    VK_keymap[VK_DOWN] = SDLK_DOWN;
   1.506 +    VK_keymap[VK_RIGHT] = SDLK_RIGHT;
   1.507 +    VK_keymap[VK_LEFT] = SDLK_LEFT;
   1.508 +    VK_keymap[VK_INSERT] = SDLK_INSERT;
   1.509 +    VK_keymap[VK_HOME] = SDLK_HOME;
   1.510 +    VK_keymap[VK_END] = SDLK_END;
   1.511 +    VK_keymap[VK_PRIOR] = SDLK_PAGEUP;
   1.512 +    VK_keymap[VK_NEXT] = SDLK_PAGEDOWN;
   1.513  
   1.514 -	VK_keymap[VK_BACK] = SDLK_BACKSPACE;
   1.515 -	VK_keymap[VK_TAB] = SDLK_TAB;
   1.516 -	VK_keymap[VK_CLEAR] = SDLK_CLEAR;
   1.517 -	VK_keymap[VK_RETURN] = SDLK_RETURN;
   1.518 -	VK_keymap[VK_PAUSE] = SDLK_PAUSE;
   1.519 -	VK_keymap[VK_ESCAPE] = SDLK_ESCAPE;
   1.520 -	VK_keymap[VK_SPACE] = SDLK_SPACE;
   1.521 -	VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE;
   1.522 -	VK_keymap[VK_COMMA] = SDLK_COMMA;
   1.523 -	VK_keymap[VK_MINUS] = SDLK_MINUS;
   1.524 -	VK_keymap[VK_PERIOD] = SDLK_PERIOD;
   1.525 -	VK_keymap[VK_SLASH] = SDLK_SLASH;
   1.526 -	VK_keymap[VK_0] = SDLK_0;
   1.527 -	VK_keymap[VK_1] = SDLK_1;
   1.528 -	VK_keymap[VK_2] = SDLK_2;
   1.529 -	VK_keymap[VK_3] = SDLK_3;
   1.530 -	VK_keymap[VK_4] = SDLK_4;
   1.531 -	VK_keymap[VK_5] = SDLK_5;
   1.532 -	VK_keymap[VK_6] = SDLK_6;
   1.533 -	VK_keymap[VK_7] = SDLK_7;
   1.534 -	VK_keymap[VK_8] = SDLK_8;
   1.535 -	VK_keymap[VK_9] = SDLK_9;
   1.536 -	VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON;
   1.537 -	VK_keymap[VK_EQUALS] = SDLK_EQUALS;
   1.538 -	VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
   1.539 -	VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
   1.540 -	VK_keymap[VK_OEM_102] = SDLK_LESS;
   1.541 -	VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
   1.542 -	VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
   1.543 -	VK_keymap[VK_BACKTICK] = SDLK_BACKQUOTE;
   1.544 -	VK_keymap[VK_A] = SDLK_a;
   1.545 -	VK_keymap[VK_B] = SDLK_b;
   1.546 -	VK_keymap[VK_C] = SDLK_c;
   1.547 -	VK_keymap[VK_D] = SDLK_d;
   1.548 -	VK_keymap[VK_E] = SDLK_e;
   1.549 -	VK_keymap[VK_F] = SDLK_f;
   1.550 -	VK_keymap[VK_G] = SDLK_g;
   1.551 -	VK_keymap[VK_H] = SDLK_h;
   1.552 -	VK_keymap[VK_I] = SDLK_i;
   1.553 -	VK_keymap[VK_J] = SDLK_j;
   1.554 -	VK_keymap[VK_K] = SDLK_k;
   1.555 -	VK_keymap[VK_L] = SDLK_l;
   1.556 -	VK_keymap[VK_M] = SDLK_m;
   1.557 -	VK_keymap[VK_N] = SDLK_n;
   1.558 -	VK_keymap[VK_O] = SDLK_o;
   1.559 -	VK_keymap[VK_P] = SDLK_p;
   1.560 -	VK_keymap[VK_Q] = SDLK_q;
   1.561 -	VK_keymap[VK_R] = SDLK_r;
   1.562 -	VK_keymap[VK_S] = SDLK_s;
   1.563 -	VK_keymap[VK_T] = SDLK_t;
   1.564 -	VK_keymap[VK_U] = SDLK_u;
   1.565 -	VK_keymap[VK_V] = SDLK_v;
   1.566 -	VK_keymap[VK_W] = SDLK_w;
   1.567 -	VK_keymap[VK_X] = SDLK_x;
   1.568 -	VK_keymap[VK_Y] = SDLK_y;
   1.569 -	VK_keymap[VK_Z] = SDLK_z;
   1.570 -	VK_keymap[VK_DELETE] = SDLK_DELETE;
   1.571 +    VK_keymap[VK_F1] = SDLK_F1;
   1.572 +    VK_keymap[VK_F2] = SDLK_F2;
   1.573 +    VK_keymap[VK_F3] = SDLK_F3;
   1.574 +    VK_keymap[VK_F4] = SDLK_F4;
   1.575 +    VK_keymap[VK_F5] = SDLK_F5;
   1.576 +    VK_keymap[VK_F6] = SDLK_F6;
   1.577 +    VK_keymap[VK_F7] = SDLK_F7;
   1.578 +    VK_keymap[VK_F8] = SDLK_F8;
   1.579 +    VK_keymap[VK_F9] = SDLK_F9;
   1.580 +    VK_keymap[VK_F10] = SDLK_F10;
   1.581 +    VK_keymap[VK_F11] = SDLK_F11;
   1.582 +    VK_keymap[VK_F12] = SDLK_F12;
   1.583 +    VK_keymap[VK_F13] = SDLK_F13;
   1.584 +    VK_keymap[VK_F14] = SDLK_F14;
   1.585 +    VK_keymap[VK_F15] = SDLK_F15;
   1.586  
   1.587 -	VK_keymap[VK_NUMPAD0] = SDLK_KP0;
   1.588 -	VK_keymap[VK_NUMPAD1] = SDLK_KP1;
   1.589 -	VK_keymap[VK_NUMPAD2] = SDLK_KP2;
   1.590 -	VK_keymap[VK_NUMPAD3] = SDLK_KP3;
   1.591 -	VK_keymap[VK_NUMPAD4] = SDLK_KP4;
   1.592 -	VK_keymap[VK_NUMPAD5] = SDLK_KP5;
   1.593 -	VK_keymap[VK_NUMPAD6] = SDLK_KP6;
   1.594 -	VK_keymap[VK_NUMPAD7] = SDLK_KP7;
   1.595 -	VK_keymap[VK_NUMPAD8] = SDLK_KP8;
   1.596 -	VK_keymap[VK_NUMPAD9] = SDLK_KP9;
   1.597 -	VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD;
   1.598 -	VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE;
   1.599 -	VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY;
   1.600 -	VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS;
   1.601 -	VK_keymap[VK_ADD] = SDLK_KP_PLUS;
   1.602 +    VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
   1.603 +    VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
   1.604 +    VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK;
   1.605 +    VK_keymap[VK_RSHIFT] = SDLK_RSHIFT;
   1.606 +    VK_keymap[VK_LSHIFT] = SDLK_LSHIFT;
   1.607 +    VK_keymap[VK_RCONTROL] = SDLK_RCTRL;
   1.608 +    VK_keymap[VK_LCONTROL] = SDLK_LCTRL;
   1.609 +    VK_keymap[VK_RMENU] = SDLK_RALT;
   1.610 +    VK_keymap[VK_LMENU] = SDLK_LALT;
   1.611 +    VK_keymap[VK_RWIN] = SDLK_RSUPER;
   1.612 +    VK_keymap[VK_LWIN] = SDLK_LSUPER;
   1.613  
   1.614 -	VK_keymap[VK_UP] = SDLK_UP;
   1.615 -	VK_keymap[VK_DOWN] = SDLK_DOWN;
   1.616 -	VK_keymap[VK_RIGHT] = SDLK_RIGHT;
   1.617 -	VK_keymap[VK_LEFT] = SDLK_LEFT;
   1.618 -	VK_keymap[VK_INSERT] = SDLK_INSERT;
   1.619 -	VK_keymap[VK_HOME] = SDLK_HOME;
   1.620 -	VK_keymap[VK_END] = SDLK_END;
   1.621 -	VK_keymap[VK_PRIOR] = SDLK_PAGEUP;
   1.622 -	VK_keymap[VK_NEXT] = SDLK_PAGEDOWN;
   1.623 -
   1.624 -	VK_keymap[VK_F1] = SDLK_F1;
   1.625 -	VK_keymap[VK_F2] = SDLK_F2;
   1.626 -	VK_keymap[VK_F3] = SDLK_F3;
   1.627 -	VK_keymap[VK_F4] = SDLK_F4;
   1.628 -	VK_keymap[VK_F5] = SDLK_F5;
   1.629 -	VK_keymap[VK_F6] = SDLK_F6;
   1.630 -	VK_keymap[VK_F7] = SDLK_F7;
   1.631 -	VK_keymap[VK_F8] = SDLK_F8;
   1.632 -	VK_keymap[VK_F9] = SDLK_F9;
   1.633 -	VK_keymap[VK_F10] = SDLK_F10;
   1.634 -	VK_keymap[VK_F11] = SDLK_F11;
   1.635 -	VK_keymap[VK_F12] = SDLK_F12;
   1.636 -	VK_keymap[VK_F13] = SDLK_F13;
   1.637 -	VK_keymap[VK_F14] = SDLK_F14;
   1.638 -	VK_keymap[VK_F15] = SDLK_F15;
   1.639 -
   1.640 -	VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
   1.641 -	VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
   1.642 -	VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK;
   1.643 -	VK_keymap[VK_RSHIFT] = SDLK_RSHIFT;
   1.644 -	VK_keymap[VK_LSHIFT] = SDLK_LSHIFT;
   1.645 -	VK_keymap[VK_RCONTROL] = SDLK_RCTRL;
   1.646 -	VK_keymap[VK_LCONTROL] = SDLK_LCTRL;
   1.647 -	VK_keymap[VK_RMENU] = SDLK_RALT;
   1.648 -	VK_keymap[VK_LMENU] = SDLK_LALT;
   1.649 -	VK_keymap[VK_RWIN] = SDLK_RSUPER;
   1.650 -	VK_keymap[VK_LWIN] = SDLK_LSUPER;
   1.651 -
   1.652 -	VK_keymap[VK_HELP] = SDLK_HELP;
   1.653 +    VK_keymap[VK_HELP] = SDLK_HELP;
   1.654  #ifdef VK_PRINT
   1.655 -	VK_keymap[VK_PRINT] = SDLK_PRINT;
   1.656 +    VK_keymap[VK_PRINT] = SDLK_PRINT;
   1.657  #endif
   1.658 -	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   1.659 -	VK_keymap[VK_CANCEL] = SDLK_BREAK;
   1.660 -	VK_keymap[VK_APPS] = SDLK_MENU;
   1.661 +    VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
   1.662 +    VK_keymap[VK_CANCEL] = SDLK_BREAK;
   1.663 +    VK_keymap[VK_APPS] = SDLK_MENU;
   1.664  }
   1.665  
   1.666 -#define EXTKEYPAD(keypad) ((scancode & 0x100)?(mvke):(keypad))
   1.667 +static SDL_keysym *
   1.668 +TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym * keysym, int pressed)
   1.669 +{
   1.670 +    /* Set the keysym information */
   1.671 +    keysym->scancode = (unsigned char) scancode;
   1.672 +    keysym->sym = VK_keymap[vkey];
   1.673 +    keysym->mod = KMOD_NONE;
   1.674 +    keysym->unicode = 0;
   1.675 +    if (pressed && SDL_TranslateUNICODE) {
   1.676 +#ifdef NO_GETKEYBOARDSTATE
   1.677 +        /* Uh oh, better hope the vkey is close enough.. */
   1.678 +        keysym->unicode = vkey;
   1.679 +#else
   1.680 +        BYTE keystate[256];
   1.681 +        Uint16 wchars[2];
   1.682  
   1.683 -static int SDL_MapVirtualKey(int scancode, int vkey)
   1.684 -{
   1.685 -	int	mvke  = MapVirtualKeyEx(scancode & 0xFF, 1, hLayoutUS);
   1.686 -
   1.687 -	switch(vkey) {
   1.688 -		/* These are always correct */
   1.689 -		case VK_DIVIDE:
   1.690 -		case VK_MULTIPLY:
   1.691 -		case VK_SUBTRACT:
   1.692 -		case VK_ADD:
   1.693 -		case VK_LWIN:
   1.694 -		case VK_RWIN:
   1.695 -		case VK_APPS:
   1.696 -		/* These are already handled */
   1.697 -		case VK_LCONTROL:
   1.698 -		case VK_RCONTROL:
   1.699 -		case VK_LSHIFT:
   1.700 -		case VK_RSHIFT:
   1.701 -		case VK_LMENU:
   1.702 -		case VK_RMENU:
   1.703 -		case VK_SNAPSHOT:
   1.704 -		case VK_PAUSE:
   1.705 -			return vkey;
   1.706 -	}	
   1.707 -	switch(mvke) {
   1.708 -		/* Distinguish between keypad and extended keys */
   1.709 -		case VK_INSERT: return EXTKEYPAD(VK_NUMPAD0);
   1.710 -		case VK_DELETE: return EXTKEYPAD(VK_DECIMAL);
   1.711 -		case VK_END:    return EXTKEYPAD(VK_NUMPAD1);
   1.712 -		case VK_DOWN:   return EXTKEYPAD(VK_NUMPAD2);
   1.713 -		case VK_NEXT:   return EXTKEYPAD(VK_NUMPAD3);
   1.714 -		case VK_LEFT:   return EXTKEYPAD(VK_NUMPAD4);
   1.715 -		case VK_CLEAR:  return EXTKEYPAD(VK_NUMPAD5);
   1.716 -		case VK_RIGHT:  return EXTKEYPAD(VK_NUMPAD6);
   1.717 -		case VK_HOME:   return EXTKEYPAD(VK_NUMPAD7);
   1.718 -		case VK_UP:     return EXTKEYPAD(VK_NUMPAD8);
   1.719 -		case VK_PRIOR:  return EXTKEYPAD(VK_NUMPAD9);
   1.720 -	}
   1.721 -	return mvke?mvke:vkey;
   1.722 +        GetKeyboardState(keystate);
   1.723 +        if (SDL_ToUnicode
   1.724 +            ((UINT) vkey, scancode, keystate, wchars,
   1.725 +             sizeof(wchars) / sizeof(wchars[0]), 0) == 1) {
   1.726 +            keysym->unicode = wchars[0];
   1.727 +        }
   1.728 +#endif /* NO_GETKEYBOARDSTATE */
   1.729 +    }
   1.730 +    return (keysym);
   1.731  }
   1.732  
   1.733 -static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym *keysym, int pressed)
   1.734 +int
   1.735 +DIB_CreateWindow(_THIS)
   1.736  {
   1.737 -	/* Set the keysym information */
   1.738 -	keysym->scancode = (unsigned char) scancode;
   1.739 -	keysym->mod = KMOD_NONE;
   1.740 -	keysym->unicode = 0;
   1.741 -	if ( pressed && SDL_TranslateUNICODE ) {
   1.742 -#ifdef NO_GETKEYBOARDSTATE
   1.743 -		/* Uh oh, better hope the vkey is close enough.. */
   1.744 -		keysym->unicode = vkey;
   1.745 +    char *windowid = SDL_getenv("SDL_WINDOWID");
   1.746 +
   1.747 +    SDL_RegisterApp(NULL, 0, 0);
   1.748 +
   1.749 +    SDL_windowid = (windowid != NULL);
   1.750 +    if (SDL_windowid) {
   1.751 +#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
   1.752 +        /* wince 2.1 does not have strtol */
   1.753 +        wchar_t *windowid_t =
   1.754 +            SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t));
   1.755 +        MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1,
   1.756 +                            windowid_t, SDL_strlen(windowid) + 1);
   1.757 +        SDL_Window = (HWND) wcstol(windowid_t, NULL, 0);
   1.758 +        SDL_free(windowid_t);
   1.759  #else
   1.760 -		BYTE	keystate[256];
   1.761 -		Uint16	wchars[2];
   1.762 +        SDL_Window = (HWND) SDL_strtoull(windowid, NULL, 0);
   1.763 +#endif
   1.764 +        if (SDL_Window == NULL) {
   1.765 +            SDL_SetError("Couldn't get user specified window");
   1.766 +            return (-1);
   1.767 +        }
   1.768  
   1.769 -		GetKeyboardState(keystate);
   1.770 -		if (SDL_ToUnicode((UINT)vkey, scancode, keystate, wchars, sizeof(wchars)/sizeof(wchars[0]), 0) == 1)
   1.771 -		{
   1.772 -			keysym->unicode = wchars[0];
   1.773 -		}
   1.774 -#endif /* NO_GETKEYBOARDSTATE */
   1.775 -	}
   1.776 +        /* DJM: we want all event's for the user specified
   1.777 +           window to be handled by SDL.
   1.778 +         */
   1.779 +        userWindowProc =
   1.780 +            (WNDPROCTYPE) GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
   1.781 +        SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage);
   1.782 +    } else {
   1.783 +        SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
   1.784 +                                  (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
   1.785 +                                   | WS_MINIMIZEBOX), CW_USEDEFAULT,
   1.786 +                                  CW_USEDEFAULT, 0, 0, NULL, NULL,
   1.787 +                                  SDL_Instance, NULL);
   1.788 +        if (SDL_Window == NULL) {
   1.789 +            SDL_SetError("Couldn't create window");
   1.790 +            return (-1);
   1.791 +        }
   1.792 +        ShowWindow(SDL_Window, SW_HIDE);
   1.793 +    }
   1.794  
   1.795 -	if ((vkey == VK_RETURN) && (scancode & 0x100)) {
   1.796 -		/* No VK_ code for the keypad enter key */
   1.797 -		keysym->sym = SDLK_KP_ENTER;
   1.798 -	}
   1.799 -	else {
   1.800 -		keysym->sym = VK_keymap[SDL_MapVirtualKey(scancode, vkey)];
   1.801 -	}
   1.802 +    /* JC 14 Mar 2006
   1.803 +       Flush the message loop or this can cause big problems later
   1.804 +       Especially if the user decides to use dialog boxes or assert()!
   1.805 +     */
   1.806 +    WIN_FlushMessageQueue();
   1.807  
   1.808 -#if 0
   1.809 -	{
   1.810 -		HKL     hLayoutCurrent = GetKeyboardLayout(0);
   1.811 -		int     sc = scancode & 0xFF;
   1.812 -
   1.813 -		printf("SYM:%d, VK:0x%02X, SC:0x%04X, US:(1:0x%02X, 3:0x%02X), "
   1.814 -			"Current:(1:0x%02X, 3:0x%02X)\n",
   1.815 -			keysym->sym, vkey, scancode,
   1.816 -			MapVirtualKeyEx(sc, 1, hLayoutUS),
   1.817 -			MapVirtualKeyEx(sc, 3, hLayoutUS),
   1.818 -			MapVirtualKeyEx(sc, 1, hLayoutCurrent),
   1.819 -			MapVirtualKeyEx(sc, 3, hLayoutCurrent)
   1.820 -		);
   1.821 -	}
   1.822 -#endif
   1.823 -	return(keysym);
   1.824 +    return (0);
   1.825  }
   1.826  
   1.827 -int DIB_CreateWindow(_THIS)
   1.828 +void
   1.829 +DIB_DestroyWindow(_THIS)
   1.830  {
   1.831 -	char *windowid = SDL_getenv("SDL_WINDOWID");
   1.832 +    if (SDL_windowid) {
   1.833 +        SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) userWindowProc);
   1.834 +    } else {
   1.835 +        DestroyWindow(SDL_Window);
   1.836 +    }
   1.837 +    SDL_UnregisterApp();
   1.838  
   1.839 -	SDL_RegisterApp(NULL, 0, 0);
   1.840 -
   1.841 -	SDL_windowid = (windowid != NULL);
   1.842 -	if ( SDL_windowid ) {
   1.843 -#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
   1.844 -		/* wince 2.1 does not have strtol */
   1.845 -		wchar_t *windowid_t = SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t));
   1.846 -		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, SDL_strlen(windowid) + 1);
   1.847 -		SDL_Window = (HWND)wcstol(windowid_t, NULL, 0);
   1.848 -		SDL_free(windowid_t);
   1.849 -#else
   1.850 -		SDL_Window = (HWND)SDL_strtoull(windowid, NULL, 0);
   1.851 -#endif
   1.852 -		if ( SDL_Window == NULL ) {
   1.853 -			SDL_SetError("Couldn't get user specified window");
   1.854 -			return(-1);
   1.855 -		}
   1.856 -
   1.857 -		/* DJM: we want all event's for the user specified
   1.858 -			window to be handled by SDL.
   1.859 -		 */
   1.860 -		userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWLP_WNDPROC);
   1.861 -		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)WinMessage);
   1.862 -	} else {
   1.863 -		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
   1.864 -                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
   1.865 -                        CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL);
   1.866 -		if ( SDL_Window == NULL ) {
   1.867 -			SDL_SetError("Couldn't create window");
   1.868 -			return(-1);
   1.869 -		}
   1.870 -		ShowWindow(SDL_Window, SW_HIDE);
   1.871 -	}
   1.872 -
   1.873 -	/* JC 14 Mar 2006
   1.874 -		Flush the message loop or this can cause big problems later
   1.875 -		Especially if the user decides to use dialog boxes or assert()!
   1.876 -	*/
   1.877 -	WIN_FlushMessageQueue();
   1.878 -
   1.879 -	return(0);
   1.880 +    /* JC 14 Mar 2006
   1.881 +       Flush the message loop or this can cause big problems later
   1.882 +       Especially if the user decides to use dialog boxes or assert()!
   1.883 +     */
   1.884 +    WIN_FlushMessageQueue();
   1.885  }
   1.886  
   1.887 -void DIB_DestroyWindow(_THIS)
   1.888 -{
   1.889 -	if ( SDL_windowid ) {
   1.890 -		SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)userWindowProc);
   1.891 -	} else {
   1.892 -		DestroyWindow(SDL_Window);
   1.893 -	}
   1.894 -	SDL_UnregisterApp();
   1.895 -
   1.896 -	/* JC 14 Mar 2006
   1.897 -		Flush the message loop or this can cause big problems later
   1.898 -		Especially if the user decides to use dialog boxes or assert()!
   1.899 -	*/
   1.900 -	WIN_FlushMessageQueue();
   1.901 -}
   1.902 +/* vi: set ts=4 sw=4 expandtab: */