[SVN] r3910 - in branches/gsoc2008_force_feedback/src: haptic/win32 joystick/win32

svn-owner at libsdl.org svn-owner at libsdl.org
Wed Aug 6 02:52:52 PDT 2008


Author: bobbens
Date: 2008-08-06 02:52:51 -0700 (Wed, 06 Aug 2008)
New Revision: 3910

Modified:
   branches/gsoc2008_force_feedback/src/haptic/win32/SDL_syshaptic.c
   branches/gsoc2008_force_feedback/src/joystick/win32/SDL_dxjoystick.c
Log:
This should hopefully allow initailizing the joystick/haptic subsystems without calling SetVideoMode first.


Modified: branches/gsoc2008_force_feedback/src/haptic/win32/SDL_syshaptic.c
===================================================================
--- branches/gsoc2008_force_feedback/src/haptic/win32/SDL_syshaptic.c	2008-08-06 09:35:09 UTC (rev 3909)
+++ branches/gsoc2008_force_feedback/src/haptic/win32/SDL_syshaptic.c	2008-08-06 09:52:51 UTC (rev 3910)
@@ -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;

Modified: branches/gsoc2008_force_feedback/src/joystick/win32/SDL_dxjoystick.c
===================================================================
--- branches/gsoc2008_force_feedback/src/joystick/win32/SDL_dxjoystick.c	2008-08-06 09:35:09 UTC (rev 3909)
+++ branches/gsoc2008_force_feedback/src/joystick/win32/SDL_dxjoystick.c	2008-08-06 09:52:51 UTC (rev 3910)
@@ -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);



More information about the SVN mailing list