mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-29 04:21:03 +08:00
Simplify and cleanup DirectInput joystick backend code:
- Do not call IDirectInputDevice8_QueryInterface(device, &IID_IDirectInputDevice8,...) on DIRECTINPUTDEVICE8 device - Get joystick VendorID and ProductID via IDirectInputDevice8_GetProperty(.., DIPROP_VIDPID, ..) call instead of messing with DIDEVICEINSTANCE.guidProduct - Normalize HID device interface path to upper case for stable operation of XInput check - Remove useless RawInput calls in SDL_IsXInputDevice() - just check for "IG_" string in HID device interface path that we already have There shouldn't be any observable behavior changes.
This commit is contained in:
committed by
Sam Lantinga
parent
f2f759dca3
commit
73dc68a7ae
@@ -419,7 +419,6 @@ SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item)
|
|||||||
{
|
{
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
LPDIRECTINPUTDEVICE8 device;
|
LPDIRECTINPUTDEVICE8 device;
|
||||||
LPDIRECTINPUTDEVICE8 device8;
|
|
||||||
|
|
||||||
/* Open the device */
|
/* Open the device */
|
||||||
ret = IDirectInput8_CreateDevice(dinput, &item->instance.guidInstance,
|
ret = IDirectInput8_CreateDevice(dinput, &item->instance.guidInstance,
|
||||||
@@ -429,19 +428,8 @@ SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now get the IDirectInputDevice8 interface, instead. */
|
if (SDL_DINPUT_HapticOpenFromDevice(haptic, device, SDL_FALSE) < 0) {
|
||||||
ret = IDirectInputDevice8_QueryInterface(device,
|
IDirectInputDevice8_Release(device);
|
||||||
&IID_IDirectInputDevice8,
|
|
||||||
(LPVOID *)&device8);
|
|
||||||
/* Done with the temporary one now. */
|
|
||||||
IDirectInputDevice8_Release(device);
|
|
||||||
if (FAILED(ret)) {
|
|
||||||
DI_SetError("Querying DirectInput interface", ret);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_DINPUT_HapticOpenFromDevice(haptic, device8, SDL_FALSE) < 0) {
|
|
||||||
IDirectInputDevice8_Release(device8);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -713,7 +701,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
|
|||||||
/* Specifics */
|
/* Specifics */
|
||||||
periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
|
periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
|
||||||
periodic->lOffset = CONVERT(hap_periodic->offset);
|
periodic->lOffset = CONVERT(hap_periodic->offset);
|
||||||
periodic->dwPhase =
|
periodic->dwPhase =
|
||||||
(hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000;
|
(hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000;
|
||||||
periodic->dwPeriod = hap_periodic->period * 1000;
|
periodic->dwPeriod = hap_periodic->period * 1000;
|
||||||
dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
|
dest->cbTypeSpecificParams = sizeof(DIPERIODIC);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,7 @@ typedef struct JoyStick_DeviceData
|
|||||||
BYTE SubType;
|
BYTE SubType;
|
||||||
Uint8 XInputUserId;
|
Uint8 XInputUserId;
|
||||||
DIDEVICEINSTANCE dxdevice;
|
DIDEVICEINSTANCE dxdevice;
|
||||||
WCHAR hidPath[MAX_PATH];
|
char hidPath[MAX_PATH];
|
||||||
struct JoyStick_DeviceData *pNext;
|
struct JoyStick_DeviceData *pNext;
|
||||||
} JoyStick_DeviceData;
|
} JoyStick_DeviceData;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user