Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
This should hopefully allow initailizing the joystick/haptic subsyste…
Browse files Browse the repository at this point in the history
…ms without calling SetVideoMode first.
  • Loading branch information
bobbens committed Aug 6, 2008
1 parent e985b8e commit 9842dbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/haptic/win32/SDL_syshaptic.c
Expand Up @@ -91,7 +91,6 @@ static LPDIRECTINPUT dinput = NULL;
/*
* External stuff.
*/
extern HINSTANCE SDL_Instance;
extern HWND SDL_HelperWindow;


Expand Down Expand Up @@ -146,6 +145,7 @@ int
SDL_SYS_HapticInit(void)
{
HRESULT ret;
HINSTANCE instance;

if (dinput != NULL) { /* Already open. */
SDL_SetError("Haptic: SubSystem already open.");
Expand All @@ -171,7 +171,12 @@ SDL_SYS_HapticInit(void)
}

/* 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;
Expand Down
8 changes: 6 additions & 2 deletions src/joystick/win32/SDL_dxjoystick.c
Expand Up @@ -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;


Expand Down Expand Up @@ -117,8 +116,13 @@ SDL_SYS_JoystickInit(void)
}

/* 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);
Expand Down

0 comments on commit 9842dbc

Please sign in to comment.