summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2026-09-03 21:28:20 +0200
committerGitHub <noreply@github.com>2026-09-03 21:28:20 +0200
commit5ff90a0471d7ac6905290c508559db1c4da5193f (patch)
tree82d0d66921a30b26237edfa4fcd1c1078814c1cd /Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp
parenta1e636d72c8469acf747ac6542f0b7ace7cea02f (diff)
parent7da0baae932f55a228ae92be7f4cf7231683f4ca (diff)
Merge pull request #14686 from JoshuaVandaele/sdl-touchpads
SDLGamepad: Support multiple touchpads
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp
index 09457598c6..682e24c28a 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp
@@ -104,15 +104,21 @@ Gamepad::Gamepad(SDL_Gamepad* const gamepad, SDL_Joystick* const joystick)
}
// Touchpad
- if (SDL_GetNumGamepadTouchpads(m_gamepad) > 0)
+ const int num_touchpads = SDL_GetNumGamepadTouchpads(m_gamepad);
+ if (num_touchpads > 0)
{
- const char* const name_x = "Touchpad X";
- AddInput(new NonDetectableDirectionalInput<-1>(name_x, &m_touchpad_x));
- AddInput(new NonDetectableDirectionalInput<+1>(name_x, &m_touchpad_x));
- const char* const name_y = "Touchpad Y";
- AddInput(new NonDetectableDirectionalInput<-1>(name_y, &m_touchpad_y));
- AddInput(new NonDetectableDirectionalInput<+1>(name_y, &m_touchpad_y));
- AddInput(new NormalizedInput("Touchpad Pressure", &m_touchpad_pressure));
+ m_touchpads.resize(num_touchpads);
+ for (int t = 0; t < num_touchpads; ++t)
+ {
+ // We do not number the first touchpad to keep backwards compatibility with existing configs
+ // that use "Touchpad X" and "Touchpad Y" as input names.
+ const std::string prefix = t > 0 ? fmt::format("Touchpad {} ", t) : "Touchpad ";
+ AddInput(new NonDetectableDirectionalInput<-1>(prefix + "X", &m_touchpads[t].x));
+ AddInput(new NonDetectableDirectionalInput<+1>(prefix + "X", &m_touchpads[t].x));
+ AddInput(new NonDetectableDirectionalInput<-1>(prefix + "Y", &m_touchpads[t].y));
+ AddInput(new NonDetectableDirectionalInput<+1>(prefix + "Y", &m_touchpads[t].y));
+ AddInput(new NormalizedInput(prefix + "Pressure", &m_touchpads[t].pressure));
+ }
}
// Motion