early-access version 1780

This commit is contained in:
pineappleEA
2021-06-11 20:56:03 +02:00
parent e46a402c25
commit 388881fdbb
93 changed files with 2410 additions and 851 deletions

View File

@@ -526,6 +526,7 @@ static const char *s_ControllerMappings [] =
"05000000a00500003232000001000000,8BitDo Zero Gamepad,a:b1,b:b0,back:b10,dpdown:b122,dpleft:b119,dpright:b120,dpup:b117,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000a00500003232000008010000,8BitDo Zero Gamepad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000a00500003232000008010000,8BitDo Zero Gamepad,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"03000000c82d00000031000011010000,8Bitdo Receiver,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
"03000000c82d00001290000011010000,8Bitdo SN30 Gamepad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"03000000c82d00001290000011010000,8Bitdo SN30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000c82d00006228000000010000,8Bitdo SN30 Gamepad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
@@ -536,6 +537,10 @@ static const char *s_ControllerMappings [] =
"030000006f0e00003901000000430000,Afterglow Prismatic Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
"03000000503200000110000000000000,Atari Classic Controller,a:b0,x:b1,back:b2,guide:b4,start:b3,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2",
"05000000503200000110000000000000,Atari Classic Controller,a:b0,x:b1,back:b2,guide:b4,start:b3,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2",
"03000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,x:b3,y:b2,back:b6,guide:b8,start:b7,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5",
"05000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,x:b3,y:b2,back:b6,guide:b8,start:b7,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5",
"05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
"05000000710100001904000000010000,Amazon Luna Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"03000000790000003018000011010000,Arcade Fightstick F300,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
@@ -673,6 +678,7 @@ static const char *s_ControllerMappings [] =
"030000004c050000e60c000011010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
"050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
"030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,",
"03000000c62400003a54000001010000,PowerA XBox One Controller,a:b0,b:b1,back:b6,dpdown:h0.7,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,",
"030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
@@ -767,6 +773,7 @@ static const char *s_ControllerMappings [] =
"050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,",
"030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,",
"03000000120c0000f70e000011010000,Brook Universal Fighting Board,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:,lefty:,rightx:,righty:,lefttrigger:b6,righttrigger:b7,",
#endif
#if defined(__ANDROID__)
"05000000c82d000006500000ffff3f00,8BitDo M30 Gamepad,a:b0,b:b1,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a4,start:b6,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",

View File

@@ -2062,6 +2062,8 @@ static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid)
MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */
MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */
MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */
MAKE_VIDPID(0x044f, 0xb66e), /* Thrustmaster T300RS */
MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */
MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */
MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */
};

View File

@@ -187,7 +187,7 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x045e, 0x028f ), k_eControllerType_XBox360Controller, "Xbox 360 Controller" }, // Microsoft X-Box 360 pad v2
{ MAKE_CONTROLLER_ID( 0x045e, 0x0291 ), k_eControllerType_XBox360Controller, "Xbox 360 Wireless Controller" }, // Xbox 360 Wireless Receiver (XBOX)
{ MAKE_CONTROLLER_ID( 0x045e, 0x02a0 ), k_eControllerType_XBox360Controller, NULL }, // Microsoft X-Box 360 Big Button IR
{ MAKE_CONTROLLER_ID( 0x045e, 0x02a1 ), k_eControllerType_XBox360Controller, NULL }, // Microsoft X-Box 360 pad
{ MAKE_CONTROLLER_ID( 0x045e, 0x02a1 ), k_eControllerType_XBox360Controller, NULL }, // Microsoft X-Box 360 Wireless Controller with XUSB driver on Windows
{ MAKE_CONTROLLER_ID( 0x045e, 0x02a9 ), k_eControllerType_XBox360Controller, "Xbox 360 Wireless Controller" }, // Xbox 360 Wireless Receiver (third party knockoff)
{ MAKE_CONTROLLER_ID( 0x045e, 0x0719 ), k_eControllerType_XBox360Controller, "Xbox 360 Wireless Controller" }, // Xbox 360 Wireless Receiver
{ MAKE_CONTROLLER_ID( 0x046d, 0xc21d ), k_eControllerType_XBox360Controller, NULL }, // Logitech Gamepad F310
@@ -322,11 +322,11 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x045e, 0x02e3 ), k_eControllerType_XBoxOneController, "Xbox One Elite Controller" }, // Microsoft X-Box One Elite pad
{ MAKE_CONTROLLER_ID( 0x045e, 0x02ea ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft X-Box One S pad
{ MAKE_CONTROLLER_ID( 0x045e, 0x02fd ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft X-Box One S pad (Bluetooth)
{ MAKE_CONTROLLER_ID( 0x045e, 0x02ff ), k_eControllerType_XBoxOneController, NULL }, // Microsoft X-Box One controller with the RAWINPUT driver on Windows
{ MAKE_CONTROLLER_ID( 0x045e, 0x02ff ), k_eControllerType_XBoxOneController, NULL }, // Microsoft X-Box One controller with XBOXGIP driver on Windows
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b00 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // Microsoft X-Box One Elite Series 2 pad
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b05 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // Microsoft X-Box One Elite Series 2 pad (Bluetooth)
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b12 ), k_eControllerType_XBoxOneController, "Xbox One Series X Controller" }, // Microsoft X-Box One Elite Series X pad
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b13 ), k_eControllerType_XBoxOneController, "Xbox One Series X Controller" }, // Microsoft X-Box One Elite Series X pad (Bluetooth)
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b12 ), k_eControllerType_XBoxOneController, "Xbox One Series X Controller" }, // Microsoft X-Box One Series X pad
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b13 ), k_eControllerType_XBoxOneController, "Xbox One Series X Controller" }, // Microsoft X-Box One Series X pad (Bluetooth)
{ MAKE_CONTROLLER_ID( 0x0738, 0x4a01 ), k_eControllerType_XBoxOneController, NULL }, // Mad Catz FightStick TE 2
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0139 ), k_eControllerType_XBoxOneController, "PDP Xbox One Afterglow" }, // PDP Afterglow Wired Controller for Xbox One
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x013B ), k_eControllerType_XBoxOneController, "PDP Xbox One Face-Off Controller" }, // PDP Face-Off Gamepad for Xbox One

View File

@@ -709,7 +709,7 @@ HIDAPI_DriverPS5_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick
static SDL_bool
HIDAPI_DriverPS5_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{
return SDL_FALSE;
return SDL_TRUE;
}
static int

View File

@@ -717,11 +717,7 @@ static Sint16 ApplyStickCalibrationCentered(SDL_DriverSwitch_Context *ctx, int n
ctx->m_StickExtents[nStick].axis[nAxis].sMin = sRawValue;
}
if (sRawValue > 0) {
return (Sint16)HIDAPI_RemapVal(sRawValue, 0, ctx->m_StickExtents[nStick].axis[nAxis].sMax, 0, SDL_MAX_SINT16);
} else {
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, 0, SDL_MIN_SINT16, 0);
}
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, ctx->m_StickExtents[nStick].axis[nAxis].sMax, SDL_MIN_SINT16, SDL_MAX_SINT16);
}
static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue)

View File

@@ -1086,12 +1086,12 @@ HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, SDL_HIDAPI_Devi
if (vendor_id == USB_VENDOR_MICROSOFT) {
/* If we're looking for the wireless XBox 360 controller, also look for the dongle */
if (product_id == 0x02a1 && device->product_id == 0x0719) {
if (product_id == USB_PRODUCT_XBOX360_XUSB_CONTROLLER && device->product_id == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER) {
return SDL_TRUE;
}
/* If we're looking for the raw input Xbox One controller, match it against any other Xbox One controller */
if (product_id == USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER &&
if (product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER &&
SDL_GetJoystickGameControllerType(device->name, device->vendor_id, device->product_id, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol) == SDL_CONTROLLER_TYPE_XBOXONE) {
return SDL_TRUE;
}

View File

@@ -127,6 +127,14 @@ FixupDeviceInfoForMapping(int fd, struct input_id *inpid)
inpid->version = 0x0902;
}
}
/* For Atari vcs modern and classic controllers have the version reflecting
* firmware version, but the mapping stays stable so ignore
* version information */
if (inpid->vendor == 0x3250
&& (inpid->product == 0x1001 || inpid->product == 0x1002)) {
inpid->version = 0;
}
}
#ifdef SDL_JOYSTICK_HIDAPI

View File

@@ -51,6 +51,8 @@
#define USB_PRODUCT_SONY_DS4_DONGLE 0x0ba0
#define USB_PRODUCT_SONY_DS4_SLIM 0x09cc
#define USB_PRODUCT_SONY_DS5 0x0ce6
#define USB_PRODUCT_XBOX360_XUSB_CONTROLLER 0x02a1 /* XUSB driver software PID */
#define USB_PRODUCT_XBOX360_WIRELESS_RECEIVER 0x0719
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1 0x02e3
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 0x0b00
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH 0x0b05
@@ -60,7 +62,7 @@
#define USB_PRODUCT_XBOX_ONE_SERIES_X 0x0b12
#define USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH 0x0b13
#define USB_PRODUCT_XBOX_ONE_SERIES_X_POWERA 0x2001
#define USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER 0x02ff
#define USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER 0x02ff /* XBOXGIP driver software PID */
#define USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER 0x02fe /* Made up product ID for XInput */
/* USB usage pages */

View File

@@ -45,8 +45,6 @@ extern HWND SDL_HelperWindow;
/* local variables */
static SDL_bool coinitialized = SDL_FALSE;
static LPDIRECTINPUT8 dinput = NULL;
static PRAWINPUTDEVICELIST SDL_RawDevList = NULL;
static UINT SDL_RawDevListCount = 0;
/* Taken from Wine - Thanks! */
static DIOBJECTDATAFORMAT dfDIJoystick2[] = {
@@ -235,210 +233,104 @@ SetDIerror(const char *function, HRESULT code)
return SDL_SetError("%s() DirectX error 0x%8.8lx", function, code);
}
#if 0 /* Microsoft recommended implementation, but slower than checking raw devices */
#define COBJMACROS
#include <wbemidl.h>
#include <oleauto.h>
static const IID CLSID_WbemLocator = { 0x4590f811, 0x1d3a, 0x11d0,{ 0x89, 0x1f, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } };
static const IID IID_IWbemLocator = { 0xdc12a687, 0x737f, 0x11cf,{ 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } };
static SDL_bool
WIN_IsXInputDevice(const TCHAR *name, const GUID* pGuidProductFromDirectInput)
SDL_IsXInputDevice(Uint16 vendor_id, Uint16 product_id, const char* hidPath)
{
IWbemLocator* pIWbemLocator = NULL;
IEnumWbemClassObject* pEnumDevices = NULL;
IWbemClassObject* pDevices[20];
IWbemServices* pIWbemServices = NULL;
BSTR bstrNamespace = NULL;
BSTR bstrDeviceID = NULL;
BSTR bstrClassName = NULL;
DWORD uReturned = 0;
SDL_bool bIsXinputDevice = SDL_FALSE;
UINT iDevice = 0;
VARIANT var;
HRESULT hr;
SDL_GameControllerType type;
if (!SDL_XINPUT_Enabled()) {
return SDL_FALSE;
}
if (SDL_tcsstr(name, TEXT(" XINPUT ")) != NULL) {
/* This is a duplicate interface for a controller that will show up with XInput,
e.g. Xbox One Elite Series 2 in Bluetooth mode.
*/
type = SDL_GetJoystickGameControllerType("", vendor_id, product_id, -1, 0, 0, 0);
if (type == SDL_CONTROLLER_TYPE_XBOX360 ||
type == SDL_CONTROLLER_TYPE_XBOXONE ||
(vendor_id == 0x28DE && product_id == 0x11FF)) {
return SDL_TRUE;
}
SDL_zeroa(pDevices);
// Create WMI
hr = CoCreateInstance(&CLSID_WbemLocator,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IWbemLocator,
(LPVOID*)&pIWbemLocator);
if (FAILED(hr) || pIWbemLocator == NULL)
goto LCleanup;
bstrNamespace = SysAllocString(L"\\\\.\\root\\cimv2"); if (bstrNamespace == NULL) goto LCleanup;
bstrClassName = SysAllocString(L"Win32_PNPEntity"); if (bstrClassName == NULL) goto LCleanup;
bstrDeviceID = SysAllocString(L"DeviceID"); if (bstrDeviceID == NULL) goto LCleanup;
// Connect to WMI
hr = IWbemLocator_ConnectServer(pIWbemLocator, bstrNamespace, NULL, NULL, 0L,
0L, NULL, NULL, &pIWbemServices);
if (FAILED(hr) || pIWbemServices == NULL) {
goto LCleanup;
}
// Switch security level to IMPERSONATE.
CoSetProxyBlanket((IUnknown *)pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
hr = IWbemServices_CreateInstanceEnum(pIWbemServices, bstrClassName, 0, NULL, &pEnumDevices);
if (FAILED(hr) || pEnumDevices == NULL)
goto LCleanup;
// Loop over all devices
for (;;) {
// Get 20 at a time
hr = IEnumWbemClassObject_Next(pEnumDevices, 10000, SDL_arraysize(pDevices), pDevices, &uReturned);
if (FAILED(hr)) {
goto LCleanup;
}
if (uReturned == 0) {
break;
}
for (iDevice = 0; iDevice < uReturned; iDevice++) {
// For each device, get its device ID
hr = IWbemClassObject_Get(pDevices[iDevice], bstrDeviceID, 0L, &var, NULL, NULL);
if (SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != NULL) {
// Check if the device ID contains "IG_". If it does, then it's an XInput device
// This information can not be found from DirectInput
if (SDL_wcsstr(var.bstrVal, L"IG_")) {
char *bstrVal = WIN_StringToUTF8W(var.bstrVal);
// If it does, then get the VID/PID from var.bstrVal
DWORD dwPid = 0, dwVid = 0, dwVidPid;
const char *strVid, *strPid;
strVid = SDL_strstr(bstrVal, "VID_");
if (strVid && SDL_sscanf(strVid, "VID_%4X", &dwVid) != 1)
dwVid = 0;
strPid = SDL_strstr(bstrVal, "PID_");
if (strPid && SDL_sscanf(strPid, "PID_%4X", &dwPid) != 1)
dwPid = 0;
SDL_free(bstrVal);
// Compare the VID/PID to the DInput device
dwVidPid = MAKELONG(dwVid, dwPid);
if (dwVidPid == pGuidProductFromDirectInput->Data1) {
bIsXinputDevice = SDL_TRUE;
goto LCleanup;
}
}
}
IWbemClassObject_Release(pDevices[iDevice]);
}
}
LCleanup:
if (bstrNamespace) {
SysFreeString(bstrNamespace);
}
if (bstrDeviceID) {
SysFreeString(bstrDeviceID);
}
if (bstrClassName) {
SysFreeString(bstrClassName);
}
for (iDevice = 0; iDevice < SDL_arraysize(pDevices); iDevice++) {
if (pDevices[iDevice]) {
IWbemClassObject_Release(pDevices[iDevice]);
}
}
if (pEnumDevices) {
IEnumWbemClassObject_Release(pEnumDevices);
}
if (pIWbemLocator) {
IWbemLocator_Release(pIWbemLocator);
}
if (pIWbemServices) {
IWbemServices_Release(pIWbemServices);
}
return bIsXinputDevice;
}
#endif /* 0 */
static SDL_bool
SDL_IsXInputDevice(const TCHAR *name, const GUID* pGuidProductFromDirectInput)
{
UINT i;
if (!SDL_XINPUT_Enabled()) {
return SDL_FALSE;
}
if (SDL_tcsstr(name, TEXT(" XINPUT ")) != NULL) {
/* This is a duplicate interface for a controller that will show up with XInput,
e.g. Xbox One Elite Series 2 in Bluetooth mode.
*/
/* If device path contains "IG_" then its an XInput device */
/* See: https://docs.microsoft.com/windows/win32/xinput/xinput-and-directinput */
if (SDL_strstr(hidPath, "IG_") != NULL) {
return SDL_TRUE;
}
if (SDL_memcmp(&pGuidProductFromDirectInput->Data4[2], "PIDVID", 6) == 0) {
Uint16 vendor_id = (Uint16)LOWORD(pGuidProductFromDirectInput->Data1);
Uint16 product_id = (Uint16)HIWORD(pGuidProductFromDirectInput->Data1);
SDL_GameControllerType type = SDL_GetJoystickGameControllerType("", vendor_id, product_id, -1, 0, 0, 0);
if (type == SDL_CONTROLLER_TYPE_XBOX360 ||
type == SDL_CONTROLLER_TYPE_XBOXONE ||
(vendor_id == 0x28DE && product_id == 0x11FF)) {
return SDL_TRUE;
}
}
/* Go through RAWINPUT (WinXP and later) to find HID devices. */
/* Cache this if we end up using it. */
if (SDL_RawDevList == NULL) {
if ((GetRawInputDeviceList(NULL, &SDL_RawDevListCount, sizeof(RAWINPUTDEVICELIST)) == -1) || (!SDL_RawDevListCount)) {
return SDL_FALSE; /* oh well. */
}
SDL_RawDevList = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * SDL_RawDevListCount);
if (SDL_RawDevList == NULL) {
SDL_OutOfMemory();
return SDL_FALSE;
}
if (GetRawInputDeviceList(SDL_RawDevList, &SDL_RawDevListCount, sizeof(RAWINPUTDEVICELIST)) == -1) {
SDL_free(SDL_RawDevList);
SDL_RawDevList = NULL;
return SDL_FALSE; /* oh well. */
}
}
for (i = 0; i < SDL_RawDevListCount; i++) {
RID_DEVICE_INFO rdi;
char devName[MAX_PATH];
UINT rdiSize = sizeof(rdi);
UINT nameSize = SDL_arraysize(devName);
rdi.cbSize = sizeof(rdi);
if ((SDL_RawDevList[i].dwType == RIM_TYPEHID) &&
(GetRawInputDeviceInfoA(SDL_RawDevList[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) &&
(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)pGuidProductFromDirectInput->Data1)) &&
(GetRawInputDeviceInfoA(SDL_RawDevList[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
(SDL_strstr(devName, "IG_") != NULL)) {
return SDL_TRUE;
}
}
return SDL_FALSE;
}
static SDL_bool
QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char** device_name)
{
DIPROPSTRING dipstr;
if (!device || !device_name) {
return SDL_FALSE;
}
dipstr.diph.dwSize = sizeof(dipstr);
dipstr.diph.dwHeaderSize = sizeof(dipstr.diph);
dipstr.diph.dwObj = 0;
dipstr.diph.dwHow = DIPH_DEVICE;
if (FAILED(IDirectInputDevice8_GetProperty(device, DIPROP_PRODUCTNAME, &dipstr.diph))) {
return SDL_FALSE;
}
*device_name = WIN_StringToUTF8(dipstr.wsz);
return SDL_TRUE;
}
static SDL_bool
QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char** device_path)
{
DIPROPGUIDANDPATH dippath;
if (!device || !device_path) {
return SDL_FALSE;
}
dippath.diph.dwSize = sizeof(dippath);
dippath.diph.dwHeaderSize = sizeof(dippath.diph);
dippath.diph.dwObj = 0;
dippath.diph.dwHow = DIPH_DEVICE;
if (FAILED(IDirectInputDevice8_GetProperty(device, DIPROP_GUIDANDPATH, &dippath.diph))) {
return SDL_FALSE;
}
*device_path = WIN_StringToUTF8W(dippath.wszPath);
/* Normalize path to upper case. */
SDL_strupr(*device_path);
return SDL_TRUE;
}
static SDL_bool
QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16* vendor_id, Uint16* product_id)
{
DIPROPDWORD dipdw;
if (!device || !vendor_id || !product_id) {
return SDL_FALSE;
}
dipdw.diph.dwSize = sizeof(dipdw);
dipdw.diph.dwHeaderSize = sizeof(dipdw.diph);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
if (FAILED(IDirectInputDevice8_GetProperty(device, DIPROP_VIDPID, &dipdw.diph))) {
return SDL_FALSE;
}
*vendor_id = LOWORD(dipdw.dwData);
*product_id = HIWORD(dipdw.dwData);
return SDL_TRUE;
}
void FreeRumbleEffectData(DIEFFECT *effect)
{
if (!effect) {
@@ -533,88 +425,49 @@ SDL_DINPUT_JoystickInit(void)
/* helper function for direct input, gets called for each connected joystick */
static BOOL CALLBACK
EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
EnumJoysticksCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext)
{
JoyStick_DeviceData *pNewJoystick;
#define CHECK(exp) { if(!(exp)) goto err; }
JoyStick_DeviceData *pNewJoystick = NULL;
JoyStick_DeviceData *pPrevJoystick = NULL;
const DWORD devtype = (pdidInstance->dwDevType & 0xFF);
Uint16 *guid16;
Uint16 vendor = 0;
Uint16 product = 0;
Uint16 version = 0;
WCHAR hidPath[MAX_PATH];
char *name;
char *hidPath = NULL;
char *name = NULL;
LPDIRECTINPUTDEVICE8 device = NULL;
if (devtype == DI8DEVTYPE_SUPPLEMENTAL) {
/* Add any supplemental devices that should be ignored here */
#define MAKE_TABLE_ENTRY(VID, PID) ((((DWORD)PID)<<16)|VID)
static DWORD ignored_devices[] = {
MAKE_TABLE_ENTRY(0, 0)
};
#undef MAKE_TABLE_ENTRY
unsigned int i;
/* We are only supporting HID devices. */
CHECK((pDeviceInstance->dwDevType & DIDEVTYPE_HID) != 0);
for (i = 0; i < SDL_arraysize(ignored_devices); ++i) {
if (pdidInstance->guidProduct.Data1 == ignored_devices[i]) {
return DIENUM_CONTINUE;
}
}
}
CHECK(SUCCEEDED(IDirectInput8_CreateDevice(dinput, &pDeviceInstance->guidInstance, &device, NULL)));
CHECK(QueryDeviceName(device, &name));
CHECK(QueryDevicePath(device, &hidPath));
CHECK(QueryDeviceInfo(device, &vendor, &product));
if (SDL_IsXInputDevice(pdidInstance->tszProductName, &pdidInstance->guidProduct)) {
return DIENUM_CONTINUE; /* ignore XInput devices here, keep going. */
}
CHECK(!SDL_IsXInputDevice(vendor, product, hidPath));
{
HRESULT result;
LPDIRECTINPUTDEVICE8 device;
LPDIRECTINPUTDEVICE8 InputDevice;
DIPROPGUIDANDPATH dipdw2;
result = IDirectInput8_CreateDevice(dinput, &(pdidInstance->guidInstance), &device, NULL);
if (FAILED(result)) {
return DIENUM_CONTINUE; /* better luck next time? */
}
/* Now get the IDirectInputDevice8 interface, instead. */
result = IDirectInputDevice8_QueryInterface(device, &IID_IDirectInputDevice8, (LPVOID *)&InputDevice);
/* We are done with this object. Use the stored one from now on. */
IDirectInputDevice8_Release(device);
if (FAILED(result)) {
return DIENUM_CONTINUE; /* better luck next time? */
}
dipdw2.diph.dwSize = sizeof(dipdw2);
dipdw2.diph.dwHeaderSize = sizeof(dipdw2.diph);
dipdw2.diph.dwObj = 0; // device property
dipdw2.diph.dwHow = DIPH_DEVICE;
result = IDirectInputDevice8_GetProperty(InputDevice, DIPROP_GUIDANDPATH, &dipdw2.diph);
IDirectInputDevice8_Release(InputDevice);
if (FAILED(result)) {
return DIENUM_CONTINUE; /* better luck next time? */
}
/* Get device path, compare that instead of GUID, additionally update GUIDs of joysticks with matching paths, in case they're not open yet. */
SDL_wcslcpy(hidPath, dipdw2.wszPath, SDL_arraysize(hidPath));
}
pNewJoystick = *(JoyStick_DeviceData **)pContext;
pNewJoystick = *(JoyStick_DeviceData**)pContext;
while (pNewJoystick) {
if (SDL_wcscmp(pNewJoystick->hidPath, hidPath) == 0) {
/* update GUIDs of joysticks with matching paths, in case they're not open yet */
if (SDL_strcmp(pNewJoystick->hidPath, hidPath) == 0) {
/* if we are replacing the front of the list then update it */
if (pNewJoystick == *(JoyStick_DeviceData **)pContext) {
*(JoyStick_DeviceData **)pContext = pNewJoystick->pNext;
} else if (pPrevJoystick) {
if (pNewJoystick == *(JoyStick_DeviceData**)pContext) {
*(JoyStick_DeviceData**)pContext = pNewJoystick->pNext;
}
else if (pPrevJoystick) {
pPrevJoystick->pNext = pNewJoystick->pNext;
}
/* Update with new guid/etc, if it has changed */
SDL_memcpy(&pNewJoystick->dxdevice, pdidInstance, sizeof(DIDEVICEINSTANCE));
SDL_memcpy(&pNewJoystick->dxdevice, pDeviceInstance, sizeof(DIDEVICEINSTANCE));
pNewJoystick->pNext = SYS_Joystick;
SYS_Joystick = pNewJoystick;
return DIENUM_CONTINUE; /* already have this joystick loaded, just keep going */
pNewJoystick = NULL;
CHECK(FALSE);
}
pPrevJoystick = pNewJoystick;
@@ -622,31 +475,18 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
}
pNewJoystick = (JoyStick_DeviceData *)SDL_malloc(sizeof(JoyStick_DeviceData));
if (!pNewJoystick) {
return DIENUM_CONTINUE; /* better luck next time? */
}
CHECK(pNewJoystick);
SDL_zerop(pNewJoystick);
SDL_wcslcpy(pNewJoystick->hidPath, hidPath, SDL_arraysize(pNewJoystick->hidPath));
SDL_memcpy(&pNewJoystick->dxdevice, pdidInstance, sizeof(DIDEVICEINSTANCE));
SDL_strlcpy(pNewJoystick->hidPath, hidPath, SDL_arraysize(pNewJoystick->hidPath));
SDL_memcpy(&pNewJoystick->dxdevice, pDeviceInstance, sizeof(DIDEVICEINSTANCE));
SDL_memset(pNewJoystick->guid.data, 0, sizeof(pNewJoystick->guid.data));
if (SDL_memcmp(&pdidInstance->guidProduct.Data4[2], "PIDVID", 6) == 0) {
vendor = (Uint16)LOWORD(pdidInstance->guidProduct.Data1);
product = (Uint16)HIWORD(pdidInstance->guidProduct.Data1);
}
name = WIN_StringToUTF8(pdidInstance->tszProductName);
pNewJoystick->joystickname = SDL_CreateJoystickName(vendor, product, NULL, name);
SDL_free(name);
if (!pNewJoystick->joystickname) {
SDL_free(pNewJoystick);
return DIENUM_CONTINUE; /* better luck next time? */
}
CHECK(pNewJoystick->joystickname);
guid16 = (Uint16 *)pNewJoystick->guid.data;
if (SDL_memcmp(&pdidInstance->guidProduct.Data4[2], "PIDVID", 6) == 0) {
if (vendor && product) {
*guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_USB);
*guid16++ = 0;
*guid16++ = SDL_SwapLE16(vendor);
@@ -661,127 +501,102 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
SDL_strlcpy((char*)guid16, pNewJoystick->joystickname, sizeof(pNewJoystick->guid.data) - 4);
}
if (SDL_ShouldIgnoreJoystick(pNewJoystick->joystickname, pNewJoystick->guid)) {
SDL_free(pNewJoystick->joystickname);
SDL_free(pNewJoystick);
return DIENUM_CONTINUE;
}
CHECK(!SDL_ShouldIgnoreJoystick(pNewJoystick->joystickname, pNewJoystick->guid));
#ifdef SDL_JOYSTICK_HIDAPI
if (HIDAPI_IsDevicePresent(vendor, product, 0, pNewJoystick->joystickname)) {
/* The HIDAPI driver is taking care of this device */
SDL_free(pNewJoystick->joystickname);
SDL_free(pNewJoystick);
return DIENUM_CONTINUE;
}
CHECK(!HIDAPI_IsDevicePresent(vendor, product, version, pNewJoystick->joystickname));
#endif
#ifdef SDL_JOYSTICK_RAWINPUT
if (RAWINPUT_IsDevicePresent(vendor, product, 0, pNewJoystick->joystickname)) {
/* The RAWINPUT driver is taking care of this device */
SDL_free(pNewJoystick);
return DIENUM_CONTINUE;
}
CHECK(!RAWINPUT_IsDevicePresent(vendor, product, version, pNewJoystick->joystickname));
#endif
WINDOWS_AddJoystickDevice(pNewJoystick);
pNewJoystick = NULL;
err:
if (pNewJoystick) {
SDL_free(pNewJoystick->joystickname);
SDL_free(pNewJoystick);
}
SDL_free(hidPath);
SDL_free(name);
if (device) {
IDirectInputDevice8_Release(device);
}
return DIENUM_CONTINUE; /* get next device, please */
#undef CHECK
}
void
SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
{
IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, pContext, DIEDFL_ATTACHEDONLY);
if (SDL_RawDevList) {
SDL_free(SDL_RawDevList); /* in case we used this in DirectInput detection */
SDL_RawDevList = NULL;
}
SDL_RawDevListCount = 0;
}
typedef struct
SDL_bool
SDL_DINPUT_JoystickPresent(Uint16 vendor_id, Uint16 product_id, Uint16 version_number)
{
Uint16 vendor;
Uint16 product;
Uint16 version;
SDL_bool present;
} EnumJoystickPresentData;
static BOOL CALLBACK
EnumJoystickPresentCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
{
EnumJoystickPresentData *data = (EnumJoystickPresentData *)pContext;
JoyStick_DeviceData* joystick = SYS_Joystick;
Uint16 vendor = 0;
Uint16 product = 0;
Uint16 version = 0;
if (SDL_memcmp(&pdidInstance->guidProduct.Data4[2], "PIDVID", 6) == 0) {
vendor = (Uint16)LOWORD(pdidInstance->guidProduct.Data1);
product = (Uint16)HIWORD(pdidInstance->guidProduct.Data1);
if (data->vendor == vendor && data->product == product && data->version == version) {
data->present = SDL_TRUE;
return DIENUM_STOP;
while (joystick) {
SDL_GetJoystickGUIDInfo(joystick->guid, &vendor, &product, &version);
if (!joystick->bXInputDevice &&
vendor == vendor_id &&
product == product_id &&
version == version_number) {
return SDL_TRUE;
}
}
return DIENUM_CONTINUE;
}
SDL_bool
SDL_DINPUT_JoystickPresent(Uint16 vendor, Uint16 product, Uint16 version)
{
EnumJoystickPresentData data;
if (dinput == NULL) {
return SDL_FALSE;
joystick = joystick->pNext;
}
data.vendor = vendor;
data.product = product;
data.version = version;
data.present = SDL_FALSE;
IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoystickPresentCallback, &data, DIEDFL_ATTACHEDONLY);
return data.present;
return SDL_FALSE;
}
static BOOL CALLBACK
EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE pDeviceObject, LPVOID pContext)
{
SDL_Joystick *joystick = (SDL_Joystick *)pvRef;
SDL_Joystick *joystick = (SDL_Joystick *)pContext;
HRESULT result;
input_t *in = &joystick->hwdata->Inputs[joystick->hwdata->NumInputs];
if (dev->dwType & DIDFT_BUTTON) {
if (pDeviceObject->dwType & DIDFT_BUTTON) {
in->type = BUTTON;
in->num = joystick->nbuttons;
in->ofs = DIJOFS_BUTTON(in->num);
joystick->nbuttons++;
} else if (dev->dwType & DIDFT_POV) {
} else if (pDeviceObject->dwType & DIDFT_POV) {
in->type = HAT;
in->num = joystick->nhats;
in->ofs = DIJOFS_POV(in->num);
joystick->nhats++;
} else if (dev->dwType & DIDFT_AXIS) {
} else if (pDeviceObject->dwType & DIDFT_AXIS) {
DIPROPRANGE diprg;
DIPROPDWORD dilong;
in->type = AXIS;
in->num = joystick->naxes;
if (!SDL_memcmp(&dev->guidType, &GUID_XAxis, sizeof(dev->guidType)))
if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_XAxis, sizeof(pDeviceObject->guidType)))
in->ofs = DIJOFS_X;
else if (!SDL_memcmp(&dev->guidType, &GUID_YAxis, sizeof(dev->guidType)))
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_YAxis, sizeof(pDeviceObject->guidType)))
in->ofs = DIJOFS_Y;
else if (!SDL_memcmp(&dev->guidType, &GUID_ZAxis, sizeof(dev->guidType)))
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_ZAxis, sizeof(pDeviceObject->guidType)))
in->ofs = DIJOFS_Z;
else if (!SDL_memcmp(&dev->guidType, &GUID_RxAxis, sizeof(dev->guidType)))
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_RxAxis, sizeof(pDeviceObject->guidType)))
in->ofs = DIJOFS_RX;
else if (!SDL_memcmp(&dev->guidType, &GUID_RyAxis, sizeof(dev->guidType)))
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_RyAxis, sizeof(pDeviceObject->guidType)))
in->ofs = DIJOFS_RY;
else if (!SDL_memcmp(&dev->guidType, &GUID_RzAxis, sizeof(dev->guidType)))
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_RzAxis, sizeof(pDeviceObject->guidType)))
in->ofs = DIJOFS_RZ;
else if (!SDL_memcmp(&dev->guidType, &GUID_Slider, sizeof(dev->guidType))) {
else if (!SDL_memcmp(&pDeviceObject->guidType, &GUID_Slider, sizeof(pDeviceObject->guidType))) {
in->ofs = DIJOFS_SLIDER(joystick->hwdata->NumSliders);
++joystick->hwdata->NumSliders;
} else {
@@ -790,7 +605,7 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
diprg.diph.dwSize = sizeof(diprg);
diprg.diph.dwHeaderSize = sizeof(diprg.diph);
diprg.diph.dwObj = dev->dwType;
diprg.diph.dwObj = pDeviceObject->dwType;
diprg.diph.dwHow = DIPH_BYID;
diprg.lMin = SDL_JOYSTICK_AXIS_MIN;
diprg.lMax = SDL_JOYSTICK_AXIS_MAX;
@@ -805,7 +620,7 @@ EnumDevObjectsCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
/* Set dead zone to 0. */
dilong.diph.dwSize = sizeof(dilong);
dilong.diph.dwHeaderSize = sizeof(dilong.diph);
dilong.diph.dwObj = dev->dwType;
dilong.diph.dwObj = pDeviceObject->dwType;
dilong.diph.dwHow = DIPH_BYID;
dilong.dwData = 0;
result =
@@ -882,7 +697,6 @@ int
SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickdevice)
{
HRESULT result;
LPDIRECTINPUTDEVICE8 device;
DIPROPDWORD dipdw;
joystick->hwdata->buffered = SDL_TRUE;
@@ -894,23 +708,13 @@ SDL_DINPUT_JoystickOpen(SDL_Joystick * joystick, JoyStick_DeviceData *joystickde
result =
IDirectInput8_CreateDevice(dinput,
&(joystickdevice->dxdevice.guidInstance), &device, NULL);
&joystickdevice->dxdevice.guidInstance,
&joystick->hwdata->InputDevice,
NULL);
if (FAILED(result)) {
return SetDIerror("IDirectInput::CreateDevice", result);
}
/* Now get the IDirectInputDevice8 interface, instead. */
result = IDirectInputDevice8_QueryInterface(device,
&IID_IDirectInputDevice8,
(LPVOID *)& joystick->
hwdata->InputDevice);
/* We are done with this object. Use the stored one from now on. */
IDirectInputDevice8_Release(device);
if (FAILED(result)) {
return SetDIerror("IDirectInputDevice8::QueryInterface", result);
}
/* Acquire shared access. Exclusive access is required for forces,
* though. */
result =

View File

@@ -891,7 +891,7 @@ RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, co
/* The Xbox One controller shows up as a hardcoded raw input VID/PID */
if (name && SDL_strcmp(name, "Xbox One Game Controller") == 0 &&
device->vendor_id == USB_VENDOR_MICROSOFT &&
device->product_id == USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER) {
device->product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) {
return SDL_TRUE;
}

View File

@@ -429,11 +429,11 @@ WINDOWS_JoystickDetect(void)
if (pCurList->bXInputDevice) {
#if SDL_HAPTIC_XINPUT
SDL_XINPUT_MaybeRemoveDevice(pCurList->XInputUserId);
SDL_XINPUT_HapticMaybeRemoveDevice(pCurList->XInputUserId);
#endif
} else {
#if SDL_HAPTIC_DINPUT
SDL_DINPUT_MaybeRemoveDevice(&pCurList->dxdevice);
SDL_DINPUT_HapticMaybeRemoveDevice(&pCurList->dxdevice);
#endif
}
@@ -449,11 +449,11 @@ WINDOWS_JoystickDetect(void)
if (pCurList->send_add_event) {
if (pCurList->bXInputDevice) {
#if SDL_HAPTIC_XINPUT
SDL_XINPUT_MaybeAddDevice(pCurList->XInputUserId);
SDL_XINPUT_HapticMaybeAddDevice(pCurList->XInputUserId);
#endif
} else {
#if SDL_HAPTIC_DINPUT
SDL_DINPUT_MaybeAddDevice(&pCurList->dxdevice);
SDL_DINPUT_HapticMaybeAddDevice(&pCurList->dxdevice);
#endif
}

View File

@@ -37,7 +37,7 @@ typedef struct JoyStick_DeviceData
BYTE SubType;
Uint8 XInputUserId;
DIDEVICEINSTANCE dxdevice;
WCHAR hidPath[MAX_PATH];
char hidPath[MAX_PATH];
struct JoyStick_DeviceData *pNext;
} JoyStick_DeviceData;