diff options
Diffstat (limited to 'src/core/hle/service/hid/controllers/xpad.h')
-rw-r--r-- | src/core/hle/service/hid/controllers/xpad.h | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/src/core/hle/service/hid/controllers/xpad.h b/src/core/hle/service/hid/controllers/xpad.h index ad229787c..5b59961bd 100644 --- a/src/core/hle/service/hid/controllers/xpad.h +++ b/src/core/hle/service/hid/controllers/xpad.h @@ -4,6 +4,7 @@ #pragma once +#include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" #include "common/swap.h" @@ -28,6 +29,67 @@ public: void OnLoadInputDevices() override; private: + struct Attributes { + union { + u32_le raw{}; + BitField<0, 1, u32> is_connected; + BitField<1, 1, u32> is_wired; + BitField<2, 1, u32> is_left_connected; + BitField<3, 1, u32> is_left_wired; + BitField<4, 1, u32> is_right_connected; + BitField<5, 1, u32> is_right_wired; + }; + }; + static_assert(sizeof(Attributes) == 4, "Attributes is an invalid size"); + + struct Buttons { + union { + u32_le raw{}; + // Button states + BitField<0, 1, u32> a; + BitField<1, 1, u32> b; + BitField<2, 1, u32> x; + BitField<3, 1, u32> y; + BitField<4, 1, u32> l_stick; + BitField<5, 1, u32> r_stick; + BitField<6, 1, u32> l; + BitField<7, 1, u32> r; + BitField<8, 1, u32> zl; + BitField<9, 1, u32> zr; + BitField<10, 1, u32> plus; + BitField<11, 1, u32> minus; + + // D-Pad + BitField<12, 1, u32> d_left; + BitField<13, 1, u32> d_up; + BitField<14, 1, u32> d_right; + BitField<15, 1, u32> d_down; + + // Left JoyStick + BitField<16, 1, u32> l_stick_left; + BitField<17, 1, u32> l_stick_up; + BitField<18, 1, u32> l_stick_right; + BitField<19, 1, u32> l_stick_down; + + // Right JoyStick + BitField<20, 1, u32> r_stick_left; + BitField<21, 1, u32> r_stick_up; + BitField<22, 1, u32> r_stick_right; + BitField<23, 1, u32> r_stick_down; + + // Not always active? + BitField<24, 1, u32> left_sl; + BitField<25, 1, u32> left_sr; + + BitField<26, 1, u32> right_sl; + BitField<27, 1, u32> right_sr; + + BitField<28, 1, u32> palma; + BitField<30, 1, u32> handheld_left_b; + }; + }; + static_assert(sizeof(Buttons) == 4, "Buttons is an invalid size"); + struct AnalogStick { s32_le x; s32_le y; @@ -37,10 +99,10 @@ private: struct XPadState { s64_le sampling_number; s64_le sampling_number2; - s32_le attributes; - u32_le pad_states; - AnalogStick x_stick; - AnalogStick y_stick; + Attributes attributes; + Buttons pad_states; + AnalogStick l_stick; + AnalogStick r_stick; }; static_assert(sizeof(XPadState) == 0x28, "XPadState is an invalid size"); |