commonlibsse_ng\re\b/
BSWin32GamepadDevice.rs

1use crate::re::offsets_rtti::RTTI_BSWin32GamepadDevice;
2use crate::re::offsets_vtable::VTABLE_BSWin32GamepadDevice;
3use crate::rel::id::VariantID;
4use windows::Win32::UI::Input::XboxController::XINPUT_STATE;
5
6#[repr(C)]
7#[derive(Debug, PartialEq)]
8pub struct BSWin32GamepadDevice {
9    pub __base: [u8; 0xd8], // BSPCGamepadDeviceDelegate
10
11    previousState: XINPUT_STATE, // 0x0D8
12    previousLT: f32,             // 0x0E8
13    previousRT: f32,             // 0x0EC
14    previousLX: f32,             // 0x0F0
15    previousLY: f32,             // 0x0F4
16    previousRX: f32,             // 0x0F8
17    previousRY: f32,             // 0x0FC
18    currentState: XINPUT_STATE,  // 0x100
19    currentLT: f32,              // 0x110
20    currentRT: f32,              // 0x114
21    currentLX: f32,              // 0x118
22    currentLY: f32,              // 0x11C
23    currentRX: f32,              // 0x120
24    currentRY: f32,              // 0x124
25}
26const _: () = assert!(core::mem::size_of::<BSWin32GamepadDevice>() == 0x128);
27
28impl BSWin32GamepadDevice {
29    /// Address & offset of RTTI for `BSWin32GamepadDevice`.
30    pub const RTTI: VariantID = RTTI_BSWin32GamepadDevice;
31
32    /// Address & offset of Virtual function table.
33    pub const VTABLE: [VariantID; 1] = VTABLE_BSWin32GamepadDevice;
34}
35
36/// Button masks for wButtons
37#[commonlibsse_ng_derive_internal::ffi_enum]
38#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
39#[repr(u32)]
40pub enum Key {
41    Up = 0x0001,
42    Down = 0x0002,
43    Left = 0x0004,
44    Right = 0x0008,
45    Start = 0x0010,
46    Back = 0x0020,
47    LeftThumb = 0x0040,
48    RightThumb = 0x0080,
49    LeftShoulder = 0x0100,
50    RightShoulder = 0x0200,
51    A = 0x1000,
52    B = 0x2000,
53    X = 0x4000,
54    Y = 0x8000,
55
56    // arbitrary values
57    // IDs meant to be used with ButtonEvent
58    LeftTrigger = 0x0009,
59    RightTrigger = 0x000A,
60
61    // IDs meant to be used with ThumbStickEvent
62    LeftStick = 0x000B,
63    RightStick = 0x000C,
64}
65
66#[commonlibsse_ng_derive_internal::to_bitflags]
67#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
68pub enum ButtonState {
69    up = 0x0001,
70    down = 0x0002,
71    left = 0x0004,
72    right = 0x0008,
73    start = 0x0010,
74    back = 0x0020,
75    leftThumb = 0x0040,
76    rightThumb = 0x0080,
77    leftShoulder = 0x0100,
78    /// skip over 2 bits (XInput documentation says the state of these two bits are undefined)
79    rightShoulder = 0x0200,
80    a = 0x1000,
81    b = 0x2000,
82    x = 0x4000,
83    y = 0x8000,
84}