Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Added the concept of the HelperWindow to help with DirectInput.
- Loading branch information
|
@@ -51,6 +51,10 @@ extern void SDL_StartTicks(void); |
|
|
extern int SDL_TimerInit(void); |
|
|
extern void SDL_TimerQuit(void); |
|
|
#endif |
|
|
#if defined(__WIN32__) |
|
|
extern int SDL_HelperWindowCreate(void); |
|
|
extern int SDL_HelperWindowDestroy(void); |
|
|
#endif |
|
|
|
|
|
/* The initialized subsystems */ |
|
|
static Uint32 SDL_initialized = 0; |
|
@@ -172,6 +176,12 @@ SDL_Init(Uint32 flags) |
|
|
/* Clear the error message */ |
|
|
SDL_ClearError(); |
|
|
|
|
|
#if defined(__WIN32__) |
|
|
if (SDL_HelperWindowCreate() < 0) { |
|
|
return -1; |
|
|
} |
|
|
#endif |
|
|
|
|
|
/* Initialize the desired subsystems */ |
|
|
if (SDL_InitSubSystem(flags) < 0) { |
|
|
return (-1); |
|
@@ -243,6 +253,10 @@ SDL_Quit(void) |
|
|
printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); |
|
|
fflush(stdout); |
|
|
#endif |
|
|
|
|
|
#if defined(__WIN32__) |
|
|
SDL_HelperWindowDestroy(); |
|
|
#endif |
|
|
SDL_QuitSubSystem(SDL_INIT_EVERYTHING); |
|
|
|
|
|
#ifdef CHECK_LEAKS |
|
|
|
@@ -36,7 +36,9 @@ |
|
|
#include <dinput.h> |
|
|
#include <dxerr.h> |
|
|
#ifdef _MSC_VER |
|
|
# pragma comment (lib, "dxerr.lib") |
|
|
# pragma comment (lib, "dinput8.lib") |
|
|
# pragma comment (lib, "dxguid.lib") |
|
|
# pragma comment (lib, "dxerr.lib") |
|
|
#endif /* _MSC_VER */ |
|
|
|
|
|
/* an ISO hack for VisualC++ */ |
|
@@ -88,7 +90,7 @@ static LPDIRECTINPUT dinput = NULL; |
|
|
* External stuff. |
|
|
*/ |
|
|
extern HINSTANCE SDL_Instance; |
|
|
extern HWND SDL_Window; |
|
|
extern HWND SDL_HelperWindow; |
|
|
|
|
|
|
|
|
/* |
|
@@ -274,7 +276,7 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance) |
|
|
|
|
|
/* Grab it exclusively to use force feedback stuff. */ |
|
|
ret =IDirectInputDevice2_SetCooperativeLevel( haptic->hwdata->device, |
|
|
SDL_Window, |
|
|
SDL_HelperWindow, |
|
|
DISCL_EXCLUSIVE | DISCL_BACKGROUND ); |
|
|
if (FAILED(ret)) { |
|
|
DI_SetError("Setting cooperative level to exclusive",ret); |
|
|
|
@@ -67,7 +67,7 @@ |
|
|
|
|
|
/* external variables referenced. */ |
|
|
extern HINSTANCE SDL_Instance; |
|
|
extern HWND SDL_Window; |
|
|
extern HWND SDL_HelperWindow; |
|
|
|
|
|
|
|
|
/* local variables */ |
|
@@ -250,7 +250,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick) |
|
|
* though. */ |
|
|
result = |
|
|
IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata-> |
|
|
InputDevice, SDL_Window, |
|
|
InputDevice, SDL_HelperWindow, |
|
|
DISCL_EXCLUSIVE | |
|
|
DISCL_BACKGROUND); |
|
|
if (FAILED(result)) { |
|
|
|
@@ -30,6 +30,10 @@ |
|
|
#include "SDL_syswm.h" |
|
|
|
|
|
|
|
|
/* Fake window to help with DirectInput events. */ |
|
|
HWND SDL_HelperWindow = NULL; |
|
|
|
|
|
|
|
|
static int |
|
|
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) |
|
|
{ |
|
@@ -409,4 +413,48 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Creates a HelperWindow used for DirectInput events. |
|
|
*/ |
|
|
int |
|
|
SDL_HelperWindowCreate(void) |
|
|
{ |
|
|
HINSTANCE hInstance = pGetModuleHandleA(NULL); |
|
|
const char *class_name = "SDLHelperWindowInputCatcher"; |
|
|
const char *win_name = "SDLHelperWindowInputMsgWindow"; |
|
|
WNDCLASSEX wce; |
|
|
|
|
|
ZeroMemory(&wce, sizeof (wce)); |
|
|
wce.cbSize = sizeof(WNDCLASSEX); |
|
|
wce.lpfnWndProc = RawWndProc; |
|
|
wce.lpszClassName = class_name; |
|
|
wce.hInstance = hInstance; |
|
|
|
|
|
SDL_HelperWindow = pCreateWindowExA(0, class_name, win_name, WS_OVERLAPPEDWINDOW, |
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
|
|
CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL); |
|
|
|
|
|
if (SDL_HelperWindow == NULL) { |
|
|
SDL_SetError("Unable to create Helper Window."); |
|
|
return -1; |
|
|
} |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* Destroys the HelperWindow previously created with SDL_HelperWindowCreate. |
|
|
*/ |
|
|
void |
|
|
SDL_HelperWindowDestroy(void) |
|
|
{ |
|
|
if (SDL_HelperWindow) { |
|
|
pDestroyWindow(SDL_HelperWindow); |
|
|
SDL_HelperWindow = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */ |