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 switch pro controller mappings and gamepad.getInputLabel #2254

Merged
merged 7 commits into from
Jun 7, 2020

Conversation

Geokureli
Copy link
Member

@Geokureli Geokureli commented Apr 19, 2020

Mappings Added:

  • Switch Pro Controller
  • Solo L and R Switch Joycons
  • Dual Joycons as single gamepad

Because Nintendo's controllers have very contradictory labelling compared to our input scheme, I thought it was important that flixel offer easy ways for devs to accurately distinguish these buttons to players. I've gone and mapped inputIDs to custom labels so they can display a string label for any button on any mapped gamepad device.

Example:

trace(myGamePad.getInputLabel(LEFT_SHOULDER), myGamePad.getInputLabel(LEFT_TRIGGER))

will have the following values:

Switch Pro: l, zl
Switch Left Joycon: sl, zl
Switch Right Joycon: sl, null
XBox/XInput: lb, lt
PS4/Vita: l1, l2
Wii+Nunchuck: c, z

@Gama11
Copy link
Member

Gama11 commented Apr 19, 2020

I don't have a switch pro controller, so not too much I can test here. @larsiusprime Do you maybe want to take a look at this?

@Geokureli
Copy link
Member Author

And if someone knows why flash behavior seems inconsistent, I'd love to know. At first I got seemingly random button presses and axis changes until I update my FP debugger, then it worked perfectly. The next day it was back to chaos

@Geokureli
Copy link
Member Author

Decided to trim down FlxGamepad.checkStatus @Gama11 brought up that it's a bit hefty for an inline function in #2253

@larsiusprime
Copy link
Member

larsiusprime commented Apr 19, 2020 via email

Comment on lines +420 to +425
else if (name.contains("pro controller") || name.contains("joycon l+r"))
SWITCH_PRO;
else if (name.contains("joycon (l)"))
SWITCH_JOYCON_LEFT;
else if (name.contains("joycon (r)"))
SWITCH_JOYCON_RIGHT;
Copy link
Member Author

Choose a reason for hiding this comment

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

Can always wrap this in #if !switch if it messes with current switch mappings. I don't have a Switch SDK so this isn't something I can look into

@Gama11
Copy link
Member

Gama11 commented May 1, 2020

@larsiusprime Ping.

@Gama11
Copy link
Member

Gama11 commented Jun 7, 2020

Ok, I'll just have to assume the changes are good then.

@Gama11 Gama11 merged commit d42a07d into HaxeFlixel:dev Jun 7, 2020
@Geokureli Geokureli deleted the switch_gamepad branch July 2, 2020 15:44
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.

3 participants