diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_common/sdl/sdl_impl.cpp | 45 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.h | 5 |
3 files changed, 29 insertions, 33 deletions
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index a9f7e5103..6024ed97a 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp | |||
| @@ -1068,7 +1068,6 @@ public: | |||
| 1068 | 1068 | ||
| 1069 | void Start(const std::string& device_id) override { | 1069 | void Start(const std::string& device_id) override { |
| 1070 | SDLPoller::Start(device_id); | 1070 | SDLPoller::Start(device_id); |
| 1071 | // Load the game controller | ||
| 1072 | // Reset stored axes | 1071 | // Reset stored axes |
| 1073 | analog_x_axis = -1; | 1072 | analog_x_axis = -1; |
| 1074 | analog_y_axis = -1; | 1073 | analog_y_axis = -1; |
| @@ -1081,40 +1080,21 @@ public: | |||
| 1081 | if (event.type == SDL_JOYAXISMOTION && std::abs(event.jaxis.value / 32767.0) < 0.5) { | 1080 | if (event.type == SDL_JOYAXISMOTION && std::abs(event.jaxis.value / 32767.0) < 0.5) { |
| 1082 | continue; | 1081 | continue; |
| 1083 | } | 1082 | } |
| 1084 | // Simplify controller config by testing if game controller support is enabled. | ||
| 1085 | if (event.type == SDL_JOYAXISMOTION) { | 1083 | if (event.type == SDL_JOYAXISMOTION) { |
| 1086 | const auto axis = event.jaxis.axis; | 1084 | const auto axis = event.jaxis.axis; |
| 1087 | if (const auto joystick = state.GetSDLJoystickBySDLID(event.jaxis.which); | 1085 | // In order to return a complete analog param, we need inputs for both axes. |
| 1088 | auto* const controller = joystick->GetSDLGameController()) { | 1086 | // First we take the x-axis (horizontal) input, then the y-axis (vertical) input. |
| 1089 | const auto axis_left_x = | 1087 | if (analog_x_axis == -1) { |
| 1090 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTX) | 1088 | analog_x_axis = axis; |
| 1091 | .value.axis; | 1089 | } else if (analog_y_axis == -1 && analog_x_axis != axis) { |
| 1092 | const auto axis_left_y = | 1090 | analog_y_axis = axis; |
| 1093 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTY) | 1091 | } |
| 1094 | .value.axis; | 1092 | } else { |
| 1095 | const auto axis_right_x = | 1093 | // If the press wasn't accepted as a joy axis, check for a button press |
| 1096 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX) | 1094 | auto button_press = button_poller.FromEvent(event); |
| 1097 | .value.axis; | 1095 | if (button_press) { |
| 1098 | const auto axis_right_y = | 1096 | return *button_press; |
| 1099 | SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY) | ||
| 1100 | .value.axis; | ||
| 1101 | |||
| 1102 | if (axis == axis_left_x || axis == axis_left_y) { | ||
| 1103 | analog_x_axis = axis_left_x; | ||
| 1104 | analog_y_axis = axis_left_y; | ||
| 1105 | break; | ||
| 1106 | } else if (axis == axis_right_x || axis == axis_right_y) { | ||
| 1107 | analog_x_axis = axis_right_x; | ||
| 1108 | analog_y_axis = axis_right_y; | ||
| 1109 | break; | ||
| 1110 | } | ||
| 1111 | } | 1097 | } |
| 1112 | } | ||
| 1113 | |||
| 1114 | // If the press wasn't accepted as a joy axis, check for a button press | ||
| 1115 | auto button_press = button_poller.FromEvent(event); | ||
| 1116 | if (button_press) { | ||
| 1117 | return *button_press; | ||
| 1118 | } | 1098 | } |
| 1119 | } | 1099 | } |
| 1120 | 1100 | ||
| @@ -1127,6 +1107,7 @@ public: | |||
| 1127 | return params; | 1107 | return params; |
| 1128 | } | 1108 | } |
| 1129 | } | 1109 | } |
| 1110 | |||
| 1130 | return {}; | 1111 | return {}; |
| 1131 | } | 1112 | } |
| 1132 | 1113 | ||
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 4ed704793..5abf9f0bf 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -370,6 +370,18 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | connect(analog_button, &QPushButton::clicked, [=, this] { | 372 | connect(analog_button, &QPushButton::clicked, [=, this] { |
| 373 | if (!map_analog_stick_accepted) { | ||
| 374 | map_analog_stick_accepted = | ||
| 375 | QMessageBox::information( | ||
| 376 | this, tr("Map Analog Stick"), | ||
| 377 | tr("After pressing OK, first move your joystick horizontally, and then " | ||
| 378 | "vertically.\nTo invert the axes, first move your joystick " | ||
| 379 | "vertically, and then horizontally."), | ||
| 380 | QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok; | ||
| 381 | if (!map_analog_stick_accepted) { | ||
| 382 | return; | ||
| 383 | } | ||
| 384 | } | ||
| 373 | HandleClick( | 385 | HandleClick( |
| 374 | analog_map_buttons[analog_id][sub_button_id], | 386 | analog_map_buttons[analog_id][sub_button_id], |
| 375 | [=, this](const Common::ParamPackage& params) { | 387 | [=, this](const Common::ParamPackage& params) { |
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 05dee5af5..4895e8850 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h | |||
| @@ -181,9 +181,12 @@ private: | |||
| 181 | 181 | ||
| 182 | std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers; | 182 | std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> device_pollers; |
| 183 | 183 | ||
| 184 | /// A flag to indicate that the "Map Analog Stick" pop-up has been shown and accepted once. | ||
| 185 | bool map_analog_stick_accepted{}; | ||
| 186 | |||
| 184 | /// A flag to indicate if keyboard keys are okay when configuring an input. If this is false, | 187 | /// A flag to indicate if keyboard keys are okay when configuring an input. If this is false, |
| 185 | /// keyboard events are ignored. | 188 | /// keyboard events are ignored. |
| 186 | bool want_keyboard_mouse = false; | 189 | bool want_keyboard_mouse{}; |
| 187 | 190 | ||
| 188 | /// List of physical devices users can map with. If a SDL backed device is selected, then you | 191 | /// List of physical devices users can map with. If a SDL backed device is selected, then you |
| 189 | /// can use this device to get a default mapping. | 192 | /// can use this device to get a default mapping. |