sdl_window: Allow alternate face button keys on any system. (#2275)

* sdl_window: Allow alternate face button keys on any system.

* readme: Fix typo
This commit is contained in:
squidbus 2025-01-30 00:09:11 -08:00 committed by GitHub
parent 0358271b93
commit 0b50e2e270
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 44 deletions

View file

@ -76,6 +76,9 @@ For more information on how to test, debug and report issues with the emulator o
# Keyboard mapping # Keyboard mapping
> [!NOTE]
> Some keyboards may also require you to hold the Fn key to use the F\* keys. Mac users should use the Command key instead of Control, and need to use Command+F11 for full screen to avoid conflicting with system key bindings.
| Button | Function | | Button | Function |
|-------------|-------------| |-------------|-------------|
F10 | FPS Counter F10 | FPS Counter
@ -86,32 +89,32 @@ F12 | Trigger RenderDoc Capture
> [!NOTE] > [!NOTE]
> Xbox and DualShock controllers work out of the box. > Xbox and DualShock controllers work out of the box.
| Controller button | Keyboard equivelant | Mac alternative | | Controller button | Keyboard equivalent |
|-------------|-------------|--------------| |-------------|-------------|
LEFT AXIS UP | W | | LEFT AXIS UP | W |
LEFT AXIS DOWN | S | | LEFT AXIS DOWN | S |
LEFT AXIS LEFT | A | | LEFT AXIS LEFT | A |
LEFT AXIS RIGHT | D | | LEFT AXIS RIGHT | D |
RIGHT AXIS UP | I | | RIGHT AXIS UP | I |
RIGHT AXIS DOWN | K | | RIGHT AXIS DOWN | K |
RIGHT AXIS LEFT | J | | RIGHT AXIS LEFT | J |
RIGHT AXIS RIGHT | L | | RIGHT AXIS RIGHT | L |
TRIANGLE | Numpad 8 | C | TRIANGLE | Numpad 8 or C |
CIRCLE | Numpad 6 | B | CIRCLE | Numpad 6 or B |
CROSS | Numpad 2 | N | CROSS | Numpad 2 or N |
SQUARE | Numpad 4 | V | SQUARE | Numpad 4 or V |
PAD UP | UP | | PAD UP | UP |
PAD DOWN | DOWN | | PAD DOWN | DOWN |
PAD LEFT | LEFT | | PAD LEFT | LEFT |
PAD RIGHT | RIGHT | | PAD RIGHT | RIGHT |
OPTIONS | RETURN | | OPTIONS | RETURN |
BACK BUTTON / TOUCH PAD | SPACE | | BACK BUTTON / TOUCH PAD | SPACE |
L1 | Q | | L1 | Q |
R1 | U | | R1 | U |
L2 | E | | L2 | E |
R2 | O | | R2 | O |
L3 | X | | L3 | X |
R3 | M | | R3 | M |
# Main team # Main team

View file

@ -382,20 +382,6 @@ void WindowSDL::OnResize() {
} }
void WindowSDL::OnKeyPress(const SDL_Event* event) { void WindowSDL::OnKeyPress(const SDL_Event* event) {
#ifdef __APPLE__
// Use keys that are more friendly for keyboards without a keypad.
// Once there are key binding options this won't be necessary.
constexpr SDL_Keycode CrossKey = SDLK_N;
constexpr SDL_Keycode CircleKey = SDLK_B;
constexpr SDL_Keycode SquareKey = SDLK_V;
constexpr SDL_Keycode TriangleKey = SDLK_C;
#else
constexpr SDL_Keycode CrossKey = SDLK_KP_2;
constexpr SDL_Keycode CircleKey = SDLK_KP_6;
constexpr SDL_Keycode SquareKey = SDLK_KP_4;
constexpr SDL_Keycode TriangleKey = SDLK_KP_8;
#endif
auto button = OrbisPadButtonDataOffset::None; auto button = OrbisPadButtonDataOffset::None;
Input::Axis axis = Input::Axis::AxisMax; Input::Axis axis = Input::Axis::AxisMax;
int axisvalue = 0; int axisvalue = 0;
@ -414,16 +400,21 @@ void WindowSDL::OnKeyPress(const SDL_Event* event) {
case SDLK_RIGHT: case SDLK_RIGHT:
button = OrbisPadButtonDataOffset::Right; button = OrbisPadButtonDataOffset::Right;
break; break;
case TriangleKey: // Provide alternatives for face buttons for users without a numpad.
case SDLK_KP_8:
case SDLK_C:
button = OrbisPadButtonDataOffset::Triangle; button = OrbisPadButtonDataOffset::Triangle;
break; break;
case CircleKey: case SDLK_KP_6:
case SDLK_B:
button = OrbisPadButtonDataOffset::Circle; button = OrbisPadButtonDataOffset::Circle;
break; break;
case CrossKey: case SDLK_KP_2:
case SDLK_N:
button = OrbisPadButtonDataOffset::Cross; button = OrbisPadButtonDataOffset::Cross;
break; break;
case SquareKey: case SDLK_KP_4:
case SDLK_V:
button = OrbisPadButtonDataOffset::Square; button = OrbisPadButtonDataOffset::Square;
break; break;
case SDLK_RETURN: case SDLK_RETURN: