Browse Source

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
pull/15/merge
Morph 5 years ago
parent
commit
0a966e2cac
  1. 77
      src/core/hle/service/hid/controllers/npad.h

77
src/core/hle/service/hid/controllers/npad.h

@ -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 {
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;
enum class NPadControllerType {
None,
ProController,
Handheld,
JoyDual,
JoyLeft,
JoyRight,
Pokeball,
};
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 {
f32 amp_low;
f32 freq_low;
f32 amp_high;
f32 freq_high;
enum class DeviceIndex : u8 {
Left = 0,
Right = 1,
None = 2,
}; };
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:
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:
None = 2, None = 2,
}; };
enum class NPadControllerType {
None,
ProController,
Handheld,
JoyDual,
JoyLeft,
JoyRight,
Pokeball,
struct DeviceHandle {
NpadType npad_type{};
u8 npad_id{};
DeviceIndex device_index{};
INSERT_PADDING_BYTES(1);
}; };
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) {

Loading…
Cancel
Save