comparison src/video/windx5/SDL_dx5events.c @ 145:29a638dc26db

Applied David MacCormack's patch to fix SDL_WINDOWID on Windows, and added a function to cache the application handle so DirectInput still works properly.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 09 Aug 2001 12:21:32 +0000
parents 994ed1d668e7
children e8157fcb3114
comparison
equal deleted inserted replaced
144:1cfa4282f2eb 145:29a638dc26db
56 static int mouse_pressed; 56 static int mouse_pressed;
57 57
58 /* The translation table from a DirectInput scancode to an SDL keysym */ 58 /* The translation table from a DirectInput scancode to an SDL keysym */
59 static SDLKey DIK_keymap[256]; 59 static SDLKey DIK_keymap[256];
60 static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed); 60 static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed);
61
62 /* DJM: If the user setup the window for us, we want to save his window proc,
63 and give him a chance to handle some messages. */
64 static WNDPROC userWindowProc = NULL;
61 65
62 /* Convert a DirectInput return code to a text message */ 66 /* Convert a DirectInput return code to a text message */
63 static void SetDIerror(char *function, int code) 67 static void SetDIerror(char *function, int code)
64 { 68 {
65 static char *error; 69 static char *error;
507 wmmsg.hwnd = hwnd; 511 wmmsg.hwnd = hwnd;
508 wmmsg.msg = msg; 512 wmmsg.msg = msg;
509 wmmsg.wParam = wParam; 513 wmmsg.wParam = wParam;
510 wmmsg.lParam = lParam; 514 wmmsg.lParam = lParam;
511 posted = SDL_PrivateSysWMEvent(&wmmsg); 515 posted = SDL_PrivateSysWMEvent(&wmmsg);
512 } 516
517 /* DJM: If the user isn't watching for private messages in her
518 SDL event loop, then pass it along to any win32 specific
519 window proc.
520 */
521 } else if (userWindowProc) {
522 return userWindowProc(hwnd, msg, wParam, lParam);
523 }
513 } 524 }
514 break; 525 break;
515 } 526 }
516 return(DefWindowProc(hwnd, msg, wParam, lParam)); 527 return(DefWindowProc(hwnd, msg, wParam, lParam));
517 } 528 }
762 773
763 /* Create the SDL window */ 774 /* Create the SDL window */
764 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); 775 SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
765 if ( SDL_windowid ) { 776 if ( SDL_windowid ) {
766 SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); 777 SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
778
779 /* DJM: we want all event's for the user specified
780 window to be handled by SDL.
781 */
782 if (SDL_Window) {
783 userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
784 SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
785 }
767 } else { 786 } else {
768 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, 787 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
769 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX), 788 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
770 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL); 789 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL);
771 if ( SDL_Window == NULL ) { 790 if ( SDL_Window == NULL ) {