diff options
author | David Marcec <dmarcecguzman@gmail.com> | 2020-05-12 12:40:50 +1000 |
---|---|---|
committer | David Marcec <dmarcecguzman@gmail.com> | 2020-05-12 12:40:50 +1000 |
commit | a79f060ea2a8dd24f399309d052db74c6456224b (patch) | |
tree | 1944d4cda7343e3f1c3cbd425c5c807f468b6af0 /src | |
parent | 6ec6cb50dd23fe75e01e7aee198e48b9cafd0542 (diff) |
hid: Clear keyboard states & fix logic issue
Previously we never cleared the states of the entries and the key would stay held down, also looping over the key bytes for each key lead to setting every bit for the key state instead of the key we wanted
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/hid/controllers/keyboard.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp index 358cb9329..9a8d354ba 100644 --- a/src/core/hle/service/hid/controllers/keyboard.cpp +++ b/src/core/hle/service/hid/controllers/keyboard.cpp @@ -38,10 +38,11 @@ void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing, cur_entry.sampling_number = last_entry.sampling_number + 1; cur_entry.sampling_number2 = cur_entry.sampling_number; + cur_entry.key.fill(0); + cur_entry.modifier = 0; + for (std::size_t i = 0; i < keyboard_keys.size(); ++i) { - for (std::size_t k = 0; k < KEYS_PER_BYTE; ++k) { - cur_entry.key[i / KEYS_PER_BYTE] |= (keyboard_keys[i]->GetStatus() << k); - } + 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) { |