src/haptic/win32/SDL_syshaptic.c
branchgsoc2008_force_feedback
changeset 2623 6deba05725ac
parent 2621 83659de20bf2
child 2626 53dd30491c71
     1.1 --- a/src/haptic/win32/SDL_syshaptic.c	Wed Aug 06 09:35:09 2008 +0000
     1.2 +++ b/src/haptic/win32/SDL_syshaptic.c	Wed Aug 06 09:52:51 2008 +0000
     1.3 @@ -91,7 +91,6 @@
     1.4  /*
     1.5   * External stuff.
     1.6   */
     1.7 -extern HINSTANCE SDL_Instance;
     1.8  extern HWND SDL_HelperWindow;
     1.9  
    1.10  
    1.11 @@ -146,6 +145,7 @@
    1.12  SDL_SYS_HapticInit(void)
    1.13  {
    1.14     HRESULT ret;
    1.15 +   HINSTANCE instance;
    1.16  
    1.17     if (dinput != NULL) { /* Already open. */
    1.18        SDL_SetError("Haptic: SubSystem already open.");
    1.19 @@ -171,7 +171,12 @@
    1.20     }
    1.21  
    1.22     /* Because we used CoCreateInstance, we need to Initialize it, first. */
    1.23 -   ret = IDirectInput_Initialize(dinput, SDL_Instance, DIRECTINPUT_VERSION);
    1.24 +   instance = GetModuleHandle(NULL);
    1.25 +   if (instance == NULL) {
    1.26 +      SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError());
    1.27 +      return -1;
    1.28 +   }
    1.29 +   ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
    1.30     if (FAILED(ret)) {
    1.31        DI_SetError("Initializing DirectInput device",ret);
    1.32        return -1;