Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Input] Get mapped joy events for joypad #100791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MJacred
Copy link
Contributor

@MJacred MJacred commented Dec 24, 2024

Get the buttons and axes mapped to the connected joypad w/o having to use them all.

Motivation behind this PR:

  • I want the user to be able to change their mappings in-game. This requires knowledge about the capabilities of their connected joypad. It also allows me to fetch a different joypad image.
    • different joypads have different buttons/axes available: some joypads have JOY_BUTTON_PADDLE_*, some don't. Some don't have JOY_BUTTON_MISC1, or JOY_AXIS_RIGHT_*, etc.
  • Using the joypad name is not reliable, as the same joypad can have different names on different platforms/APIs.
    • the guid is also not sensible

See attached test project:
joypad-event-test.zip

Output for my joypad using the test project:

Xbox 360 Controller
["a", "b", "x", "y", "back", "guide", "start", "leftstick", "rightstick", "leftshoulder", "rightshoulder", "dpup", "dpdown", "dpleft", "dpright"]
["leftx", "lefty", "rightx", "righty", "lefttrigger", "righttrigger"]

@MJacred MJacred requested a review from a team as a code owner December 24, 2024 14:53
@MJacred MJacred force-pushed the get_joy_mapping_info branch from 5ce890e to ee48457 Compare December 24, 2024 14:54
@MJacred MJacred requested a review from a team as a code owner December 24, 2024 14:54
@Chaosus Chaosus added this to the 4.x milestone Dec 26, 2024
@MJacred
Copy link
Contributor Author

MJacred commented Jan 5, 2025

@akien-mga: Could I get a review on this, please? :)

@AThousandShips
Copy link
Member

People are just coming back from the holidays, most people were either still away or just coming back last week, people should be able to review this in the following week

@MJacred
Copy link
Contributor Author

MJacred commented Jan 17, 2025

@AThousandShips as the feature freeze has been put in place, can we get this queued for 4.5, please…?
And a review, if possible.

@AThousandShips
Copy link
Member

It'll be put on a specific milestone when reviewed, for example 4.5, but not before, the relevant teams have been notified but we're busy with 4.4 so will probably not be a priority until after releasing

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on Linux, it works as expected.

Xbox One Elite 2 Controller
["a", "b", "x", "y", "back", "guide", "start", "leftstick", "rightstick", "leftshoulder", "rightshoulder", "dpup", "dpdown", "dpleft", "dpright"]
["leftx", "lefty", "rightx", "righty", "lefttrigger", "righttrigger"]

However, if your goal is to show correct button prompts or gamepad images, I think #89193 is more suited. There isn't a lot of variance in buttons across modern controllers nowadays. I think the only exception that really matters in games are the lack of analog triggers on Switch controllers (which #89193 can take into account).

Personally, I would prefer #89193 to be merged first, then wait and see if we really need to do something more before we go forward with this PR.

@MJacred
Copy link
Contributor Author

MJacred commented Jan 28, 2025

Thanks, didn't know about that PR :)
I have a few busy weeks ahead, afterwards, I'll re-evaluate my PR

@MJacred
Copy link
Contributor Author

MJacred commented Feb 24, 2025

@Calinou: after looking at that PR, I must say it does not satisfy my requirements.
I have a generic controller called "Wireless Gamepad F710" which follows the playstation layout, for which no name check would match, and no scheme would be returned. Therefore, I won't know about the joypad's abilities.
But let's take a more interesting case: say I had one xbox controller with paddles, and one xbox controller without. The other PR wouldn't help me learn which buttons the joypad actually has/supports (i.e. which has paddles?).

Moreover, relying on the device name is not reliable at all (depending on the OS/driver, you get different names for the same device), though I still see value in the other PR in the sense that it helps me localizing the button/axes names, provided all the constant strings are visibly documented outside the codebase.

In that sense, I'd say the two PRs actually harmonize with each other.

EDIT: Just to give a bit more context, I also want to provide several joypad button/axes to action default mappings, then auto-select the most fitting one on first connect (and more supporting features)

@MJacred
Copy link
Contributor Author

MJacred commented Mar 9, 2025

Personally, I would prefer #89193 to be merged first, then wait and see if we really need to do something more before we go forward with this PR.

@Calinou: I hope I could convey my requirements better in my previous comment. Did it change how you feel about this PR?

@Calinou
Copy link
Member

Calinou commented Mar 9, 2025

@Calinou: I hope I could convey my requirements better in my previous comment. Did it change how you feel about this PR?

I'm still undecided on this. I haven't seen much prior art of this in other engines/games where things like paddles are detected and bound automatically if present.

@MJacred
Copy link
Contributor Author

MJacred commented Mar 9, 2025

Fair enough. Though I would also use this code to give warnings if their connected joypad does not have some mandatory/preferred buttons/axes, e.g. has only one (or none) joystick and 2 are required (or preferred) - I know most have them, but some people like using retro controllers whenever possible.

Until this PR's future is decided I can do a custom build, keeping this change compatible is easy enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants