CommonLibSSE (powerof3)
BSPCOrbisGamepadDevice.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include "REX/PS4/SCEPAD.h"
6 
7 namespace RE
8 {
9  // PS4 controller used via HID polling
11  {
12  public:
13  inline static constexpr auto RTTI = RTTI_BSPCOrbisGamepadDevice;
14  inline static constexpr auto VTABLE = VTABLE_BSPCOrbisGamepadDevice;
15 
16  struct Keys
17  {
18  enum Key : std::uint32_t
19  {
20  // Masks for buttonState
21  // Key hardware value
27  kPS3_Back = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_TOUCH_PAD, // This is mapped to the touchpad on the PS4 controller
36 
37  // Unused by Skyrim
38  kPS4_Share = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_SHARE, // Skyrim uses the touchpad for Back and leaves the Share button unused
39  kPS4_L2 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_L2, // Skyrim uses trigger axis read instead of button press
40  kPS4_R2 = REX::PS4::SCE_PAD_BUTTON::SCE_PAD_BUTTON_R2, // Skyrim uses trigger axis read instead of button press
42 
43  // arbitrary values
44  // IDs meant to be used with ButtonEvent
45  kPS3_LT = 0x0009,
46  kPS3_RT = 0x000a,
47  // IDs meant to be used with ThumbstickEvent
48  kPS3_LS = 0x000b,
49  kPS3_RS = 0x000c,
50  };
51  };
52  using Key = Keys::Key;
53 
54  struct ButtonState
55  {
56  bool Share: 1; // 0x0001 -- unused by Skyrim
57  bool L3: 1; // 0x0002
58  bool R3: 1; // 0x0004
59  bool Start: 1; // 0x0008
60  bool Up: 1; // 0x0010
61  bool Right: 1; // 0x0020
62  bool Down: 1; // 0x0040
63  bool Left: 1; // 0x0080
64  bool L2btn: 1; // 0x0100 -- unused by Skyrim, which uses axis data
65  bool R2btn: 1; // 0x0200 -- unused by Skyrim, which uses axis data
66  bool LB: 1; // 0x0400
67  bool RB: 1; // 0x0800
68  bool Triangle_Y: 1; // 0x1000
69  bool Circle_B: 1; // 0x2000
70  bool Cross_A: 1; // 0x4000
71  bool Square_X: 1; // 0x8000
72  bool PSbtn: 1; // 0x00010000 -- unused by Skyrim
73  bool _unused20000: 1; // 0x00020000
74  bool _unused40000: 1; // 0x00040000
75  bool _unused80000: 1; // 0x00080000
76  bool Touchpad: 1; // 0x00100000
77  bool _unused200000: 1; // 0x00200000
78  bool _unused400000: 1; // 0x00400000
79  bool _unused800000: 1; // 0x00800000
80  bool _unused1000000: 1; // 0x01000000
81  bool _unused2000000: 1; // 0x02000000
82  bool _unused4000000: 1; // 0x04000000
83  bool _unused8000000: 1; // 0x08000000
84  bool _unused10000000: 1; // 0x10000000
85  bool _unused20000000: 1; // 0x20000000
86  bool _unused40000000: 1; // 0x40000000
87  bool _Intercepted: 1; // 0x80000000
88  };
89  static_assert(sizeof(ButtonState) == 0x4);
90 
91  struct Vector3
92  {
93  float x; // 00
94  float y; // 04
95  float z; // 08
96  };
97  static_assert(sizeof(Vector3) == 0x0C);
98 
99  struct Vector4
100  {
101  float x; // 00
102  float y; // 04
103  float z; // 08
104  float w; // 0C
105  };
106  static_assert(sizeof(Vector4) == 0x10);
107 
108  struct PadTouch
109  {
110  std::uint16_t x; // 00
111  std::uint16_t y; // 02
112  std::uint8_t touch_id; // 04
113  std::uint8_t pad05[3]; // 05
114  };
115  static_assert(sizeof(PadTouch) == 0x08);
116 
118  {
119  std::uint8_t touchNum; // 00 - Number of touch reports
120  std::uint8_t pad01[3]; // 01
121  std::uint32_t pad04; // 04
122  PadTouch touch[2]; // 08 - Touch Data for max number of touch points = 2
123  };
124  static_assert(sizeof(TouchPadData) == 0x18);
125 
127  {
128  std::uint32_t extUnitId; // 00
129  std::uint8_t pad04; // 04
130  std::uint8_t dataLength; // 05
131  std::uint8_t data[10]; // 06
132  };
133  static_assert(sizeof(UnusedExtensionData) == 0x10);
134 
135  struct GamepadData
136  {
137  std::uint32_t buttonState; // 00
138  std::byte rawLeftStickX; // 04
139  std::byte rawLeftStickY; // 05
140  std::byte rawRightStickX; // 06
141  std::byte rawRightStickY; // 07
142  std::byte rawLeftTrigger; // 08
143  std::byte rawRightTrigger; // 09
144  std::byte pad0A[2]; // 0A
149  bool padConnected; // 4C
150  std::byte pad4D[3]; // 4D
151  std::uint64_t timestamp; // 50
153  std::uint8_t connectedCount; // 68 -- Controller handle connected count
154  std::uint8_t pad69[2]; // 69
155  std::uint8_t specialDataLen; // 6B
156  std::uint8_t specialData[12]; // 6C -- Device data for special controllers
157  };
158  static_assert(sizeof(GamepadData) == 0x78);
159 
160  ~BSPCOrbisGamepadDevice() override; // 00
161 
162  // override (BSPCGamepadDeviceDelegate)
163  void Initialize() override; // 01
164  void Process(float a_arg1) override; // 02
165  void Release() override; // 03
166  void Reset() override; // 08 - { memset(this+0xD8, 0, 0x120); }
167  void SetRumble(float lValue, float rValue) override; // 09
168  void SetLEDColor(ColorParam* colorParam) override; // 0A
169  void ResetLEDColor() override; // 0B
170  void ProcessRawInput(int32_t a_rawX, int32_t a_rawY, float& a_outX, float& a_outY) override; // 0D
171  void Unk_0E(void) override; // 0E - { return; }
172 
174  {
175  return stl::unrestricted_cast<ButtonState>(previousPadState.buttonState);
176  }
178  {
179  return stl::unrestricted_cast<ButtonState>(currentPadState.buttonState);
180  }
181 
182  // members
184  float previousLT; // 150
185  float previousRT; // 154
186  float previousLX; // 158
187  float previousLY; // 15C
188  float previousRX; // 160
189  float previousRY; // 164
191  float currentLT; // 1E0
192  float currentRT; // 1E4
193  float currentLX; // 1E8
194  float currentLY; // 1EC
195  float currentRX; // 1F0
196  float currentRY; // 1F4
197 
198  protected:
201  };
202  static_assert(sizeof(BSPCOrbisGamepadDevice) == 0x1F8);
203 }
Definition: BSPCGamepadDeviceDelegate.h:10
Definition: BSPCOrbisGamepadDevice.h:11
float previousRT
Definition: BSPCOrbisGamepadDevice.h:185
GamepadData previousPadState
Definition: BSPCOrbisGamepadDevice.h:183
float previousRX
Definition: BSPCOrbisGamepadDevice.h:188
float previousLX
Definition: BSPCOrbisGamepadDevice.h:186
static constexpr auto RTTI
Definition: BSPCOrbisGamepadDevice.h:13
void SetLEDColor(ColorParam *colorParam) override
float currentLY
Definition: BSPCOrbisGamepadDevice.h:194
ButtonState GetPreviousButtonState() const
Definition: BSPCOrbisGamepadDevice.h:173
void ProcessRawInput(int32_t a_rawX, int32_t a_rawY, float &a_outX, float &a_outY) override
static constexpr auto VTABLE
Definition: BSPCOrbisGamepadDevice.h:14
GamepadData currentPadState
Definition: BSPCOrbisGamepadDevice.h:190
void Initialize() override
float currentLX
Definition: BSPCOrbisGamepadDevice.h:193
float previousLT
Definition: BSPCOrbisGamepadDevice.h:184
float previousLY
Definition: BSPCOrbisGamepadDevice.h:187
float currentRX
Definition: BSPCOrbisGamepadDevice.h:195
void ResetLEDColor() override
float currentRY
Definition: BSPCOrbisGamepadDevice.h:196
float previousRY
Definition: BSPCOrbisGamepadDevice.h:189
~BSPCOrbisGamepadDevice() override
ButtonState GetCurrentButtonState() const
Definition: BSPCOrbisGamepadDevice.h:177
void Unk_0E(void) override
void Process(float a_arg1) override
void SetRumble(float lValue, float rValue) override
float currentRT
Definition: BSPCOrbisGamepadDevice.h:192
float currentLT
Definition: BSPCOrbisGamepadDevice.h:191
friend class BSGamepadDeviceHandler
Definition: BSPCOrbisGamepadDevice.h:199
@ SCE_PAD_BUTTON_R3
Definition: SCEPAD.h:9
@ SCE_PAD_BUTTON_L1
Definition: SCEPAD.h:17
@ SCE_PAD_BUTTON_SHARE
Definition: SCEPAD.h:7
@ SCE_PAD_BUTTON_CROSS
Definition: SCEPAD.h:21
@ SCE_PAD_BUTTON_R1
Definition: SCEPAD.h:18
@ SCE_PAD_BUTTON_DOWN
Definition: SCEPAD.h:13
@ SCE_PAD_BUTTON_UP
Definition: SCEPAD.h:11
@ SCE_PAD_BUTTON_OPTIONS
Definition: SCEPAD.h:10
@ SCE_PAD_BUTTON_L3
Definition: SCEPAD.h:8
@ SCE_PAD_BUTTON_L2
Definition: SCEPAD.h:15
@ SCE_PAD_BUTTON_RIGHT
Definition: SCEPAD.h:12
@ SCE_PAD_BUTTON_TRIANGLE
Definition: SCEPAD.h:19
@ SCE_PAD_BUTTON_LEFT
Definition: SCEPAD.h:14
@ SCE_PAD_BUTTON_R2
Definition: SCEPAD.h:16
@ SCE_PAD_BUTTON_PLAYSTATION
Definition: SCEPAD.h:23
@ SCE_PAD_BUTTON_TOUCH_PAD
Definition: SCEPAD.h:24
@ SCE_PAD_BUTTON_CIRCLE
Definition: SCEPAD.h:20
@ SCE_PAD_BUTTON_SQUARE
Definition: SCEPAD.h:22
Definition: AbsorbEffect.h:6
constexpr std::array< REL::ID, 1 > VTABLE_BSPCOrbisGamepadDevice
Definition: Offsets_VTABLE.h:9292
constexpr REL::ID RTTI_BSPCOrbisGamepadDevice(static_cast< std::uint64_t >(690318))
Definition: BSGamepadDevice.h:19
Definition: BSPCOrbisGamepadDevice.h:55
bool Cross_A
Definition: BSPCOrbisGamepadDevice.h:70
bool L2btn
Definition: BSPCOrbisGamepadDevice.h:64
bool R3
Definition: BSPCOrbisGamepadDevice.h:58
bool Down
Definition: BSPCOrbisGamepadDevice.h:62
bool _Intercepted
Definition: BSPCOrbisGamepadDevice.h:87
bool Up
Definition: BSPCOrbisGamepadDevice.h:60
bool _unused200000
Definition: BSPCOrbisGamepadDevice.h:77
bool _unused80000
Definition: BSPCOrbisGamepadDevice.h:75
bool RB
Definition: BSPCOrbisGamepadDevice.h:67
bool _unused2000000
Definition: BSPCOrbisGamepadDevice.h:81
bool _unused800000
Definition: BSPCOrbisGamepadDevice.h:79
bool Circle_B
Definition: BSPCOrbisGamepadDevice.h:69
bool L3
Definition: BSPCOrbisGamepadDevice.h:57
bool Start
Definition: BSPCOrbisGamepadDevice.h:59
bool _unused8000000
Definition: BSPCOrbisGamepadDevice.h:83
bool Touchpad
Definition: BSPCOrbisGamepadDevice.h:76
bool R2btn
Definition: BSPCOrbisGamepadDevice.h:65
bool _unused40000000
Definition: BSPCOrbisGamepadDevice.h:86
bool Right
Definition: BSPCOrbisGamepadDevice.h:61
bool _unused10000000
Definition: BSPCOrbisGamepadDevice.h:84
bool Left
Definition: BSPCOrbisGamepadDevice.h:63
bool _unused40000
Definition: BSPCOrbisGamepadDevice.h:74
bool LB
Definition: BSPCOrbisGamepadDevice.h:66
bool PSbtn
Definition: BSPCOrbisGamepadDevice.h:72
bool _unused20000
Definition: BSPCOrbisGamepadDevice.h:73
bool Triangle_Y
Definition: BSPCOrbisGamepadDevice.h:68
bool _unused400000
Definition: BSPCOrbisGamepadDevice.h:78
bool Share
Definition: BSPCOrbisGamepadDevice.h:56
bool _unused20000000
Definition: BSPCOrbisGamepadDevice.h:85
bool _unused4000000
Definition: BSPCOrbisGamepadDevice.h:82
bool Square_X
Definition: BSPCOrbisGamepadDevice.h:71
bool _unused1000000
Definition: BSPCOrbisGamepadDevice.h:80
Definition: BSPCOrbisGamepadDevice.h:136
std::uint32_t buttonState
Definition: BSPCOrbisGamepadDevice.h:137
std::byte rawRightStickY
Definition: BSPCOrbisGamepadDevice.h:141
std::uint8_t pad69[2]
Definition: BSPCOrbisGamepadDevice.h:154
Vector4 orientation
Definition: BSPCOrbisGamepadDevice.h:145
std::byte pad0A[2]
Definition: BSPCOrbisGamepadDevice.h:144
std::uint8_t specialData[12]
Definition: BSPCOrbisGamepadDevice.h:156
std::byte rawLeftTrigger
Definition: BSPCOrbisGamepadDevice.h:142
std::uint64_t timestamp
Definition: BSPCOrbisGamepadDevice.h:151
std::uint8_t specialDataLen
Definition: BSPCOrbisGamepadDevice.h:155
UnusedExtensionData unusedExtData
Definition: BSPCOrbisGamepadDevice.h:152
std::byte rawLeftStickX
Definition: BSPCOrbisGamepadDevice.h:138
TouchPadData touchPadData
Definition: BSPCOrbisGamepadDevice.h:148
std::byte rawRightTrigger
Definition: BSPCOrbisGamepadDevice.h:143
std::byte rawRightStickX
Definition: BSPCOrbisGamepadDevice.h:140
std::uint8_t connectedCount
Definition: BSPCOrbisGamepadDevice.h:153
std::byte pad4D[3]
Definition: BSPCOrbisGamepadDevice.h:150
Vector3 angularVelocity
Definition: BSPCOrbisGamepadDevice.h:147
bool padConnected
Definition: BSPCOrbisGamepadDevice.h:149
std::byte rawLeftStickY
Definition: BSPCOrbisGamepadDevice.h:139
Vector3 acceleration
Definition: BSPCOrbisGamepadDevice.h:146
Definition: BSPCOrbisGamepadDevice.h:17
Key
Definition: BSPCOrbisGamepadDevice.h:19
@ kPS3_R3
Definition: BSPCOrbisGamepadDevice.h:29
@ kPS3_LT
Definition: BSPCOrbisGamepadDevice.h:45
@ kPS3_RB
Definition: BSPCOrbisGamepadDevice.h:31
@ kLeft
Definition: BSPCOrbisGamepadDevice.h:24
@ kPS3_B
Definition: BSPCOrbisGamepadDevice.h:33
@ kUp
Definition: BSPCOrbisGamepadDevice.h:22
@ kPS3_RS
Definition: BSPCOrbisGamepadDevice.h:49
@ kPS3_Y
Definition: BSPCOrbisGamepadDevice.h:35
@ kRight
Definition: BSPCOrbisGamepadDevice.h:25
@ kPS3_X
Definition: BSPCOrbisGamepadDevice.h:34
@ kDown
Definition: BSPCOrbisGamepadDevice.h:23
@ kPS3_Start
Definition: BSPCOrbisGamepadDevice.h:26
@ kPS4_R2
Definition: BSPCOrbisGamepadDevice.h:40
@ kPS4_L2
Definition: BSPCOrbisGamepadDevice.h:39
@ kPS4_PSBtn
Definition: BSPCOrbisGamepadDevice.h:41
@ kPS3_Back
Definition: BSPCOrbisGamepadDevice.h:27
@ kPS4_Share
Definition: BSPCOrbisGamepadDevice.h:38
@ kPS3_LS
Definition: BSPCOrbisGamepadDevice.h:48
@ kPS3_A
Definition: BSPCOrbisGamepadDevice.h:32
@ kPS3_L3
Definition: BSPCOrbisGamepadDevice.h:28
@ kPS3_LB
Definition: BSPCOrbisGamepadDevice.h:30
@ kPS3_RT
Definition: BSPCOrbisGamepadDevice.h:46
Definition: BSPCOrbisGamepadDevice.h:109
std::uint8_t touch_id
Definition: BSPCOrbisGamepadDevice.h:112
std::uint16_t y
Definition: BSPCOrbisGamepadDevice.h:111
std::uint8_t pad05[3]
Definition: BSPCOrbisGamepadDevice.h:113
std::uint16_t x
Definition: BSPCOrbisGamepadDevice.h:110
Definition: BSPCOrbisGamepadDevice.h:118
PadTouch touch[2]
Definition: BSPCOrbisGamepadDevice.h:122
std::uint8_t pad01[3]
Definition: BSPCOrbisGamepadDevice.h:120
std::uint8_t touchNum
Definition: BSPCOrbisGamepadDevice.h:119
std::uint32_t pad04
Definition: BSPCOrbisGamepadDevice.h:121
Definition: BSPCOrbisGamepadDevice.h:127
std::uint32_t extUnitId
Definition: BSPCOrbisGamepadDevice.h:128
std::uint8_t dataLength
Definition: BSPCOrbisGamepadDevice.h:130
std::uint8_t pad04
Definition: BSPCOrbisGamepadDevice.h:129
std::uint8_t data[10]
Definition: BSPCOrbisGamepadDevice.h:131
Definition: BSPCOrbisGamepadDevice.h:92
float x
Definition: BSPCOrbisGamepadDevice.h:93
float z
Definition: BSPCOrbisGamepadDevice.h:95
float y
Definition: BSPCOrbisGamepadDevice.h:94
Definition: BSPCOrbisGamepadDevice.h:100
float y
Definition: BSPCOrbisGamepadDevice.h:102
float z
Definition: BSPCOrbisGamepadDevice.h:103
float x
Definition: BSPCOrbisGamepadDevice.h:101
float w
Definition: BSPCOrbisGamepadDevice.h:104