diff options
author | Kevin Hartman <kevin@hart.mn> | 2014-09-04 03:12:58 +0200 |
---|---|---|
committer | Kevin Hartman <kevin@hart.mn> | 2014-09-12 07:43:42 +0200 |
commit | 4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02 (patch) | |
tree | 2588f0c6051c9a5e3f23057d2953c35a854dbc43 /src/core/hle/service/hid.h | |
parent | Created structure for PAD. (diff) | |
download | yuzu-4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02.tar yuzu-4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02.tar.gz yuzu-4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02.tar.bz2 yuzu-4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02.tar.lz yuzu-4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02.tar.xz yuzu-4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02.tar.zst yuzu-4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02.zip |
Diffstat (limited to 'src/core/hle/service/hid.h')
-rw-r--r-- | src/core/hle/service/hid.h | 87 |
1 files changed, 70 insertions, 17 deletions
diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h index 6ddf2f80f..f5f76f0fc 100644 --- a/src/core/hle/service/hid.h +++ b/src/core/hle/service/hid.h @@ -15,30 +15,83 @@ namespace HID_User { +/// Structure of a PAD controller state struct PADState { union { u32 hex; - BitField<0, 1, u32> A; - BitField<1, 1, u32> B; - BitField<2, 1, u32> Select; - BitField<3, 1, u32> Start; - BitField<4, 1, u32> Right; - BitField<5, 1, u32> Left; - BitField<6, 1, u32> Up; - BitField<7, 1, u32> Down; - BitField<8, 1, u32> R; - BitField<9, 1, u32> L; - BitField<10, 1, u32> X; - BitField<11, 1, u32> Y; - - BitField<28, 1, u32> CircleRight; - BitField<29, 1, u32> CircleLeft; - BitField<30, 1, u32> CircleUp; - BitField<31, 1, u32> CircleDown; + BitField<0, 1, u32> a; + BitField<1, 1, u32> b; + BitField<2, 1, u32> select; + BitField<3, 1, u32> start; + BitField<4, 1, u32> right; + BitField<5, 1, u32> left; + BitField<6, 1, u32> up; + BitField<7, 1, u32> down; + BitField<8, 1, u32> r; + BitField<9, 1, u32> l; + BitField<10, 1, u32> x; + BitField<11, 1, u32> y; + + BitField<28, 1, u32> circle_right; + BitField<29, 1, u32> circle_left; + BitField<30, 1, u32> circle_up; + BitField<31, 1, u32> circle_down; }; }; +/// Structure of a single entry in the PADData's PAD state history array +struct PADDataEntry { + PADState current_state; + PADState delta_additions; + PADState delta_removals; + + s16 circle_pad_x; + s16 circle_pad_y; +}; + +/// Structure of all data related to the 3DS Pad +struct PADData { + s64 index_reset_ticks; + s64 index_reset_ticks_previous; + u32 index; // the index of the last updated PAD state history element + + u32 pad1; + u32 pad2; + + PADState current_state; // same as entries[index].current_state + u32 raw_circle_pad_data; + + u32 pad3; + + std::array<PADDataEntry, 8> entries; // PAD state history +}; + +// Pre-defined PADStates for single button presses +const PADState PAD_NONE = {{0}}; +const PADState PAD_A = {{1u << 0}}; +const PADState PAD_B = {{1u << 1}}; +const PADState PAD_SELECT = {{1u << 2}}; +const PADState PAD_START = {{1u << 3}}; +const PADState PAD_RIGHT = {{1u << 4}}; +const PADState PAD_LEFT = {{1u << 5}}; +const PADState PAD_UP = {{1u << 6}}; +const PADState PAD_DOWN = {{1u << 7}}; +const PADState PAD_R = {{1u << 8}}; +const PADState PAD_L = {{1u << 9}}; +const PADState PAD_X = {{1u << 10}}; +const PADState PAD_Y = {{1u << 11}}; +const PADState PAD_CIRCLE_RIGHT = {{1u << 28}}; +const PADState PAD_CIRCLE_LEFT = {{1u << 29}}; +const PADState PAD_CIRCLE_UP = {{1u << 30}}; +const PADState PAD_CIRCLE_DOWN = {{1u << 31}}; + +// Methods for updating the HID module's state +void PADButtonPress(PADState pad_state); +void PADButtonRelease(PADState pad_state); +void PADUpdateComplete(); + +/// HID service interface class Interface : public Service::Interface { public: |