Skip to content
Snippets Groups Projects
Commit 0a966e2c authored by Morph's avatar Morph
Browse files

controllers/npad: Add DeviceHandle struct

A DeviceHandle describes a vibration device or six-axis sensor based on the npad type, npad id, and device index/position
parent ceb7b11f
No related branches found
No related tags found
No related merge requests found
...@@ -39,28 +39,30 @@ public: ...@@ -39,28 +39,30 @@ public:
// Called when input devices should be loaded // Called when input devices should be loaded
void OnLoadInputDevices() override; void OnLoadInputDevices() override;
struct NPadType { enum class NPadControllerType {
union { None,
u32_le raw{}; ProController,
Handheld,
BitField<0, 1, u32> pro_controller; JoyDual,
BitField<1, 1, u32> handheld; JoyLeft,
BitField<2, 1, u32> joycon_dual; JoyRight,
BitField<3, 1, u32> joycon_left; Pokeball,
BitField<4, 1, u32> joycon_right; };
BitField<6, 1, u32> pokeball; // TODO(ogniK): Confirm when possible enum class NpadType : u8 {
}; ProController = 3,
Handheld = 4,
JoyconDual = 5,
JoyconLeft = 6,
JoyconRight = 7,
Pokeball = 9,
}; };
static_assert(sizeof(NPadType) == 4, "NPadType is an invalid size");
struct Vibration { enum class DeviceIndex : u8 {
f32 amp_low; Left = 0,
f32 freq_low; Right = 1,
f32 amp_high; None = 2,
f32 freq_high;
}; };
static_assert(sizeof(Vibration) == 0x10, "Vibration is an invalid size");
enum class GyroscopeZeroDriftMode : u32 { enum class GyroscopeZeroDriftMode : u32 {
Loose = 0, Loose = 0,
...@@ -73,7 +75,7 @@ public: ...@@ -73,7 +75,7 @@ public:
Horizontal = 1, Horizontal = 1,
}; };
enum class NPadAssignments : u32_le { enum class NPadAssignments : u32 {
Dual = 0, Dual = 0,
Single = 1, Single = 1,
}; };
...@@ -84,15 +86,36 @@ public: ...@@ -84,15 +86,36 @@ public:
None = 2, None = 2,
}; };
enum class NPadControllerType { struct DeviceHandle {
None, NpadType npad_type{};
ProController, u8 npad_id{};
Handheld, DeviceIndex device_index{};
JoyDual, INSERT_PADDING_BYTES(1);
JoyLeft,
JoyRight,
Pokeball,
}; };
static_assert(sizeof(DeviceHandle) == 4, "DeviceHandle is an invalid size");
struct NPadType {
union {
u32_le raw{};
BitField<0, 1, u32> pro_controller;
BitField<1, 1, u32> handheld;
BitField<2, 1, u32> joycon_dual;
BitField<3, 1, u32> joycon_left;
BitField<4, 1, u32> joycon_right;
BitField<6, 1, u32> pokeball; // TODO(ogniK): Confirm when possible
};
};
static_assert(sizeof(NPadType) == 4, "NPadType is an invalid size");
struct Vibration {
f32 amp_low;
f32 freq_low;
f32 amp_high;
f32 freq_high;
};
static_assert(sizeof(Vibration) == 0x10, "Vibration is an invalid size");
struct LedPattern { struct LedPattern {
explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) { explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment