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

Add ability to "reserve" devices by player in Android using settings #16269

Conversation

PatrickStankard
Copy link
Contributor

@PatrickStankard PatrickStankard commented Feb 20, 2024

Description

I use RetroArch on an Arcade1Up Simpsons arcade cabinet running Android 10. I wanted to be able to have a controller always map to a specific player when it's plugged in, regardless of the order that it was initialized by RetroArch.

This PR adds settings to the configuration, so that you can "reserve" a device for a given player, based on it's VID/PID, or name. I based this on how the input_android_physical_keyboard setting is handled. This is very useful in my specific situation (running a MAME 2003-plus core where the player order needs to match the order of the controllers mounted in the cabinet), but I could image it being useful in other situations, too.

Right now, only the Android input driver is checking to see if a port is reserved, based on the config value. However, other input drivers utilize this change by calling input_device_get_reserved_port.

Related Issues

#12924

Reviewers

I'm not sure who to tag for a review, but I'll post the PR in Discord

@PatrickStankard PatrickStankard force-pushed the android_reserved_device_setting branch 2 times, most recently from 7976bac to e148c31 Compare February 21, 2024 15:24
@hizzlekizzle
Copy link
Contributor

let's see if @sonninnos and/or @LibretroAdmin care to take a look

@PatrickStankard
Copy link
Contributor Author

PatrickStankard commented Feb 21, 2024

In this commit (7658c80), I made it so that the settings themselves, and the method to get a reserved port based on the settings, was no longer Android specific. However, the only place that it's being used is in the Android input driver:

reserved_port = input_device_get_reserved_port(
vendorId, productId, device_name);
if (reserved_port > -1) {
android->pads_connected = reserved_port;
*port = reserved_port;
}

So it only works on Android, but it makes it so that other platforms and input drivers can use it, too

@PatrickStankard PatrickStankard force-pushed the android_reserved_device_setting branch from 928b1e3 to 57bedd3 Compare April 16, 2024 16:26
input/drivers/android_input.c Outdated Show resolved Hide resolved
input/input_driver.c Outdated Show resolved Hide resolved
configuration.h Outdated Show resolved Hide resolved
configuration.c Outdated Show resolved Hide resolved
input/input_driver.c Outdated Show resolved Hide resolved
@PatrickStankard PatrickStankard force-pushed the android_reserved_device_setting branch 4 times, most recently from dc16a01 to d6adef8 Compare April 17, 2024 17:19
@PatrickStankard PatrickStankard changed the title [DRAFT] Add ability to "reserve" devices by player in Android using settings Add ability to "reserve" devices by player in Android using settings Apr 17, 2024
@PatrickStankard PatrickStankard force-pushed the android_reserved_device_setting branch 3 times, most recently from c69a36c to 2e64d80 Compare April 17, 2024 19:11
@PatrickStankard PatrickStankard force-pushed the android_reserved_device_setting branch 2 times, most recently from 85fe09d to 8cb3f68 Compare April 18, 2024 15:57
@PatrickStankard PatrickStankard force-pushed the android_reserved_device_setting branch from 8cb3f68 to 9f63f01 Compare April 19, 2024 16:44
@PatrickStankard
Copy link
Contributor Author

@LibretroAdmin This is good for another review now 👍

zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request May 18, 2024
Reservation config option and matching function lifted from:
PatrickStankard libretro#16269

Moved it to autoconfig to be more generic. Testing and GUI updates
are needed, refinements also possible.
@zoltanvb
Copy link
Contributor

Hi @PatrickStankard,

this is one of the requests that are recurring, thank you for taking the effort!

I lifted your code and moved it to autoconfig part, and it works there as well:
master...zoltanvb:RetroArch:input_driver_reserve_device

The advantage of having it in the autoconfig part would be that it is then automatically valid for all joypad drivers, Matching the driver defined ports to the player* settings is done by input_joypad_index. On the other hand, I did not see how android input driver calls the autoconfig, so that may be an exception.

I extended the test joypad driver and ran a few tests, looks OK so far but there may still be some corner cases, removing devices, multiple devices with same vid/pid, etc... so at least this modified version still needs work. If you agree, we could collaborate on this in some form.

zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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.
zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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.
zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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.
zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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.
zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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.
zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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 <[email protected]>
zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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 <[email protected]>
zoltanvb added a commit to zoltanvb/RetroArch that referenced this pull request Jun 4, 2024
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 <[email protected]>
LibretroAdmin pushed a commit that referenced this pull request Jun 5, 2024
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 #16269

Test joypad driver was extended for more tests.

Co-authored-by: Patrick Stankard <[email protected]>
@PatrickStankard
Copy link
Contributor Author

This was merged as a part of #16647

@PatrickStankard PatrickStankard deleted the android_reserved_device_setting branch June 20, 2024 13:42
Sunderland93 pushed a commit to Sunderland93/RetroArch that referenced this pull request Dec 26, 2024
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 <[email protected]>
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.

4 participants