Skip to content

Conversation

@AL2009man
Copy link

@AL2009man AL2009man commented Jun 10, 2025

note: this PR requires #627

What SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS does is that SDL's Controller API will follow on Button Labels, by default: it is set to 1. Consequences: the modern Nintendo Switch layout will be using the Nintendo Layout across Menu Navigation and Gameplay.

     (Y)              (X)
  (X)   (B)        (Y)   (A)
     (A)              (B)

  Standard         Nintendo

Beyond copy-pasting: it results in muscle memory. The initial workaround would be to rebind to the Key Binding section, but I argue it ain't very nice. Taking a page from yquake2/yquake2@9e07dc2, I took a stab at it myself. the results is very mixed and feels a bit hacky-- but it should be easier on the UI/UX front.

do note that it only applies to both "ACCEPT_BUTTON/CK_ACCEPT" and "CANCEL_BUTTON/CK_CANCEL" action at the moment, no plans to touch Use / Accept/Cancel action

While both toggles aren't accessible in-game, both JapaneseButtonLayout (will only swap Menu Accept/Cancel) is always accessible within pd.ini.

As of this writing: the only holdout is the deadzone itself. Right now: both DEFAULT_DEADZONE (4096) and DEFAULT_DEADZONE_RY (6144) controls baseline deadzone slider, but if using a legitament Nintendo Switch controller (not the third-party kind): both left and right stick will drift. That part might be easily addressable by increasing both sliders, or add a NintendoSwitch-specific deadzone slider to remedy the problem.

AL2009man added 9 commits June 9, 2025 18:32
`SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS` will follow the Button Labels, which causes issues in games that uses it. This commit will turn it off by default, but the default can be restored via `useNintendoLayout` within pd.ini file
…yout

`SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS` is set to 0, which will follow the positional diamond-shaped face buttons on the game controller. making everything more streamlined and easier to translate across all modern contorllers. This solves a specific issue with

Japanese-style face buttons for `BUTTON_UI_ACCEPT`/`BUTTON_UI_CANCEL` actions has been added. A bit of a hacky workaround, but it'll do for now. By default: it'll only kicks in when using a Nintendo Switch controller, but `JapaneseButtonLayout` is accessible within `pd.ini`
leftovers due to switching to Visual Studios code
when going to the Keybind page, you'd see "[JPN LAYOUT - B/A]" on UI Accept/Cancel text, UI Text will change dynamically.
@AL2009man
Copy link
Author

AL2009man commented Jun 10, 2025

Note: this PR also contains issues with build-i686-linux. It won't compile properly due to "SDL_CONTROLLER_TYPE" interacts with Nintendo Switch controller types, but based on initial look: I believe this is related to using older version of SDL for i686-linux

As this PR is more or less a foundation for adding proper Button Labels support while viewing the keybind menu, this PR can't be pushed until that'd be solved.

@LonelySpaceDetective
Copy link

LonelySpaceDetective commented Jun 10, 2025

I don't use gamepads when I can help it for FPSes, but as someone who prefers to use Circle as confirm and Cross as cancel on their DualSense, I approve of having an convenient option to swap confirm/cancel without altering in-gameplay controls.

I do wish to ask one question though: If the option to swap ABXY to BAYX and the option to just swap confirm and cancel are both separate and potentially can be both enabled at the same time, what happens if you do just that? Do you end up with a weird layout where the bottom button is confirm and the right is cancel, but the left and top buttons have their functions swapped? Or does one of them override the other?

@AL2009man
Copy link
Author

AL2009man commented Jun 10, 2025

I don't use gamepads when I can help it for FPSes, but as someone who prefers to use Circle as confirm and Cross as cancel on their DualSense, I approve of having an convenient option to swap confirm/cancel without altering in-gameplay controls.

I do wish to ask one question though: If the option to swap ABXY to BAYX and the option to just swap confirm and cancel are both separate and potentially can be both enabled at the same time, what happens if you do just that? Do you end up with a weird layout where the bottom button is confirm and the right is cancel, but the left and top buttons have their functions swapped? Or does one of them override the other?

SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS will make the Face Button layout follow the Button labels. However, it has been shown (libsdl-org/SDL#6117) that it causes confusion down the road. Even more so in some sourceports who aren't aware of that hint. This is the major reason why SDL3 has switched to a Positional layout as opposed to labels. . it's also the true reason why useJapaneseLayout was created, a contingency plan for when fgsfdsfgs ports the project over to SDL3's.

Setting that hint (called "useNintendoLayout") defaults back to original default hint, and useJapaneseLayout will respects it.

@fgsfdsfgs
Copy link
Owner

fgsfdsfgs commented Jun 11, 2025

The A/B/X/Y swapping is a good feature, however I feel like the "Japanese layout" thing can be just as well accomplished by just swapping the bindings on the Accept/Cancel buttons in the Extended Controls menu. I don't really want to add to the already complicated and confusing input logic just to make it very slightly easier to do, as it's already a pretty niche thing.
In any case, it would also be best for them to be in separate PRs.

The i686 problem is likely because the version of SDL2 available (or just used) for i686-linux is older and does not have this feature. It is in general best to guard these things with SDL_VERSION checks.

I won't add controller-specific deadzone settings, that's a bit too insane. It also depends on the specific Switch controller. I tested these settings against the joycons on my own early model Switch and it was fine. It's generally not possible to account for everything, which is why the deadzone is user-adjustable.

@AL2009man
Copy link
Author

AL2009man commented Jun 11, 2025

The A/B/X/Y swapping is a good feature, however I feel like the "Japanese layout" thing can be just as well accomplished by just swapping the bindings on the Accept/Cancel buttons in the Extended Controls menu. I don't really want to add to the already complicated and confusing input logic just to make it very slightly easier to do, as it's already a pretty niche thing. In any case, it would also be best for them to be in separate PRs.

Not a new feature, a necessity.

After playing with my Nintendo Switch controller, it follows the Nintendo layout in a literal way. I could rebind them to correct it, but since I often switch (no pun intended) controller types: it retroactively changes Player 1/2/3/4 bindings in the process. This is not ideal.

This is why useJapaneseLayout is a thing. What it really does is reversing "ACCEPT_BUTTON" / "CANCEL_BUTTON". Under the hood; it's really the same binding, this is only done for backwards compatibility.

I originally planned for the hardcoded approach, but based on feedback: I might revise it by opting for Button Input instead of an action.

note: this setup happened to be a standard in Nintendo Switch games, even in Nintendo's own games: Face Button swap only applies to Menus while Gameplay remains the same. SDL maintainers also suggested doing so.

I won't add controller-specific deadzone settings, that's a bit too insane. It also depends on the specific Switch controller. I tested these settings against the joycons on my own early model Switch and it was fine. It's generally not possible to account for everything, which is why the deadzone is user-adjustable.

Which is why I'm deciding whenever or not:

  • Increase overall minimum deadzone to better account for first party controllers that wasn't calibrated or requires dedicated hardware (which is my case with Switch Pro Controller)
  • change default In-Game Deadzone to something a bit higher. This option is far more likely for me

…apanese layout

also changed the guard function for GitHubAction CI
reverted back to the game action-based setup for the time being. this might be revised when a separate PR changes the Button Input labels. (make it easier to troubleshoot
to better accout for uncalibrated joysticks: the default joystick slider will be increasing to 6 percent. This should address a specific issue for first-party Nintendo Switch Pro Controller users who can't calibrate their joystick drifts.
this will be moved to a separate PR (fgsfdsfgs#627).
@AL2009man AL2009man changed the title improved Nintendo Switch controller support (Face button layout, Menu Confirm/Cancel function) Japanese Layout in Menus (Swaps Accept/Confirm button) and increased Deadzone default Jun 13, 2025
@AL2009man AL2009man changed the title Japanese Layout in Menus (Swaps Accept/Confirm button) and increased Deadzone default Japanese Layout in Menus (Swaps Accept/Confirm button), increased Deadzone default Jun 13, 2025
@AL2009man
Copy link
Author

AL2009man commented Jun 24, 2025

I won't add controller-specific deadzone settings, that's a bit too insane. It also depends on the specific Switch controller. I tested these settings against the joycons on my own early model Switch and it was fine. It's generally not possible to account for everything, which is why the deadzone is user-adjustable.

got good news to tell @fgsfdsfgs: the next SDL2/3 release candidate (or Steam Beta client as of this writing) will address this issue. I tested it using the main branch of SDL2 to confirm this specific problem is solved.

We can wait for the next release before making this PR ready for review.

@AL2009man AL2009man changed the title Japanese Layout in Menus (Swaps Accept/Confirm button), increased Deadzone default Japanese Layout in Menus (Swaps Accept/Confirm button) Jun 24, 2025
libsdl-org/SDL#13260 addresses this particular issue for Nintendo Switch Pro Controller's center deadzone, this: the original default deadzone has been restored to 4 percent and 6 percent
Cleaned up and fixed the remaining bugs within the input system. Options Menu's Bind UI should now correctly reflect the Japanese Layout
@AL2009man AL2009man marked this pull request as ready for review July 8, 2025 02:03
To better prepare for `SDL_GetGamepadButtonLabel`/SDL3: the entire setup has been simplified by combining `inputIsJapaneseLayoutActive` and `inputRemapUIButton` into one, while giving it a new name
@AL2009man
Copy link
Author

AL2009man commented Jul 20, 2025

The A/B/X/Y swapping is a good feature, however I feel like the "Japanese layout" thing can be just as well accomplished by just swapping the bindings on the Accept/Cancel buttons in the Extended Controls menu. I don't really want to add to the already complicated and confusing input logic just to make it very slightly easier to do, as it's already a pretty niche thing. In any case, it would also be best for them to be in separate PRs.

ok, after experimented with SDL_Get GamepadButtonLabel (SDL3 only): it's actually a lot easier to avoid making a complicated/confusing input logic by simply making this as our basis on Button UI Swap.

Example code:

        if (SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_B) {
            flipped_buttons = true;
        } else {
            flipped_buttons = false;
        }

This gets rid of the need for Nintendo Switch-specific detection system as SDL_GetGamepadButtonLabel( covers that automatically. For that: I simplify the setup to set the foundation

@AL2009man AL2009man closed this Jul 20, 2025
@AL2009man AL2009man reopened this Jul 20, 2025
double-checked SDL2 version to addrsss incorrect build release`
to make things a bit more consistent, the order on how to enable or disable has been swapped
this reduces the sheer amount of bloat, as most of the functions are moved to a helper function. This also fixes a bug where the Swap applies to all Actions while rebinding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants