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

Controller device reservation / preference. #16647

Merged
merged 2 commits into from
Jun 5, 2024

Conversation

zoltanvb
Copy link
Contributor

@zoltanvb zoltanvb commented Jun 4, 2024

Description

For each player, 2 new options are added:

  • a reservation type (no reservation, preferred, reserved)
  • a reserved device name

Screenshot from 2024-06-04 06-16-17

When a new device is added via autoconfig, it will be added to the first free player. Reserved devices will be assigned to the reserved player slot. If reservation type is "reserved", no other device can take that player slot automatically. If reservation type is "preferred", other device can be mapped, but as soon as the preferred device appears, it will be mapped there.

Some notes:

  • if there is no reservation option for any of the players, no reassignment will happen (not even the logic to use first free player)
  • "all users control menu" works as before, but that means if first player has reserved device, and that device is not present, no user can control the menu
  • even reserved slots can be temporarily overruled by setting Device Index, but that will not take effect after a restart (since autoconfig logic will run again)
  • device is identified same way as "physical keyboard" for Android, storing vid/pid as well for matching
  • all mapping logic is in task_autodetect.c, everything else is just config file, menu support, and test files
  • it would have been nice to hide "reserved device" option if reservation type is None, but that would complicate the code even more (see e.g. the fixed icon offsets in xmb/ozone) so it is not done
  • the pop-up message when connecting a controller, will still say "connected to port x", where x is not the player. Technically it is correct, but somewhat misleading, as remapping happens after this message.

Reservation config option and matching function lifted from PatrickStankard: #16269

Test joypad driver was extended for more tests, see the .cfg for a scenario (last file in diff).

(edit: re-worded a bit. "port" is the identifier used inside the input/joypad driver, I used "slot" for the player <-> port assignment)

Related Issues

#12924
#12200

Related Pull Requests

#16269

Reviewers

@PatrickStankard

@zoltanvb zoltanvb force-pushed the input_driver_reserve_device branch 4 times, most recently from 0f0b157 to 68981e4 Compare June 4, 2024 05:22
@sonninnos
Copy link
Collaborator

Please follow the common capitalization standard with menu item labels.

@hizzlekizzle
Copy link
Contributor

How does a reservation interact with 2 identical pads? E.g. a pair of xbox controllers? Does it just allocate the first one it sees to the first open reservation?

@gouchi
Copy link
Member

gouchi commented Jun 4, 2024

Also, not sure if could consider also this issue ?

@PatrickStankard
Copy link
Contributor

@gouchi I think this PR can address the example in that issue by assigning the SNES controllers to players 1-4, or assigning the joystick to a non-playable player for that core (like player 5)

@zoltanvb zoltanvb force-pushed the input_driver_reserve_device branch 2 times, most recently from 0b8994c to a7d2b6e Compare June 4, 2024 19:41
@zoltanvb
Copy link
Contributor Author

zoltanvb commented Jun 4, 2024

I ran a test with identical pads and the result is not quite right, I'll make an update (maybe tomorrow)

For each player, 2 new options are added:
- a reservation type (no reservation, preferred, reserved)
- a reserved device name

When handling port - player assignments, reserved devices
will be assigned to the respective player port. If reservation
type is "reserved", no other device can take that port
automatically.

Reservation config option and matching function lifted from:
PatrickStankard libretro#16269

Test joypad driver was extended for more tests.

Co-authored-by: Patrick Stankard <me@patrickstankard.com>
@zoltanvb zoltanvb force-pushed the input_driver_reserve_device branch 2 times, most recently from 4f3a8c6 to efb45c1 Compare June 5, 2024 18:46
@zoltanvb
Copy link
Contributor Author

zoltanvb commented Jun 5, 2024

Update uploaded, with a new test scenario. Reserving multiple entries for the same controller type should work now.

About #6707, I am not quite sure. There is a lot of discussion under that ticket, some cases mentioned can be solved now, others I think should be already covered by earlier PRs like #12534 .

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.

6 participants