summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp
diff options
context:
space:
mode:
authorJoshua Vandaƫle <joshua@vandaele.software>2026-06-15 16:42:16 +0200
committerJoshua Vandaƫle <joshua@vandaele.software>2026-08-10 22:41:40 +0200
commit7da0baae932f55a228ae92be7f4cf7231683f4ca (patch)
treefaff58fc3f41cbaf177bfa55fae5a694c2d3a80a /Source/Core/InputCommon/ControllerInterface/SDL/SDLGamepad.cpp
parent3450298af0109d85210d57e9b94bb3f71a5fbae5 (diff)
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