From bb7ddede159d820b6f8b49caf0758940903ece3b Mon Sep 17 00:00:00 2001 From: Kevin Hartman Date: Tue, 2 Sep 2014 22:24:03 -0700 Subject: Created structure for PAD. --- src/core/hle/service/hid.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/core/hle/service/hid.h') diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h index b17fcfa86..6ddf2f80f 100644 --- a/src/core/hle/service/hid.h +++ b/src/core/hle/service/hid.h @@ -5,6 +5,7 @@ #pragma once #include "core/hle/service/service.h" +#include "common/bit_field.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace HID_User @@ -14,6 +15,30 @@ namespace HID_User { +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; + }; +}; + class Interface : public Service::Interface { public: -- cgit v1.2.3 From 4a94ec934ab1a2216f94e3fcc46f5dde1d6e2f02 Mon Sep 17 00:00:00 2001 From: Kevin Hartman Date: Wed, 3 Sep 2014 18:12:58 -0700 Subject: Initial HID PAD work, with GLFW only. --- src/core/hle/service/hid.h | 87 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 17 deletions(-) (limited to 'src/core/hle/service/hid.h') 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 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: -- cgit v1.2.3 From 02fd19b2f60f4db8a683734e4300d7498c861309 Mon Sep 17 00:00:00 2001 From: Kevin Hartman Date: Mon, 8 Sep 2014 21:46:02 -0700 Subject: Added support for multiple input device types for KeyMap and connected Qt. --- src/core/hle/service/hid.h | 80 +++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 36 deletions(-) (limited to 'src/core/hle/service/hid.h') diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h index f5f76f0fc..a077e25cd 100644 --- a/src/core/hle/service/hid.h +++ b/src/core/hle/service/hid.h @@ -10,13 +10,15 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace HID_User -// This service is used for interfacing to physical user controls... perhaps "Human Interface -// Devices"? Uses include game pad controls, accelerometers, gyroscopes, etc. +// This service is used for interfacing to physical user controls. +// Uses include game pad controls, touchscreen, accelerometers, gyroscopes, and debug pad. namespace HID_User { -/// Structure of a PAD controller state -struct PADState { +/** + * Structure of a Pad controller state. + */ +struct PadState { union { u32 hex; @@ -40,58 +42,64 @@ struct PADState { }; }; -/// Structure of a single entry in the PADData's PAD state history array -struct PADDataEntry { - PADState current_state; - PADState delta_additions; - PADState delta_removals; +/** + * 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 { +/** + * 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 index; // the index of the last updated Pad state history element u32 pad1; u32 pad2; - PADState current_state; // same as entries[index].current_state + PadState current_state; // same as entries[index].current_state u32 raw_circle_pad_data; u32 pad3; - std::array entries; // PAD state history + std::array 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}}; +// 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(); +void PadButtonPress(PadState pad_state); +void PadButtonRelease(PadState pad_state); +void PadUpdateComplete(); -/// HID service interface +/** + * HID service interface. + */ class Interface : public Service::Interface { public: -- cgit v1.2.3