diff options
| author | 2020-10-06 04:35:07 -0400 | |
|---|---|---|
| committer | 2020-11-15 23:33:20 -0500 | |
| commit | 0a966e2cac40477ffc62f747f7703afbf3bfda2a (patch) | |
| tree | 545fe03a72a71aa36ec9f11c8c70039b28c7b01b | |
| parent | configure_input_player: Change "Defaults" button behavior (diff) | |
| download | yuzu-0a966e2cac40477ffc62f747f7703afbf3bfda2a.tar.gz yuzu-0a966e2cac40477ffc62f747f7703afbf3bfda2a.tar.xz yuzu-0a966e2cac40477ffc62f747f7703afbf3bfda2a.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index fd5c5a6eb..8dabae6e3 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -39,28 +39,30 @@ public: | |||
| 39 | // Called when input devices should be loaded | 39 | // Called when input devices should be loaded |
| 40 | void OnLoadInputDevices() override; | 40 | void OnLoadInputDevices() override; |
| 41 | 41 | ||
| 42 | struct NPadType { | 42 | enum class NPadControllerType { |
| 43 | union { | 43 | None, |
| 44 | u32_le raw{}; | 44 | ProController, |
| 45 | 45 | Handheld, | |
| 46 | BitField<0, 1, u32> pro_controller; | 46 | JoyDual, |
| 47 | BitField<1, 1, u32> handheld; | 47 | JoyLeft, |
| 48 | BitField<2, 1, u32> joycon_dual; | 48 | JoyRight, |
| 49 | BitField<3, 1, u32> joycon_left; | 49 | Pokeball, |
| 50 | BitField<4, 1, u32> joycon_right; | 50 | }; |
| 51 | 51 | ||
| 52 | BitField<6, 1, u32> pokeball; // TODO(ogniK): Confirm when possible | 52 | enum class NpadType : u8 { |
| 53 | }; | 53 | ProController = 3, |
| 54 | Handheld = 4, | ||
| 55 | JoyconDual = 5, | ||
| 56 | JoyconLeft = 6, | ||
| 57 | JoyconRight = 7, | ||
| 58 | Pokeball = 9, | ||
| 54 | }; | 59 | }; |
| 55 | static_assert(sizeof(NPadType) == 4, "NPadType is an invalid size"); | ||
| 56 | 60 | ||
| 57 | struct Vibration { | 61 | enum class DeviceIndex : u8 { |
| 58 | f32 amp_low; | 62 | Left = 0, |
| 59 | f32 freq_low; | 63 | Right = 1, |
| 60 | f32 amp_high; | 64 | None = 2, |
| 61 | f32 freq_high; | ||
| 62 | }; | 65 | }; |
| 63 | static_assert(sizeof(Vibration) == 0x10, "Vibration is an invalid size"); | ||
| 64 | 66 | ||
| 65 | enum class GyroscopeZeroDriftMode : u32 { | 67 | enum class GyroscopeZeroDriftMode : u32 { |
| 66 | Loose = 0, | 68 | Loose = 0, |
| @@ -73,7 +75,7 @@ public: | |||
| 73 | Horizontal = 1, | 75 | Horizontal = 1, |
| 74 | }; | 76 | }; |
| 75 | 77 | ||
| 76 | enum class NPadAssignments : u32_le { | 78 | enum class NPadAssignments : u32 { |
| 77 | Dual = 0, | 79 | Dual = 0, |
| 78 | Single = 1, | 80 | Single = 1, |
| 79 | }; | 81 | }; |
| @@ -84,15 +86,36 @@ public: | |||
| 84 | None = 2, | 86 | None = 2, |
| 85 | }; | 87 | }; |
| 86 | 88 | ||
| 87 | enum class NPadControllerType { | 89 | struct DeviceHandle { |
| 88 | None, | 90 | NpadType npad_type{}; |
| 89 | ProController, | 91 | u8 npad_id{}; |
| 90 | Handheld, | 92 | DeviceIndex device_index{}; |
| 91 | JoyDual, | 93 | INSERT_PADDING_BYTES(1); |
| 92 | JoyLeft, | ||
| 93 | JoyRight, | ||
| 94 | Pokeball, | ||
| 95 | }; | 94 | }; |
| 95 | static_assert(sizeof(DeviceHandle) == 4, "DeviceHandle is an invalid size"); | ||
| 96 | |||
| 97 | struct NPadType { | ||
| 98 | union { | ||
| 99 | u32_le raw{}; | ||
| 100 | |||
| 101 | BitField<0, 1, u32> pro_controller; | ||
| 102 | BitField<1, 1, u32> handheld; | ||
| 103 | BitField<2, 1, u32> joycon_dual; | ||
| 104 | BitField<3, 1, u32> joycon_left; | ||
| 105 | BitField<4, 1, u32> joycon_right; | ||
| 106 | |||
| 107 | BitField<6, 1, u32> pokeball; // TODO(ogniK): Confirm when possible | ||
| 108 | }; | ||
| 109 | }; | ||
| 110 | static_assert(sizeof(NPadType) == 4, "NPadType is an invalid size"); | ||
| 111 | |||
| 112 | struct Vibration { | ||
| 113 | f32 amp_low; | ||
| 114 | f32 freq_low; | ||
| 115 | f32 amp_high; | ||
| 116 | f32 freq_high; | ||
| 117 | }; | ||
| 118 | static_assert(sizeof(Vibration) == 0x10, "Vibration is an invalid size"); | ||
| 96 | 119 | ||
| 97 | struct LedPattern { | 120 | struct LedPattern { |
| 98 | explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) { | 121 | explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) { |