CommonLibSSE (powerof3)
BSWin32GamepadDevice.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include "REX/W32/XINPUT.h"
6 
7 namespace RE
8 {
10  {
11  public:
12  inline static constexpr auto RTTI = RTTI_BSWin32GamepadDevice;
13  inline static constexpr auto VTABLE = VTABLE_BSWin32GamepadDevice;
14 
15  struct Keys
16  {
17  enum Key : std::uint32_t
18  {
19  // button masks for wButtons
34 
35  // arbitrary values
36  // IDs meant to be used with ButtonEvent
37  kLeftTrigger = 0x0009,
38  kRightTrigger = 0x000A,
39  // IDs meant to be used with ThumbstickEvent
40  kLeftStick = 0x000B,
41  kRightStick = 0x000C
42  };
43  };
44  using Key = Keys::Key;
45 
46  struct ButtonState
47  {
48  bool up: 1; // 0x0001
49  bool down: 1; // 0x0002
50  bool left: 1; // 0x0004
51  bool right: 1; // 0x0008
52  bool start: 1; // 0x0010
53  bool back: 1; // 0x0020
54  bool leftThumb: 1; // 0x0040
55  bool rightThumb: 1; // 0x0080
56  bool leftShoulder: 1; // 0x0100
57  bool rightShoulder: 3; // 0x0200, skip over 2 bits (XInput documentation says the state of these two bits are undefined)
58  bool a: 1; // 0x1000
59  bool b: 1; // 0x2000
60  bool x: 1; // 0x4000
61  bool y: 1; // 0x8000
62  };
63 
64  ~BSWin32GamepadDevice() override; // 00
65 
66  // override (BSPCGamepadDeviceDelegate)
67  void Initialize() override; // 01
68  void Process(float a_arg1) override; // 02
69  void Release() override; // 03 - { return; }
70  void Reset() override; // 08 - { std::memset(&unk0D8, 0, 0x50); }
71  void SetRumble(float lValue, float rValue) override; // 09 - { return; }
72 
73  // Returns the previous ButtonState of the gamepad
75  {
76  return stl::unrestricted_cast<ButtonState>(previousState.gamepad.buttons & REX::W32::XINPUT_GAMEPAD_BUTTON_MASK);
77  }
78 
79  // Returns the current ButtonState of the gamepad
81  {
82  return stl::unrestricted_cast<ButtonState>(currentState.gamepad.buttons & REX::W32::XINPUT_GAMEPAD_BUTTON_MASK);
83  }
84 
85  // members
87  float previousLT; // 0E8
88  float previousRT; // 0EC
89  float previousLX; // 0F0
90  float previousLY; // 0F4
91  float previousRX; // 0F8
92  float previousRY; // 0FC
94  float currentLT; // 110
95  float currentRT; // 114
96  float currentLX; // 118
97  float currentLY; // 11C
98  float currentRX; // 120
99  float currentRY; // 124
100 
101  protected:
104  };
105  static_assert(sizeof(BSWin32GamepadDevice) == 0x128);
106 }
Definition: BSPCGamepadDeviceDelegate.h:10
Definition: BSWin32GamepadDevice.h:10
float currentRX
Definition: BSWin32GamepadDevice.h:98
float previousLT
Definition: BSWin32GamepadDevice.h:87
float previousRY
Definition: BSWin32GamepadDevice.h:92
float previousRX
Definition: BSWin32GamepadDevice.h:91
float currentLY
Definition: BSWin32GamepadDevice.h:97
static constexpr auto VTABLE
Definition: BSWin32GamepadDevice.h:13
~BSWin32GamepadDevice() override
float currentRT
Definition: BSWin32GamepadDevice.h:95
float previousLY
Definition: BSWin32GamepadDevice.h:90
float currentRY
Definition: BSWin32GamepadDevice.h:99
float previousLX
Definition: BSWin32GamepadDevice.h:89
float currentLX
Definition: BSWin32GamepadDevice.h:96
static constexpr auto RTTI
Definition: BSWin32GamepadDevice.h:12
ButtonState GetPreviousButtonState() const
Definition: BSWin32GamepadDevice.h:74
float currentLT
Definition: BSWin32GamepadDevice.h:94
ButtonState GetCurrentButtonState() const
Definition: BSWin32GamepadDevice.h:80
REX::W32::XINPUT_STATE currentState
Definition: BSWin32GamepadDevice.h:93
void Process(float a_arg1) override
void SetRumble(float lValue, float rValue) override
float previousRT
Definition: BSWin32GamepadDevice.h:88
void Release() override
void Initialize() override
REX::W32::XINPUT_STATE previousState
Definition: BSWin32GamepadDevice.h:86
void Reset() override
friend class BSGamepadDeviceHandler
Definition: BSWin32GamepadDevice.h:102
@ XINPUT_GAMEPAD_A
Definition: XINPUT.h:24
@ XINPUT_GAMEPAD_BUTTON_MASK
Definition: XINPUT.h:28
@ XINPUT_GAMEPAD_DPAD_LEFT
Definition: XINPUT.h:16
@ XINPUT_GAMEPAD_Y
Definition: XINPUT.h:27
@ XINPUT_GAMEPAD_LEFT_THUMB
Definition: XINPUT.h:20
@ XINPUT_GAMEPAD_RIGHT_SHOULDER
Definition: XINPUT.h:23
@ XINPUT_GAMEPAD_START
Definition: XINPUT.h:18
@ XINPUT_GAMEPAD_RIGHT_THUMB
Definition: XINPUT.h:21
@ XINPUT_GAMEPAD_B
Definition: XINPUT.h:25
@ XINPUT_GAMEPAD_BACK
Definition: XINPUT.h:19
@ XINPUT_GAMEPAD_DPAD_RIGHT
Definition: XINPUT.h:17
@ XINPUT_GAMEPAD_DPAD_UP
Definition: XINPUT.h:14
@ XINPUT_GAMEPAD_X
Definition: XINPUT.h:26
@ XINPUT_GAMEPAD_DPAD_DOWN
Definition: XINPUT.h:15
@ XINPUT_GAMEPAD_LEFT_SHOULDER
Definition: XINPUT.h:22
Definition: AbsorbEffect.h:6
constexpr std::array< REL::ID, 1 > VTABLE_BSWin32GamepadDevice
Definition: Offsets_VTABLE.h:10570
constexpr REL::ID RTTI_BSWin32GamepadDevice(static_cast< std::uint64_t >(690317))
std::uint16_t buttons
Definition: XINPUT.h:42
Definition: XINPUT.h:61
XINPUT_GAMEPAD gamepad
Definition: XINPUT.h:63
Definition: BSWin32GamepadDevice.h:47
bool y
Definition: BSWin32GamepadDevice.h:61
bool b
Definition: BSWin32GamepadDevice.h:59
bool rightThumb
Definition: BSWin32GamepadDevice.h:55
bool left
Definition: BSWin32GamepadDevice.h:50
bool leftShoulder
Definition: BSWin32GamepadDevice.h:56
bool back
Definition: BSWin32GamepadDevice.h:53
bool down
Definition: BSWin32GamepadDevice.h:49
bool leftThumb
Definition: BSWin32GamepadDevice.h:54
bool a
Definition: BSWin32GamepadDevice.h:58
bool rightShoulder
Definition: BSWin32GamepadDevice.h:57
bool start
Definition: BSWin32GamepadDevice.h:52
bool x
Definition: BSWin32GamepadDevice.h:60
bool up
Definition: BSWin32GamepadDevice.h:48
bool right
Definition: BSWin32GamepadDevice.h:51
Definition: BSWin32GamepadDevice.h:16
Key
Definition: BSWin32GamepadDevice.h:18
@ kUp
Definition: BSWin32GamepadDevice.h:20
@ kRightThumb
Definition: BSWin32GamepadDevice.h:27
@ kRight
Definition: BSWin32GamepadDevice.h:23
@ kB
Definition: BSWin32GamepadDevice.h:31
@ kLeftThumb
Definition: BSWin32GamepadDevice.h:26
@ kDown
Definition: BSWin32GamepadDevice.h:21
@ kA
Definition: BSWin32GamepadDevice.h:30
@ kLeft
Definition: BSWin32GamepadDevice.h:22
@ kBack
Definition: BSWin32GamepadDevice.h:25
@ kY
Definition: BSWin32GamepadDevice.h:33
@ kRightTrigger
Definition: BSWin32GamepadDevice.h:38
@ kLeftTrigger
Definition: BSWin32GamepadDevice.h:37
@ kRightShoulder
Definition: BSWin32GamepadDevice.h:29
@ kLeftStick
Definition: BSWin32GamepadDevice.h:40
@ kX
Definition: BSWin32GamepadDevice.h:32
@ kStart
Definition: BSWin32GamepadDevice.h:24
@ kRightStick
Definition: BSWin32GamepadDevice.h:41
@ kLeftShoulder
Definition: BSWin32GamepadDevice.h:28