src/joystick/win32/SDL_dxjoystick.c
branchgsoc2008_force_feedback
changeset 2623 6deba05725ac
parent 2616 acd5da848404
child 2625 9bad8efcb75e
equal deleted inserted replaced
2622:446054caaa81 2623:6deba05725ac
    50 #define AXIS_MIN	-32768  /* minimum value for axis coordinate */
    50 #define AXIS_MIN	-32768  /* minimum value for axis coordinate */
    51 #define AXIS_MAX	32767   /* maximum value for axis coordinate */
    51 #define AXIS_MAX	32767   /* maximum value for axis coordinate */
    52 #define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100)   /* 1% motion */
    52 #define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100)   /* 1% motion */
    53 
    53 
    54 /* external variables referenced. */
    54 /* external variables referenced. */
    55 extern HINSTANCE SDL_Instance;
       
    56 extern HWND SDL_HelperWindow;
    55 extern HWND SDL_HelperWindow;
    57 
    56 
    58 
    57 
    59 /* local variables */
    58 /* local variables */
    60 static LPDIRECTINPUT dinput = NULL;
    59 static LPDIRECTINPUT dinput = NULL;
   115         SetDIerror("CoCreateInstance", result);
   114         SetDIerror("CoCreateInstance", result);
   116         return (-1);
   115         return (-1);
   117     }
   116     }
   118 
   117 
   119     /* Because we used CoCreateInstance, we need to Initialize it, first. */
   118     /* Because we used CoCreateInstance, we need to Initialize it, first. */
   120     result =
   119     instance = GetModuleHandle(NULL);
   121         IDirectInput_Initialize(dinput, SDL_Instance, DIRECTINPUT_VERSION);
   120     if (instance == NULL) {
       
   121         SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError());
       
   122         return (-1);
       
   123     }
       
   124     result =
       
   125         IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION);
   122 
   126 
   123     if (FAILED(result)) {
   127     if (FAILED(result)) {
   124         SetDIerror("IDirectInput::Initialize", result);
   128         SetDIerror("IDirectInput::Initialize", result);
   125         return (-1);
   129         return (-1);
   126     }
   130     }