diff options
| author | 2021-10-24 11:22:20 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:25 -0600 | |
| commit | 464c4d26ac8e7af6302390684445b357e5cda4e4 (patch) | |
| tree | 160f98a8bce324756f46b7b5aee889bb5b53f8af /src/core | |
| parent | web_applet: Replace HIDButton with NpadButton (diff) | |
| download | yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar.gz yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.tar.xz yuzu-464c4d26ac8e7af6302390684445b357e5cda4e4.zip | |
settings: Fix mouse and keyboard mappings
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 8 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.cpp | 19 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.h | 3 |
3 files changed, 19 insertions, 11 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 228f80183..bd0b89c05 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -246,7 +246,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const { | |||
| 246 | devices.begin(), devices.end(), [param](const Common::ParamPackage param_) { | 246 | devices.begin(), devices.end(), [param](const Common::ParamPackage param_) { |
| 247 | return param.Get("engine", "") == param_.Get("engine", "") && | 247 | return param.Get("engine", "") == param_.Get("engine", "") && |
| 248 | param.Get("guid", "") == param_.Get("guid", "") && | 248 | param.Get("guid", "") == param_.Get("guid", "") && |
| 249 | param.Get("port", "") == param_.Get("port", ""); | 249 | param.Get("port", 0) == param_.Get("port", 0); |
| 250 | }); | 250 | }); |
| 251 | if (devices_it != devices.end()) { | 251 | if (devices_it != devices.end()) { |
| 252 | continue; | 252 | continue; |
| @@ -254,7 +254,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const { | |||
| 254 | Common::ParamPackage device{}; | 254 | Common::ParamPackage device{}; |
| 255 | device.Set("engine", param.Get("engine", "")); | 255 | device.Set("engine", param.Get("engine", "")); |
| 256 | device.Set("guid", param.Get("guid", "")); | 256 | device.Set("guid", param.Get("guid", "")); |
| 257 | device.Set("port", param.Get("port", "")); | 257 | device.Set("port", param.Get("port", 0)); |
| 258 | devices.push_back(device); | 258 | devices.push_back(device); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| @@ -269,7 +269,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const { | |||
| 269 | devices.begin(), devices.end(), [param](const Common::ParamPackage param_) { | 269 | devices.begin(), devices.end(), [param](const Common::ParamPackage param_) { |
| 270 | return param.Get("engine", "") == param_.Get("engine", "") && | 270 | return param.Get("engine", "") == param_.Get("engine", "") && |
| 271 | param.Get("guid", "") == param_.Get("guid", "") && | 271 | param.Get("guid", "") == param_.Get("guid", "") && |
| 272 | param.Get("port", "") == param_.Get("port", ""); | 272 | param.Get("port", 0) == param_.Get("port", 0); |
| 273 | }); | 273 | }); |
| 274 | if (devices_it != devices.end()) { | 274 | if (devices_it != devices.end()) { |
| 275 | continue; | 275 | continue; |
| @@ -277,7 +277,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const { | |||
| 277 | Common::ParamPackage device{}; | 277 | Common::ParamPackage device{}; |
| 278 | device.Set("engine", param.Get("engine", "")); | 278 | device.Set("engine", param.Get("engine", "")); |
| 279 | device.Set("guid", param.Get("guid", "")); | 279 | device.Set("guid", param.Get("guid", "")); |
| 280 | device.Set("port", param.Get("port", "")); | 280 | device.Set("port", param.Get("port", 0)); |
| 281 | devices.push_back(device); | 281 | devices.push_back(device); |
| 282 | } | 282 | } |
| 283 | return devices; | 283 | return devices; |
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; |
diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index c6c19fae4..7ed95eac6 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h | |||
| @@ -143,6 +143,9 @@ public: | |||
| 143 | void DeleteCallback(int key); | 143 | void DeleteCallback(int key); |
| 144 | 144 | ||
| 145 | private: | 145 | private: |
| 146 | /// Helps assigning a value to keyboard_state | ||
| 147 | void UpdateKey(std::size_t key_index, bool status); | ||
| 148 | |||
| 146 | /** | 149 | /** |
| 147 | * Updates the touch status of the console | 150 | * Updates the touch status of the console |
| 148 | * @param callback: A CallbackStatus containing the key status | 151 | * @param callback: A CallbackStatus containing the key status |