Merge pull request #4350 from ogniK5377/hid-update-connected

hid: Only update keyboard & debug pad inputs if enabled
master
bunnei 2020-07-25 11:57:24 +07:00 committed by GitHub
commit a2e1810287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 32 deletions

@ -39,6 +39,8 @@ void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing,
cur_entry.sampling_number = last_entry.sampling_number + 1; cur_entry.sampling_number = last_entry.sampling_number + 1;
cur_entry.sampling_number2 = cur_entry.sampling_number; cur_entry.sampling_number2 = cur_entry.sampling_number;
if (Settings::values.debug_pad_enabled) {
cur_entry.attribute.connected.Assign(1); cur_entry.attribute.connected.Assign(1);
auto& pad = cur_entry.pad_state; auto& pad = cur_entry.pad_state;
@ -66,6 +68,7 @@ void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing,
cur_entry.l_stick.y = static_cast<s32>(stick_l_y_f * HID_JOYSTICK_MAX); cur_entry.l_stick.y = static_cast<s32>(stick_l_y_f * HID_JOYSTICK_MAX);
cur_entry.r_stick.x = static_cast<s32>(stick_r_x_f * HID_JOYSTICK_MAX); cur_entry.r_stick.x = static_cast<s32>(stick_r_x_f * HID_JOYSTICK_MAX);
cur_entry.r_stick.y = static_cast<s32>(stick_r_y_f * HID_JOYSTICK_MAX); cur_entry.r_stick.y = static_cast<s32>(stick_r_y_f * HID_JOYSTICK_MAX);
}
std::memcpy(data, &shared_memory, sizeof(SharedMemory)); std::memcpy(data, &shared_memory, sizeof(SharedMemory));
} }

@ -40,15 +40,16 @@ void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing,
cur_entry.key.fill(0); cur_entry.key.fill(0);
cur_entry.modifier = 0; cur_entry.modifier = 0;
if (Settings::values.keyboard_enabled) {
for (std::size_t i = 0; i < keyboard_keys.size(); ++i) { for (std::size_t i = 0; i < keyboard_keys.size(); ++i) {
cur_entry.key[i / KEYS_PER_BYTE] |= (keyboard_keys[i]->GetStatus() << (i % KEYS_PER_BYTE)); cur_entry.key[i / KEYS_PER_BYTE] |=
(keyboard_keys[i]->GetStatus() << (i % KEYS_PER_BYTE));
} }
for (std::size_t i = 0; i < keyboard_mods.size(); ++i) { for (std::size_t i = 0; i < keyboard_mods.size(); ++i) {
cur_entry.modifier |= (keyboard_mods[i]->GetStatus() << i); cur_entry.modifier |= (keyboard_mods[i]->GetStatus() << i);
} }
}
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory)); std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
} }