Mercurial > sdl-ios-xcode
comparison src/video/windx5/SDL_dx5events.c @ 970:fb8b91365766
Date: Tue, 19 Oct 2004 23:04:58 -0700
From: "Trevor Scroggins"
Subject: [SDL] [PATCH] DirectX and SDL_WINDOWID Hack
Hello, all. The IDirectInputDevice2_SetCooperativeLevel call in
SDL_dx5events.c expects to be passed a root-level HWND. More often than not,
a child window is used with the SDL_WINDOWID hack, causing the
IDirectInputDevice2_SetCooperativeLevel call to fail.
This is a small patch to SDL_dx5events.c v1.21 that fixes the problem by
retrieving a handle to the root-level ancestor of the current SDL_Window and
passing that handle to IDirectInputDevice2_SetCooperativeLevel.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 12 Nov 2004 23:14:47 +0000 |
parents | 31fa08b36380 |
children | add87cc1de0a |
comparison
equal
deleted
inserted
replaced
969:cfb9518670f4 | 970:fb8b91365766 |
---|---|
139 { | 139 { |
140 int i; | 140 int i; |
141 LPDIRECTINPUTDEVICE device; | 141 LPDIRECTINPUTDEVICE device; |
142 HRESULT result; | 142 HRESULT result; |
143 DIPROPDWORD dipdw; | 143 DIPROPDWORD dipdw; |
144 HWND topwnd; | |
144 | 145 |
145 /* Create the DirectInput object */ | 146 /* Create the DirectInput object */ |
146 result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION, | 147 result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION, |
147 &dinput, NULL); | 148 &dinput, NULL); |
148 if ( result != DI_OK ) { | 149 if ( result != DI_OK ) { |
165 IDirectInputDevice_Release(device); | 166 IDirectInputDevice_Release(device); |
166 if ( result != DI_OK ) { | 167 if ( result != DI_OK ) { |
167 SetDIerror("DirectInputDevice::QueryInterface", result); | 168 SetDIerror("DirectInputDevice::QueryInterface", result); |
168 return(-1); | 169 return(-1); |
169 } | 170 } |
171 topwnd = GetAncestor(SDL_Window, GA_ROOT); | |
170 result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], | 172 result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], |
171 SDL_Window, inputs[i].win_level); | 173 topwnd, inputs[i].win_level); |
172 if ( result != DI_OK ) { | 174 if ( result != DI_OK ) { |
173 SetDIerror("DirectInputDevice::SetCooperativeLevel", | 175 SetDIerror("DirectInputDevice::SetCooperativeLevel", |
174 result); | 176 result); |
175 return(-1); | 177 return(-1); |
176 } | 178 } |
638 void DX5_DInputReset(_THIS, int fullscreen) | 640 void DX5_DInputReset(_THIS, int fullscreen) |
639 { | 641 { |
640 DWORD level; | 642 DWORD level; |
641 int i; | 643 int i; |
642 HRESULT result; | 644 HRESULT result; |
645 HWND topwnd; | |
643 | 646 |
644 for ( i=0; i<MAX_INPUTS; ++i ) { | 647 for ( i=0; i<MAX_INPUTS; ++i ) { |
645 if ( SDL_DIdev[i] != NULL ) { | 648 if ( SDL_DIdev[i] != NULL ) { |
646 if ( fullscreen ) { | 649 if ( fullscreen ) { |
647 level = inputs[i].raw_level; | 650 level = inputs[i].raw_level; |
648 } else { | 651 } else { |
649 level = inputs[i].win_level; | 652 level = inputs[i].win_level; |
650 } | 653 } |
651 IDirectInputDevice2_Unacquire(SDL_DIdev[i]); | 654 IDirectInputDevice2_Unacquire(SDL_DIdev[i]); |
655 topwnd = GetAncestor(SDL_Window, GA_ROOT); | |
652 result = IDirectInputDevice2_SetCooperativeLevel( | 656 result = IDirectInputDevice2_SetCooperativeLevel( |
653 SDL_DIdev[i], SDL_Window, level); | 657 SDL_DIdev[i], topwnd, level); |
654 IDirectInputDevice2_Acquire(SDL_DIdev[i]); | 658 IDirectInputDevice2_Acquire(SDL_DIdev[i]); |
655 if ( result != DI_OK ) { | 659 if ( result != DI_OK ) { |
656 SetDIerror( | 660 SetDIerror( |
657 "DirectInputDevice::SetCooperativeLevel", result); | 661 "DirectInputDevice::SetCooperativeLevel", result); |
658 } | 662 } |