summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/input_common/drivers/sdl_driver.cpp23
-rw-r--r--src/input_common/input_poller.cpp9
2 files changed, 8 insertions, 24 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 0b24f1858..d5af6c09b 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -220,24 +220,6 @@ public:
220 return "Unknown"; 220 return "Unknown";
221 } 221 }
222 222
223 bool IsYAxis(u8 index) {
224 if (!sdl_controller) {
225 return false;
226 }
227
228 const auto& binding_left_y =
229 SDL_GameControllerGetBindForAxis(sdl_controller.get(), SDL_CONTROLLER_AXIS_LEFTY);
230 const auto& binding_right_y =
231 SDL_GameControllerGetBindForAxis(sdl_controller.get(), SDL_CONTROLLER_AXIS_RIGHTY);
232 if (index == binding_left_y.value.axis) {
233 return true;
234 }
235 if (index == binding_right_y.value.axis) {
236 return true;
237 }
238 return false;
239 }
240
241private: 223private:
242 std::string guid; 224 std::string guid;
243 int port; 225 int port;
@@ -376,11 +358,6 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
376 case SDL_JOYAXISMOTION: { 358 case SDL_JOYAXISMOTION: {
377 if (const auto joystick = GetSDLJoystickBySDLID(event.jaxis.which)) { 359 if (const auto joystick = GetSDLJoystickBySDLID(event.jaxis.which)) {
378 const PadIdentifier identifier = joystick->GetPadIdentifier(); 360 const PadIdentifier identifier = joystick->GetPadIdentifier();
379 // Vertical axis is inverted on nintendo compared to SDL
380 if (joystick->IsYAxis(event.jaxis.axis)) {
381 SetAxis(identifier, event.jaxis.axis, -event.jaxis.value / 32767.0f);
382 break;
383 }
384 SetAxis(identifier, event.jaxis.axis, event.jaxis.value / 32767.0f); 361 SetAxis(identifier, event.jaxis.axis, event.jaxis.value / 32767.0f);
385 } 362 }
386 break; 363 break;
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index 92cf690cd..7e4eafded 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -146,7 +146,8 @@ public:
146 Common::Input::AnalogProperties properties_y_, 146 Common::Input::AnalogProperties properties_y_,
147 InputEngine* input_engine_) 147 InputEngine* input_engine_)
148 : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), 148 : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_),
149 properties_y(properties_y_), input_engine(input_engine_) { 149 properties_y(properties_y_),
150 input_engine(input_engine_), invert_axis_y{input_engine_->GetEngineName() == "sdl"} {
150 UpdateCallback engine_callback{[this]() { OnChange(); }}; 151 UpdateCallback engine_callback{[this]() { OnChange(); }};
151 const InputIdentifier x_input_identifier{ 152 const InputIdentifier x_input_identifier{
152 .identifier = identifier, 153 .identifier = identifier,
@@ -181,6 +182,11 @@ public:
181 .raw_value = input_engine->GetAxis(identifier, axis_y), 182 .raw_value = input_engine->GetAxis(identifier, axis_y),
182 .properties = properties_y, 183 .properties = properties_y,
183 }; 184 };
185 // This is a workaround too keep compatibility with old yuzu versions. Vertical axis is
186 // inverted on SDL compared to Nintendo
187 if (invert_axis_y) {
188 status.y.raw_value = -status.y.raw_value;
189 }
184 return status; 190 return status;
185 } 191 }
186 192
@@ -220,6 +226,7 @@ private:
220 float last_axis_x_value; 226 float last_axis_x_value;
221 float last_axis_y_value; 227 float last_axis_y_value;
222 InputEngine* input_engine; 228 InputEngine* input_engine;
229 const bool invert_axis_y;
223}; 230};
224 231
225class InputFromTouch final : public Common::Input::InputDevice { 232class InputFromTouch final : public Common::Input::InputDevice {