settings: Fix mouse and keyboard mappings
This commit is contained in:
parent
cc651c7c99
commit
464c4d26ac
10 changed files with 100 additions and 103 deletions
|
@ -246,7 +246,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const {
|
|||
devices.begin(), devices.end(), [param](const Common::ParamPackage param_) {
|
||||
return param.Get("engine", "") == param_.Get("engine", "") &&
|
||||
param.Get("guid", "") == param_.Get("guid", "") &&
|
||||
param.Get("port", "") == param_.Get("port", "");
|
||||
param.Get("port", 0) == param_.Get("port", 0);
|
||||
});
|
||||
if (devices_it != devices.end()) {
|
||||
continue;
|
||||
|
@ -254,7 +254,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const {
|
|||
Common::ParamPackage device{};
|
||||
device.Set("engine", param.Get("engine", ""));
|
||||
device.Set("guid", param.Get("guid", ""));
|
||||
device.Set("port", param.Get("port", ""));
|
||||
device.Set("port", param.Get("port", 0));
|
||||
devices.push_back(device);
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const {
|
|||
devices.begin(), devices.end(), [param](const Common::ParamPackage param_) {
|
||||
return param.Get("engine", "") == param_.Get("engine", "") &&
|
||||
param.Get("guid", "") == param_.Get("guid", "") &&
|
||||
param.Get("port", "") == param_.Get("port", "");
|
||||
param.Get("port", 0) == param_.Get("port", 0);
|
||||
});
|
||||
if (devices_it != devices.end()) {
|
||||
continue;
|
||||
|
@ -277,7 +277,7 @@ std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices() const {
|
|||
Common::ParamPackage device{};
|
||||
device.Set("engine", param.Get("engine", ""));
|
||||
device.Set("guid", param.Get("guid", ""));
|
||||
device.Set("port", param.Get("port", ""));
|
||||
device.Set("port", param.Get("port", 0));
|
||||
devices.push_back(device);
|
||||
}
|
||||
return devices;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -143,6 +143,9 @@ public:
|
|||
void DeleteCallback(int key);
|
||||
|
||||
private:
|
||||
/// Helps assigning a value to keyboard_state
|
||||
void UpdateKey(std::size_t key_index, bool status);
|
||||
|
||||
/**
|
||||
* Updates the touch status of the console
|
||||
* @param callback: A CallbackStatus containing the key status
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue