comparison src/video/windx5/SDL_dx5events.c @ 1114:242a35a85852

Patches to make SDL compatible with Win95 again.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 11 Aug 2005 01:02:01 +0000
parents add87cc1de0a
children 040aa1bea9fc
comparison
equal deleted inserted replaced
1113:39408f59a0f7 1114:242a35a85852
65 static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed); 65 static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed);
66 66
67 /* DJM: If the user setup the window for us, we want to save his window proc, 67 /* DJM: If the user setup the window for us, we want to save his window proc,
68 and give him a chance to handle some messages. */ 68 and give him a chance to handle some messages. */
69 static WNDPROC userWindowProc = NULL; 69 static WNDPROC userWindowProc = NULL;
70
71 static HWND GetTopLevelParent(HWND hWnd)
72 {
73 HWND hParentWnd;
74 while (1)
75 {
76 hParentWnd = GetParent(hWnd);
77 if (hParentWnd == NULL)
78 break;
79 hWnd = hParentWnd;
80 }
81 return hWnd;
82 }
70 83
71 /* Convert a DirectInput return code to a text message */ 84 /* Convert a DirectInput return code to a text message */
72 static void SetDIerror(char *function, int code) 85 static void SetDIerror(char *function, int code)
73 { 86 {
74 static char *error; 87 static char *error;
166 IDirectInputDevice_Release(device); 179 IDirectInputDevice_Release(device);
167 if ( result != DI_OK ) { 180 if ( result != DI_OK ) {
168 SetDIerror("DirectInputDevice::QueryInterface", result); 181 SetDIerror("DirectInputDevice::QueryInterface", result);
169 return(-1); 182 return(-1);
170 } 183 }
171 topwnd = GetAncestor(SDL_Window, GA_ROOT); 184 topwnd = GetTopLevelParent(SDL_Window, GA_ROOT);
172 result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], 185 result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i],
173 topwnd, inputs[i].win_level); 186 topwnd, inputs[i].win_level);
174 if ( result != DI_OK ) { 187 if ( result != DI_OK ) {
175 SetDIerror("DirectInputDevice::SetCooperativeLevel", 188 SetDIerror("DirectInputDevice::SetCooperativeLevel",
176 result); 189 result);
650 level = inputs[i].raw_level; 663 level = inputs[i].raw_level;
651 } else { 664 } else {
652 level = inputs[i].win_level; 665 level = inputs[i].win_level;
653 } 666 }
654 IDirectInputDevice2_Unacquire(SDL_DIdev[i]); 667 IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
655 topwnd = GetAncestor(SDL_Window, GA_ROOT); 668 topwnd = GetTopLevelParent(SDL_Window, GA_ROOT);
656 result = IDirectInputDevice2_SetCooperativeLevel( 669 result = IDirectInputDevice2_SetCooperativeLevel(
657 SDL_DIdev[i], topwnd, level); 670 SDL_DIdev[i], topwnd, level);
658 IDirectInputDevice2_Acquire(SDL_DIdev[i]); 671 IDirectInputDevice2_Acquire(SDL_DIdev[i]);
659 if ( result != DI_OK ) { 672 if ( result != DI_OK ) {
660 SetDIerror( 673 SetDIerror(