mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-26 08:47:10 +02:00
Initial HID PAD work, with GLFW only.
This commit is contained in:
parent
bb7ddede15
commit
4a94ec934a
7 changed files with 309 additions and 26 deletions
|
|
@ -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<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<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:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue