core/hid: Improve accuracy of the keyboard implementation

This commit is contained in:
german77 2021-11-13 23:25:45 -06:00 committed by Narr the Reg
parent 7fcfe24a3e
commit b673857d7d
13 changed files with 682 additions and 313 deletions

View file

@ -170,13 +170,14 @@ void EmulatedDevices::SetKeyboardButton(Common::Input::CallbackStatus callback,
return;
}
// Index should be converted from NativeKeyboard to KeyboardKeyIndex
UpdateKey(index, current_status.value);
TriggerOnChange(DeviceTriggerType::Keyboard);
}
void EmulatedDevices::UpdateKey(std::size_t key_index, bool status) {
constexpr u8 KEYS_PER_BYTE = 8;
constexpr std::size_t KEYS_PER_BYTE = 8;
auto& entry = device_status.keyboard_state.key[key_index / KEYS_PER_BYTE];
const u8 mask = static_cast<u8>(1 << (key_index % KEYS_PER_BYTE));
if (status) {