Commit bf7fdf59 authored by Sam Lantinga's avatar Sam Lantinga

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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40971
parent e443aa34
...@@ -141,6 +141,7 @@ static int DX5_DInputInit(_THIS) ...@@ -141,6 +141,7 @@ static int DX5_DInputInit(_THIS)
LPDIRECTINPUTDEVICE device; LPDIRECTINPUTDEVICE device;
HRESULT result; HRESULT result;
DIPROPDWORD dipdw; DIPROPDWORD dipdw;
HWND topwnd;
/* Create the DirectInput object */ /* Create the DirectInput object */
result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION, result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION,
...@@ -167,8 +168,9 @@ static int DX5_DInputInit(_THIS) ...@@ -167,8 +168,9 @@ static int DX5_DInputInit(_THIS)
SetDIerror("DirectInputDevice::QueryInterface", result); SetDIerror("DirectInputDevice::QueryInterface", result);
return(-1); return(-1);
} }
topwnd = GetAncestor(SDL_Window, GA_ROOT);
result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i],
SDL_Window, inputs[i].win_level); topwnd, inputs[i].win_level);
if ( result != DI_OK ) { if ( result != DI_OK ) {
SetDIerror("DirectInputDevice::SetCooperativeLevel", SetDIerror("DirectInputDevice::SetCooperativeLevel",
result); result);
...@@ -640,6 +642,7 @@ void DX5_DInputReset(_THIS, int fullscreen) ...@@ -640,6 +642,7 @@ void DX5_DInputReset(_THIS, int fullscreen)
DWORD level; DWORD level;
int i; int i;
HRESULT result; HRESULT result;
HWND topwnd;
for ( i=0; i<MAX_INPUTS; ++i ) { for ( i=0; i<MAX_INPUTS; ++i ) {
if ( SDL_DIdev[i] != NULL ) { if ( SDL_DIdev[i] != NULL ) {
...@@ -649,8 +652,9 @@ void DX5_DInputReset(_THIS, int fullscreen) ...@@ -649,8 +652,9 @@ void DX5_DInputReset(_THIS, int fullscreen)
level = inputs[i].win_level; level = inputs[i].win_level;
} }
IDirectInputDevice2_Unacquire(SDL_DIdev[i]); IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
topwnd = GetAncestor(SDL_Window, GA_ROOT);
result = IDirectInputDevice2_SetCooperativeLevel( result = IDirectInputDevice2_SetCooperativeLevel(
SDL_DIdev[i], SDL_Window, level); SDL_DIdev[i], topwnd, level);
IDirectInputDevice2_Acquire(SDL_DIdev[i]); IDirectInputDevice2_Acquire(SDL_DIdev[i]);
if ( result != DI_OK ) { if ( result != DI_OK ) {
SetDIerror( SetDIerror(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment