diff options
-rw-r--r-- | src/core/hle/service/am/applets/controller.cpp | 23 | ||||
-rw-r--r-- | src/core/settings.h | 2 | ||||
-rwxr-xr-x | src/input_common/analog_from_button.cpp | 22 | ||||
-rw-r--r-- | src/yuzu/configuration/config.cpp | 5 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_advanced.cpp | 2 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_advanced.ui | 31 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_motion_touch.cpp | 4 |
7 files changed, 65 insertions, 24 deletions
diff --git a/src/core/hle/service/am/applets/controller.cpp b/src/core/hle/service/am/applets/controller.cpp index e8ea4248b..7edfca64e 100644 --- a/src/core/hle/service/am/applets/controller.cpp +++ b/src/core/hle/service/am/applets/controller.cpp @@ -29,14 +29,14 @@ static Core::Frontend::ControllerParameters ConvertToFrontendParameters( npad_style_set.raw = private_arg.style_set; return { - .min_players = std::max(s8(1), header.player_count_min), + .min_players = std::max(s8{1}, header.player_count_min), .max_players = header.player_count_max, .keep_controllers_connected = header.enable_take_over_connection, .enable_single_mode = header.enable_single_mode, .enable_border_color = header.enable_identification_color, - .border_colors = identification_colors, + .border_colors = std::move(identification_colors), .enable_explain_text = enable_text, - .explain_text = text, + .explain_text = std::move(text), .allow_pro_controller = npad_style_set.pro_controller == 1, .allow_handheld = npad_style_set.handheld == 1, .allow_dual_joycons = npad_style_set.joycon_dual == 1, @@ -227,15 +227,14 @@ void Controller::ConfigurationComplete() { // If enable_single_mode is enabled, player_count is 1 regardless of any other parameters. // Otherwise, only count connected players from P1-P8. result_info.player_count = - is_single_mode ? 1 - : static_cast<s8>(std::count_if( - players.begin(), players.end() - 2, - [](Settings::PlayerInput player) { return player.connected; })); - - result_info.selected_id = HID::Controller_NPad::IndexToNPad( - std::distance(players.begin(), - std::find_if(players.begin(), players.end(), - [](Settings::PlayerInput player) { return player.connected; }))); + is_single_mode + ? 1 + : static_cast<s8>(std::count_if(players.begin(), players.end() - 2, + [](const auto& player) { return player.connected; })); + + result_info.selected_id = HID::Controller_NPad::IndexToNPad(std::distance( + players.begin(), std::find_if(players.begin(), players.end(), + [](const auto& player) { return player.connected; }))); result_info.result = 0; diff --git a/src/core/settings.h b/src/core/settings.h index 8e076f7ef..d5f8d2b7e 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -180,6 +180,8 @@ struct Values { std::string motion_device; std::string udp_input_servers; + bool emulate_analog_keyboard; + bool mouse_enabled; std::string mouse_device; MouseButtonsRaw mouse_buttons; diff --git a/src/input_common/analog_from_button.cpp b/src/input_common/analog_from_button.cpp index d748c1c04..40b516f85 100755 --- a/src/input_common/analog_from_button.cpp +++ b/src/input_common/analog_from_button.cpp @@ -6,6 +6,7 @@ #include <cmath> #include <thread> #include "common/math_util.h" +#include "core/settings.h" #include "input_common/analog_from_button.h" namespace InputCommon { @@ -112,7 +113,26 @@ public: } std::tuple<float, float> GetStatus() const override { - return std::make_tuple(std::cos(angle) * amplitude, std::sin(angle) * amplitude); + if (Settings::values.emulate_analog_keyboard) { + return std::make_tuple(std::cos(angle) * amplitude, std::sin(angle) * amplitude); + } + constexpr float SQRT_HALF = 0.707106781f; + int x = 0, y = 0; + if (right->GetStatus()) { + ++x; + } + if (left->GetStatus()) { + --x; + } + if (up->GetStatus()) { + ++y; + } + if (down->GetStatus()) { + --y; + } + const float coef = modifier->GetStatus() ? modifier_scale : 1.0f; + return std::make_tuple(static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF), + static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF)); } bool GetAnalogDirectionStatus(Input::AnalogDirection direction) const override { diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index fcc38b3af..0ec5b861a 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -511,6 +511,9 @@ void Config::ReadControlValues() { ReadTouchscreenValues(); ReadMotionTouchValues(); + Settings::values.emulate_analog_keyboard = + ReadSetting(QStringLiteral("emulate_analog_keyboard"), false).toBool(); + ReadSettingGlobal(Settings::values.use_docked_mode, QStringLiteral("use_docked_mode"), false); ReadSettingGlobal(Settings::values.vibration_enabled, QStringLiteral("vibration_enabled"), true); @@ -1186,6 +1189,8 @@ void Config::SaveControlValues() { QString::fromStdString(Settings::values.touch_device), QStringLiteral("engine:emu_window")); WriteSetting(QStringLiteral("keyboard_enabled"), Settings::values.keyboard_enabled, false); + WriteSetting(QStringLiteral("emulate_analog_keyboard"), + Settings::values.emulate_analog_keyboard, false); qt_config->endGroup(); } diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index abaf03630..4e557bc6f 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp @@ -121,6 +121,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() { Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked(); Settings::values.mouse_enabled = ui->mouse_enabled->isChecked(); Settings::values.keyboard_enabled = ui->keyboard_enabled->isChecked(); + Settings::values.emulate_analog_keyboard = ui->emulate_analog_keyboard->isChecked(); Settings::values.touchscreen.enabled = ui->touchscreen_enabled->isChecked(); } @@ -147,6 +148,7 @@ void ConfigureInputAdvanced::LoadConfiguration() { ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled); ui->mouse_enabled->setChecked(Settings::values.mouse_enabled); ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled); + ui->emulate_analog_keyboard->setChecked(Settings::values.emulate_analog_keyboard); ui->touchscreen_enabled->setChecked(Settings::values.touchscreen.enabled); UpdateUIEnabled(); diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui index a880a7c68..f207e5d3b 100644 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ b/src/yuzu/configuration/configure_input_advanced.ui @@ -2546,14 +2546,27 @@ </property> </widget> </item> - <item row="4" column="2"> + <item row="1" column="0"> + <widget class="QCheckBox" name="emulate_analog_keyboard"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="text"> + <string>Emulate Analog with Keyboard Input</string> + </property> + </widget> + </item> + <item row="5" column="2"> <widget class="QPushButton" name="touchscreen_advanced"> <property name="text"> <string>Advanced</string> </property> </widget> </item> - <item row="1" column="1"> + <item row="2" column="1"> <spacer name="horizontalSpacer_8"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -2569,21 +2582,21 @@ </property> </spacer> </item> - <item row="1" column="2"> + <item row="2" column="2"> <widget class="QPushButton" name="mouse_advanced"> <property name="text"> <string>Advanced</string> </property> </widget> </item> - <item row="4" column="0"> + <item row="5" column="0"> <widget class="QCheckBox" name="touchscreen_enabled"> <property name="text"> <string>Touchscreen</string> </property> </widget> </item> - <item row="1" column="0"> + <item row="2" column="0"> <widget class="QCheckBox" name="mouse_enabled"> <property name="minimumSize"> <size> @@ -2596,28 +2609,28 @@ </property> </widget> </item> - <item row="6" column="0"> + <item row="7" column="0"> <widget class="QLabel" name="motion_touch"> <property name="text"> <string>Motion / Touch</string> </property> </widget> </item> - <item row="6" column="2"> + <item row="7" column="2"> <widget class="QPushButton" name="buttonMotionTouch"> <property name="text"> <string>Configure</string> </property> </widget> </item> - <item row="5" column="0"> + <item row="6" column="0"> <widget class="QCheckBox" name="debug_enabled"> <property name="text"> <string>Debug Controller</string> </property> </widget> </item> - <item row="5" column="2"> + <item row="6" column="2"> <widget class="QPushButton" name="debug_configure"> <property name="text"> <string>Configure</string> diff --git a/src/yuzu/configuration/configure_motion_touch.cpp b/src/yuzu/configuration/configure_motion_touch.cpp index 2afac591a..c2a7113da 100644 --- a/src/yuzu/configuration/configure_motion_touch.cpp +++ b/src/yuzu/configuration/configure_motion_touch.cpp @@ -183,8 +183,8 @@ void ConfigureMotionTouch::ConnectEvents() { } void ConfigureMotionTouch::OnUDPAddServer() { - QRegExp re(tr("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[" - "0-9][0-9]?)$")); // a valid ip address + QRegExp re(tr(R"re(^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4]" + "[0-9]|[01]?[0-9][0-9]?)$)re")); // a valid ip address bool ok; QString port_text = ui->udp_port->text(); QString server_text = ui->udp_server->text(); |