diff options
Diffstat (limited to 'src')
| -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 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 17 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 1 | ||||
| -rw-r--r-- | src/input_common/input_engine.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/main.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 147 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_vibration.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu/debugger/controller.cpp | 3 |
10 files changed, 102 insertions, 105 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 |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 2c2432fb7..1c32b54be 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -121,12 +121,27 @@ void Mouse::StopPanning() { | |||
| 121 | std::vector<Common::ParamPackage> Mouse::GetInputDevices() const { | 121 | std::vector<Common::ParamPackage> Mouse::GetInputDevices() const { |
| 122 | std::vector<Common::ParamPackage> devices; | 122 | std::vector<Common::ParamPackage> devices; |
| 123 | devices.emplace_back(Common::ParamPackage{ | 123 | devices.emplace_back(Common::ParamPackage{ |
| 124 | {"engine", "keyboard"}, | 124 | {"engine", GetEngineName()}, |
| 125 | {"display", "Keyboard/Mouse"}, | 125 | {"display", "Keyboard/Mouse"}, |
| 126 | }); | 126 | }); |
| 127 | return devices; | 127 | return devices; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | AnalogMapping Mouse::GetAnalogMappingForDevice( | ||
| 131 | [[maybe_unused]] const Common::ParamPackage& params) { | ||
| 132 | // Only overwrite different buttons from default | ||
| 133 | AnalogMapping mapping = {}; | ||
| 134 | Common::ParamPackage right_analog_params; | ||
| 135 | right_analog_params.Set("engine", GetEngineName()); | ||
| 136 | right_analog_params.Set("axis_x", 0); | ||
| 137 | right_analog_params.Set("axis_y", 1); | ||
| 138 | right_analog_params.Set("threshold", 0.5f); | ||
| 139 | right_analog_params.Set("range", 1.0f); | ||
| 140 | right_analog_params.Set("deadzone", 0.0f); | ||
| 141 | mapping.insert_or_assign(Settings::NativeAnalog::RStick, std::move(right_analog_params)); | ||
| 142 | return mapping; | ||
| 143 | } | ||
| 144 | |||
| 130 | std::string Mouse::GetUIName(const Common::ParamPackage& params) const { | 145 | std::string Mouse::GetUIName(const Common::ParamPackage& params) const { |
| 131 | if (params.Has("button")) { | 146 | if (params.Has("button")) { |
| 132 | return fmt::format("Mouse {}", params.Get("button", 0)); | 147 | return fmt::format("Mouse {}", params.Get("button", 0)); |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index e8355751a..d3178b1a9 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -55,6 +55,7 @@ public: | |||
| 55 | void ReleaseAllButtons(); | 55 | void ReleaseAllButtons(); |
| 56 | 56 | ||
| 57 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 57 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
| 58 | AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; | ||
| 58 | std::string GetUIName(const Common::ParamPackage& params) const override; | 59 | std::string GetUIName(const Common::ParamPackage& params) const override; |
| 59 | 60 | ||
| 60 | private: | 61 | private: |
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 1534f24b0..9cfe0f232 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -202,6 +202,8 @@ void InputEngine::TriggerOnButtonChange(const PadIdentifier& identifier, int but | |||
| 202 | if (!configuring || !mapping_callback.on_data) { | 202 | if (!configuring || !mapping_callback.on_data) { |
| 203 | return; | 203 | return; |
| 204 | } | 204 | } |
| 205 | |||
| 206 | PreSetButton(identifier, button); | ||
| 205 | if (value == GetButton(identifier, button)) { | 207 | if (value == GetButton(identifier, button)) { |
| 206 | return; | 208 | return; |
| 207 | } | 209 | } |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 8f7ce59b7..07d514ad7 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -143,6 +143,9 @@ struct InputSubsystem::Impl { | |||
| 143 | return {}; | 143 | return {}; |
| 144 | } | 144 | } |
| 145 | const std::string engine = params.Get("engine", ""); | 145 | const std::string engine = params.Get("engine", ""); |
| 146 | if (engine == mouse->GetEngineName()) { | ||
| 147 | return mouse->GetAnalogMappingForDevice(params); | ||
| 148 | } | ||
| 146 | if (engine == gcadapter->GetEngineName()) { | 149 | if (engine == gcadapter->GetEngineName()) { |
| 147 | return gcadapter->GetAnalogMappingForDevice(params); | 150 | return gcadapter->GetAnalogMappingForDevice(params); |
| 148 | } | 151 | } |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index cd33b5711..416096333 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -478,37 +478,39 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 478 | UpdateControllerEnabledButtons(); | 478 | UpdateControllerEnabledButtons(); |
| 479 | UpdateControllerButtonNames(); | 479 | UpdateControllerButtonNames(); |
| 480 | UpdateMotionButtons(); | 480 | UpdateMotionButtons(); |
| 481 | connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), [this, player_index](int) { | 481 | connect(ui->comboControllerType, qOverload<int>(&QComboBox::currentIndexChanged), |
| 482 | UpdateControllerAvailableButtons(); | 482 | [this, player_index](int) { |
| 483 | UpdateControllerEnabledButtons(); | 483 | UpdateControllerAvailableButtons(); |
| 484 | UpdateControllerButtonNames(); | 484 | UpdateControllerEnabledButtons(); |
| 485 | UpdateMotionButtons(); | 485 | UpdateControllerButtonNames(); |
| 486 | const Core::HID::NpadType type = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); | 486 | UpdateMotionButtons(); |
| 487 | 487 | const Core::HID::NpadType type = | |
| 488 | if (player_index == 0) { | 488 | GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); |
| 489 | auto* emulated_controller_p1 = | 489 | |
| 490 | system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); | 490 | if (player_index == 0) { |
| 491 | auto* emulated_controller_hanheld = | 491 | auto* emulated_controller_p1 = |
| 492 | system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); | 492 | system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1); |
| 493 | bool is_connected = emulated_controller->IsConnected(true); | 493 | auto* emulated_controller_hanheld = |
| 494 | 494 | system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); | |
| 495 | emulated_controller_p1->SetNpadType(type); | 495 | bool is_connected = emulated_controller->IsConnected(true); |
| 496 | emulated_controller_hanheld->SetNpadType(type); | 496 | |
| 497 | if (is_connected) { | 497 | emulated_controller_p1->SetNpadType(type); |
| 498 | if (type == Core::HID::NpadType::Handheld) { | 498 | emulated_controller_hanheld->SetNpadType(type); |
| 499 | emulated_controller_p1->Disconnect(); | 499 | if (is_connected) { |
| 500 | emulated_controller_hanheld->Connect(); | 500 | if (type == Core::HID::NpadType::Handheld) { |
| 501 | emulated_controller = emulated_controller_hanheld; | 501 | emulated_controller_p1->Disconnect(); |
| 502 | } else { | 502 | emulated_controller_hanheld->Connect(); |
| 503 | emulated_controller_hanheld->Disconnect(); | 503 | emulated_controller = emulated_controller_hanheld; |
| 504 | emulated_controller_p1->Connect(); | 504 | } else { |
| 505 | emulated_controller = emulated_controller_p1; | 505 | emulated_controller_hanheld->Disconnect(); |
| 506 | emulated_controller_p1->Connect(); | ||
| 507 | emulated_controller = emulated_controller_p1; | ||
| 508 | } | ||
| 509 | } | ||
| 510 | ui->controllerFrame->SetController(emulated_controller); | ||
| 506 | } | 511 | } |
| 507 | } | 512 | emulated_controller->SetNpadType(type); |
| 508 | ui->controllerFrame->SetController(emulated_controller); | 513 | }); |
| 509 | } | ||
| 510 | emulated_controller->SetNpadType(type); | ||
| 511 | }); | ||
| 512 | 514 | ||
| 513 | connect(ui->comboDevices, qOverload<int>(&QComboBox::activated), this, | 515 | connect(ui->comboDevices, qOverload<int>(&QComboBox::activated), this, |
| 514 | &ConfigureInputPlayer::UpdateMappingWithDefaults); | 516 | &ConfigureInputPlayer::UpdateMappingWithDefaults); |
| @@ -555,7 +557,7 @@ ConfigureInputPlayer::~ConfigureInputPlayer() { | |||
| 555 | } else { | 557 | } else { |
| 556 | emulated_controller->DisableConfiguration(); | 558 | emulated_controller->DisableConfiguration(); |
| 557 | } | 559 | } |
| 558 | }; | 560 | } |
| 559 | 561 | ||
| 560 | void ConfigureInputPlayer::ApplyConfiguration() { | 562 | void ConfigureInputPlayer::ApplyConfiguration() { |
| 561 | if (player_index == 0) { | 563 | if (player_index == 0) { |
| @@ -642,7 +644,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() { | |||
| 642 | 644 | ||
| 643 | const auto first_engine = devices[0].Get("engine", ""); | 645 | const auto first_engine = devices[0].Get("engine", ""); |
| 644 | const auto first_guid = devices[0].Get("guid", ""); | 646 | const auto first_guid = devices[0].Get("guid", ""); |
| 645 | const auto first_port = devices[0].Get("port", ""); | 647 | const auto first_port = devices[0].Get("port", 0); |
| 646 | 648 | ||
| 647 | if (devices.size() == 1) { | 649 | if (devices.size() == 1) { |
| 648 | const auto devices_it = | 650 | const auto devices_it = |
| @@ -650,7 +652,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() { | |||
| 650 | [first_engine, first_guid, first_port](const Common::ParamPackage param) { | 652 | [first_engine, first_guid, first_port](const Common::ParamPackage param) { |
| 651 | return param.Get("engine", "") == first_engine && | 653 | return param.Get("engine", "") == first_engine && |
| 652 | param.Get("guid", "") == first_guid && | 654 | param.Get("guid", "") == first_guid && |
| 653 | param.Get("port", "") == first_port; | 655 | param.Get("port", 0) == first_port; |
| 654 | }); | 656 | }); |
| 655 | const int device_index = | 657 | const int device_index = |
| 656 | devices_it != input_devices.end() | 658 | devices_it != input_devices.end() |
| @@ -662,7 +664,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() { | |||
| 662 | 664 | ||
| 663 | const auto second_engine = devices[1].Get("engine", ""); | 665 | const auto second_engine = devices[1].Get("engine", ""); |
| 664 | const auto second_guid = devices[1].Get("guid", ""); | 666 | const auto second_guid = devices[1].Get("guid", ""); |
| 665 | const auto second_port = devices[1].Get("port", ""); | 667 | const auto second_port = devices[1].Get("port", 0); |
| 666 | 668 | ||
| 667 | const bool is_keyboard_mouse = (first_engine == "keyboard" || first_engine == "mouse") && | 669 | const bool is_keyboard_mouse = (first_engine == "keyboard" || first_engine == "mouse") && |
| 668 | (second_engine == "keyboard" || second_engine == "mouse"); | 670 | (second_engine == "keyboard" || second_engine == "mouse"); |
| @@ -684,7 +686,7 @@ void ConfigureInputPlayer::UpdateInputDeviceCombobox() { | |||
| 684 | param.Get("guid2", "") == second_guid) || | 686 | param.Get("guid2", "") == second_guid) || |
| 685 | (param.Get("guid", "") == second_guid && param.Get("guid2", "") == first_guid); | 687 | (param.Get("guid", "") == second_guid && param.Get("guid2", "") == first_guid); |
| 686 | return param.Get("engine", "") == first_engine && is_guid_valid && | 688 | return param.Get("engine", "") == first_engine && is_guid_valid && |
| 687 | param.Get("port", "") == first_port; | 689 | param.Get("port", 0) == first_port; |
| 688 | }); | 690 | }); |
| 689 | const int device_index = | 691 | const int device_index = |
| 690 | devices_it != input_devices.end() | 692 | devices_it != input_devices.end() |
| @@ -1096,8 +1098,8 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() { | |||
| 1096 | emulated_controller->SetMotionParam(motion_id, {}); | 1098 | emulated_controller->SetMotionParam(motion_id, {}); |
| 1097 | } | 1099 | } |
| 1098 | 1100 | ||
| 1099 | // Reset keyboard bindings | 1101 | // Reset keyboard or mouse bindings |
| 1100 | if (ui->comboDevices->currentIndex() == 1) { | 1102 | if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) { |
| 1101 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) { | 1103 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) { |
| 1102 | emulated_controller->SetButtonParam( | 1104 | emulated_controller->SetButtonParam( |
| 1103 | button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam( | 1105 | button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam( |
| @@ -1122,63 +1124,30 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() { | |||
| 1122 | Config::default_motions[motion_id])}); | 1124 | Config::default_motions[motion_id])}); |
| 1123 | } | 1125 | } |
| 1124 | 1126 | ||
| 1125 | UpdateUI(); | 1127 | // If mouse is selected we want to override with mappings from the driver |
| 1126 | return; | 1128 | if (ui->comboDevices->currentIndex() == 1) { |
| 1127 | } | 1129 | UpdateUI(); |
| 1128 | 1130 | return; | |
| 1129 | // Reset keyboard with mouse bindings | ||
| 1130 | if (ui->comboDevices->currentIndex() == 2) { | ||
| 1131 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; ++button_id) { | ||
| 1132 | emulated_controller->SetButtonParam( | ||
| 1133 | button_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam( | ||
| 1134 | Config::default_buttons[button_id])}); | ||
| 1135 | } | ||
| 1136 | |||
| 1137 | Common::ParamPackage left_analog_param{}; | ||
| 1138 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { | ||
| 1139 | Common::ParamPackage params{InputCommon::GenerateKeyboardParam( | ||
| 1140 | Config::default_analogs[Settings::NativeAnalog::LStick][sub_button_id])}; | ||
| 1141 | SetAnalogParam(params, left_analog_param, analog_sub_buttons[sub_button_id]); | ||
| 1142 | } | ||
| 1143 | left_analog_param.Set("modifier", | ||
| 1144 | InputCommon::GenerateKeyboardParam( | ||
| 1145 | Config::default_stick_mod[Settings::NativeAnalog::LStick])); | ||
| 1146 | emulated_controller->SetStickParam(Settings::NativeAnalog::LStick, left_analog_param); | ||
| 1147 | |||
| 1148 | Common::ParamPackage right_analog_param{}; | ||
| 1149 | right_analog_param.Set("engine", "mouse"); | ||
| 1150 | right_analog_param.Set("port", 0); | ||
| 1151 | right_analog_param.Set("axis_x", 0); | ||
| 1152 | right_analog_param.Set("axis_y", 1); | ||
| 1153 | emulated_controller->SetStickParam(Settings::NativeAnalog::RStick, | ||
| 1154 | std::move(right_analog_param)); | ||
| 1155 | |||
| 1156 | for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { | ||
| 1157 | emulated_controller->SetMotionParam( | ||
| 1158 | motion_id, Common::ParamPackage{InputCommon::GenerateKeyboardParam( | ||
| 1159 | Config::default_motions[motion_id])}); | ||
| 1160 | } | 1131 | } |
| 1161 | |||
| 1162 | UpdateUI(); | ||
| 1163 | return; | ||
| 1164 | } | 1132 | } |
| 1165 | 1133 | ||
| 1166 | // Reset controller bindings | 1134 | // Reset controller bindings |
| 1167 | const auto& device = input_devices[ui->comboDevices->currentIndex()]; | 1135 | const auto& device = input_devices[ui->comboDevices->currentIndex()]; |
| 1168 | auto button_mapping = input_subsystem->GetButtonMappingForDevice(device); | 1136 | auto button_mappings = input_subsystem->GetButtonMappingForDevice(device); |
| 1169 | auto analog_mapping = input_subsystem->GetAnalogMappingForDevice(device); | 1137 | auto analog_mappings = input_subsystem->GetAnalogMappingForDevice(device); |
| 1170 | auto motion_mapping = input_subsystem->GetMotionMappingForDevice(device); | 1138 | auto motion_mappings = input_subsystem->GetMotionMappingForDevice(device); |
| 1171 | for (std::size_t i = 0; i < button_mapping.size(); ++i) { | 1139 | |
| 1172 | emulated_controller->SetButtonParam( | 1140 | for (const auto& button_mapping : button_mappings) { |
| 1173 | i, button_mapping[static_cast<Settings::NativeButton::Values>(i)]); | 1141 | const std::size_t index = button_mapping.first; |
| 1142 | emulated_controller->SetButtonParam(index, button_mapping.second); | ||
| 1174 | } | 1143 | } |
| 1175 | for (std::size_t i = 0; i < analog_mapping.size(); ++i) { | 1144 | for (const auto& analog_mapping : analog_mappings) { |
| 1176 | emulated_controller->SetStickParam( | 1145 | const std::size_t index = analog_mapping.first; |
| 1177 | i, analog_mapping[static_cast<Settings::NativeAnalog::Values>(i)]); | 1146 | emulated_controller->SetStickParam(index, analog_mapping.second); |
| 1178 | } | 1147 | } |
| 1179 | for (std::size_t i = 0; i < motion_mapping.size(); ++i) { | 1148 | for (const auto& motion_mapping : motion_mappings) { |
| 1180 | emulated_controller->SetMotionParam( | 1149 | const std::size_t index = motion_mapping.first; |
| 1181 | i, motion_mapping[static_cast<Settings::NativeMotion::Values>(i)]); | 1150 | emulated_controller->SetMotionParam(index, motion_mapping.second); |
| 1182 | } | 1151 | } |
| 1183 | 1152 | ||
| 1184 | UpdateUI(); | 1153 | UpdateUI(); |
| @@ -1237,7 +1206,7 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params) | |||
| 1237 | } | 1206 | } |
| 1238 | 1207 | ||
| 1239 | // Keyboard/Mouse | 1208 | // Keyboard/Mouse |
| 1240 | if (ui->comboDevices->currentIndex() == 2) { | 1209 | if (ui->comboDevices->currentIndex() == 1 || ui->comboDevices->currentIndex() == 2) { |
| 1241 | return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse"; | 1210 | return params.Get("engine", "") == "keyboard" || params.Get("engine", "") == "mouse"; |
| 1242 | } | 1211 | } |
| 1243 | 1212 | ||
| @@ -1245,7 +1214,7 @@ bool ConfigureInputPlayer::IsInputAcceptable(const Common::ParamPackage& params) | |||
| 1245 | return params.Get("engine", "") == current_input_device.Get("engine", "") && | 1214 | return params.Get("engine", "") == current_input_device.Get("engine", "") && |
| 1246 | (params.Get("guid", "") == current_input_device.Get("guid", "") || | 1215 | (params.Get("guid", "") == current_input_device.Get("guid", "") || |
| 1247 | params.Get("guid", "") == current_input_device.Get("guid2", "")) && | 1216 | params.Get("guid", "") == current_input_device.Get("guid2", "")) && |
| 1248 | params.Get("port", "") == current_input_device.Get("port", ""); | 1217 | params.Get("port", 0) == current_input_device.Get("port", 0); |
| 1249 | } | 1218 | } |
| 1250 | 1219 | ||
| 1251 | void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) { | 1220 | void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) { |
diff --git a/src/yuzu/configuration/configure_vibration.cpp b/src/yuzu/configuration/configure_vibration.cpp index 46a0f3025..f1ce7205d 100644 --- a/src/yuzu/configuration/configure_vibration.cpp +++ b/src/yuzu/configuration/configure_vibration.cpp | |||
| @@ -97,7 +97,7 @@ void ConfigureVibration::SetVibrationDevices(std::size_t player_index) { | |||
| 97 | 97 | ||
| 98 | const auto engine = param.Get("engine", ""); | 98 | const auto engine = param.Get("engine", ""); |
| 99 | const auto guid = param.Get("guid", ""); | 99 | const auto guid = param.Get("guid", ""); |
| 100 | const auto port = param.Get("port", ""); | 100 | const auto port = param.Get("port", 0); |
| 101 | 101 | ||
| 102 | if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") { | 102 | if (engine.empty() || engine == "keyboard" || engine == "mouse" || engine == "tas") { |
| 103 | continue; | 103 | continue; |
| @@ -105,7 +105,7 @@ void ConfigureVibration::SetVibrationDevices(std::size_t player_index) { | |||
| 105 | 105 | ||
| 106 | vibration_param_str += fmt::format("engine:{}", engine); | 106 | vibration_param_str += fmt::format("engine:{}", engine); |
| 107 | 107 | ||
| 108 | if (!port.empty()) { | 108 | if (port != 0) { |
| 109 | vibration_param_str += fmt::format(",port:{}", port); | 109 | vibration_param_str += fmt::format(",port:{}", port); |
| 110 | } | 110 | } |
| 111 | if (!guid.empty()) { | 111 | if (!guid.empty()) { |
diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp index 3619aed26..f93a46421 100644 --- a/src/yuzu/debugger/controller.cpp +++ b/src/yuzu/debugger/controller.cpp | |||
| @@ -21,8 +21,7 @@ ControllerDialog::ControllerDialog(Core::System& system, QWidget* parent) | |||
| 21 | Qt::WindowMaximizeButtonHint); | 21 | Qt::WindowMaximizeButtonHint); |
| 22 | 22 | ||
| 23 | widget = new PlayerControlPreview(this); | 23 | widget = new PlayerControlPreview(this); |
| 24 | widget->SetController(system.HIDCore().GetEmulatedController( | 24 | widget->SetController(system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1)); |
| 25 | Core::HID::NpadIdType::Player1)); | ||
| 26 | QLayout* layout = new QVBoxLayout(this); | 25 | QLayout* layout = new QVBoxLayout(this); |
| 27 | layout->setContentsMargins(0, 0, 0, 0); | 26 | layout->setContentsMargins(0, 0, 0, 0); |
| 28 | layout->addWidget(widget); | 27 | layout->addWidget(widget); |