Move all DirectInput code from DI2 to DI8.

Fixes failing Haptic subsystem initialization on Windows.
This commit is contained in:
Ryan C. Gordon 2012-11-29 15:24:56 -05:00
parent 0b8d0b3c80
commit 6ac6dd737a
3 changed files with 63 additions and 63 deletions

View file

@ -49,7 +49,7 @@ static struct
*/ */
struct haptic_hwdata struct haptic_hwdata
{ {
LPDIRECTINPUTDEVICE2 device; LPDIRECTINPUTDEVICE8 device;
DWORD axes[3]; /* Axes to use. */ DWORD axes[3]; /* Axes to use. */
int is_joystick; /* Device is loaded as joystick. */ int is_joystick; /* Device is loaded as joystick. */
}; };
@ -69,7 +69,7 @@ struct haptic_hweffect
* Internal stuff. * Internal stuff.
*/ */
static SDL_bool coinitialized = SDL_FALSE; static SDL_bool coinitialized = SDL_FALSE;
static LPDIRECTINPUT dinput = NULL; static LPDIRECTINPUT8 dinput = NULL;
/* /*
@ -85,8 +85,8 @@ static void DI_SetError(const char *str, HRESULT err);
static int DI_GUIDIsSame(const GUID * a, const GUID * b); static int DI_GUIDIsSame(const GUID * a, const GUID * b);
static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic,
DIDEVICEINSTANCE instance); DIDEVICEINSTANCE instance);
static int SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic, static int SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic,
LPDIRECTINPUTDEVICE2 device2); LPDIRECTINPUTDEVICE8 device8);
static DWORD DIGetTriggerButton(Uint16 button); static DWORD DIGetTriggerButton(Uint16 button);
static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir,
int naxes); int naxes);
@ -151,8 +151,8 @@ SDL_SYS_HapticInit(void)
coinitialized = SDL_TRUE; coinitialized = SDL_TRUE;
ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, ret = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectInput, (LPVOID) & dinput); &IID_IDirectInput8, (LPVOID) & dinput);
if (FAILED(ret)) { if (FAILED(ret)) {
SDL_SYS_HapticQuit(); SDL_SYS_HapticQuit();
DI_SetError("CoCreateInstance", ret); DI_SetError("CoCreateInstance", ret);
@ -167,7 +167,7 @@ SDL_SYS_HapticInit(void)
GetLastError()); GetLastError());
return -1; return -1;
} }
ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION); ret = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION);
if (FAILED(ret)) { if (FAILED(ret)) {
SDL_SYS_HapticQuit(); SDL_SYS_HapticQuit();
DI_SetError("Initializing DirectInput device", ret); DI_SetError("Initializing DirectInput device", ret);
@ -175,7 +175,7 @@ SDL_SYS_HapticInit(void)
} }
/* Look for haptic devices. */ /* Look for haptic devices. */
ret = IDirectInput_EnumDevices(dinput, ret = IDirectInput8_EnumDevices(dinput,
0, 0,
EnumHapticsCallback, EnumHapticsCallback,
NULL, NULL,
@ -197,14 +197,14 @@ static BOOL CALLBACK
EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
{ {
HRESULT ret; HRESULT ret;
LPDIRECTINPUTDEVICE device; LPDIRECTINPUTDEVICE8 device;
/* Copy the instance over, useful for creating devices. */ /* Copy the instance over, useful for creating devices. */
SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance, SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance,
sizeof(DIDEVICEINSTANCE)); sizeof(DIDEVICEINSTANCE));
/* Open the device */ /* Open the device */
ret = IDirectInput_CreateDevice(dinput, &pdidInstance->guidInstance, ret = IDirectInput8_CreateDevice(dinput, &pdidInstance->guidInstance,
&device, NULL); &device, NULL);
if (FAILED(ret)) { if (FAILED(ret)) {
/* DI_SetError("Creating DirectInput device",ret); */ /* DI_SetError("Creating DirectInput device",ret); */
@ -213,12 +213,12 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
/* Get capabilities. */ /* Get capabilities. */
SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS); SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS);
ret = IDirectInputDevice_GetCapabilities(device, ret = IDirectInputDevice8_GetCapabilities(device,
&SDL_hapticlist[SDL_numhaptics]. &SDL_hapticlist[SDL_numhaptics].
capabilities); capabilities);
if (FAILED(ret)) { if (FAILED(ret)) {
/* DI_SetError("Getting device capabilities",ret); */ /* DI_SetError("Getting device capabilities",ret); */
IDirectInputDevice_Release(device); IDirectInputDevice8_Release(device);
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
@ -226,7 +226,7 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName); SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName);
/* Close up device and count it. */ /* Close up device and count it. */
IDirectInputDevice_Release(device); IDirectInputDevice8_Release(device);
SDL_numhaptics++; SDL_numhaptics++;
/* Watch out for hard limit. */ /* Watch out for hard limit. */
@ -306,16 +306,16 @@ DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
* *
* Steps: * Steps:
* - Open temporary DirectInputDevice interface. * - Open temporary DirectInputDevice interface.
* - Create DirectInputDevice2 interface. * - Create DirectInputDevice8 interface.
* - Release DirectInputDevice interface. * - Release DirectInputDevice interface.
* - Call SDL_SYS_HapticOpenFromDevice2 * - Call SDL_SYS_HapticOpenFromDevice8
*/ */
static int static int
SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance) SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
{ {
HRESULT ret; HRESULT ret;
int ret2; int ret2;
LPDIRECTINPUTDEVICE device; LPDIRECTINPUTDEVICE8 device;
/* Allocate the hwdata */ /* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *) haptic->hwdata = (struct haptic_hwdata *)
@ -327,26 +327,26 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
/* Open the device */ /* Open the device */
ret = IDirectInput_CreateDevice(dinput, &instance.guidInstance, ret = IDirectInput8_CreateDevice(dinput, &instance.guidInstance,
&device, NULL); &device, NULL);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Creating DirectInput device", ret); DI_SetError("Creating DirectInput device", ret);
goto creat_err; goto creat_err;
} }
/* Now get the IDirectInputDevice2 interface, instead. */ /* Now get the IDirectInputDevice8 interface, instead. */
ret = IDirectInputDevice_QueryInterface(device, ret = IDirectInputDevice8_QueryInterface(device,
&IID_IDirectInputDevice2, &IID_IDirectInputDevice8,
(LPVOID *) & haptic->hwdata-> (LPVOID *) & haptic->hwdata->
device); device);
/* Done with the temporary one now. */ /* Done with the temporary one now. */
IDirectInputDevice_Release(device); IDirectInputDevice8_Release(device);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Querying DirectInput interface", ret); DI_SetError("Querying DirectInput interface", ret);
goto creat_err; goto creat_err;
} }
ret2 = SDL_SYS_HapticOpenFromDevice2(haptic, haptic->hwdata->device); ret2 = SDL_SYS_HapticOpenFromDevice8(haptic, haptic->hwdata->device);
if (ret2 < 0) { if (ret2 < 0) {
goto query_err; goto query_err;
} }
@ -354,7 +354,7 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
return 0; return 0;
query_err: query_err:
IDirectInputDevice2_Release(haptic->hwdata->device); IDirectInputDevice8_Release(haptic->hwdata->device);
creat_err: creat_err:
if (haptic->hwdata != NULL) { if (haptic->hwdata != NULL) {
SDL_free(haptic->hwdata); SDL_free(haptic->hwdata);
@ -375,17 +375,17 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance)
* - Get supported featuers. * - Get supported featuers.
*/ */
static int static int
SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic, SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic,
LPDIRECTINPUTDEVICE2 device2) LPDIRECTINPUTDEVICE8 device8)
{ {
HRESULT ret; HRESULT ret;
DIPROPDWORD dipdw; DIPROPDWORD dipdw;
/* We'll use the device2 from now on. */ /* We'll use the device8 from now on. */
haptic->hwdata->device = device2; haptic->hwdata->device = device8;
/* Grab it exclusively to use force feedback stuff. */ /* Grab it exclusively to use force feedback stuff. */
ret = IDirectInputDevice2_SetCooperativeLevel(haptic->hwdata->device, ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device,
SDL_HelperWindow, SDL_HelperWindow,
DISCL_EXCLUSIVE | DISCL_EXCLUSIVE |
DISCL_BACKGROUND); DISCL_BACKGROUND);
@ -395,7 +395,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Set data format. */ /* Set data format. */
ret = IDirectInputDevice2_SetDataFormat(haptic->hwdata->device, ret = IDirectInputDevice8_SetDataFormat(haptic->hwdata->device,
&c_dfDIJoystick2); &c_dfDIJoystick2);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Setting data format", ret); DI_SetError("Setting data format", ret);
@ -403,7 +403,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Get number of axes. */ /* Get number of axes. */
ret = IDirectInputDevice2_EnumObjects(haptic->hwdata->device, ret = IDirectInputDevice8_EnumObjects(haptic->hwdata->device,
DI_DeviceObjectCallback, DI_DeviceObjectCallback,
haptic, DIDFT_AXIS); haptic, DIDFT_AXIS);
if (FAILED(ret)) { if (FAILED(ret)) {
@ -412,14 +412,14 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Acquire the device. */ /* Acquire the device. */
ret = IDirectInputDevice2_Acquire(haptic->hwdata->device); ret = IDirectInputDevice8_Acquire(haptic->hwdata->device);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Acquiring DirectInput device", ret); DI_SetError("Acquiring DirectInput device", ret);
goto acquire_err; goto acquire_err;
} }
/* Reset all actuators - just in case. */ /* Reset all actuators - just in case. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_RESET); DISFFC_RESET);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Resetting device", ret); DI_SetError("Resetting device", ret);
@ -427,7 +427,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Enabling actuators. */ /* Enabling actuators. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_SETACTUATORSON); DISFFC_SETACTUATORSON);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Enabling actuators", ret); DI_SetError("Enabling actuators", ret);
@ -435,7 +435,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
} }
/* Get supported effects. */ /* Get supported effects. */
ret = IDirectInputDevice2_EnumEffects(haptic->hwdata->device, ret = IDirectInputDevice8_EnumEffects(haptic->hwdata->device,
DI_EffectCallback, haptic, DI_EffectCallback, haptic,
DIEFT_ALL); DIEFT_ALL);
if (FAILED(ret)) { if (FAILED(ret)) {
@ -453,7 +453,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
dipdw.diph.dwObj = 0; dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE; dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = 10000; dipdw.dwData = 10000;
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_FFGAIN, &dipdw.diph); DIPROP_FFGAIN, &dipdw.diph);
if (!FAILED(ret)) { /* Gain is supported. */ if (!FAILED(ret)) { /* Gain is supported. */
haptic->supported |= SDL_HAPTIC_GAIN; haptic->supported |= SDL_HAPTIC_GAIN;
@ -461,7 +461,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
dipdw.diph.dwObj = 0; dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE; dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = DIPROPAUTOCENTER_OFF; dipdw.dwData = DIPROPAUTOCENTER_OFF;
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_AUTOCENTER, &dipdw.diph); DIPROP_AUTOCENTER, &dipdw.diph);
if (!FAILED(ret)) { /* Autocenter is supported. */ if (!FAILED(ret)) { /* Autocenter is supported. */
haptic->supported |= SDL_HAPTIC_AUTOCENTER; haptic->supported |= SDL_HAPTIC_AUTOCENTER;
@ -492,7 +492,7 @@ SDL_SYS_HapticOpenFromDevice2(SDL_Haptic * haptic,
/* Error handling */ /* Error handling */
acquire_err: acquire_err:
IDirectInputDevice2_Unacquire(haptic->hwdata->device); IDirectInputDevice8_Unacquire(haptic->hwdata->device);
return -1; return -1;
} }
@ -555,12 +555,12 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); joy_instance.dwSize = sizeof(DIDEVICEINSTANCE);
/* Get the device instances. */ /* Get the device instances. */
ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device, ret = IDirectInputDevice8_GetDeviceInfo(haptic->hwdata->device,
&hap_instance); &hap_instance);
if (FAILED(ret)) { if (FAILED(ret)) {
return 0; return 0;
} }
ret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice, ret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice,
&joy_instance); &joy_instance);
if (FAILED(ret)) { if (FAILED(ret)) {
return 0; return 0;
@ -586,7 +586,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
/* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
for (i=0; i<SDL_numhaptics; i++) { for (i=0; i<SDL_numhaptics; i++) {
idret = IDirectInputDevice2_GetDeviceInfo(joystick->hwdata->InputDevice, idret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice,
&joy_instance); &joy_instance);
if (FAILED(idret)) { if (FAILED(idret)) {
return -1; return -1;
@ -612,7 +612,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
/* Now open the device. */ /* Now open the device. */
ret = ret =
SDL_SYS_HapticOpenFromDevice2(haptic, joystick->hwdata->InputDevice); SDL_SYS_HapticOpenFromDevice8(haptic, joystick->hwdata->InputDevice);
if (ret < 0) { if (ret < 0) {
return -1; return -1;
} }
@ -638,10 +638,10 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic)
haptic->neffects = 0; haptic->neffects = 0;
/* Clean up */ /* Clean up */
IDirectInputDevice2_Unacquire(haptic->hwdata->device); IDirectInputDevice8_Unacquire(haptic->hwdata->device);
/* Only release if isn't grabbed by a joystick. */ /* Only release if isn't grabbed by a joystick. */
if (haptic->hwdata->is_joystick == 0) { if (haptic->hwdata->is_joystick == 0) {
IDirectInputDevice2_Release(haptic->hwdata->device); IDirectInputDevice8_Release(haptic->hwdata->device);
} }
/* Free */ /* Free */
@ -667,7 +667,7 @@ SDL_SYS_HapticQuit(void)
} }
if (dinput != NULL) { if (dinput != NULL) {
IDirectInput_Release(dinput); IDirectInput8_Release(dinput);
dinput = NULL; dinput = NULL;
} }
@ -1148,7 +1148,7 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
} }
/* Create the actual effect. */ /* Create the actual effect. */
ret = IDirectInputDevice2_CreateEffect(haptic->hwdata->device, type, ret = IDirectInputDevice8_CreateEffect(haptic->hwdata->device, type,
&effect->hweffect->effect, &effect->hweffect->effect,
&effect->hweffect->ref, NULL); &effect->hweffect->ref, NULL);
if (FAILED(ret)) { if (FAILED(ret)) {
@ -1319,7 +1319,7 @@ SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain)
dipdw.dwData = gain * 100; /* 0 to 10,000 */ dipdw.dwData = gain * 100; /* 0 to 10,000 */
/* Try to set the autocenter. */ /* Try to set the autocenter. */
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_FFGAIN, &dipdw.diph); DIPROP_FFGAIN, &dipdw.diph);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Setting gain", ret); DI_SetError("Setting gain", ret);
@ -1348,7 +1348,7 @@ SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter)
DIPROPAUTOCENTER_ON; DIPROPAUTOCENTER_ON;
/* Try to set the autocenter. */ /* Try to set the autocenter. */
ret = IDirectInputDevice2_SetProperty(haptic->hwdata->device, ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device,
DIPROP_AUTOCENTER, &dipdw.diph); DIPROP_AUTOCENTER, &dipdw.diph);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Setting autocenter", ret); DI_SetError("Setting autocenter", ret);
@ -1368,7 +1368,7 @@ SDL_SYS_HapticPause(SDL_Haptic * haptic)
HRESULT ret; HRESULT ret;
/* Pause the device. */ /* Pause the device. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_PAUSE); DISFFC_PAUSE);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Pausing the device", ret); DI_SetError("Pausing the device", ret);
@ -1388,7 +1388,7 @@ SDL_SYS_HapticUnpause(SDL_Haptic * haptic)
HRESULT ret; HRESULT ret;
/* Unpause the device. */ /* Unpause the device. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_CONTINUE); DISFFC_CONTINUE);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Pausing the device", ret); DI_SetError("Pausing the device", ret);
@ -1408,7 +1408,7 @@ SDL_SYS_HapticStopAll(SDL_Haptic * haptic)
HRESULT ret; HRESULT ret;
/* Try to stop the effects. */ /* Try to stop the effects. */
ret = IDirectInputDevice2_SendForceFeedbackCommand(haptic->hwdata->device, ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device,
DISFFC_STOPALL); DISFFC_STOPALL);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Stopping the device", ret); DI_SetError("Stopping the device", ret);

View file

@ -63,7 +63,7 @@ extern HWND SDL_HelperWindow;
/* local variables */ /* local variables */
static SDL_bool coinitialized = SDL_FALSE; static SDL_bool coinitialized = SDL_FALSE;
static LPDIRECTINPUT dinput = NULL; static LPDIRECTINPUT8 dinput = NULL;
static SDL_bool s_bDeviceAdded = SDL_FALSE; static SDL_bool s_bDeviceAdded = SDL_FALSE;
static SDL_bool s_bDeviceRemoved = SDL_FALSE; static SDL_bool s_bDeviceRemoved = SDL_FALSE;
static int s_nInstanceID = -1; static int s_nInstanceID = -1;
@ -919,7 +919,7 @@ int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{ {
HRESULT result; HRESULT result;
LPDIRECTINPUTDEVICE device; LPDIRECTINPUTDEVICE8 device;
DIPROPDWORD dipdw; DIPROPDWORD dipdw;
JoyStick_DeviceData *joystickdevice = SYS_Joystick; JoyStick_DeviceData *joystickdevice = SYS_Joystick;
@ -1008,7 +1008,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
return (-1); return (-1);
} }
/* Now get the IDirectInputDevice2 interface, instead. */ /* Now get the IDirectInputDevice8 interface, instead. */
result = IDirectInputDevice8_QueryInterface(device, result = IDirectInputDevice8_QueryInterface(device,
&IID_IDirectInputDevice8, &IID_IDirectInputDevice8,
(LPVOID *) & joystick-> (LPVOID *) & joystick->
@ -1017,7 +1017,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
IDirectInputDevice8_Release(device); IDirectInputDevice8_Release(device);
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice::QueryInterface", result); SetDIerror("IDirectInputDevice8::QueryInterface", result);
return (-1); return (-1);
} }
@ -1029,7 +1029,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
DISCL_NONEXCLUSIVE | DISCL_NONEXCLUSIVE |
DISCL_BACKGROUND); DISCL_BACKGROUND);
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::SetCooperativeLevel", result); SetDIerror("IDirectInputDevice8::SetCooperativeLevel", result);
return (-1); return (-1);
} }
@ -1038,7 +1038,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
IDirectInputDevice8_SetDataFormat(joystick->hwdata->InputDevice, IDirectInputDevice8_SetDataFormat(joystick->hwdata->InputDevice,
&c_dfDIJoystick2); &c_dfDIJoystick2);
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::SetDataFormat", result); SetDIerror("IDirectInputDevice8::SetDataFormat", result);
return (-1); return (-1);
} }
@ -1048,7 +1048,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
&joystick->hwdata->Capabilities); &joystick->hwdata->Capabilities);
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::GetCapabilities", result); SetDIerror("IDirectInputDevice8::GetCapabilities", result);
return (-1); return (-1);
} }
@ -1058,7 +1058,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
result = IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice); result = IDirectInputDevice8_Acquire(joystick->hwdata->InputDevice);
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::Acquire", result); SetDIerror("IDirectInputDevice8::Acquire", result);
return (-1); return (-1);
} }
@ -1070,7 +1070,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
/* Not necessarily supported, ignore if not supported. /* Not necessarily supported, ignore if not supported.
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::SendForceFeedbackCommand", SetDIerror("IDirectInputDevice8::SendForceFeedbackCommand",
result); result);
return (-1); return (-1);
} }
@ -1079,7 +1079,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
result = IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice); result = IDirectInputDevice8_Unacquire(joystick->hwdata->InputDevice);
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::Unacquire", result); SetDIerror("IDirectInputDevice8::Unacquire", result);
return (-1); return (-1);
} }
@ -1095,7 +1095,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
/* Not necessarily supported, ignore if not supported. /* Not necessarily supported, ignore if not supported.
if (FAILED(result)) { if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::SetProperty", result); SetDIerror("IDirectInputDevice8::SetProperty", result);
return (-1); return (-1);
} }
*/ */
@ -1124,7 +1124,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
* to use less reliable polling. */ * to use less reliable polling. */
joystick->hwdata->buffered = 0; joystick->hwdata->buffered = 0;
} else if (FAILED(result)) { } else if (FAILED(result)) {
SetDIerror("IDirectInputDevice2::SetProperty", result); SetDIerror("IDirectInputDevice8::SetProperty", result);
return (-1); return (-1);
} }
} }

View file

@ -84,7 +84,7 @@ typedef struct
/* The private structure used to keep track of a joystick */ /* The private structure used to keep track of a joystick */
struct joystick_hwdata struct joystick_hwdata
{ {
LPDIRECTINPUTDEVICE2 InputDevice; LPDIRECTINPUTDEVICE8 InputDevice;
DIDEVCAPS Capabilities; DIDEVCAPS Capabilities;
int buffered; int buffered;
JoystickGUID guid; JoystickGUID guid;