mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-18 23:07:07 -05:00
feat(libScePad): bind L2 to R and the first mouse side button
This commit is contained in:
1 parent
cdb7ed0355
commit
367d46e480
3 files changed
+22
-2
No files matched your search
@@ -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}
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -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<std::uint32_t>(Pad::PadButton::L2);
|
||||
const auto r2 = static_cast<std::uint32_t>(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<std::uint32_t>(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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user