diff options
Diffstat (limited to 'src/core/hid/emulated_devices.cpp')
| -rw-r--r-- | src/core/hid/emulated_devices.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index 1c4065cd8..5afd83f62 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 | |||
| 162 | return; | 162 | return; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | // TODO(german77): Do this properly | 165 | UpdateKey(index, current_status.value); |
| 166 | // switch (index) { | ||
| 167 | // case Settings::NativeKeyboard::A: | ||
| 168 | // interface_status.keyboard_state.a.Assign(current_status.value); | ||
| 169 | // break; | ||
| 170 | // .... | ||
| 171 | // } | ||
| 172 | 166 | ||
| 173 | TriggerOnChange(DeviceTriggerType::Keyboard); | 167 | TriggerOnChange(DeviceTriggerType::Keyboard); |
| 174 | } | 168 | } |
| 175 | 169 | ||
| 170 | void EmulatedDevices::UpdateKey(std::size_t key_index, bool status) { | ||
| 171 | constexpr u8 KEYS_PER_BYTE = 8; | ||
| 172 | auto& entry = device_status.keyboard_state.key[key_index / KEYS_PER_BYTE]; | ||
| 173 | const u8 mask = 1 << (key_index % KEYS_PER_BYTE); | ||
| 174 | if (status) { | ||
| 175 | entry = entry | mask; | ||
| 176 | } else { | ||
| 177 | entry = entry & ~mask; | ||
| 178 | } | ||
| 179 | } | ||
| 180 | |||
| 176 | void EmulatedDevices::SetKeyboardModifier(Input::CallbackStatus callback, std::size_t index) { | 181 | void EmulatedDevices::SetKeyboardModifier(Input::CallbackStatus callback, std::size_t index) { |
| 177 | if (index >= device_status.keyboard_moddifier_values.size()) { | 182 | if (index >= device_status.keyboard_moddifier_values.size()) { |
| 178 | return; | 183 | return; |