From 367d46e480bcaefe59b27fdef04b7ee8b2979e37 Mon Sep 17 00:00:00 2001 From: AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> Date: Sun, 18 Oct 2026 10:49:11 +0200 Subject: [PATCH] feat(libScePad): bind L2 to R and the first mouse side button --- .../prx/libScePad/include/InputMapping.hpp | 2 ++ .../libSceVideoOut/tests/KeyboardMouse.cpp | 19 +++++++++++++++++++ docs/user/INPUT_MAPPING.md | 3 +-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/libs/prx/libScePad/include/InputMapping.hpp b/core/libs/prx/libScePad/include/InputMapping.hpp index a8914303d5..eab287c508 100644 --- a/core/libs/prx/libScePad/include/InputMapping.hpp +++ b/core/libs/prx/libScePad/include/InputMapping.hpp @@ -42,6 +42,7 @@ inline constexpr std::array InputMapping{ InputBinding{SDL_SCANCODE_C, MouseButton::None, InputControl::Button, PadButton::Circle}, InputBinding{SDL_SCANCODE_Q, MouseButton::None, InputControl::Button, PadButton::L1}, InputBinding{SDL_SCANCODE_E, MouseButton::None, InputControl::Button, PadButton::R1}, + InputBinding{SDL_SCANCODE_R, MouseButton::None, InputControl::Button, PadButton::L2}, InputBinding{SDL_SCANCODE_LALT, MouseButton::None, InputControl::Button, PadButton::R1}, InputBinding{SDL_SCANCODE_RALT, MouseButton::None, InputControl::Button, PadButton::R1}, InputBinding{SDL_SCANCODE_LSHIFT, MouseButton::None, InputControl::Button, PadButton::L3}, @@ -65,6 +66,7 @@ inline constexpr std::array InputMapping{ InputBinding{SDL_SCANCODE_UNKNOWN, MouseButton::Middle, InputControl::ToggleMouse}, InputBinding{SDL_SCANCODE_UNKNOWN, MouseButton::Left, InputControl::Button, PadButton::Square}, InputBinding{SDL_SCANCODE_UNKNOWN, MouseButton::Right, InputControl::Button, PadButton::R2}, + InputBinding{SDL_SCANCODE_UNKNOWN, MouseButton::X1, InputControl::Button, PadButton::L2}, InputBinding{SDL_SCANCODE_UNKNOWN, MouseButton::None, InputControl::Button, PadButton::Up, 1}, InputBinding{SDL_SCANCODE_UNKNOWN, MouseButton::None, InputControl::Button, PadButton::Down, -1} }; diff --git a/core/libs/prx/libSceVideoOut/tests/KeyboardMouse.cpp b/core/libs/prx/libSceVideoOut/tests/KeyboardMouse.cpp index fa9b6f7e3a..50895e00aa 100644 --- a/core/libs/prx/libSceVideoOut/tests/KeyboardMouse.cpp +++ b/core/libs/prx/libSceVideoOut/tests/KeyboardMouse.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -286,6 +287,23 @@ void testToggleRequests() { check(keyboardMouse.HandleEvent(KeyEvent(SDL_SCANCODE_F11, true), now).toggleFullscreen, "F11 asks to toggle fullscreen"); } +void testDefaultL2() { + const auto l2 = static_cast(Pad::PadButton::L2); + const auto r2 = static_cast(Pad::PadButton::R2); + const auto now = Pad::KeyboardMouse::Clock::now(); + for (const auto& [name, press, release] : { + std::tuple{"R", KeyEvent(SDL_SCANCODE_R, true), KeyEvent(SDL_SCANCODE_R, false)}, + std::tuple{"mouse button 4", PadSimulation::ButtonEvent(SDL_BUTTON_X1, true), PadSimulation::ButtonEvent(SDL_BUTTON_X1, false)}}) { + Pad::KeyboardMouse keyboardMouse(defaults()); + keyboardMouse.HandleEvent(press, now); + const auto held = keyboardMouse.Compose(PadInputState{}); + check((held.buttons & l2) != 0 && held.analogButtonsL2 == 255, std::string(name) + " presses L2 fully"); + check((held.buttons & r2) == 0 && held.analogButtonsR2 == 0, std::string(name) + " leaves R2 alone"); + keyboardMouse.HandleEvent(release, now); + const auto released = keyboardMouse.Compose(PadInputState{}); + check((released.buttons & l2) == 0 && released.analogButtonsL2 == 0, std::string(name) + " released lets go of L2"); + } +} void testTitleReadsMouse() { const auto square = static_cast(Pad::PadButton::Square); @@ -349,6 +367,7 @@ int main() { {"wheel and keys on focus loss", testWheelFocusLoss}, {"focus loss releases the mouse", testFocusLossReleasesMouse}, {"toggle requests", testToggleRequests}, + {"default L2", testDefaultL2}, {"title reads the mouse", testTitleReadsMouse}, }; for (const auto& [name, test] : tests) { diff --git a/docs/user/INPUT_MAPPING.md b/docs/user/INPUT_MAPPING.md index 882ce0a000..f4d867dd73 100644 --- a/docs/user/INPUT_MAPPING.md +++ b/docs/user/INPUT_MAPPING.md @@ -30,6 +30,7 @@ Without an `anyps5-input.ini`, or for actions the file does not mention, these b | `Square` | Left mouse button | | `L1` | Q | | `R1` | E, Left Alt, Right Alt | +| `L2` | R, Mouse button 4 (X1) | | `R2` | Right mouse button | | `L3` | Left Shift, Right Shift | | `R3` | Left Ctrl, Right Ctrl | @@ -41,8 +42,6 @@ Without an `anyps5-input.ini`, or for actions the file does not mention, these b | `ToggleMouse` | Middle mouse button | | `ToggleFullscreen` | F11 | -`L2` has no built-in keyboard or mouse binding. - For example, this changes Cross to F or Space, moves the left stick to IJKL, uses the mouse buttons for Square and R2, and keeps all other built-in bindings: ```ini