MCPcopy Create free account
hub / github.com/cathery/sys-con / UsbEventThreadFunc

Function UsbEventThreadFunc

source/Sysmodule/source/usb_module.cpp:48–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 s32 QueryVendorProduct(uint16_t vendor_id, uint16_t product_id);
47
48 void UsbEventThreadFunc(void* arg)
49 {
50 do
51 {
52 if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX)))
53 {
54 WriteToLog("Catch-all event went off");
55
56 SwitchUtils::ScopedLock usbLock(usbMutex);
57 if (!controllers::IsAtControllerLimit())
58 {
59 s32 total_entries;
60 if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 1)) != 0)
61 WriteToLog("Initializing Xbox 360 controller: 0x%x", controllers::Insert(std::make_unique<Xbox360Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
62
63 if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 93, 129)) != 0)
64 for (int i = 0; i != total_entries; ++i)
65 WriteToLog("Initializing Xbox 360 wireless controller: 0x%x", controllers::Insert(std::make_unique<Xbox360WirelessController>(std::make_unique<SwitchUSBDevice>(interfaces + i, 1))));
66
67 if ((total_entries = QueryInterfaces(0x58, 0x42, 0x00)) != 0)
68 WriteToLog("Initializing Xbox Original controller: 0x%x", controllers::Insert(std::make_unique<XboxController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
69
70 if ((total_entries = QueryInterfaces(USB_CLASS_VENDOR_SPEC, 71, 208)) != 0)
71 WriteToLog("Initializing Xbox One controller: 0x%x", controllers::Insert(std::make_unique<XboxOneController>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries))));
72 }
73 }
74 } while (is_usb_event_thread_running);
75 }
76
77 void UsbSonyEventThreadFunc(void* arg)
78 {

Callers

nothing calls this directly

Calls 4

WriteToLogFunction · 0.85
IsAtControllerLimitFunction · 0.85
QueryInterfacesFunction · 0.85
InsertFunction · 0.85

Tested by

no test coverage detected