diff options
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 26 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.h | 105 |
2 files changed, 68 insertions, 63 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 81eceb027..42e0f1e12 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -66,27 +66,27 @@ private: | |||
| 66 | LoadInputDevices(); | 66 | LoadInputDevices(); |
| 67 | 67 | ||
| 68 | // Set up controllers as neon red+blue Joy-Con attached to console | 68 | // Set up controllers as neon red+blue Joy-Con attached to console |
| 69 | ControllerHeader& controllerHeader = mem->controllers[Controller_Handheld].header; | 69 | ControllerHeader& controller_header = mem->controllers[Controller_Handheld].header; |
| 70 | controllerHeader.type = ControllerType_Handheld | ControllerType_JoyconPair; | 70 | controller_header.type = ControllerType_Handheld | ControllerType_JoyconPair; |
| 71 | controllerHeader.singleColorsDescriptor = ColorDesc_ColorsNonexistent; | 71 | controller_header.single_colors_descriptor = ColorDesc_ColorsNonexistent; |
| 72 | controllerHeader.rightColorBody = 0xFF3C28; | 72 | controller_header.right_color_body = JOYCON_BODY_NEON_RED; |
| 73 | controllerHeader.rightColorButtons = 0x1E0A0A; | 73 | controller_header.right_color_buttons = JOYCON_BUTTONS_NEON_RED; |
| 74 | controllerHeader.leftColorBody = 0x0AB9E6; | 74 | controller_header.left_color_body = JOYCON_BODY_NEON_BLUE; |
| 75 | controllerHeader.leftColorButtons = 0x001E1E; | 75 | controller_header.left_color_buttons = JOYCON_BUTTONS_NEON_BLUE; |
| 76 | 76 | ||
| 77 | for (int layoutIdx = 0; layoutIdx < HID_NUM_LAYOUTS; layoutIdx++) | 77 | for (int layoutIdx = 0; layoutIdx < HID_NUM_LAYOUTS; layoutIdx++) |
| 78 | { | 78 | { |
| 79 | ControllerLayout& layout = mem->controllers[Controller_Handheld].layouts[layoutIdx]; | 79 | ControllerLayout& layout = mem->controllers[Controller_Handheld].layouts[layoutIdx]; |
| 80 | layout.header.numEntries = HID_NUM_ENTRIES; | 80 | layout.header.num_entries = HID_NUM_ENTRIES; |
| 81 | layout.header.maxEntryIndex = HID_NUM_ENTRIES - 1; | 81 | layout.header.max_entry_index = HID_NUM_ENTRIES - 1; |
| 82 | 82 | ||
| 83 | // HID shared memory stores the state of the past 17 samples in a circlular buffer, | 83 | // HID shared memory stores the state of the past 17 samples in a circlular buffer, |
| 84 | // each with a timestamp in number of samples since boot. | 84 | // each with a timestamp in number of samples since boot. |
| 85 | layout.header.timestampTicks = CoreTiming::GetTicks(); | 85 | layout.header.timestamp_ticks = CoreTiming::GetTicks(); |
| 86 | layout.header.latestEntry = (layout.header.latestEntry + 1) % HID_NUM_ENTRIES; | 86 | layout.header.latest_entry = (layout.header.latest_entry + 1) % HID_NUM_ENTRIES; |
| 87 | 87 | ||
| 88 | ControllerInputEntry& entry = layout.entries[layout.header.latestEntry]; | 88 | ControllerInputEntry& entry = layout.entries[layout.header.latest_entry]; |
| 89 | entry.connectionState = ConnectionState_Connected | ConnectionState_Wired; | 89 | entry.connection_state = ConnectionState_Connected | ConnectionState_Wired; |
| 90 | entry.timestamp++; | 90 | entry.timestamp++; |
| 91 | entry.timestamp_2++; // TODO(shinyquagsire23): Is this always identical to timestamp? | 91 | entry.timestamp_2++; // TODO(shinyquagsire23): Is this always identical to timestamp? |
| 92 | 92 | ||
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index dbffd3a74..3de9adb4b 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -17,6 +17,11 @@ constexpr u32 HID_NUM_LAYOUTS = 7; | |||
| 17 | constexpr s32 HID_JOYSTICK_MAX = 0x8000; | 17 | constexpr s32 HID_JOYSTICK_MAX = 0x8000; |
| 18 | constexpr s32 HID_JOYSTICK_MIN = -0x8000; | 18 | constexpr s32 HID_JOYSTICK_MIN = -0x8000; |
| 19 | 19 | ||
| 20 | constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; | ||
| 21 | constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; | ||
| 22 | constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6; | ||
| 23 | constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E; | ||
| 24 | |||
| 20 | enum ControllerType : u32 { | 25 | enum ControllerType : u32 { |
| 21 | ControllerType_ProController = 1 << 0, | 26 | ControllerType_ProController = 1 << 0, |
| 22 | ControllerType_Handheld = 1 << 1, | 27 | ControllerType_Handheld = 1 << 1, |
| @@ -62,10 +67,10 @@ enum ControllerID { | |||
| 62 | // Begin TouchScreen | 67 | // Begin TouchScreen |
| 63 | 68 | ||
| 64 | struct TouchScreenHeader { | 69 | struct TouchScreenHeader { |
| 65 | u64 timestampTicks; | 70 | u64 timestamp_ticks; |
| 66 | u64 numEntries; | 71 | u64 num_entries; |
| 67 | u64 latestEntry; | 72 | u64 latest_entry; |
| 68 | u64 maxEntryIndex; | 73 | u64 max_entry_index; |
| 69 | u64 timestamp; | 74 | u64 timestamp; |
| 70 | }; | 75 | }; |
| 71 | static_assert(sizeof(TouchScreenHeader) == 0x28, | 76 | static_assert(sizeof(TouchScreenHeader) == 0x28, |
| @@ -73,7 +78,7 @@ static_assert(sizeof(TouchScreenHeader) == 0x28, | |||
| 73 | 78 | ||
| 74 | struct TouchScreenEntryHeader { | 79 | struct TouchScreenEntryHeader { |
| 75 | u64 timestamp; | 80 | u64 timestamp; |
| 76 | u64 numTouches; | 81 | u64 num_touches; |
| 77 | }; | 82 | }; |
| 78 | static_assert(sizeof(TouchScreenEntryHeader) == 0x10, | 83 | static_assert(sizeof(TouchScreenEntryHeader) == 0x10, |
| 79 | "HID touch screen entry header structure has incorrect size"); | 84 | "HID touch screen entry header structure has incorrect size"); |
| @@ -81,11 +86,11 @@ static_assert(sizeof(TouchScreenEntryHeader) == 0x10, | |||
| 81 | struct TouchScreenEntryTouch { | 86 | struct TouchScreenEntryTouch { |
| 82 | u64 timestamp; | 87 | u64 timestamp; |
| 83 | u32 padding; | 88 | u32 padding; |
| 84 | u32 touchIndex; | 89 | u32 touch_index; |
| 85 | u32 x; | 90 | u32 x; |
| 86 | u32 y; | 91 | u32 y; |
| 87 | u32 diameterX; | 92 | u32 diameter_x; |
| 88 | u32 diameterY; | 93 | u32 diameter_y; |
| 89 | u32 angle; | 94 | u32 angle; |
| 90 | u32 padding_2; | 95 | u32 padding_2; |
| 91 | }; | 96 | }; |
| @@ -112,10 +117,10 @@ static_assert(sizeof(TouchScreen) == 0x3000, "HID touch screen structure has inc | |||
| 112 | // Begin Mouse | 117 | // Begin Mouse |
| 113 | 118 | ||
| 114 | struct MouseHeader { | 119 | struct MouseHeader { |
| 115 | u64 timestampTicks; | 120 | u64 timestamp_ticks; |
| 116 | u64 numEntries; | 121 | u64 num_entries; |
| 117 | u64 latestEntry; | 122 | u64 latest_entry; |
| 118 | u64 maxEntryIndex; | 123 | u64 max_entry_index; |
| 119 | }; | 124 | }; |
| 120 | static_assert(sizeof(MouseHeader) == 0x20, "HID mouse header structure has incorrect size"); | 125 | static_assert(sizeof(MouseHeader) == 0x20, "HID mouse header structure has incorrect size"); |
| 121 | 126 | ||
| @@ -137,10 +142,10 @@ struct MouseEntry { | |||
| 137 | u64 timestamp_2; | 142 | u64 timestamp_2; |
| 138 | u32 x; | 143 | u32 x; |
| 139 | u32 y; | 144 | u32 y; |
| 140 | u32 velocityX; | 145 | u32 velocity_x; |
| 141 | u32 velocityY; | 146 | u32 velocity_y; |
| 142 | u32 scrollVelocityX; | 147 | u32 scroll_velocity_x; |
| 143 | u32 scrollVelocityY; | 148 | u32 scroll_velocity_y; |
| 144 | MouseButtonState buttons; | 149 | MouseButtonState buttons; |
| 145 | }; | 150 | }; |
| 146 | static_assert(sizeof(MouseEntry) == 0x30, "HID mouse entry structure has incorrect size"); | 151 | static_assert(sizeof(MouseEntry) == 0x30, "HID mouse entry structure has incorrect size"); |
| @@ -157,10 +162,10 @@ static_assert(sizeof(Mouse) == 0x400, "HID mouse structure has incorrect size"); | |||
| 157 | // Begin Keyboard | 162 | // Begin Keyboard |
| 158 | 163 | ||
| 159 | struct KeyboardHeader { | 164 | struct KeyboardHeader { |
| 160 | u64 timestampTicks; | 165 | u64 timestamp_ticks; |
| 161 | u64 numEntries; | 166 | u64 num_entries; |
| 162 | u64 latestEntry; | 167 | u64 latest_entry; |
| 163 | u64 maxEntryIndex; | 168 | u64 max_entry_index; |
| 164 | }; | 169 | }; |
| 165 | static_assert(sizeof(KeyboardHeader) == 0x20, "HID keyboard header structure has incorrect size"); | 170 | static_assert(sizeof(KeyboardHeader) == 0x20, "HID keyboard header structure has incorrect size"); |
| 166 | 171 | ||
| @@ -212,24 +217,24 @@ static_assert(sizeof(ControllerMAC) == 0x20, "HID controller MAC structure has i | |||
| 212 | 217 | ||
| 213 | struct ControllerHeader { | 218 | struct ControllerHeader { |
| 214 | u32 type; | 219 | u32 type; |
| 215 | u32 isHalf; | 220 | u32 is_half; |
| 216 | u32 singleColorsDescriptor; | 221 | u32 single_colors_descriptor; |
| 217 | u32 singleColorBody; | 222 | u32 single_color_body; |
| 218 | u32 singleColorButtons; | 223 | u32 single_color_buttons; |
| 219 | u32 splitColorsDescriptor; | 224 | u32 split_colors_descriptor; |
| 220 | u32 leftColorBody; | 225 | u32 left_color_body; |
| 221 | u32 leftColorButtons; | 226 | u32 left_color_buttons; |
| 222 | u32 rightColorBody; | 227 | u32 right_color_body; |
| 223 | u32 rightColorButtons; | 228 | u32 right_color_buttons; |
| 224 | }; | 229 | }; |
| 225 | static_assert(sizeof(ControllerHeader) == 0x28, | 230 | static_assert(sizeof(ControllerHeader) == 0x28, |
| 226 | "HID controller header structure has incorrect size"); | 231 | "HID controller header structure has incorrect size"); |
| 227 | 232 | ||
| 228 | struct ControllerLayoutHeader { | 233 | struct ControllerLayoutHeader { |
| 229 | u64 timestampTicks; | 234 | u64 timestamp_ticks; |
| 230 | u64 numEntries; | 235 | u64 num_entries; |
| 231 | u64 latestEntry; | 236 | u64 latest_entry; |
| 232 | u64 maxEntryIndex; | 237 | u64 max_entry_index; |
| 233 | }; | 238 | }; |
| 234 | static_assert(sizeof(ControllerLayoutHeader) == 0x20, | 239 | static_assert(sizeof(ControllerLayoutHeader) == 0x20, |
| 235 | "HID controller layout header structure has incorrect size"); | 240 | "HID controller layout header structure has incorrect size"); |
| @@ -279,11 +284,11 @@ struct ControllerInputEntry { | |||
| 279 | u64 timestamp; | 284 | u64 timestamp; |
| 280 | u64 timestamp_2; | 285 | u64 timestamp_2; |
| 281 | ControllerPadState buttons; | 286 | ControllerPadState buttons; |
| 282 | u32 joystickLeftX; | 287 | u32 joystick_left_x; |
| 283 | u32 joystickLeftY; | 288 | u32 joystick_left_y; |
| 284 | u32 joystickRightX; | 289 | u32 joystick_right_x; |
| 285 | u32 joystickRightY; | 290 | u32 joystick_right_y; |
| 286 | u64 connectionState; | 291 | u64 connection_state; |
| 287 | }; | 292 | }; |
| 288 | static_assert(sizeof(ControllerInputEntry) == 0x30, | 293 | static_assert(sizeof(ControllerInputEntry) == 0x30, |
| 289 | "HID controller input entry structure has incorrect size"); | 294 | "HID controller input entry structure has incorrect size"); |
| @@ -299,8 +304,8 @@ struct Controller { | |||
| 299 | ControllerHeader header; | 304 | ControllerHeader header; |
| 300 | std::array<ControllerLayout, 7> layouts; | 305 | std::array<ControllerLayout, 7> layouts; |
| 301 | std::array<u8, 0x2a70> unk_1; | 306 | std::array<u8, 0x2a70> unk_1; |
| 302 | ControllerMAC macLeft; | 307 | ControllerMAC mac_left; |
| 303 | ControllerMAC macRight; | 308 | ControllerMAC mac_right; |
| 304 | std::array<u8, 0xdf8> unk_2; | 309 | std::array<u8, 0xdf8> unk_2; |
| 305 | }; | 310 | }; |
| 306 | static_assert(sizeof(Controller) == 0x5000, "HID controller structure has incorrect size"); | 311 | static_assert(sizeof(Controller) == 0x5000, "HID controller structure has incorrect size"); |
| @@ -312,17 +317,17 @@ struct SharedMemory { | |||
| 312 | TouchScreen touchscreen; | 317 | TouchScreen touchscreen; |
| 313 | Mouse mouse; | 318 | Mouse mouse; |
| 314 | Keyboard keyboard; | 319 | Keyboard keyboard; |
| 315 | std::array<u8, 0x400> unkSection1; | 320 | std::array<u8, 0x400> unk_section_1; |
| 316 | std::array<u8, 0x400> unkSection2; | 321 | std::array<u8, 0x400> unk_section_2; |
| 317 | std::array<u8, 0x400> unkSection3; | 322 | std::array<u8, 0x400> unk_section_3; |
| 318 | std::array<u8, 0x400> unkSection4; | 323 | std::array<u8, 0x400> unk_section_4; |
| 319 | std::array<u8, 0x200> unkSection5; | 324 | std::array<u8, 0x200> unk_section_5; |
| 320 | std::array<u8, 0x200> unkSection6; | 325 | std::array<u8, 0x200> unk_section_6; |
| 321 | std::array<u8, 0x200> unkSection7; | 326 | std::array<u8, 0x200> unk_section_7; |
| 322 | std::array<u8, 0x800> unkSection8; | 327 | std::array<u8, 0x800> unk_section_8; |
| 323 | std::array<u8, 0x4000> controllerSerials; | 328 | std::array<u8, 0x4000> controller_serials; |
| 324 | std::array<Controller, 10> controllers; | 329 | std::array<Controller, 10> controllers; |
| 325 | std::array<u8, 0x4600> unkSection9; | 330 | std::array<u8, 0x4600> unk_section_9; |
| 326 | }; | 331 | }; |
| 327 | static_assert(sizeof(SharedMemory) == 0x40000, "HID Shared Memory structure has incorrect size"); | 332 | static_assert(sizeof(SharedMemory) == 0x40000, "HID Shared Memory structure has incorrect size"); |
| 328 | 333 | ||