1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-07-08 03:58:43 +00:00

Fix inconsistent event index

This commit is contained in:
cathery 2019-11-22 01:02:39 +03:00
parent 04bcc1dd97
commit 60776a8cce

View File

@ -11,6 +11,10 @@
#define APP_VERSION "0.5.1" #define APP_VERSION "0.5.1"
#define DS3EVENT_INDEX 0
#define DS4EVENT_INDEX 1
#define ALLEVENT_INDEX 2
static const bool useAbstractedPad = hosversionBetween(5, 7); static const bool useAbstractedPad = hosversionBetween(5, 7);
std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>> controllerInterfaces; std::vector<std::unique_ptr<SwitchVirtualGamepadHandler>> controllerInterfaces;
@ -53,7 +57,7 @@ Result CreateDualshck3AvailableEvent(Event &out)
filter.Flags = UsbHsInterfaceFilterFlags_idVendor | UsbHsInterfaceFilterFlags_idProduct; filter.Flags = UsbHsInterfaceFilterFlags_idVendor | UsbHsInterfaceFilterFlags_idProduct;
filter.idVendor = VENDOR_SONY; filter.idVendor = VENDOR_SONY;
filter.idProduct = PRODUCT_DUALSHOCK3; filter.idProduct = PRODUCT_DUALSHOCK3;
Result rc = usbHsCreateInterfaceAvailableEvent(&out, true, 0, &filter); Result rc = usbHsCreateInterfaceAvailableEvent(&out, true, DS3EVENT_INDEX, &filter);
if (R_FAILED(rc)) if (R_FAILED(rc))
WriteToLog("Failed to open event for Dualshock 3"); WriteToLog("Failed to open event for Dualshock 3");
else else
@ -67,7 +71,7 @@ Result CreateDualshock4AvailableEvent(Event &out)
filter.Flags = UsbHsInterfaceFilterFlags_idVendor | UsbHsInterfaceFilterFlags_idProduct; filter.Flags = UsbHsInterfaceFilterFlags_idVendor | UsbHsInterfaceFilterFlags_idProduct;
filter.idVendor = VENDOR_SONY; filter.idVendor = VENDOR_SONY;
filter.idProduct = _globalConfig.dualshock4_productID; filter.idProduct = _globalConfig.dualshock4_productID;
Result rc = usbHsCreateInterfaceAvailableEvent(&out, true, 1, &filter); Result rc = usbHsCreateInterfaceAvailableEvent(&out, true, DS4EVENT_INDEX, &filter);
if (R_FAILED(rc)) if (R_FAILED(rc))
WriteToLog("Failed to open event for Dualshock 4 0x", std::hex, _globalConfig.dualshock4_productID); WriteToLog("Failed to open event for Dualshock 4 0x", std::hex, _globalConfig.dualshock4_productID);
else else
@ -80,7 +84,7 @@ Result CreateAllAvailableEvent(Event &out)
UsbHsInterfaceFilter filter; UsbHsInterfaceFilter filter;
filter.Flags = UsbHsInterfaceFilterFlags_bcdDevice_Min; filter.Flags = UsbHsInterfaceFilterFlags_bcdDevice_Min;
filter.bcdDevice_Min = 0; filter.bcdDevice_Min = 0;
Result rc = usbHsCreateInterfaceAvailableEvent(&out, true, 2, &filter); Result rc = usbHsCreateInterfaceAvailableEvent(&out, true, ALLEVENT_INDEX, &filter);
if (R_FAILED(rc)) if (R_FAILED(rc))
WriteToLog("Failed to open catch-all event"); WriteToLog("Failed to open catch-all event");
else else
@ -290,7 +294,7 @@ Result mainLoop()
{ {
WriteToLog("File check succeeded! Loading configs..."); WriteToLog("File check succeeded! Loading configs...");
LoadAllConfigs(); LoadAllConfigs();
usbHsDestroyInterfaceAvailableEvent(&ds4Event, 2); usbHsDestroyInterfaceAvailableEvent(&ds4Event, DS4EVENT_INDEX);
CreateDualshock4AvailableEvent(ds4Event); CreateDualshock4AvailableEvent(ds4Event);
} }
} }
@ -304,9 +308,9 @@ Result mainLoop()
//After we break out of the loop, close all events and exit //After we break out of the loop, close all events and exit
WriteToLog("Destroying events"); WriteToLog("Destroying events");
usbHsDestroyInterfaceAvailableEvent(&ds3Event, 0); usbHsDestroyInterfaceAvailableEvent(&ds3Event, DS3EVENT_INDEX);
usbHsDestroyInterfaceAvailableEvent(&catchAllEvent, 1); usbHsDestroyInterfaceAvailableEvent(&ds4Event, DS4EVENT_INDEX);
usbHsDestroyInterfaceAvailableEvent(&ds4Event, 2); usbHsDestroyInterfaceAvailableEvent(&catchAllEvent, ALLEVENT_INDEX);
controllerInterfaces.clear(); controllerInterfaces.clear();
return rc; return rc;