From f0419185f468b5a10f47a3efb226309d03dce3b5 Mon Sep 17 00:00:00 2001 From: cathery Date: Tue, 5 Nov 2019 22:44:44 +0300 Subject: [PATCH] Added deadzone to close #8 Xbox One sync button now takes a capture --- .../include/Controllers/Dualshock3Controller.h | 4 ++-- .../include/Controllers/Dualshock4Controller.h | 8 ++++---- ControllerUSB/include/Controllers/Xbox360Controller.h | 8 ++++---- ControllerUSB/include/Controllers/XboxOneController.h | 11 ++++++----- .../source/Controllers/XboxOneController.cpp | 6 +++--- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ControllerUSB/include/Controllers/Dualshock3Controller.h b/ControllerUSB/include/Controllers/Dualshock3Controller.h index 8d1bb37..619bfc6 100644 --- a/ControllerUSB/include/Controllers/Dualshock3Controller.h +++ b/ControllerUSB/include/Controllers/Dualshock3Controller.h @@ -155,8 +155,8 @@ private: Dualshock3ButtonData m_buttonData; - int8_t kLeftThumbDeadzone = 0; - int8_t kRightThumbDeadzone = 0; + int8_t kLeftThumbDeadzone = 10; + int8_t kRightThumbDeadzone = 10; int8_t kTriggerMax = 0; int8_t kTriggerDeadzone = 0; diff --git a/ControllerUSB/include/Controllers/Dualshock4Controller.h b/ControllerUSB/include/Controllers/Dualshock4Controller.h index e8b5516..e68a35d 100644 --- a/ControllerUSB/include/Controllers/Dualshock4Controller.h +++ b/ControllerUSB/include/Controllers/Dualshock4Controller.h @@ -51,10 +51,10 @@ private: Dualshock4ButtonData m_buttonData; - int16_t kLeftThumbDeadzone = 0; //7849; - int16_t kRightThumbDeadzone = 0; //8689; - uint16_t kTriggerMax = 0; //1023; - uint16_t kTriggerDeadzone = 0; //120; + int16_t kLeftThumbDeadzone = 2000; //7849; + int16_t kRightThumbDeadzone = 2000; //8689; + uint16_t kTriggerMax = 0; //1023; + uint16_t kTriggerDeadzone = 0; //120; public: Dualshock4Controller(std::unique_ptr &&interface); diff --git a/ControllerUSB/include/Controllers/Xbox360Controller.h b/ControllerUSB/include/Controllers/Xbox360Controller.h index 497dcad..3fce217 100644 --- a/ControllerUSB/include/Controllers/Xbox360Controller.h +++ b/ControllerUSB/include/Controllers/Xbox360Controller.h @@ -68,10 +68,10 @@ private: Xbox360ButtonData m_buttonData; - int16_t kLeftThumbDeadzone = 0; //7849; - int16_t kRightThumbDeadzone = 0; //8689; - uint16_t kTriggerMax = 0; //1023; - uint16_t kTriggerDeadzone = 0; //120; + int16_t kLeftThumbDeadzone = 8000; //7849; + int16_t kRightThumbDeadzone = 8000; //8689; + uint16_t kTriggerMax = 0; //1023; + uint16_t kTriggerDeadzone = 0; //120; public: Xbox360Controller(std::unique_ptr &&interface); diff --git a/ControllerUSB/include/Controllers/XboxOneController.h b/ControllerUSB/include/Controllers/XboxOneController.h index 1037a08..d041dbb 100644 --- a/ControllerUSB/include/Controllers/XboxOneController.h +++ b/ControllerUSB/include/Controllers/XboxOneController.h @@ -79,11 +79,12 @@ private: IUSBEndpoint *m_outPipe = nullptr; XboxOneButtonData m_buttonData; + bool m_GuidePressed; - int16_t kLeftThumbDeadzone = 0; //7849; - int16_t kRightThumbDeadzone = 0; //8689; - uint16_t kTriggerMax = 0; //1023; - uint16_t kTriggerDeadzone = 0; //120; + int16_t kLeftThumbDeadzone = 2500; //7849; + int16_t kRightThumbDeadzone = 3500; //8689; + uint16_t kTriggerMax = 0; //1023; + uint16_t kTriggerDeadzone = 0; //120; uint8_t m_rumbleDataCounter = 0; public: @@ -109,5 +110,5 @@ public: Status SendInitBytes(); Status WriteAckGuideReport(uint8_t sequence); - Status SetRumble(uint8_t strong_magnitude,uint8_t weak_magnitude); + Status SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude); }; \ No newline at end of file diff --git a/ControllerUSB/source/Controllers/XboxOneController.cpp b/ControllerUSB/source/Controllers/XboxOneController.cpp index f3c2640..febd717 100644 --- a/ControllerUSB/source/Controllers/XboxOneController.cpp +++ b/ControllerUSB/source/Controllers/XboxOneController.cpp @@ -95,7 +95,7 @@ Status XboxOneController::GetInput() } else if (type == XBONEINPUT_GUIDEBUTTON) //Guide button status { - m_buttonData.sync = input_bytes[4]; + m_GuidePressed = input_bytes[4]; //Xbox one S needs to be sent an ack report for guide buttons //TODO: needs testing @@ -188,10 +188,10 @@ NormalizedButtonData XboxOneController::GetNormalizedButtonData() normalData.left_stick_click = m_buttonData.stick_left_click; normalData.right_stick_click = m_buttonData.stick_right_click; - normalData.capture = false; + normalData.capture = m_buttonData.sync; normalData.home = false; - normalData.guide = m_buttonData.sync; + normalData.guide = m_GuidePressed; normalData.left_trigger = NormalizeTrigger(m_buttonData.trigger_left); normalData.right_trigger = NormalizeTrigger(m_buttonData.trigger_right);