# HG changeset patch # User Edgar Simo # Date 1218016371 0 # Node ID 6deba05725ace44e89d26dcd5987f5fd2e2523c2 # Parent 446054caaa8194d19a6a6c78bf659c5edb0517d3 This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first. diff -r 446054caaa81 -r 6deba05725ac src/haptic/win32/SDL_syshaptic.c --- a/src/haptic/win32/SDL_syshaptic.c Wed Aug 06 09:35:09 2008 +0000 +++ b/src/haptic/win32/SDL_syshaptic.c Wed Aug 06 09:52:51 2008 +0000 @@ -91,7 +91,6 @@ /* * External stuff. */ -extern HINSTANCE SDL_Instance; extern HWND SDL_HelperWindow; @@ -146,6 +145,7 @@ SDL_SYS_HapticInit(void) { HRESULT ret; + HINSTANCE instance; if (dinput != NULL) { /* Already open. */ SDL_SetError("Haptic: SubSystem already open."); @@ -171,7 +171,12 @@ } /* Because we used CoCreateInstance, we need to Initialize it, first. */ - ret = IDirectInput_Initialize(dinput, SDL_Instance, DIRECTINPUT_VERSION); + instance = GetModuleHandle(NULL); + if (instance == NULL) { + SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError()); + return -1; + } + ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION); if (FAILED(ret)) { DI_SetError("Initializing DirectInput device",ret); return -1; diff -r 446054caaa81 -r 6deba05725ac src/joystick/win32/SDL_dxjoystick.c --- a/src/joystick/win32/SDL_dxjoystick.c Wed Aug 06 09:35:09 2008 +0000 +++ b/src/joystick/win32/SDL_dxjoystick.c Wed Aug 06 09:52:51 2008 +0000 @@ -52,7 +52,6 @@ #define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */ /* external variables referenced. */ -extern HINSTANCE SDL_Instance; extern HWND SDL_HelperWindow; @@ -117,8 +116,13 @@ } /* Because we used CoCreateInstance, we need to Initialize it, first. */ + instance = GetModuleHandle(NULL); + if (instance == NULL) { + SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError()); + return (-1); + } result = - IDirectInput_Initialize(dinput, SDL_Instance, DIRECTINPUT_VERSION); + IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION); if (FAILED(result)) { SetDIerror("IDirectInput::Initialize", result);