SDL_ShouldIgnoreGamepad() should take product IDs rather than a guid.
This lets us early out when scanning for new hardware more quickly.
This commit is contained in:
parent
8a30def5f2
commit
c41b2bb855
13 changed files with 42 additions and 65 deletions
|
@ -2595,12 +2595,8 @@ bool SDL_IsGamepad(SDL_JoystickID instance_id)
|
||||||
/*
|
/*
|
||||||
* Return 1 if the gamepad should be ignored by SDL
|
* Return 1 if the gamepad should be ignored by SDL
|
||||||
*/
|
*/
|
||||||
bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid)
|
bool SDL_ShouldIgnoreGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||||
{
|
{
|
||||||
Uint16 vendor;
|
|
||||||
Uint16 product;
|
|
||||||
Uint16 version;
|
|
||||||
|
|
||||||
#ifdef SDL_PLATFORM_LINUX
|
#ifdef SDL_PLATFORM_LINUX
|
||||||
if (SDL_endswith(name, " Motion Sensors")) {
|
if (SDL_endswith(name, " Motion Sensors")) {
|
||||||
// Don't treat the PS3 and PS4 motion controls as a separate gamepad
|
// Don't treat the PS3 and PS4 motion controls as a separate gamepad
|
||||||
|
@ -2624,19 +2620,17 @@ bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL);
|
if (SDL_IsJoystickSteamVirtualGamepad(vendor_id, product_id, version)) {
|
||||||
|
|
||||||
if (SDL_IsJoystickSteamVirtualGamepad(vendor, product, version)) {
|
|
||||||
return !SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", false);
|
return !SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_allowed_gamepads.num_included_entries > 0) {
|
if (SDL_allowed_gamepads.num_included_entries > 0) {
|
||||||
if (SDL_VIDPIDInList(vendor, product, &SDL_allowed_gamepads)) {
|
if (SDL_VIDPIDInList(vendor_id, product_id, &SDL_allowed_gamepads)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (SDL_VIDPIDInList(vendor, product, &SDL_ignored_gamepads)) {
|
if (SDL_VIDPIDInList(vendor_id, product_id, &SDL_ignored_gamepads)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -39,7 +39,7 @@ extern void SDL_PrivateGamepadRemoved(SDL_JoystickID instance_id);
|
||||||
extern bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid);
|
extern bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid);
|
||||||
|
|
||||||
// Function to return whether a gamepad should be ignored
|
// Function to return whether a gamepad should be ignored
|
||||||
extern bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid);
|
extern bool SDL_ShouldIgnoreGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name);
|
||||||
|
|
||||||
// Handle delayed guide button on a gamepad
|
// Handle delayed guide button on a gamepad
|
||||||
extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick);
|
extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick);
|
||||||
|
|
|
@ -3236,24 +3236,19 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_GUID guid)
|
||||||
return SDL_JOYSTICK_TYPE_UNKNOWN;
|
return SDL_JOYSTICK_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid)
|
bool SDL_ShouldIgnoreJoystick(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||||
{
|
{
|
||||||
Uint16 vendor;
|
|
||||||
Uint16 product;
|
|
||||||
|
|
||||||
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL);
|
|
||||||
|
|
||||||
// Check the joystick blacklist
|
// Check the joystick blacklist
|
||||||
if (SDL_VIDPIDInList(vendor, product, &blacklist_devices)) {
|
if (SDL_VIDPIDInList(vendor_id, product_id, &blacklist_devices)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_ROG_CHAKRAM, false)) {
|
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_ROG_CHAKRAM, false)) {
|
||||||
if (SDL_VIDPIDInList(vendor, product, &rog_gamepad_mice)) {
|
if (SDL_VIDPIDInList(vendor_id, product_id, &rog_gamepad_mice)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreGamepad(name, guid)) {
|
if (SDL_ShouldIgnoreGamepad(vendor_id, product_id, version, name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ extern bool SDL_IsJoystickRAWINPUT(SDL_GUID guid);
|
||||||
extern bool SDL_IsJoystickVIRTUAL(SDL_GUID guid);
|
extern bool SDL_IsJoystickVIRTUAL(SDL_GUID guid);
|
||||||
|
|
||||||
// Function to return whether a joystick should be ignored
|
// Function to return whether a joystick should be ignored
|
||||||
extern bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid);
|
extern bool SDL_ShouldIgnoreJoystick(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name);
|
||||||
|
|
||||||
// Internal event queueing functions
|
// Internal event queueing functions
|
||||||
extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers);
|
extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers);
|
||||||
|
|
|
@ -498,6 +498,10 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SDL_ShouldIgnoreJoystick(vendor, product, 0, name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
#ifdef ENABLE_PHYSICAL_INPUT_PROFILE
|
||||||
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
|
||||||
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
NSDictionary<NSString *, GCControllerElement *> *elements = controller.physicalInputProfile.elements;
|
||||||
|
@ -666,10 +670,6 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||||
}
|
}
|
||||||
device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, signature, NULL, name, 'm', subtype);
|
device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, signature, NULL, name, 'm', subtype);
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(name, device->guid)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This will be set when the first button press of the controller is
|
/* This will be set when the first button press of the controller is
|
||||||
* detected. */
|
* detected. */
|
||||||
controller.playerIndex = -1;
|
controller.playerIndex = -1;
|
||||||
|
|
|
@ -426,7 +426,7 @@ static bool MaybeAddDevice(const char *path)
|
||||||
name = SDL_CreateJoystickName(di.udi_vendorNo, di.udi_productNo, di.udi_vendor, di.udi_product);
|
name = SDL_CreateJoystickName(di.udi_vendorNo, di.udi_productNo, di.udi_vendor, di.udi_product);
|
||||||
guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, di.udi_vendor, di.udi_product, 0, 0);
|
guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, di.udi_vendor, di.udi_product, 0, 0);
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(name, guid) ||
|
if (SDL_ShouldIgnoreJoystick(di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, name) ||
|
||||||
SDL_JoystickHandledByAnotherDriver(&SDL_BSD_JoystickDriver, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, name)) {
|
SDL_JoystickHandledByAnotherDriver(&SDL_BSD_JoystickDriver, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, name)) {
|
||||||
SDL_free(name);
|
SDL_free(name);
|
||||||
FreeHwData(hw);
|
FreeHwData(hw);
|
||||||
|
|
|
@ -495,6 +495,10 @@ static bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
|
||||||
SDL_free(name);
|
SDL_free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SDL_ShouldIgnoreJoystick(vendor, product, version, pDevice->product)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_JoystickHandledByAnotherDriver(&SDL_DARWIN_JoystickDriver, vendor, product, version, pDevice->product)) {
|
if (SDL_JoystickHandledByAnotherDriver(&SDL_DARWIN_JoystickDriver, vendor, product, version, pDevice->product)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -553,11 +557,6 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender
|
||||||
return; // not a device we care about, probably.
|
return; // not a device we care about, probably.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(device->product, device->guid)) {
|
|
||||||
FreeDevice(device);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get notified when this device is disconnected.
|
// Get notified when this device is disconnected.
|
||||||
IOHIDDeviceRegisterRemovalCallback(ioHIDDeviceObject, JoystickDeviceWasRemovedCallback, device);
|
IOHIDDeviceRegisterRemovalCallback(ioHIDDeviceObject, JoystickDeviceWasRemovedCallback, device);
|
||||||
IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE);
|
IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE);
|
||||||
|
|
|
@ -328,7 +328,7 @@ static SDL_HIDAPI_DeviceDriver *HIDAPI_GetDeviceDriver(SDL_HIDAPI_Device *device
|
||||||
return &SDL_HIDAPI_DriverCombined;
|
return &SDL_HIDAPI_DriverCombined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(device->name, device->guid)) {
|
if (SDL_ShouldIgnoreJoystick(device->vendor_id, device->product_id, device->version, device->name)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,15 +329,14 @@ static bool IsJoystick(const char *path, int *fd, char **name_return, Uint16 *ve
|
||||||
SDL_Log("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", name, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
|
SDL_Log("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", name, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*guid = SDL_CreateJoystickGUID(inpid.bustype, inpid.vendor, inpid.product, inpid.version, NULL, product_string, 0, 0);
|
if (SDL_ShouldIgnoreJoystick(inpid.vendor, inpid.product, inpid.version, name)) {
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(name, *guid)) {
|
|
||||||
SDL_free(name);
|
SDL_free(name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*name_return = name;
|
*name_return = name;
|
||||||
*vendor_return = inpid.vendor;
|
*vendor_return = inpid.vendor;
|
||||||
*product_return = inpid.product;
|
*product_return = inpid.product;
|
||||||
|
*guid = SDL_CreateJoystickGUID(inpid.bustype, inpid.vendor, inpid.product, inpid.version, NULL, product_string, 0, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -472,6 +472,8 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
|
||||||
CHECK(QueryDeviceInfo(device, &vendor, &product));
|
CHECK(QueryDeviceInfo(device, &vendor, &product));
|
||||||
|
|
||||||
CHECK(!SDL_IsXInputDevice(vendor, product, hidPath));
|
CHECK(!SDL_IsXInputDevice(vendor, product, hidPath));
|
||||||
|
CHECK(!SDL_ShouldIgnoreJoystick(vendor, product, version, name));
|
||||||
|
CHECK(!SDL_JoystickHandledByAnotherDriver(&SDL_WINDOWS_JoystickDriver, vendor, product, version, name));
|
||||||
|
|
||||||
pNewJoystick = *(JoyStick_DeviceData **)pContext;
|
pNewJoystick = *(JoyStick_DeviceData **)pContext;
|
||||||
while (pNewJoystick) {
|
while (pNewJoystick) {
|
||||||
|
@ -514,10 +516,6 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta
|
||||||
pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, version, NULL, name, 0, 0);
|
pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, version, NULL, name, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(!SDL_ShouldIgnoreJoystick(pNewJoystick->joystickname, pNewJoystick->guid));
|
|
||||||
|
|
||||||
CHECK(!SDL_JoystickHandledByAnotherDriver(&SDL_WINDOWS_JoystickDriver, vendor, product, version, pNewJoystick->joystickname));
|
|
||||||
|
|
||||||
WINDOWS_AddJoystickDevice(pNewJoystick);
|
WINDOWS_AddJoystickDevice(pNewJoystick);
|
||||||
pNewJoystick = NULL;
|
pNewJoystick = NULL;
|
||||||
|
|
||||||
|
|
|
@ -881,7 +881,9 @@ static void RAWINPUT_AddDevice(HANDLE hDevice)
|
||||||
CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_DEVICENAME, dev_name, &size) != (UINT)-1);
|
CHECK(GetRawInputDeviceInfoA(hDevice, RIDI_DEVICENAME, dev_name, &size) != (UINT)-1);
|
||||||
// Only take XInput-capable devices
|
// Only take XInput-capable devices
|
||||||
CHECK(SDL_strstr(dev_name, "IG_") != NULL);
|
CHECK(SDL_strstr(dev_name, "IG_") != NULL);
|
||||||
|
CHECK(!SDL_ShouldIgnoreJoystick((Uint16)rdi.hid.dwVendorId, (Uint16)rdi.hid.dwProductId, (Uint16)rdi.hid.dwVersionNumber, ""));
|
||||||
CHECK(!SDL_JoystickHandledByAnotherDriver(&SDL_RAWINPUT_JoystickDriver, (Uint16)rdi.hid.dwVendorId, (Uint16)rdi.hid.dwProductId, (Uint16)rdi.hid.dwVersionNumber, ""));
|
CHECK(!SDL_JoystickHandledByAnotherDriver(&SDL_RAWINPUT_JoystickDriver, (Uint16)rdi.hid.dwVendorId, (Uint16)rdi.hid.dwProductId, (Uint16)rdi.hid.dwVersionNumber, ""));
|
||||||
|
|
||||||
device = (SDL_RAWINPUT_Device *)SDL_calloc(1, sizeof(SDL_RAWINPUT_Device));
|
device = (SDL_RAWINPUT_Device *)SDL_calloc(1, sizeof(SDL_RAWINPUT_Device));
|
||||||
CHECK(device);
|
CHECK(device);
|
||||||
device->hDevice = hDevice;
|
device->hDevice = hDevice;
|
||||||
|
|
|
@ -399,7 +399,6 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
|
||||||
hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(e, &IID___x_ABI_CWindows_CGaming_CInput_CIRawGameController, (void **)&controller);
|
hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(e, &IID___x_ABI_CWindows_CGaming_CInput_CIRawGameController, (void **)&controller);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
SDL_GUID guid = { 0 };
|
|
||||||
Uint16 bus = SDL_HARDWARE_BUS_USB;
|
Uint16 bus = SDL_HARDWARE_BUS_USB;
|
||||||
Uint16 vendor = 0;
|
Uint16 vendor = 0;
|
||||||
Uint16 product = 0;
|
Uint16 product = 0;
|
||||||
|
@ -446,6 +445,10 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
|
||||||
name = SDL_strdup("");
|
name = SDL_strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ignore_joystick && SDL_ShouldIgnoreJoystick(vendor, product, version, name)) {
|
||||||
|
ignore_joystick = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ignore_joystick && SDL_JoystickHandledByAnotherDriver(&SDL_WGI_JoystickDriver, vendor, product, version, name)) {
|
if (!ignore_joystick && SDL_JoystickHandledByAnotherDriver(&SDL_WGI_JoystickDriver, vendor, product, version, name)) {
|
||||||
ignore_joystick = true;
|
ignore_joystick = true;
|
||||||
}
|
}
|
||||||
|
@ -455,18 +458,6 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
|
||||||
ignore_joystick = true;
|
ignore_joystick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignore_joystick) {
|
|
||||||
if (game_controller) {
|
|
||||||
type = GetGameControllerType(game_controller);
|
|
||||||
}
|
|
||||||
|
|
||||||
guid = SDL_CreateJoystickGUID(bus, vendor, product, version, NULL, name, 'w', (Uint8)type);
|
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(name, guid)) {
|
|
||||||
ignore_joystick = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ignore_joystick) {
|
if (!ignore_joystick) {
|
||||||
// New device, add it
|
// New device, add it
|
||||||
WindowsGamingInputControllerState *controllers = SDL_realloc(wgi.controllers, sizeof(wgi.controllers[0]) * (wgi.controller_count + 1));
|
WindowsGamingInputControllerState *controllers = SDL_realloc(wgi.controllers, sizeof(wgi.controllers[0]) * (wgi.controller_count + 1));
|
||||||
|
@ -474,11 +465,15 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
|
||||||
WindowsGamingInputControllerState *state = &controllers[wgi.controller_count];
|
WindowsGamingInputControllerState *state = &controllers[wgi.controller_count];
|
||||||
SDL_JoystickID joystickID = SDL_GetNextObjectID();
|
SDL_JoystickID joystickID = SDL_GetNextObjectID();
|
||||||
|
|
||||||
|
if (game_controller) {
|
||||||
|
type = GetGameControllerType(game_controller);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_zerop(state);
|
SDL_zerop(state);
|
||||||
state->instance_id = joystickID;
|
state->instance_id = joystickID;
|
||||||
state->controller = controller;
|
state->controller = controller;
|
||||||
state->name = name;
|
state->name = name;
|
||||||
state->guid = guid;
|
state->guid = SDL_CreateJoystickGUID(bus, vendor, product, version, NULL, name, 'w', (Uint8)type);
|
||||||
state->type = type;
|
state->type = type;
|
||||||
state->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(controller, vendor, product);
|
state->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(controller, vendor, product);
|
||||||
|
|
||||||
|
|
|
@ -185,13 +185,18 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC
|
||||||
pNewJoystick = pNewJoystick->pNext;
|
pNewJoystick = pNewJoystick->pNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name = GetXInputName(userid, SubType);
|
||||||
|
GetXInputDeviceInfo(userid, &vendor, &product, &version);
|
||||||
|
if (SDL_ShouldIgnoreJoystick(vendor, product, version, name) ||
|
||||||
|
SDL_JoystickHandledByAnotherDriver(&SDL_WINDOWS_JoystickDriver, vendor, product, version, name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pNewJoystick = (JoyStick_DeviceData *)SDL_calloc(1, sizeof(JoyStick_DeviceData));
|
pNewJoystick = (JoyStick_DeviceData *)SDL_calloc(1, sizeof(JoyStick_DeviceData));
|
||||||
if (!pNewJoystick) {
|
if (!pNewJoystick) {
|
||||||
return; // better luck next time?
|
return; // better luck next time?
|
||||||
}
|
}
|
||||||
|
|
||||||
name = GetXInputName(userid, SubType);
|
|
||||||
GetXInputDeviceInfo(userid, &vendor, &product, &version);
|
|
||||||
pNewJoystick->bXInputDevice = true;
|
pNewJoystick->bXInputDevice = true;
|
||||||
pNewJoystick->joystickname = SDL_CreateJoystickName(vendor, product, NULL, name);
|
pNewJoystick->joystickname = SDL_CreateJoystickName(vendor, product, NULL, name);
|
||||||
if (!pNewJoystick->joystickname) {
|
if (!pNewJoystick->joystickname) {
|
||||||
|
@ -203,16 +208,6 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC
|
||||||
pNewJoystick->SubType = SubType;
|
pNewJoystick->SubType = SubType;
|
||||||
pNewJoystick->XInputUserId = userid;
|
pNewJoystick->XInputUserId = userid;
|
||||||
|
|
||||||
if (SDL_ShouldIgnoreJoystick(pNewJoystick->joystickname, pNewJoystick->guid)) {
|
|
||||||
SDL_free(pNewJoystick);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_JoystickHandledByAnotherDriver(&SDL_WINDOWS_JoystickDriver, vendor, product, version, pNewJoystick->joystickname)) {
|
|
||||||
SDL_free(pNewJoystick);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WINDOWS_AddJoystickDevice(pNewJoystick);
|
WINDOWS_AddJoystickDevice(pNewJoystick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue