diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 8be3387..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "libnx"] - path = libnx - url = https://github.com/cathery/libnx diff --git a/ControllerUSB/include/ControllerConfig.h b/ControllerUSB/include/ControllerConfig.h index 914c9d0..ef87d57 100644 --- a/ControllerUSB/include/ControllerConfig.h +++ b/ControllerUSB/include/ControllerConfig.h @@ -7,8 +7,6 @@ enum ControllerButton FACE_RIGHT, FACE_DOWN, FACE_LEFT, - LSTICK, - RSTICK, LSTICK_CLICK, RSTICK_CLICK, LEFT_BUMPER, @@ -23,14 +21,23 @@ enum ControllerButton DPAD_LEFT, SYNC, GUIDE, + NUM_CONTROLLERBUTTONS, +}; + +struct NormalizedStick +{ + float axis_x; + float axis_y; }; struct ControllerConfig { - uint16_t leftStickDeadzone; - uint16_t rightStickDeadzone; - uint16_t leftStickRotation; - uint16_t rightStickRotation; - uint16_t triggerDeadzone; - ControllerButton buttons[20]; + uint8_t leftStickDeadzonePercent; + uint8_t rightStickDeadzonePercent; + uint16_t leftStickRotationDegrees; + uint16_t rightStickRotationDegrees; + uint8_t triggerDeadzonePercent; + ControllerButton buttons[NUM_CONTROLLERBUTTONS]; + float triggers[2]; + NormalizedStick sticks[2]; }; \ No newline at end of file diff --git a/ControllerUSB/include/ControllerTypes.h b/ControllerUSB/include/ControllerTypes.h index db2442d..a0f9d4f 100644 --- a/ControllerUSB/include/ControllerTypes.h +++ b/ControllerUSB/include/ControllerTypes.h @@ -18,6 +18,15 @@ enum VendorIDs enum ProductIDs { PRODUCT_XBOX360 = 0x28e, + /* + PRODUCT_XBOX360_WIRELESS = 0x28F, + PRODUCT_XBOX360_WIRELESS_MODULE = 0x765, + PRODUCT_XBOX360_WIRELESS_ADAPTER = 0x719, + PRODUCT_XBOX360_WIRELESS_N_ADAPTER = 0x2A8, + PRODUCT_XBOX360_WIRELESS_NETWORK_ADAPTER = 0x292, + PRODUCT_XBOX360_WIRELESS_RECEIVER = 0x2A1, + PRODUCT_XBOX360_WIRELESS_RECEIVER_2 = 0x291, + */ PRODUCT_XBOXONE2013 = 0x2d1, PRODUCT_XBOXONE2015 = 0x2dd, PRODUCT_XBOXONEELITE = 0x2e3, diff --git a/ControllerUSB/include/Controllers/Dualshock3Controller.h b/ControllerUSB/include/Controllers/Dualshock3Controller.h index 8818929..1763ffa 100644 --- a/ControllerUSB/include/Controllers/Dualshock3Controller.h +++ b/ControllerUSB/include/Controllers/Dualshock3Controller.h @@ -154,7 +154,7 @@ public: inline const Dualshock3ButtonData &GetButtonData() { return m_buttonData; }; float NormalizeTrigger(uint8_t value); - void NormalizeAxis(uint8_t x, uint8_t y, uint8_t deadzone, float *x_out, float *y_out); + void NormalizeAxis(uint8_t x, uint8_t y, uint8_t deadzonePercent, float *x_out, float *y_out); Status SendInitBytes(); Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude); diff --git a/ControllerUSB/include/Controllers/Dualshock4Controller.h b/ControllerUSB/include/Controllers/Dualshock4Controller.h index 05479f4..a11d98f 100644 --- a/ControllerUSB/include/Controllers/Dualshock4Controller.h +++ b/ControllerUSB/include/Controllers/Dualshock4Controller.h @@ -77,7 +77,7 @@ public: inline const Dualshock4ButtonData &GetButtonData() { return m_buttonData; }; float NormalizeTrigger(uint16_t value); - void NormalizeAxis(int16_t x, int16_t y, int16_t deadzone, float *x_out, float *y_out); + void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out); Status SendInitBytes(); Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude); diff --git a/ControllerUSB/include/Controllers/Xbox360Controller.h b/ControllerUSB/include/Controllers/Xbox360Controller.h index f60ccc3..d203a63 100644 --- a/ControllerUSB/include/Controllers/Xbox360Controller.h +++ b/ControllerUSB/include/Controllers/Xbox360Controller.h @@ -113,8 +113,8 @@ public: inline const Xbox360ButtonData &GetButtonData() { return m_buttonData; }; - float NormalizeTrigger(uint16_t value); - void NormalizeAxis(int16_t x, int16_t y, int16_t deadzone, float *x_out, float *y_out); + float NormalizeTrigger(uint8_t value); + void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out); Status SendInitBytes(); Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude); diff --git a/ControllerUSB/include/Controllers/XboxOneController.h b/ControllerUSB/include/Controllers/XboxOneController.h index ca7a939..1f52a19 100644 --- a/ControllerUSB/include/Controllers/XboxOneController.h +++ b/ControllerUSB/include/Controllers/XboxOneController.h @@ -110,7 +110,7 @@ public: inline const XboxOneButtonData &GetButtonData() { return m_buttonData; }; float NormalizeTrigger(uint16_t value); - void NormalizeAxis(int16_t x, int16_t y, int16_t deadzone, float *x_out, float *y_out); + void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out); Status SendInitBytes(); Status WriteAckGuideReport(uint8_t sequence); diff --git a/ControllerUSB/include/IController.h b/ControllerUSB/include/IController.h index 34f3c3e..7ae37d6 100644 --- a/ControllerUSB/include/IController.h +++ b/ControllerUSB/include/IController.h @@ -6,46 +6,9 @@ struct NormalizedButtonData { - //ABXY; BAYX; square triangle cross circle; etc. - bool bottom_action; - bool right_action; - bool left_action; - bool top_action; - - //dpad directions - bool dpad_up; - bool dpad_down; - bool dpad_left; - bool dpad_right; - - // back start; select start; view and menu; share and options; etc. - bool back; - bool start; - - //bumpers - bool left_bumper; - bool right_bumper; - - //stick buttons - bool left_stick_click; - bool right_stick_click; - - //reserved for switch's capture and home buttons - bool capture; - bool home; - - //reserved for xbox's large led button or dualshock's PS button - bool guide; - - //trigger values from 0.0f to 1.0f - float left_trigger; - float right_trigger; - - //stick position values from -1.0f to 1.0f - float left_stick_x; - float left_stick_y; - float right_stick_x; - float right_stick_y; + bool buttons[NUM_CONTROLLERBUTTONS]; + float triggers[2]; + NormalizedStick sticks[2]; }; class IController diff --git a/ControllerUSB/source/ControllerHelpers.cpp b/ControllerUSB/source/ControllerHelpers.cpp index a979438..b833626 100644 --- a/ControllerUSB/source/ControllerHelpers.cpp +++ b/ControllerUSB/source/ControllerHelpers.cpp @@ -10,12 +10,23 @@ std::vector GetVendorProducts(uint16_t vendor_id) switch (vendor_id) { case VENDOR_MICROSOFT: - return {PRODUCT_XBOX360, - PRODUCT_XBOXONE2013, - PRODUCT_XBOXONE2015, - PRODUCT_XBOXONEELITE, - PRODUCT_XBOXONES, - PRODUCT_XBOXADAPTIVE}; + return { + PRODUCT_XBOX360, + PRODUCT_XBOXONE2013, + PRODUCT_XBOXONE2015, + PRODUCT_XBOXONEELITE, + PRODUCT_XBOXONES, + PRODUCT_XBOXADAPTIVE, + /* + PRODUCT_XBOX360_WIRELESS, + PRODUCT_XBOX360_WIRELESS_MODULE, + PRODUCT_XBOX360_WIRELESS_ADAPTER, + PRODUCT_XBOX360_WIRELESS_N_ADAPTER, + PRODUCT_XBOX360_WIRELESS_NETWORK_ADAPTER, + PRODUCT_XBOX360_WIRELESS_RECEIVER, + PRODUCT_XBOX360_WIRELESS_RECEIVER_2 + */ + }; case VENDOR_SONY: return {PRODUCT_DUALSHOCK3, PRODUCT_DUALSHOCK4}; @@ -51,6 +62,15 @@ ControllerType GetControllerTypeFromIds(uint16_t vendor_id, uint16_t product_id) switch (product_id) { case PRODUCT_XBOX360: + /* + case PRODUCT_XBOX360_WIRELESS: + case PRODUCT_XBOX360_WIRELESS_MODULE: + case PRODUCT_XBOX360_WIRELESS_ADAPTER: + case PRODUCT_XBOX360_WIRELESS_N_ADAPTER: + case PRODUCT_XBOX360_WIRELESS_NETWORK_ADAPTER: + case PRODUCT_XBOX360_WIRELESS_RECEIVER: + case PRODUCT_XBOX360_WIRELESS_RECEIVER_2: + */ return CONTROLLER_XBOX360; case PRODUCT_XBOXONE2013: case PRODUCT_XBOXONE2015: diff --git a/ControllerUSB/source/Controllers/Dualshock3Controller.cpp b/ControllerUSB/source/Controllers/Dualshock3Controller.cpp index c1d68b4..4626bea 100644 --- a/ControllerUSB/source/Controllers/Dualshock3Controller.cpp +++ b/ControllerUSB/source/Controllers/Dualshock3Controller.cpp @@ -95,7 +95,7 @@ Status Dualshock3Controller::OpenInterfaces() } void Dualshock3Controller::CloseInterfaces() { - m_device->Reset(); + //m_device->Reset(); m_device->Close(); } @@ -117,16 +117,16 @@ Status Dualshock3Controller::GetInput() float Dualshock3Controller::NormalizeTrigger(uint8_t value) { + uint8_t deadzone = (UINT8_MAX * _dualshock3ControllerConfig.triggerDeadzonePercent) / 100; //If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone - return value < _dualshock3ControllerConfig.triggerDeadzone + return value < deadzone ? 0 - : static_cast(value - _dualshock3ControllerConfig.triggerDeadzone) / - (UINT8_MAX - _dualshock3ControllerConfig.triggerDeadzone); + : static_cast(value - deadzone) / (UINT8_MAX - deadzone); } void Dualshock3Controller::NormalizeAxis(uint8_t x, uint8_t y, - uint8_t deadzone, + uint8_t deadzonePercent, float *x_out, float *y_out) { @@ -136,17 +136,18 @@ void Dualshock3Controller::NormalizeAxis(uint8_t x, //This will never exceed 32767 because if the stick is //horizontally maxed in one direction, vertically it must be neutral(0) and vice versa float real_magnitude = std::sqrt(x_val * x_val + y_val * y_val); + float real_deadzone = (127 * deadzonePercent) / 100; // Check if the controller is outside a circular dead zone. - if (real_magnitude > deadzone) + if (real_magnitude > real_deadzone) { // Clip the magnitude at its expected maximum value. float magnitude = std::min(127.0f, real_magnitude); // Adjust magnitude relative to the end of the dead zone. - magnitude -= deadzone; + magnitude -= real_deadzone; // Normalize the magnitude with respect to its expected range giving a // magnitude value of 0.0 to 1.0 //ratio = (currentValue / maxValue) / realValue - float ratio = (magnitude / (127 - deadzone)) / real_magnitude; + float ratio = (magnitude / (127 - real_deadzone)) / real_magnitude; *x_out = x_val * ratio; *y_out = y_val * ratio; } @@ -162,37 +163,40 @@ NormalizedButtonData Dualshock3Controller::GetNormalizedButtonData() { NormalizedButtonData normalData; - normalData.bottom_action = m_buttonData.cross; - normalData.right_action = m_buttonData.circle; - normalData.left_action = m_buttonData.square; - normalData.top_action = m_buttonData.triangle; + normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left_pressure); + normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right_pressure); - normalData.dpad_up = m_buttonData.dpad_up; - normalData.dpad_down = m_buttonData.dpad_down; - normalData.dpad_left = m_buttonData.dpad_left; - normalData.dpad_right = m_buttonData.dpad_right; + NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _dualshock3ControllerConfig.leftStickDeadzonePercent, + &normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y); + NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _dualshock3ControllerConfig.rightStickDeadzonePercent, + &normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y); - normalData.back = m_buttonData.back; - normalData.start = m_buttonData.start; + bool buttons[NUM_CONTROLLERBUTTONS] = { + m_buttonData.triangle, + m_buttonData.circle, + m_buttonData.cross, + m_buttonData.square, + m_buttonData.stick_left_click, + m_buttonData.stick_right_click, + m_buttonData.bumper_left, + m_buttonData.bumper_right, + normalData.triggers[0] > 0, + normalData.triggers[1] > 0, + m_buttonData.back, + m_buttonData.start, + m_buttonData.dpad_up, + m_buttonData.dpad_right, + m_buttonData.dpad_down, + m_buttonData.dpad_left, + false, + m_buttonData.guide, + }; - normalData.left_bumper = m_buttonData.bumper_left; - normalData.right_bumper = m_buttonData.bumper_right; - - normalData.left_stick_click = m_buttonData.stick_left_click; - normalData.right_stick_click = m_buttonData.stick_right_click; - - normalData.capture = false; - normalData.home = false; - - normalData.guide = m_buttonData.guide; - - normalData.left_trigger = m_buttonData.trigger_left; - normalData.right_trigger = m_buttonData.trigger_right; - - NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _dualshock3ControllerConfig.leftStickDeadzone, - &normalData.left_stick_x, &normalData.left_stick_y); - NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _dualshock3ControllerConfig.rightStickDeadzone, - &normalData.right_stick_x, &normalData.right_stick_y); + for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i) + { + ControllerButton button = _dualshock3ControllerConfig.buttons[i]; + normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i]; + } return normalData; } diff --git a/ControllerUSB/source/Controllers/Dualshock4Controller.cpp b/ControllerUSB/source/Controllers/Dualshock4Controller.cpp index 1b13ebc..b4ab424 100644 --- a/ControllerUSB/source/Controllers/Dualshock4Controller.cpp +++ b/ControllerUSB/source/Controllers/Dualshock4Controller.cpp @@ -77,7 +77,7 @@ Status Dualshock4Controller::OpenInterfaces() } void Dualshock4Controller::CloseInterfaces() { - m_device->Reset(); + //m_device->Reset(); m_device->Close(); } @@ -118,22 +118,6 @@ Status Dualshock4Controller::GetInput() Status Dualshock4Controller::SendInitBytes() { - /* - UCHAR hidCommandEnable[DS4_HID_COMMAND_ENABLE_SIZE] = - { - 0x42, 0x0C, 0x00, 0x00 - }; - - Context, - BmRequestHostToDevice, - BmRequestClass, - SetReport, - DS4FeatureStartDevice, - 0, - hidCommandEnable, - DS4_HID_COMMAND_ENABLE_SIZE - - */ uint8_t init_bytes[]{ 0x05, 0x20, 0x00, 0x01, 0x00}; @@ -144,16 +128,16 @@ Status Dualshock4Controller::SendInitBytes() float Dualshock4Controller::NormalizeTrigger(uint16_t value) { + uint16_t deadzone = (UINT16_MAX * _dualshock4ControllerConfig.triggerDeadzonePercent) / 100; //If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone - return value < _dualshock4ControllerConfig.triggerDeadzone + return value < deadzone ? 0 - : static_cast(value - _dualshock4ControllerConfig.triggerDeadzone) / - (UINT16_MAX - _dualshock4ControllerConfig.triggerDeadzone); + : static_cast(value - deadzone) / (UINT16_MAX - deadzone); } void Dualshock4Controller::NormalizeAxis(int16_t x, int16_t y, - int16_t deadzone, + uint8_t deadzonePercent, float *x_out, float *y_out) { @@ -163,17 +147,18 @@ void Dualshock4Controller::NormalizeAxis(int16_t x, //This will never exceed 32767 because if the stick is //horizontally maxed in one direction, vertically it must be neutral(0) and vice versa float real_magnitude = std::sqrt(x_val * x_val + y_val * y_val); + float real_deadzone = (32767 * deadzonePercent) / 100; // Check if the controller is outside a circular dead zone. - if (real_magnitude > deadzone) + if (real_magnitude > real_deadzone) { // Clip the magnitude at its expected maximum value. float magnitude = std::min(32767.0f, real_magnitude); // Adjust magnitude relative to the end of the dead zone. - magnitude -= deadzone; + magnitude -= real_deadzone; // Normalize the magnitude with respect to its expected range giving a // magnitude value of 0.0 to 1.0 //ratio = (currentValue / maxValue) / realValue - float ratio = (magnitude / (32767 - deadzone)) / real_magnitude; + float ratio = (magnitude / (32767 - real_deadzone)) / real_magnitude; // Y is negated because xbox controllers have an opposite sign from // the 'standard controller' recommendations. *x_out = x_val * ratio; @@ -191,38 +176,6 @@ NormalizedButtonData Dualshock4Controller::GetNormalizedButtonData() { NormalizedButtonData normalData; - normalData.bottom_action = m_buttonData.a; - normalData.right_action = m_buttonData.b; - normalData.left_action = m_buttonData.x; - normalData.top_action = m_buttonData.y; - - normalData.dpad_up = m_buttonData.dpad_up; - normalData.dpad_down = m_buttonData.dpad_down; - normalData.dpad_left = m_buttonData.dpad_left; - normalData.dpad_right = m_buttonData.dpad_right; - - normalData.back = m_buttonData.back; - normalData.start = m_buttonData.start; - - normalData.left_bumper = m_buttonData.bumper_left; - normalData.right_bumper = m_buttonData.bumper_right; - - normalData.left_stick_click = m_buttonData.stick_left_click; - normalData.right_stick_click = m_buttonData.stick_right_click; - - normalData.capture = false; - normalData.home = false; - - //normalData.guide = m_buttonData.sync; - - normalData.left_trigger = NormalizeTrigger(m_buttonData.trigger_left); - normalData.right_trigger = NormalizeTrigger(m_buttonData.trigger_right); - - NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _dualshock4ControllerConfig.leftStickDeadzone, - &normalData.left_stick_x, &normalData.left_stick_y); - NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _dualshock4ControllerConfig.rightStickDeadzone, - &normalData.right_stick_x, &normalData.right_stick_y); - return normalData; } diff --git a/ControllerUSB/source/Controllers/Xbox360Controller.cpp b/ControllerUSB/source/Controllers/Xbox360Controller.cpp index 1391b00..8cdd8dc 100644 --- a/ControllerUSB/source/Controllers/Xbox360Controller.cpp +++ b/ControllerUSB/source/Controllers/Xbox360Controller.cpp @@ -89,7 +89,7 @@ Status Xbox360Controller::OpenInterfaces() } void Xbox360Controller::CloseInterfaces() { - m_device->Reset(); + //m_device->Reset(); m_device->Close(); } @@ -119,18 +119,18 @@ Status Xbox360Controller::SendInitBytes() return rc; } -float Xbox360Controller::NormalizeTrigger(uint16_t value) +float Xbox360Controller::NormalizeTrigger(uint8_t value) { + uint16_t deadzone = (UINT8_MAX * _xbox360ControllerConfig.triggerDeadzonePercent) / 100; //If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone - return value < _xbox360ControllerConfig.triggerDeadzone + return value < deadzone ? 0 - : static_cast(value - _xbox360ControllerConfig.triggerDeadzone) / - (UINT16_MAX - _xbox360ControllerConfig.triggerDeadzone); + : static_cast(value - deadzone) / (UINT8_MAX - deadzone); } void Xbox360Controller::NormalizeAxis(int16_t x, int16_t y, - int16_t deadzone, + uint8_t deadzonePercent, float *x_out, float *y_out) { @@ -140,17 +140,18 @@ void Xbox360Controller::NormalizeAxis(int16_t x, //This will never exceed 32767 because if the stick is //horizontally maxed in one direction, vertically it must be neutral(0) and vice versa float real_magnitude = std::sqrt(x_val * x_val + y_val * y_val); + float real_deadzone = (32767 * deadzonePercent) / 100; // Check if the controller is outside a circular dead zone. - if (real_magnitude > deadzone) + if (real_magnitude > real_deadzone) { // Clip the magnitude at its expected maximum value. float magnitude = std::min(32767.0f, real_magnitude); // Adjust magnitude relative to the end of the dead zone. - magnitude -= deadzone; + magnitude -= real_deadzone; // Normalize the magnitude with respect to its expected range giving a // magnitude value of 0.0 to 1.0 //ratio = (currentValue / maxValue) / realValue - float ratio = (magnitude / (32767 - deadzone)) / real_magnitude; + float ratio = (magnitude / (32767 - real_deadzone)) / real_magnitude; // Y is negated because xbox controllers have an opposite sign from // the 'standard controller' recommendations. *x_out = x_val * ratio; @@ -168,37 +169,40 @@ NormalizedButtonData Xbox360Controller::GetNormalizedButtonData() { NormalizedButtonData normalData; - normalData.bottom_action = m_buttonData.a; - normalData.right_action = m_buttonData.b; - normalData.left_action = m_buttonData.x; - normalData.top_action = m_buttonData.y; + normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left); + normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right); - normalData.dpad_up = m_buttonData.dpad_up; - normalData.dpad_down = m_buttonData.dpad_down; - normalData.dpad_left = m_buttonData.dpad_left; - normalData.dpad_right = m_buttonData.dpad_right; + NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xbox360ControllerConfig.leftStickDeadzonePercent, + &normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y); + NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xbox360ControllerConfig.rightStickDeadzonePercent, + &normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y); - normalData.back = m_buttonData.back; - normalData.start = m_buttonData.start; + bool buttons[NUM_CONTROLLERBUTTONS]{ + m_buttonData.y, + m_buttonData.b, + m_buttonData.a, + m_buttonData.x, + m_buttonData.stick_left_click, + m_buttonData.stick_right_click, + m_buttonData.bumper_left, + m_buttonData.bumper_right, + normalData.triggers[0] > 0, + normalData.triggers[1] > 0, + m_buttonData.back, + m_buttonData.start, + m_buttonData.dpad_up, + m_buttonData.dpad_right, + m_buttonData.dpad_down, + m_buttonData.dpad_left, + false, + m_buttonData.guide, + }; - normalData.left_bumper = m_buttonData.bumper_left; - normalData.right_bumper = m_buttonData.bumper_right; - - normalData.left_stick_click = m_buttonData.stick_left_click; - normalData.right_stick_click = m_buttonData.stick_right_click; - - normalData.capture = false; - normalData.home = false; - - normalData.guide = m_buttonData.guide; - - normalData.left_trigger = NormalizeTrigger(m_buttonData.trigger_left); - normalData.right_trigger = NormalizeTrigger(m_buttonData.trigger_right); - - NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xbox360ControllerConfig.leftStickDeadzone, - &normalData.left_stick_x, &normalData.left_stick_y); - NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xbox360ControllerConfig.rightStickDeadzone, - &normalData.right_stick_x, &normalData.right_stick_y); + for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i) + { + ControllerButton button = _xbox360ControllerConfig.buttons[i]; + normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i]; + } return normalData; } diff --git a/ControllerUSB/source/Controllers/XboxOneController.cpp b/ControllerUSB/source/Controllers/XboxOneController.cpp index 90ba0ab..54eb06c 100644 --- a/ControllerUSB/source/Controllers/XboxOneController.cpp +++ b/ControllerUSB/source/Controllers/XboxOneController.cpp @@ -84,7 +84,7 @@ Status XboxOneController::OpenInterfaces() } void XboxOneController::CloseInterfaces() { - m_device->Reset(); + //m_device->Reset(); m_device->Close(); } @@ -131,16 +131,16 @@ Status XboxOneController::SendInitBytes() float XboxOneController::NormalizeTrigger(uint16_t value) { + uint16_t deadzone = (1023 * _xboxoneControllerConfig.triggerDeadzonePercent) / 100; //If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone - return value < _xboxoneControllerConfig.triggerDeadzone + return value < deadzone ? 0 - : static_cast(value - _xboxoneControllerConfig.triggerDeadzone) / - (UINT16_MAX - _xboxoneControllerConfig.triggerDeadzone); + : static_cast(value - deadzone) / (1023 - deadzone); } void XboxOneController::NormalizeAxis(int16_t x, int16_t y, - int16_t deadzone, + uint8_t deadzonePercent, float *x_out, float *y_out) { @@ -150,17 +150,18 @@ void XboxOneController::NormalizeAxis(int16_t x, //This will never exceed 32767 because if the stick is //horizontally maxed in one direction, vertically it must be neutral(0) and vice versa float real_magnitude = std::sqrt(x_val * x_val + y_val * y_val); + float real_deadzone = (32767 * deadzonePercent) / 100; // Check if the controller is outside a circular dead zone. - if (real_magnitude > deadzone) + if (real_magnitude > real_deadzone) { // Clip the magnitude at its expected maximum value. float magnitude = std::min(32767.0f, real_magnitude); // Adjust magnitude relative to the end of the dead zone. - magnitude -= deadzone; + magnitude -= real_deadzone; // Normalize the magnitude with respect to its expected range giving a // magnitude value of 0.0 to 1.0 //ratio = (currentValue / maxValue) / realValue - float ratio = (magnitude / (32767 - deadzone)) / real_magnitude; + float ratio = (magnitude / (32767 - real_deadzone)) / real_magnitude; // Y is negated because xbox controllers have an opposite sign from // the 'standard controller' recommendations. *x_out = x_val * ratio; @@ -178,37 +179,40 @@ NormalizedButtonData XboxOneController::GetNormalizedButtonData() { NormalizedButtonData normalData; - normalData.bottom_action = m_buttonData.a; - normalData.right_action = m_buttonData.b; - normalData.left_action = m_buttonData.x; - normalData.top_action = m_buttonData.y; + normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left); + normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right); - normalData.dpad_up = m_buttonData.dpad_up; - normalData.dpad_down = m_buttonData.dpad_down; - normalData.dpad_left = m_buttonData.dpad_left; - normalData.dpad_right = m_buttonData.dpad_right; + NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xboxoneControllerConfig.leftStickDeadzonePercent, + &normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y); + NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xboxoneControllerConfig.rightStickDeadzonePercent, + &normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y); - normalData.back = m_buttonData.back; - normalData.start = m_buttonData.start; + bool buttons[NUM_CONTROLLERBUTTONS]{ + m_buttonData.y, + m_buttonData.b, + m_buttonData.a, + m_buttonData.x, + m_buttonData.stick_left_click, + m_buttonData.stick_right_click, + m_buttonData.bumper_left, + m_buttonData.bumper_right, + normalData.triggers[0] > 0, + normalData.triggers[1] > 0, + m_buttonData.back, + m_buttonData.start, + m_buttonData.dpad_up, + m_buttonData.dpad_right, + m_buttonData.dpad_down, + m_buttonData.dpad_left, + m_buttonData.sync, + m_GuidePressed, + }; - normalData.left_bumper = m_buttonData.bumper_left; - normalData.right_bumper = m_buttonData.bumper_right; - - normalData.left_stick_click = m_buttonData.stick_left_click; - normalData.right_stick_click = m_buttonData.stick_right_click; - - normalData.capture = m_buttonData.sync; - normalData.home = false; - - normalData.guide = m_GuidePressed; - - normalData.left_trigger = NormalizeTrigger(m_buttonData.trigger_left); - normalData.right_trigger = NormalizeTrigger(m_buttonData.trigger_right); - - NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xboxoneControllerConfig.leftStickDeadzone, - &normalData.left_stick_x, &normalData.left_stick_y); - NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xboxoneControllerConfig.rightStickDeadzone, - &normalData.right_stick_x, &normalData.right_stick_y); + for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i) + { + ControllerButton button = _xboxoneControllerConfig.buttons[i]; + normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i]; + } return normalData; } diff --git a/SwitchUSB/source/SwitchAbstractedPadHandler.cpp b/SwitchUSB/source/SwitchAbstractedPadHandler.cpp index d31f2d2..7fe7d44 100644 --- a/SwitchUSB/source/SwitchAbstractedPadHandler.cpp +++ b/SwitchUSB/source/SwitchAbstractedPadHandler.cpp @@ -115,30 +115,33 @@ Result SwitchAbstractedPadHandler::ExitAbstractedPadState() void SwitchAbstractedPadHandler::FillAbstractedState(const NormalizedButtonData &data) { m_state.state.buttons = 0; - m_state.state.buttons |= (data.right_action ? KEY_A : 0); - m_state.state.buttons |= (data.bottom_action ? KEY_B : 0); - m_state.state.buttons |= (data.top_action ? KEY_X : 0); - m_state.state.buttons |= (data.left_action ? KEY_Y : 0); + m_state.state.buttons |= (data.buttons[0] ? KEY_X : 0); + m_state.state.buttons |= (data.buttons[1] ? KEY_A : 0); + m_state.state.buttons |= (data.buttons[2] ? KEY_B : 0); + m_state.state.buttons |= (data.buttons[3] ? KEY_Y : 0); - m_state.state.buttons |= (data.left_stick_click ? KEY_LSTICK : 0); - m_state.state.buttons |= (data.right_stick_click ? KEY_RSTICK : 0); + m_state.state.buttons |= (data.buttons[4] ? KEY_LSTICK : 0); + m_state.state.buttons |= (data.buttons[5] ? KEY_RSTICK : 0); - m_state.state.buttons |= (data.left_bumper ? KEY_L : 0); - m_state.state.buttons |= (data.right_bumper ? KEY_R : 0); + m_state.state.buttons |= (data.buttons[6] ? KEY_L : 0); + m_state.state.buttons |= (data.buttons[7] ? KEY_R : 0); - m_state.state.buttons |= ((data.left_trigger > 0.0f) ? KEY_ZL : 0); - m_state.state.buttons |= ((data.right_trigger > 0.0f) ? KEY_ZR : 0); + m_state.state.buttons |= (data.buttons[8] ? KEY_ZL : 0); + m_state.state.buttons |= (data.buttons[9] ? KEY_ZR : 0); - m_state.state.buttons |= (data.start ? KEY_PLUS : 0); - m_state.state.buttons |= (data.back ? KEY_MINUS : 0); + m_state.state.buttons |= (data.buttons[10] ? KEY_MINUS : 0); + m_state.state.buttons |= (data.buttons[11] ? KEY_PLUS : 0); - m_state.state.buttons |= (data.dpad_left ? KEY_DLEFT : 0); - m_state.state.buttons |= (data.dpad_up ? KEY_DUP : 0); - m_state.state.buttons |= (data.dpad_right ? KEY_DRIGHT : 0); - m_state.state.buttons |= (data.dpad_down ? KEY_DDOWN : 0); + m_state.state.buttons |= (data.buttons[12] ? KEY_DUP : 0); + m_state.state.buttons |= (data.buttons[13] ? KEY_DRIGHT : 0); + m_state.state.buttons |= (data.buttons[14] ? KEY_DDOWN : 0); + m_state.state.buttons |= (data.buttons[15] ? KEY_DLEFT : 0); - m_controllerHandler.ConvertAxisToSwitchAxis(data.left_stick_x, data.left_stick_y, 0, &m_state.state.joysticks[JOYSTICK_LEFT].dx, &m_state.state.joysticks[JOYSTICK_LEFT].dy); - m_controllerHandler.ConvertAxisToSwitchAxis(data.right_stick_x, data.right_stick_y, 0, &m_state.state.joysticks[JOYSTICK_RIGHT].dx, &m_state.state.joysticks[JOYSTICK_RIGHT].dy); + m_state.state.buttons |= (data.buttons[16] ? KEY_CAPTURE : 0); + m_state.state.buttons |= (data.buttons[17] ? KEY_HOME : 0); + + m_controllerHandler.ConvertAxisToSwitchAxis(data.sticks[0].axis_x, data.sticks[0].axis_y, 0, &m_state.state.joysticks[JOYSTICK_LEFT].dx, &m_state.state.joysticks[JOYSTICK_LEFT].dy); + m_controllerHandler.ConvertAxisToSwitchAxis(data.sticks[1].axis_x, data.sticks[1].axis_y, 0, &m_state.state.joysticks[JOYSTICK_RIGHT].dx, &m_state.state.joysticks[JOYSTICK_RIGHT].dy); } Result SwitchAbstractedPadHandler::UpdateAbstractedState() diff --git a/SwitchUSB/source/SwitchHDLHandler.cpp b/SwitchUSB/source/SwitchHDLHandler.cpp index ee928bb..c4ba50b 100644 --- a/SwitchUSB/source/SwitchHDLHandler.cpp +++ b/SwitchUSB/source/SwitchHDLHandler.cpp @@ -96,37 +96,11 @@ Result SwitchHDLHandler::ExitHdlState() Result SwitchHDLHandler::UpdateHdlState() { //Checks if the virtual device was erased, in which case re-attach the device + bool isAttached; - if (R_SUCCEEDED(serviceDispatch(hiddbgGetServiceSession(), 327))) + if (R_SUCCEEDED(hiddbgIsHdlsVirtualDeviceAttached(m_hdlHandle, &isAttached))) { - bool found_flag = false; - - if (hosversionBefore(9, 0, 0)) - { - HiddbgHdlsStateListV7 *stateList = static_cast(hiddbgGetWorkBufferTransferMemoryAddress()->src_addr); - for (int i = 0; i != stateList->total_entries; ++i) - { - if (stateList->entries[i].HdlsHandle == m_hdlHandle) - { - found_flag = true; - break; - } - } - } - else - { - HiddbgHdlsStateList *stateList = static_cast(hiddbgGetWorkBufferTransferMemoryAddress()->src_addr); - for (int i = 0; i != stateList->total_entries; ++i) - { - if (stateList->entries[i].HdlsHandle == m_hdlHandle) - { - found_flag = true; - break; - } - } - } - - if (!found_flag) + if (!isAttached) hiddbgAttachHdlsVirtualDevice(&m_hdlHandle, &m_deviceInfo); } @@ -137,34 +111,33 @@ void SwitchHDLHandler::FillHdlState(const NormalizedButtonData &data) { m_hdlState.buttons = 0; - m_hdlState.buttons |= (data.right_action ? KEY_A : 0); - m_hdlState.buttons |= (data.bottom_action ? KEY_B : 0); - m_hdlState.buttons |= (data.top_action ? KEY_X : 0); - m_hdlState.buttons |= (data.left_action ? KEY_Y : 0); + m_hdlState.buttons |= (data.buttons[0] ? KEY_X : 0); + m_hdlState.buttons |= (data.buttons[1] ? KEY_A : 0); + m_hdlState.buttons |= (data.buttons[2] ? KEY_B : 0); + m_hdlState.buttons |= (data.buttons[3] ? KEY_Y : 0); - m_hdlState.buttons |= (data.left_stick_click ? KEY_LSTICK : 0); - m_hdlState.buttons |= (data.right_stick_click ? KEY_RSTICK : 0); + m_hdlState.buttons |= (data.buttons[4] ? KEY_LSTICK : 0); + m_hdlState.buttons |= (data.buttons[5] ? KEY_RSTICK : 0); - m_hdlState.buttons |= (data.left_bumper ? KEY_L : 0); - m_hdlState.buttons |= (data.right_bumper ? KEY_R : 0); + m_hdlState.buttons |= (data.buttons[6] ? KEY_L : 0); + m_hdlState.buttons |= (data.buttons[7] ? KEY_R : 0); - m_hdlState.buttons |= ((data.left_trigger > 0.0f) ? KEY_ZL : 0); - m_hdlState.buttons |= ((data.right_trigger > 0.0f) ? KEY_ZR : 0); + m_hdlState.buttons |= (data.buttons[8] ? KEY_ZL : 0); + m_hdlState.buttons |= (data.buttons[9] ? KEY_ZR : 0); - m_hdlState.buttons |= (data.start ? KEY_PLUS : 0); - m_hdlState.buttons |= (data.back ? KEY_MINUS : 0); + m_hdlState.buttons |= (data.buttons[10] ? KEY_MINUS : 0); + m_hdlState.buttons |= (data.buttons[11] ? KEY_PLUS : 0); - m_hdlState.buttons |= (data.dpad_left ? KEY_DLEFT : 0); - m_hdlState.buttons |= (data.dpad_up ? KEY_DUP : 0); - m_hdlState.buttons |= (data.dpad_right ? KEY_DRIGHT : 0); - m_hdlState.buttons |= (data.dpad_down ? KEY_DDOWN : 0); + m_hdlState.buttons |= (data.buttons[12] ? KEY_DUP : 0); + m_hdlState.buttons |= (data.buttons[13] ? KEY_DRIGHT : 0); + m_hdlState.buttons |= (data.buttons[14] ? KEY_DDOWN : 0); + m_hdlState.buttons |= (data.buttons[15] ? KEY_DLEFT : 0); - m_hdlState.buttons |= (data.capture ? KEY_CAPTURE : 0); - m_hdlState.buttons |= (data.home ? KEY_HOME : 0); - m_hdlState.buttons |= (data.guide ? KEY_HOME : 0); + m_hdlState.buttons |= (data.buttons[16] ? KEY_CAPTURE : 0); + m_hdlState.buttons |= (data.buttons[17] ? KEY_HOME : 0); - m_controllerHandler.ConvertAxisToSwitchAxis(data.left_stick_x, data.left_stick_y, 0, &m_hdlState.joysticks[JOYSTICK_LEFT].dx, &m_hdlState.joysticks[JOYSTICK_LEFT].dy); - m_controllerHandler.ConvertAxisToSwitchAxis(data.right_stick_x, data.right_stick_y, 0, &m_hdlState.joysticks[JOYSTICK_RIGHT].dx, &m_hdlState.joysticks[JOYSTICK_RIGHT].dy); + m_controllerHandler.ConvertAxisToSwitchAxis(data.sticks[0].axis_x, data.sticks[0].axis_y, 0, &m_hdlState.joysticks[JOYSTICK_LEFT].dx, &m_hdlState.joysticks[JOYSTICK_LEFT].dy); + m_controllerHandler.ConvertAxisToSwitchAxis(data.sticks[1].axis_x, data.sticks[1].axis_y, 0, &m_hdlState.joysticks[JOYSTICK_RIGHT].dx, &m_hdlState.joysticks[JOYSTICK_RIGHT].dy); } void SwitchHDLHandler::UpdateInput() diff --git a/source/configFile.cpp b/source/configFile.cpp index 3453416..6b854a2 100644 --- a/source/configFile.cpp +++ b/source/configFile.cpp @@ -4,6 +4,7 @@ #include "switch/result.h" #include +#include #include #include "ini.h" #include "log.h" @@ -15,13 +16,11 @@ #define DUALSHOCK3CONFIG "config_dualshock3.ini" #define DUALSHOCK4CONFIG "config_dualshock4.ini" -std::array keyNames{ +std::array keyNames{ "FACE_UP", "FACE_RIGHT", "FACE_DOWN", "FACE_LEFT", - "LSTICK", - "RSTICK", "LSTICK_CLICK", "RSTICK_CLICK", "LEFT_BUMPER", @@ -40,9 +39,9 @@ std::array keyNames{ static ControllerButton _StringToKey(const char *text) { - for (int i = 0; i != keyNames.size(); ++i) + for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i) { - if (keyNames[i] == text) + if (strcmp(keyNames[i], text) == 0) { return static_cast(i); } @@ -59,31 +58,32 @@ static int _ParseConfigLine(void *dummy, const char *section, const char *name, ControllerButton button = _StringToKey(name + 4); ControllerButton buttonValue = _StringToKey(value); temp_config.buttons[button] = buttonValue; + temp_config.buttons[buttonValue] = button; return 1; } else if (strcmp(name, "left_stick_deadzone") == 0) { - temp_config.leftStickDeadzone = atoi(value); + temp_config.leftStickDeadzonePercent = atoi(value); return 1; } else if (strcmp(name, "right_stick_deadzone") == 0) { - temp_config.rightStickDeadzone = atoi(value); + temp_config.rightStickDeadzonePercent = atoi(value); return 1; } else if (strcmp(name, "left_stick_rotation") == 0) { - temp_config.leftStickRotation = atoi(value); + temp_config.leftStickRotationDegrees = atoi(value); return 1; } else if (strcmp(name, "right_stick_rotation") == 0) { - temp_config.rightStickRotation = atoi(value); + temp_config.rightStickRotationDegrees = atoi(value); return 1; } else if (strcmp(name, "trigger_deadzone") == 0) { - temp_config.triggerDeadzone = atoi(value); + temp_config.triggerDeadzonePercent = atoi(value); return 1; } @@ -92,7 +92,11 @@ static int _ParseConfigLine(void *dummy, const char *section, const char *name, static Result _ReadFromConfig(const char *path) { - temp_config = {}; + temp_config = ControllerConfig{}; + for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i) + { + temp_config.buttons[i] = NOT_SET; + } return ini_parse(path, _ParseConfigLine, NULL); } @@ -119,59 +123,50 @@ void LoadAllConfigs() WriteToLog("Failed to read from dualshock 4 config!"); } -/* -//Config example -[config_global.ini] -left_stick_deadzone = 0 -right_stick_deadzone = 0 -left_stick_rotation = 0 -right_stick_rotation = 0 -trigger_deadzone = 0 -key_FACE_UP = FACE_UP -key_FACE_RIGHT = FACE_RIGHT -key_FACE_DOWN = FACE_DOWN -key_FACE_LEFT = FACE_LEFT -key_LSTICK = LSTICK -key_RSTICK = RSTICK -key_LSTICK_CLICK = LSTICK_CLICK -key_RSTICK_CLICK = RSTICK_CLICK -key_LEFT_BUMPER = LEFT_BUMPER -key_RIGHT_BUMPER = RIGHT_BUMPER -key_LEFT_TRIGGER = LEFT_TRIGGER -key_RIGHT_TRIGGER = RIGHT_TRIGGER -key_BACK = BACK -key_START = START -key_DPAD_UP = DPAD_UP -key_DPAD_RIGHT = DPAD_RIGHT -key_DPAD_DOWN = DPAD_DOWN; -key_DPAD_LEFT = DPAD_LEFT -key_SYNC = SYNC -key_GUIDE = GUIDE +bool CheckForFileChanges() +{ + bool filesChanged = false; -[config_xboxone.ini] -left_stick_deadzone = 2500 -right_stick_deadzone = 3500 -left_stick_rotation = 0 -right_stick_rotation = 0 -trigger_deadzone = 0 -key_FACE_UP = FACE_UP -key_FACE_RIGHT = FACE_RIGHT -key_FACE_DOWN = FACE_DOWN -key_FACE_LEFT = FACE_LEFT -key_LSTICK = LSTICK -key_RSTICK = RSTICK -key_LSTICK_CLICK = LSTICK_CLICK -key_RSTICK_CLICK = RSTICK_CLICK -key_LEFT_BUMPER = LEFT_BUMPER -key_RIGHT_BUMPER = RIGHT_BUMPER -key_LEFT_TRIGGER = LEFT_TRIGGER -key_RIGHT_TRIGGER = RIGHT_TRIGGER -key_BACK = BACK -key_START = START -key_DPAD_UP = DPAD_UP -key_DPAD_RIGHT = DPAD_RIGHT -key_DPAD_DOWN = DPAD_DOWN; -key_DPAD_LEFT = DPAD_LEFT -key_SYNC = SYNC -key_GUIDE = GUIDE -*/ + static time_t globalConfigLastModified; + static time_t xbox360ConfigLastModified; + static time_t xboxOneConfigLastModified; + static time_t dualshock3ConfigLastModified; + static time_t dualshock4ConfigLastModified; + struct stat result; + + if (stat(CONFIG_PATH GLOBALCONFIG, &result) == 0) + if (globalConfigLastModified != result.st_mtime) + { + globalConfigLastModified = result.st_mtime; + filesChanged = true; + } + + if (stat(CONFIG_PATH XBOX360CONFIG, &result) == 0) + if (xbox360ConfigLastModified != result.st_mtime) + { + xbox360ConfigLastModified = result.st_mtime; + filesChanged = true; + } + + if (stat(CONFIG_PATH XBOXONECONFIG, &result) == 0) + if (xboxOneConfigLastModified != result.st_mtime) + { + xboxOneConfigLastModified = result.st_mtime; + filesChanged = true; + } + + if (stat(CONFIG_PATH DUALSHOCK3CONFIG, &result) == 0) + if (dualshock3ConfigLastModified != result.st_mtime) + { + dualshock3ConfigLastModified = result.st_mtime; + filesChanged = true; + } + + if (stat(CONFIG_PATH DUALSHOCK4CONFIG, &result) == 0) + if (dualshock4ConfigLastModified != result.st_mtime) + { + dualshock4ConfigLastModified = result.st_mtime; + filesChanged = true; + } + return filesChanged; +} \ No newline at end of file diff --git a/source/configFile.h b/source/configFile.h index 90dd1ab..8cfe029 100644 --- a/source/configFile.h +++ b/source/configFile.h @@ -2,4 +2,6 @@ #define CONFIG_PATH "/config/sys-con/" -void LoadAllConfigs(); \ No newline at end of file +void LoadAllConfigs(); + +bool CheckForFileChanges(); \ No newline at end of file diff --git a/source/mainLoop.cpp b/source/mainLoop.cpp index acf5b7a..8faea26 100644 --- a/source/mainLoop.cpp +++ b/source/mainLoop.cpp @@ -16,15 +16,19 @@ struct VendorEvent Result mainLoop() { + WriteToLog("\n\nNew sysmodule session started"); Result rc = 0; - bool useAbstractedPad = hosversionBetween(5, 7); - //hidPermitVibration(false); - //hidPermitVibration(true); + VendorEvent events[2]; std::vector> controllerInterfaces; - WriteToLog("\n\nNew sysmodule session started"); + UTimer filecheckTimer; + Waiter filecheckTimerWaiter = waiterForUTimer(&filecheckTimer); + utimerCreate(&filecheckTimer, 1e+9L, TimerType_Repeating); + utimerStart(&filecheckTimer); + CheckForFileChanges(); + LoadAllConfigs(); { UsbHsInterfaceFilter filter; @@ -49,7 +53,6 @@ Result mainLoop() } controllerInterfaces.reserve(8); - LoadAllConfigs(); while (appletMainLoop()) { @@ -197,6 +200,16 @@ Result mainLoop() } } + rc = waitSingle(filecheckTimerWaiter, 0); + if (R_SUCCEEDED(rc)) + { + if (CheckForFileChanges()) + { + WriteToLog("File check succeeded! Loading configs..."); + LoadAllConfigs(); + } + } + #ifdef __APPLET__ consoleUpdate(nullptr); #else