From 18c0cff678e06f09a6df613d41c2bb93f9472754 Mon Sep 17 00:00:00 2001 From: Laggamer2005 <158077584+Laggamer2005@users.noreply.github.com> Date: Sat, 7 Dec 2024 11:16:46 +0000 Subject: [PATCH] Update DS5State.h --- .../include/DualSenseWindows/DS5State.h | 510 +++++------------- 1 file changed, 122 insertions(+), 388 deletions(-) diff --git a/VS19_Solution/DualSenseWindows/include/DualSenseWindows/DS5State.h b/VS19_Solution/DualSenseWindows/include/DualSenseWindows/DS5State.h index dd6a21c..4930484 100644 --- a/VS19_Solution/DualSenseWindows/include/DualSenseWindows/DS5State.h +++ b/VS19_Solution/DualSenseWindows/include/DualSenseWindows/DS5State.h @@ -1,14 +1,17 @@ /* - DS5State.h is part of DualSenseWindows - https://github.com/Ohjurot/DualSense-Windows + DS5State.h is part of DualSenseWindows + https://github.com/Ohjurot/DualSense-Windows - Contributors of this file: - 11.2020 Ludwig Füchsl + Contributors of this file: + 11.2020 Ludwig Füchsl - Licensed under the MIT License (To be found in repository root directory) + Licensed under the MIT License (To be found in repository root directory) */ #pragma once +#include + +// Button and D-pad bitmasks #define DS5W_ISTATE_BTX_SQUARE 0x10 #define DS5W_ISTATE_BTX_CROSS 0x20 #define DS5W_ISTATE_BTX_CIRCLE 0x40 @@ -18,6 +21,7 @@ #define DS5W_ISTATE_DPAD_RIGHT 0x04 #define DS5W_ISTATE_DPAD_UP 0x08 +// Button A bitmasks #define DS5W_ISTATE_BTN_A_LEFT_BUMPER 0x01 #define DS5W_ISTATE_BTN_A_RIGHT_BUMPER 0x02 #define DS5W_ISTATE_BTN_A_LEFT_TRIGGER 0x04 @@ -27,10 +31,12 @@ #define DS5W_ISTATE_BTN_A_LEFT_STICK 0x40 #define DS5W_ISTATE_BTN_A_RIGHT_STICK 0x80 +// Button B bitmasks #define DS5W_ISTATE_BTN_B_PLAYSTATION_LOGO 0x01 #define DS5W_ISTATE_BTN_B_PAD_BUTTON 0x02 #define DS5W_ISTATE_BTN_B_MIC_BUTTON 0x04 +// Player LED bitmasks #define DS5W_OSTATE_PLAYER_LED_LEFT 0x01 #define DS5W_OSTATE_PLAYER_LED_MIDDLE_LEFT 0x02 #define DS5W_OSTATE_PLAYER_LED_MIDDLE 0x04 @@ -39,386 +45,114 @@ namespace DS5W { - /// - /// Analog stick - /// - typedef struct _AnalogStick { - /// - /// X Position of stick (0 = Center) - /// - char x; - - /// - /// Y Posistion of stick (0 = Center) - /// - char y; - } AnalogStick; - - /// - /// 3 Component vector - /// - typedef struct _Vec3 { - short x; - short y; - short z; - } Vector3, Vec3; - - /// - /// RGB Color - /// - typedef struct _Color { - unsigned char r; - unsigned char g; - unsigned char b; - } Color; - - /// - /// Touchpad state - /// - typedef struct _Touch { - /// - /// X positon of finger (~ 0 - 2000) - /// - unsigned int x; - - /// - /// Y position of finger (~ 0 - 2048) - /// - unsigned int y; - - /// - /// Touch is down - /// - bool down; - - /// - /// 7-bit ID for touch - /// - unsigned char id; - } Touch; - - typedef struct _Battery { - /// - /// Charching state of the battery - /// - bool chargin; - - /// - /// Indicates that the battery is fully charged - /// - bool fullyCharged; - - /// - /// Battery charge level 0x0 to - /// - unsigned char level; - }Battery; - - /// - /// State of the mic led - /// - typedef enum class _MicLed : unsigned char{ - /// - /// Lef is off - /// - OFF = 0x00, - - /// - /// Led is on - /// - ON = 0x01, - - /// - /// Led is pulsing - /// - PULSE = 0x02, - } MicLed; - - /// - /// Type of trigger effect - /// - typedef enum class _TriggerEffectType : unsigned char { - /// - /// No resistance is applied - /// - NoResitance = 0x00, - - /// - /// Continuous Resitance is applied - /// - ContinuousResitance = 0x01, - - /// - /// Seciton resistance is appleyed - /// - SectionResitance = 0x02, - - /// - /// Extended trigger effect - /// - EffectEx = 0x26, - - /// - /// Calibrate triggers - /// - Calibrate = 0xFC, - } TriggerEffectType; - - /// - /// Trigger effect - /// - typedef struct _TriggerEffect { - /// - /// Trigger effect type - /// - TriggerEffectType effectType; - - /// - /// Union for effect parameters - /// - union { - /// - /// Union one raw data - /// - unsigned char _u1_raw[6]; - - /// - /// For type == ContinuousResitance - /// - struct { - /// - /// Start position of resistance - /// - unsigned char startPosition; - - /// - /// Force of resistance - /// - unsigned char force; - - /// - /// PAD / UNUSED - /// - unsigned char _pad[4]; - } Continuous; - - /// - /// For type == SectionResitance - /// - struct { - /// - /// Start position of resistance - /// - unsigned char startPosition; - - /// - /// End position of resistance (>= start) - /// - unsigned char endPosition; - - /// - /// PAD / UNUSED - /// - unsigned char _pad[4]; - } Section; - - /// - /// For type == EffectEx - /// - struct { - /// - /// Position at witch the effect starts - /// - unsigned char startPosition; - - /// - /// Wher the effect should keep playing when trigger goes beyond 255 - /// - bool keepEffect; - - /// - /// Force applied when trigger >= (255 / 2) - /// - unsigned char beginForce; - - /// - /// Force applied when trigger <= (255 / 2) - /// - unsigned char middleForce; - - /// - /// Force applied when trigger is beyond 255 - /// - unsigned char endForce; - - /// - /// Vibration frequency of the trigger - /// - unsigned char frequency; - } EffectEx; - }; - } TriggerEffect; - - /// - /// Led brightness - /// - typedef enum _LedBrightness : unsigned char { - /// - /// Low led brightness - /// - LOW = 0x02, - - /// - /// Medium led brightness - /// - MEDIUM = 0x01, - - /// - /// High led brightness - /// - HIGH = 0x00, - } LedBrightness; - - /// - /// Player leds values - /// - typedef struct _PlayerLeds { - /// - /// Player indication leds bitflag (You may used them for other features) DS5W_OSTATE_PLAYER_LED_??? - /// - unsigned char bitmask; - - /// - /// Indicates weather the player leds should fade in - /// - bool playerLedFade; - - /// - /// Brightness of the player leds - /// - LedBrightness brightness; - } PlayerLeds; - - /// - /// Input state of the controler - /// - typedef struct _DS5InputState { - /// - /// Position of left stick - /// - AnalogStick leftStick; - - /// - /// Posisiton of right stick - /// - AnalogStick rightStick; - - /// - /// Left trigger position - /// - unsigned char leftTrigger; - - /// - /// Right trigger position - /// - unsigned char rightTrigger; - - /// - /// Buttons and dpad bitmask DS5W_ISTATE_BTX_?? and DS5W_ISTATE_DPAD_?? indices check with if(buttonsAndDpad & DS5W_ISTATE_DPAD_??)... - /// - unsigned char buttonsAndDpad; - - /// - /// Button bitmask A (DS5W_ISTATE_BTN_A_??) - /// - unsigned char buttonsA; - - /// - /// Button bitmask B (DS5W_ISTATE_BTN_B_??) - /// - unsigned char buttonsB; - - /// - /// Accelerometer - /// - Vector3 accelerometer; - - /// - /// Gyroscope (Currently only raw values will be dispayed! Probably needs calibration (Will be done within the lib in the future)) - /// - Vector3 gyroscope; - - /// - /// First touch point - /// - Touch touchPoint1; - - /// - /// Second touch point - /// - Touch touchPoint2; - - /// - /// Battery information - /// - Battery battery; - - /// - /// Indicates the connection of headphone - /// - bool headPhoneConnected; - - /// - /// EXPERIMAENTAL: Feedback of the left adaptive trigger (only when trigger effect is active) - /// - unsigned char leftTriggerFeedback; - - /// - /// EXPERIMAENTAL: Feedback of the right adaptive trigger (only when trigger effect is active) - /// - unsigned char rightTriggerFeedback; - } DS5InputState; - - typedef struct _DS5OutputState { - /// - /// Left / Hard rumbel motor - /// - unsigned char leftRumble; - - /// - /// Right / Soft rumbel motor - /// - unsigned char rightRumble; - - /// - /// State of the microphone led - /// - MicLed microphoneLed; - - /// - /// Diables all leds - /// - bool disableLeds; - - /// - /// Player leds - /// - PlayerLeds playerLeds; - - /// - /// Color of the lightbar - /// - Color lightbar; - - /// - /// Effect of left trigger - /// - TriggerEffect leftTriggerEffect; - - /// - /// Effect of right trigger - /// - TriggerEffect rightTriggerEffect; - - } DS5OutputState; -} \ No newline at end of file + struct AnalogStick { + int8_t x; // X Position of stick (0 = Center) + int8_t y; // Y Position of stick (0 = Center) + }; + + struct Vector3 { + int16_t x; + int16_t y; + int16_t z; + }; + + struct Color { + uint8_t r; + uint8_t g; + uint8_t b; + }; + + struct Touch { + uint32_t x; // X position of finger (~ 0 - 2000) + uint32_t y; // Y position of finger (~ 0 - 2048) + bool down; // Touch is down + uint8_t id; // 7-bit ID for touch + }; + + struct Battery { + bool charging; + bool fullyCharged; + uint8_t level; // Battery charge level 0x0 to 0xA + }; + + enum class MicLed : uint8_t { + OFF = 0x00, + ON = 0x01, + PULSE = 0x02, + }; + + enum class TriggerEffectType : uint8_t { + NoResistance = 0x00, + ContinuousResistance = 0x01, + SectionResistance = 0x02, + EffectEx = 0x26, + Calibrate = 0xFC, + }; + + struct TriggerEffect { + TriggerEffectType effectType; + union { + uint8_t _u1_raw[6]; + struct { + uint8_t startPosition; + uint8_t force; + uint8_t _pad[4]; + } Continuous; + struct { + uint8_t startPosition; + uint8_t endPosition; + uint8_t _pad[4]; + } Section; + struct { + uint8_t startPosition; + bool keepEffect; + uint8_t beginForce; + uint8_t middleForce; + uint8_t endForce; + uint8_t frequency; + } EffectEx; + }; + }; + + enum class LedBrightness : uint8_t { + LOW = 0x02, + MEDIUM = 0x01, + HIGH = 0x00, + }; + + struct PlayerLeds { + uint8_t bitmask; + bool playerLedFade; + LedBrightness brightness; + }; + + struct DS5InputState { + AnalogStick leftStick; + AnalogStick rightStick; + uint8_t leftTrigger; + uint8_t rightTrigger; + uint8_t buttonsAndDpad; + uint8_t buttonsA; + uint8_t buttonsB; + Vector3 accelerometer; + Vector3 gyroscope; + Touch touchPoint1; + Touch touchPoint2; + Battery battery; + bool headPhoneConnected; + uint8_t leftTriggerFeedback; + uint8_t rightTriggerFeedback; + }; + + struct DS5OutputState { + uint8_t leftRumble; + uint8_t rightRumble; + MicLed microphoneLed; + bool disableLeds; + PlayerLeds playerLeds; + Color lightbar; + TriggerEffect leftTriggerEffect; + TriggerEffect rightTriggerEffect; + }; + +} // namespace DS5W