diff options
| author | 2018-01-15 00:13:18 -0700 | |
|---|---|---|
| committer | 2018-01-15 02:30:53 -0700 | |
| commit | e08c132175232aca748321be3fb76b309c281eb6 (patch) | |
| tree | 9689bbb5ac80ec89f2c6c6d10fa2e482bbc87411 /src | |
| parent | fixed build for gcc c++17 / boost.icl incompatibility (diff) | |
| download | yuzu-e08c132175232aca748321be3fb76b309c281eb6.tar.gz yuzu-e08c132175232aca748321be3fb76b309c281eb6.tar.xz yuzu-e08c132175232aca748321be3fb76b309c281eb6.zip | |
hid: Add sharedmem structs
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/hid/hid.h | 312 |
1 files changed, 312 insertions, 0 deletions
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index f7621f62d..7803778d4 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -9,6 +9,318 @@ | |||
| 9 | namespace Service { | 9 | namespace Service { |
| 10 | namespace HID { | 10 | namespace HID { |
| 11 | 11 | ||
| 12 | // Begin enums and output structs | ||
| 13 | |||
| 14 | enum HIDControllerType : u32 { | ||
| 15 | ControllerType_ProController = 1 << 0, | ||
| 16 | ControllerType_Handheld = 1 << 1, | ||
| 17 | ControllerType_JoyconPair = 1 << 2, | ||
| 18 | ControllerType_JoyconLeft = 1 << 3, | ||
| 19 | ControllerType_JoyconRight = 1 << 4, | ||
| 20 | }; | ||
| 21 | |||
| 22 | enum HIDControllerLayoutType : u32 { | ||
| 23 | Layout_ProController = 0, // Pro Controller or HID gamepad | ||
| 24 | Layout_Handheld = 1, // Two Joy-Con docked to rails | ||
| 25 | Layout_Single = 2, // Horizontal single Joy-Con or pair of Joy-Con, adjusted for orientation | ||
| 26 | Layout_Left = 3, // Only raw left Joy-Con state, no orientation adjustment | ||
| 27 | Layout_Right = 4, // Only raw right Joy-Con state, no orientation adjustment | ||
| 28 | Layout_DefaultDigital = 5, // Same as next, but sticks have 8-direction values only | ||
| 29 | Layout_Default = 6, // Safe default, single Joy-Con have buttons/sticks rotated for orientation | ||
| 30 | }; | ||
| 31 | |||
| 32 | enum HIDControllerColorDescription { | ||
| 33 | ColorDesc_ColorsNonexistent = 1 << 1, | ||
| 34 | }; | ||
| 35 | |||
| 36 | enum HIDControllerConnectionState { | ||
| 37 | ConnectionState_Connected = 1 << 0, | ||
| 38 | ConnectionState_Wired = 1 << 1, | ||
| 39 | }; | ||
| 40 | |||
| 41 | enum HIDControllerID { | ||
| 42 | Controller_Player1 = 0, | ||
| 43 | Controller_Player2 = 1, | ||
| 44 | Controller_Player3 = 2, | ||
| 45 | Controller_Player4 = 3, | ||
| 46 | Controller_Player5 = 4, | ||
| 47 | Controller_Player6 = 5, | ||
| 48 | Controller_Player7 = 6, | ||
| 49 | Controller_Player8 = 7, | ||
| 50 | Controller_Handheld = 8, | ||
| 51 | Controller_Unknown = 9, | ||
| 52 | }; | ||
| 53 | |||
| 54 | // End enums and output structs | ||
| 55 | |||
| 56 | // Begin HIDTouchScreen | ||
| 57 | |||
| 58 | struct HIDTouchScreenHeader { | ||
| 59 | u64 timestampTicks; | ||
| 60 | u64 numEntries; | ||
| 61 | u64 latestEntry; | ||
| 62 | u64 maxEntryIndex; | ||
| 63 | u64 timestamp; | ||
| 64 | }; | ||
| 65 | static_assert(sizeof(HIDTouchScreenHeader) == 0x28, | ||
| 66 | "HID touch screen header structure has incorrect size"); | ||
| 67 | |||
| 68 | struct HIDTouchScreenEntryHeader { | ||
| 69 | u64 timestamp; | ||
| 70 | u64 numTouches; | ||
| 71 | }; | ||
| 72 | static_assert(sizeof(HIDTouchScreenEntryHeader) == 0x10, | ||
| 73 | "HID touch screen entry header structure has incorrect size"); | ||
| 74 | |||
| 75 | struct HIDTouchScreenEntryTouch { | ||
| 76 | u64 timestamp; | ||
| 77 | u32 padding; | ||
| 78 | u32 touchIndex; | ||
| 79 | u32 x; | ||
| 80 | u32 y; | ||
| 81 | u32 diameterX; | ||
| 82 | u32 diameterY; | ||
| 83 | u32 angle; | ||
| 84 | u32 padding_2; | ||
| 85 | }; | ||
| 86 | static_assert(sizeof(HIDTouchScreenEntryTouch) == 0x28, | ||
| 87 | "HID touch screen touch structure has incorrect size"); | ||
| 88 | |||
| 89 | struct HIDTouchScreenEntry { | ||
| 90 | HIDTouchScreenEntryHeader header; | ||
| 91 | std::array<HIDTouchScreenEntryTouch, 16> touches; | ||
| 92 | u64 unk; | ||
| 93 | }; | ||
| 94 | static_assert(sizeof(HIDTouchScreenEntry) == 0x298, | ||
| 95 | "HID touch screen entry structure has incorrect size"); | ||
| 96 | |||
| 97 | struct HIDTouchScreen { | ||
| 98 | HIDTouchScreenHeader header; | ||
| 99 | std::array<HIDTouchScreenEntry, 17> entries; | ||
| 100 | std::array<u8, 0x3c0> padding; | ||
| 101 | }; | ||
| 102 | static_assert(sizeof(HIDTouchScreen) == 0x3000, "HID touch screen structure has incorrect size"); | ||
| 103 | |||
| 104 | // End HIDTouchScreen | ||
| 105 | |||
| 106 | // Begin HIDMouse | ||
| 107 | |||
| 108 | struct HIDMouseHeader { | ||
| 109 | u64 timestampTicks; | ||
| 110 | u64 numEntries; | ||
| 111 | u64 latestEntry; | ||
| 112 | u64 maxEntryIndex; | ||
| 113 | }; | ||
| 114 | static_assert(sizeof(HIDMouseHeader) == 0x20, "HID mouse header structure has incorrect size"); | ||
| 115 | |||
| 116 | struct HIDMouseButtonState { | ||
| 117 | union { | ||
| 118 | u64 hex{}; | ||
| 119 | |||
| 120 | // Buttons | ||
| 121 | BitField<0, 1, u64> left; | ||
| 122 | BitField<1, 1, u64> right; | ||
| 123 | BitField<2, 1, u64> middle; | ||
| 124 | BitField<3, 1, u64> forward; | ||
| 125 | BitField<4, 1, u64> back; | ||
| 126 | }; | ||
| 127 | }; | ||
| 128 | |||
| 129 | struct HIDMouseEntry { | ||
| 130 | u64 timestamp; | ||
| 131 | u64 timestamp_2; | ||
| 132 | u32 x; | ||
| 133 | u32 y; | ||
| 134 | u32 velocityX; | ||
| 135 | u32 velocityY; | ||
| 136 | u32 scrollVelocityX; | ||
| 137 | u32 scrollVelocityY; | ||
| 138 | HIDMouseButtonState buttons; | ||
| 139 | }; | ||
| 140 | static_assert(sizeof(HIDMouseEntry) == 0x30, "HID mouse entry structure has incorrect size"); | ||
| 141 | |||
| 142 | struct HIDMouse { | ||
| 143 | HIDMouseHeader header; | ||
| 144 | std::array<HIDMouseEntry, 17> entries; | ||
| 145 | std::array<u8, 0xB0> padding; | ||
| 146 | }; | ||
| 147 | static_assert(sizeof(HIDMouse) == 0x400, "HID mouse structure has incorrect size"); | ||
| 148 | |||
| 149 | // End HIDMouse | ||
| 150 | |||
| 151 | // Begin HIDKeyboard | ||
| 152 | |||
| 153 | struct HIDKeyboardHeader { | ||
| 154 | u64 timestampTicks; | ||
| 155 | u64 numEntries; | ||
| 156 | u64 latestEntry; | ||
| 157 | u64 maxEntryIndex; | ||
| 158 | }; | ||
| 159 | static_assert(sizeof(HIDKeyboardHeader) == 0x20, | ||
| 160 | "HID keyboard header structure has incorrect size"); | ||
| 161 | |||
| 162 | struct HIDKeyboardModifierKeyState { | ||
| 163 | union { | ||
| 164 | u64 hex{}; | ||
| 165 | |||
| 166 | // Buttons | ||
| 167 | BitField<0, 1, u64> lctrl; | ||
| 168 | BitField<1, 1, u64> lshift; | ||
| 169 | BitField<2, 1, u64> lalt; | ||
| 170 | BitField<3, 1, u64> lmeta; | ||
| 171 | BitField<4, 1, u64> rctrl; | ||
| 172 | BitField<5, 1, u64> rshift; | ||
| 173 | BitField<6, 1, u64> ralt; | ||
| 174 | BitField<7, 1, u64> rmeta; | ||
| 175 | BitField<8, 1, u64> capslock; | ||
| 176 | BitField<9, 1, u64> scrolllock; | ||
| 177 | BitField<10, 1, u64> numlock; | ||
| 178 | }; | ||
| 179 | }; | ||
| 180 | |||
| 181 | struct HIDKeyboardEntry { | ||
| 182 | u64 timestamp; | ||
| 183 | u64 timestamp_2; | ||
| 184 | HIDKeyboardModifierKeyState modifier; | ||
| 185 | u32 keys[8]; | ||
| 186 | }; | ||
| 187 | static_assert(sizeof(HIDKeyboardEntry) == 0x38, "HID keyboard entry structure has incorrect size"); | ||
| 188 | |||
| 189 | struct HIDKeyboard { | ||
| 190 | HIDKeyboardHeader header; | ||
| 191 | std::array<HIDKeyboardEntry, 17> entries; | ||
| 192 | std::array<u8, 0x28> padding; | ||
| 193 | }; | ||
| 194 | static_assert(sizeof(HIDKeyboard) == 0x400, "HID keyboard structure has incorrect size"); | ||
| 195 | |||
| 196 | // End HIDKeyboard | ||
| 197 | |||
| 198 | // Begin HIDController | ||
| 199 | |||
| 200 | struct HIDControllerMAC { | ||
| 201 | u64 timestamp; | ||
| 202 | std::array<u8, 0x8> mac; | ||
| 203 | u64 unk; | ||
| 204 | u64 timestamp_2; | ||
| 205 | }; | ||
| 206 | static_assert(sizeof(HIDControllerMAC) == 0x20, "HID controller MAC structure has incorrect size"); | ||
| 207 | |||
| 208 | struct HIDControllerHeader { | ||
| 209 | u32 type; | ||
| 210 | u32 isHalf; | ||
| 211 | u32 singleColorsDescriptor; | ||
| 212 | u32 singleColorBody; | ||
| 213 | u32 singleColorButtons; | ||
| 214 | u32 splitColorsDescriptor; | ||
| 215 | u32 leftColorBody; | ||
| 216 | u32 leftColorButtons; | ||
| 217 | u32 rightColorBody; | ||
| 218 | u32 rightColorbuttons; | ||
| 219 | }; | ||
| 220 | static_assert(sizeof(HIDControllerHeader) == 0x28, | ||
| 221 | "HID controller header structure has incorrect size"); | ||
| 222 | |||
| 223 | struct HIDControllerLayoutHeader { | ||
| 224 | u64 timestampTicks; | ||
| 225 | u64 numEntries; | ||
| 226 | u64 latestEntry; | ||
| 227 | u64 maxEntryIndex; | ||
| 228 | }; | ||
| 229 | static_assert(sizeof(HIDControllerLayoutHeader) == 0x20, | ||
| 230 | "HID controller layout header structure has incorrect size"); | ||
| 231 | |||
| 232 | struct HIDControllerPadState { | ||
| 233 | union { | ||
| 234 | u64 hex{}; | ||
| 235 | |||
| 236 | // Buttons | ||
| 237 | BitField<0, 1, u64> a; | ||
| 238 | BitField<1, 1, u64> b; | ||
| 239 | BitField<2, 1, u64> x; | ||
| 240 | BitField<3, 1, u64> y; | ||
| 241 | BitField<4, 1, u64> lstick; | ||
| 242 | BitField<5, 1, u64> rstick; | ||
| 243 | BitField<6, 1, u64> l; | ||
| 244 | BitField<7, 1, u64> r; | ||
| 245 | BitField<8, 1, u64> zl; | ||
| 246 | BitField<9, 1, u64> zr; | ||
| 247 | BitField<10, 1, u64> plus; | ||
| 248 | BitField<11, 1, u64> minus; | ||
| 249 | |||
| 250 | // D-pad buttons | ||
| 251 | BitField<12, 1, u64> dleft; | ||
| 252 | BitField<13, 1, u64> dup; | ||
| 253 | BitField<14, 1, u64> dright; | ||
| 254 | BitField<15, 1, u64> ddown; | ||
| 255 | |||
| 256 | // Left stick directions | ||
| 257 | BitField<16, 1, u64> lstick_left; | ||
| 258 | BitField<17, 1, u64> lstick_up; | ||
| 259 | BitField<18, 1, u64> lstick_right; | ||
| 260 | BitField<19, 1, u64> lstick_down; | ||
| 261 | |||
| 262 | // Right stick directions | ||
| 263 | BitField<20, 1, u64> rstick_left; | ||
| 264 | BitField<21, 1, u64> rstick_up; | ||
| 265 | BitField<22, 1, u64> rstick_right; | ||
| 266 | BitField<23, 1, u64> rstick_down; | ||
| 267 | |||
| 268 | BitField<24, 1, u64> sl; | ||
| 269 | BitField<25, 1, u64> sr; | ||
| 270 | }; | ||
| 271 | }; | ||
| 272 | |||
| 273 | struct HIDControllerInputEntry { | ||
| 274 | u64 timestamp; | ||
| 275 | u64 timestamp_2; | ||
| 276 | HIDControllerPadState buttons; | ||
| 277 | u32 joystickLeftX; | ||
| 278 | u32 joystickLeftY; | ||
| 279 | u32 joystickRightX; | ||
| 280 | u32 joystickRightY; | ||
| 281 | u64 connectionState; | ||
| 282 | }; | ||
| 283 | static_assert(sizeof(HIDControllerInputEntry) == 0x30, | ||
| 284 | "HID controller input entry structure has incorrect size"); | ||
| 285 | |||
| 286 | struct HIDControllerLayout { | ||
| 287 | HIDControllerLayoutHeader header; | ||
| 288 | std::array<HIDControllerInputEntry, 17> entries; | ||
| 289 | }; | ||
| 290 | static_assert(sizeof(HIDControllerLayout) == 0x350, | ||
| 291 | "HID controller layout structure has incorrect size"); | ||
| 292 | |||
| 293 | struct HIDController { | ||
| 294 | HIDControllerHeader header; | ||
| 295 | std::array<HIDControllerLayout, 7> layouts; | ||
| 296 | std::array<u8, 0x2a70> unk_1; | ||
| 297 | HIDControllerMAC macLeft; | ||
| 298 | HIDControllerMAC macRight; | ||
| 299 | std::array<u8, 0xdf8> unk_2; | ||
| 300 | }; | ||
| 301 | static_assert(sizeof(HIDController) == 0x5000, "HID controller structure has incorrect size"); | ||
| 302 | |||
| 303 | // End HIDController | ||
| 304 | |||
| 305 | struct HIDSharedMemory { | ||
| 306 | std::array<u8, 0x400> header; | ||
| 307 | HIDTouchScreen touchscreen; | ||
| 308 | HIDMouse mouse; | ||
| 309 | HIDKeyboard keyboard; | ||
| 310 | std::array<u8, 0x400> unkSection1; | ||
| 311 | std::array<u8, 0x400> unkSection2; | ||
| 312 | std::array<u8, 0x400> unkSection3; | ||
| 313 | std::array<u8, 0x400> unkSection4; | ||
| 314 | std::array<u8, 0x200> unkSection5; | ||
| 315 | std::array<u8, 0x200> unkSection6; | ||
| 316 | std::array<u8, 0x200> unkSection7; | ||
| 317 | std::array<u8, 0x800> unkSection8; | ||
| 318 | std::array<u8, 0x4000> controllerSerials; | ||
| 319 | std::array<HIDController, 10> controllers; | ||
| 320 | std::array<u8, 0x4600> unkSection9; | ||
| 321 | }; | ||
| 322 | static_assert(sizeof(HIDSharedMemory) == 0x40000, "HID Shared Memory structure has incorrect size"); | ||
| 323 | |||
| 12 | /// Reload input devices. Used when input configuration changed | 324 | /// Reload input devices. Used when input configuration changed |
| 13 | void ReloadInputDevices(); | 325 | void ReloadInputDevices(); |
| 14 | 326 | ||