aboutsummaryrefslogtreecommitdiff
path: root/src/core/hid/emulated_devices.cpp
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-10-24 11:22:20 -0500
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-24 20:30:25 -0600
commitd1bac9024d8bec7c387f835934ef7847b0e42175 (patch)
tree160f98a8bce324756f46b7b5aee889bb5b53f8af /src/core/hid/emulated_devices.cpp
parent6743753bc75087759634e978931ef7942b008387 (diff)
settings: Fix mouse and keyboard mappings
Diffstat (limited to 'src/core/hid/emulated_devices.cpp')
-rw-r--r--src/core/hid/emulated_devices.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp
index 1c4065cd85..5afd83f62c 100644
--- a/src/core/hid/emulated_devices.cpp
+++ b/src/core/hid/emulated_devices.cpp
@@ -162,17 +162,22 @@ void EmulatedDevices::SetKeyboardButton(Input::CallbackStatus callback, std::siz
return;
}
- // TODO(german77): Do this properly
- // switch (index) {
- // case Settings::NativeKeyboard::A:
- // interface_status.keyboard_state.a.Assign(current_status.value);
- // break;
- // ....
- // }
+ UpdateKey(index, current_status.value);
TriggerOnChange(DeviceTriggerType::Keyboard);
}
+void EmulatedDevices::UpdateKey(std::size_t key_index, bool status) {
+ constexpr u8 KEYS_PER_BYTE = 8;
+ auto& entry = device_status.keyboard_state.key[key_index / KEYS_PER_BYTE];
+ const u8 mask = 1 << (key_index % KEYS_PER_BYTE);
+ if (status) {
+ entry = entry | mask;
+ } else {
+ entry = entry & ~mask;
+ }
+}
+
void EmulatedDevices::SetKeyboardModifier(Input::CallbackStatus callback, std::size_t index) {
if (index >= device_status.keyboard_moddifier_values.size()) {
return;