-
Notifications
You must be signed in to change notification settings - Fork 198
Improve Gamepad / Refactor Input Api #2752
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
Conversation
For more flexibility (mapping 1-9 on one stick) maybe could also add diagonal support for the sticks 🤔. And "semi down trigger" for X3 FF and "full down" for X10 FF 😁 |
Looks really good so far! Nice workaround to support wii (uses hat) by emulating joystick. What is missing yet is a way to rename buttons. Currently we have forced keyboard keys for homebrew platforms (which is wrong, but was easy). Wii is a little better, as it has custom mapping, however still using "joy other 4" as name instead of "Button 2". That will break as soon as we have custom mapping scene. I need this for the custom WiiUI. |
Yeah that was a lazy solution that must be fixed for the Input Settings scene.
Yeah, this was a quick workaround. The lack of button renaming is already bad at the PC. When remapping the user will currently see stuff like "JOY_STICK_LEFT_Y_UP" instead of "Joy Left Y+" in the WIP remapping scene. We need a new data structure, something like: Array_Of_Struct {
int8_t key,
char* internal_name,
char* readable_name
} Then on startup a port can overwrite the relevant strings in btw, do you want to have individual mappings for the different Wii-Accessoires or will you make "Minus on Wiimote is same as Minus on CC"? If you want to support individual could ues the provided When they can be renamed it doesn't really matter that they are called |
I want to allow using all buttons individually. |
I was talking about 8 direction support for the "secondary" analog stick so more numbers can be mapped to it easily. Here a picture to make my life easier ;) Values in degrees for EDIT: Well and the circle must be rotated a bit to have the right segments so it would be:
|
62ca99b
to
4996772
Compare
As asked by carstene1ns added a stub-api for adding platform specific names that can be queried by the Input Scene: Example usage (in Input::ButtonNamesArray Input::GetInputKeyNames() {
return {
{Keys::JOY_DPAD_DOWN, "Dpad Down"},
{Keys::JOY_A, "Classic Controller A"},
{Keys::JOY_Z, "Nunchuck Z"},
{Keys::JOY_TRIGGER_RIGHT_FULL, "Right Trigger Down"},
{Keys::JOY_OTHER_10, "Balance Board Left"},
{Keys::JOY_OTHER_20, "Bongo Right"}
};
} |
Wow this was a suuuuper boring task. Moved now all our ports to use a dedicated "Input buttons" instead of depending on input_buttons_desktop. Also attempted to add suitable input layouts based on the desktop gamepad layout. Likely broken and has tons of compile errors. Not tested yet but at least the boring part is done... |
398f1fe
to
0a846d2
Compare
Hm this will be hard to test on most ports. There is also other breakage it seems:
|
Small test case (Input test on the village) Grab the last working PR build for the system from Jenkins. For Vita please test:
For Switch please test:
|
Should now work everywhere, except:
|
15f265b
to
76ed97d
Compare
This is now ready. The Semi-broken Wii input is already a problem in master and some ports have additional features on the shoulder triggers. I will move them to the config scene in the next PR. |
… layouts JOY_HAT was removed as this is untypical for controller input (and not supported by SDL GameController API)
…keys as callbacks making this unusable and confusing.
…ondary Motivation here is to provide an option to swap which joystick is for movement, so left/right terminology is confusing.
…ys based on them. This reduces code duplication and makes the code less error prone.
Redid button mapping again now that more buttons are available.
…sktop Likely partially broken and has some FIXME depending on the settings scene.
Fix Cross and Circle mapping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@@ -120,6 +116,13 @@ CtrUi::CtrUi(int width, int height, const Game_ConfigVideo& cfg) : BaseUi(cfg) | |||
top_image.tex = tex; | |||
top_image.subtex = &subt3x; | |||
|
|||
// FIXME: Add option to settings Ui | |||
if (cfg.stretch_width.Get()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has nearly no effect, since you disable stretching in UpdateDisplay()
.
The idea here was to handle this like fullscreen for other platforms. So, no real need for config option here. Same is true for switch and vita, where you only made this a FIXME without option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this change makes no sense currently because there must be a function for toggling this. This is similiar to a "keep aspect ratio" setting. Could be even provided for SDL2 in case somebody likes it to have everything stretched... (that's why it is not the same as fullscreen)
Wanted to finish this as part of the Settings PR as I cannot do it in this PR properly (And breaking that feature for a while isn't toooo bad)
The only problem I have with it is that it completely breaks Wii input. |
This rewrites parts of the input API related to gamepads based on how most Gamepads these days are:
When the initial API was designed it was inspired by SDL Joystick. These use 32 arbitrary keys that and are very low level: You can handle any kind of controller with it.
These days the typical controller is usually:
This is an assumption made by Microsoft (XInput), SDL2 (Game Controller), HTML5 Gamepad API and libretro (Retropad).
I also removed the keyboard input in libretro. They do not forward all keyboard input anymore except if you are in "Focus Mode" which disables the RetroPad. Libretro wants exclusive access to the keyboard, so I fulfill this wish... Is kinda crap but nothing we can do here.
Changes for SDL1.0:
I kinda hacked this in. We must really drop this :/
New default mapping for Game Controllers to make them usable. (Custom remapping in settings PR)
(Note: Does not work on Linux in Browsers, works everywhere else)