From 95103a1b7b5ff0e20dc9507d1766918a60dc24c9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 19 Jul 2018 15:07:34 -0400 Subject: hid: Use HID_NUM_LAYOUTS constant for indicating size of the layouts array Gets rid of the use of a magic constant --- src/core/hle/service/hid/hid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index b499308d6..e298f23a6 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -380,7 +380,7 @@ static_assert(sizeof(ControllerLayout) == 0x350, struct Controller { ControllerHeader header; - std::array layouts; + std::array layouts; std::array unk_1; ControllerMAC mac_left; ControllerMAC mac_right; -- cgit v1.2.3 From a37a47448dff6b19f1828f83f96cc8efce129d64 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 19 Jul 2018 15:09:31 -0400 Subject: hid: Use a ranged-for loops in UpdatePadCallback Modernizes the loops themselves while also getting rid of a signed/unsigned comparison in a loop condition. --- src/core/hle/service/hid/hid.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 4f18c0fd3..475a0a5cf 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -85,8 +85,7 @@ private: controller_header.left_color_buttons = JOYCON_BUTTONS_NEON_BLUE; for (size_t controller = 0; controller < mem.controllers.size(); controller++) { - for (int index = 0; index < HID_NUM_LAYOUTS; index++) { - ControllerLayout& layout = mem.controllers[controller].layouts[index]; + for (auto& layout : mem.controllers[controller].layouts) { layout.header.num_entries = HID_NUM_ENTRIES; layout.header.max_entry_index = HID_NUM_ENTRIES - 1; @@ -213,8 +212,7 @@ private: keyboard.entries[curr_keyboard_entry].timestamp_2 = keyboard_sample_counter; // TODO(shinyquagsire23): Figure out what any of these are - for (size_t i = 0; i < mem.unk_input_1.size(); i++) { - UnkInput1& input = mem.unk_input_1[i]; + for (auto& input : mem.unk_input_1) { const u64 last_input_entry = input.header.latest_entry; const u64 curr_input_entry = (input.header.latest_entry + 1) % input.entries.size(); const u64 input_sample_counter = input.entries[last_input_entry].timestamp + 1; @@ -228,9 +226,7 @@ private: input.entries[curr_input_entry].timestamp_2 = input_sample_counter; } - for (size_t i = 0; i < mem.unk_input_2.size(); i++) { - UnkInput2& input = mem.unk_input_2[i]; - + for (auto& input : mem.unk_input_2) { input.header.timestamp_ticks = timestamp; input.header.num_entries = 17; input.header.latest_entry = 0; -- cgit v1.2.3