mirror of
https://github.com/cathery/sys-con.git
synced 2025-01-01 03:14:48 +00:00
Add a loop exit variable for usb threads
This commit is contained in:
parent
efaa2a6791
commit
6daa334da5
@ -21,10 +21,11 @@ namespace syscon::usb
|
||||
void UsbEventThreadFunc(void *arg);
|
||||
void UsbInterfaceChangeThreadFunc(void *arg);
|
||||
|
||||
ams::os::StaticThread<0x2'000> g_usb_event_thread(&UsbEventThreadFunc, nullptr, 0x3F);
|
||||
ams::os::StaticThread<0x1'000> g_usb_interface_change_thread(&UsbInterfaceChangeThreadFunc, nullptr, 0x3F);
|
||||
ams::os::StaticThread<0x2'000> g_usb_event_thread(&UsbEventThreadFunc, nullptr, 0x20);
|
||||
ams::os::StaticThread<0x2'000> g_usb_interface_change_thread(&UsbInterfaceChangeThreadFunc, nullptr, 0x20);
|
||||
|
||||
//TODO: Implement UsbInterfaceChangeThreadFunc
|
||||
bool usb_event_thread_isRunning = false;
|
||||
bool usb_interface_change_thread_isRunning = false;
|
||||
|
||||
Event g_usbCatchAllEvent;
|
||||
Event g_usbDualshock3Event;
|
||||
@ -37,7 +38,9 @@ namespace syscon::usb
|
||||
void UsbEventThreadFunc(void *arg)
|
||||
{
|
||||
WriteToLog("Starting USB Event Thread!");
|
||||
while (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, UINT64_MAX)))
|
||||
while (usb_event_thread_isRunning)
|
||||
{
|
||||
if (R_SUCCEEDED(eventWait(&g_usbCatchAllEvent, U64_MAX)))
|
||||
{
|
||||
WriteToLog("Event got caught!");
|
||||
if (handler::IsAtControllerLimit())
|
||||
@ -64,11 +67,14 @@ namespace syscon::usb
|
||||
handler::Insert(std::make_unique<Dualshock4Controller>(std::make_unique<SwitchUSBDevice>(interfaces, total_entries)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UsbInterfaceChangeThreadFunc(void *arg)
|
||||
{
|
||||
WriteToLog("Starting USB Interface Change Thread!");
|
||||
while (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX)))
|
||||
while (usb_interface_change_thread_isRunning)
|
||||
{
|
||||
if (R_SUCCEEDED(eventWait(usbHsGetInterfaceStateChangeEvent(), UINT64_MAX)))
|
||||
{
|
||||
s32 total_entries;
|
||||
//WriteToLog("Interface state was changed");
|
||||
@ -103,6 +109,7 @@ namespace syscon::usb
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s32 QueryInterfaces(u8 iclass, u8 isubclass, u8 iprotocol)
|
||||
{
|
||||
@ -176,8 +183,11 @@ namespace syscon::usb
|
||||
R_TRY(CreateDualshock3AvailableEvent());
|
||||
R_TRY(CreateDualshock4AvailableEvent());
|
||||
|
||||
usb_event_thread_isRunning = true;
|
||||
R_TRY(g_usb_event_thread.Start().GetValue());
|
||||
//R_TRY(g_usb_interface_change_thread.Start().GetValue());
|
||||
|
||||
usb_interface_change_thread_isRunning = true;
|
||||
R_TRY(g_usb_interface_change_thread.Start().GetValue());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -188,6 +198,9 @@ namespace syscon::usb
|
||||
usbHsDestroyInterfaceAvailableEvent(&g_usbDualshock3Event, Dualshock3EventIndex);
|
||||
usbHsDestroyInterfaceAvailableEvent(&g_usbDualshock4Event, Dualshock4EventIndex);
|
||||
|
||||
usb_event_thread_isRunning = false;
|
||||
usb_interface_change_thread_isRunning = false;
|
||||
|
||||
//TODO: test this without the cancel
|
||||
g_usb_event_thread.CancelSynchronization();
|
||||
g_usb_interface_change_thread.CancelSynchronization();
|
||||
|
Loading…
Reference in New Issue
Block a user