mmatyas / pegasus-frontend

A cross platform, customizable graphical frontend for launching emulators and managing your game collection.
http://pegasus-frontend.org
Other
1.22k stars 111 forks source link

Add keys support for the Select/Back button on controllers #1019

Open msheehan79 opened 1 year ago

msheehan79 commented 1 year ago

Would it be possible to add support for the Select/Back button on gamepads as an event in the api.keys object? As pretty much all of the other normal gamepad buttons are mapped to this object it would be beneficial for theme developers to also be able to leverage this button for features too.

The specific use case is for a custom theme that has both Filters and Sorting implemented, right now the api.keys.isFilters button is used to enable/disable filters, and all of the other default controls are already mapped to other functions so only the Select button didn't have any functions tied to it.

I was able to use this line to detect the Select button press on the controller for changing the sort logic, but it would be nice if it was mapped to the api.keys object as this implementation doesn't have an equivalent keyboard key which could exclude some users.

if (event.key == 1048586) { event.accepted = true; // enables sorting proxy model here }

mmatyas commented 1 year ago

The api.keys is designed around functionality common in themes, not to cover a gamepad layout (as the buttons and keys associated with them can be changed). We can add another group to the API, but I'm not sure what's the kind of functionality that, in most themes, would be useful from the Select button, while remaining clear to the users.

The alternative would be the event.key checking, but yes, they don't really have a readable name at the moment. I think I can fix that though, will look into it!