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

Make analog sticks emit "fake" digital actions for left/right/up/down… #1746

Closed
wants to merge 9 commits into from

Conversation

larsiusprime
Copy link
Member

… movement, and add ID's that make it simple to use them. Makes it easy to use an Analog stick as if it were a DPAD, a very popular input pattern.

This behavior was already implemented on legacy, but the API for it was buried. I added top level FlxGamepadInputID's for the digital events, and refactored things so that Next can emit these events as well.
Also, I added a "value" property to the FlxGamepadButton for storing last frame's analog input value, which should remove the requirement for FlxActions to call check() every frame in order to get accurate JUST_MOVED / JUST_STOPPED behavior.

(This pull request helps the FlxAction PR, but can be considered in isolation and does not depend on it)

… movement, and add ID's that make it simple to use them. Makes it easy to use an Analog stick as if it were a DPAD, a very popular input pattern.

This behavior was already implemented on legacy, but the API for it was buried. I added top level FlxGamepadInputID's for the digital events, and refactored things so that Next can emit these events as well.
Also, I added a "value" property to the FlxGamepadButton for storing last frame's analog input value, which should remove the requirement for FlxActions to call check() every frame in order to get accurate JUST_MOVED / JUST_STOPPED behavior.
@@ -261,10 +269,10 @@ class FlxGamepad implements IFlxDestroyable
manager = null;

#if FLX_JOYSTICK_API
hat = FlxDestroyUtil.put(hat);
hat = FlxDestroyUtil.put(hat);
Copy link
Member

Choose a reason for hiding this comment

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

Fyi, I'm not a fan of this formatting for vertical alignment. That's just a lot of extra maintenance effort with little benefit.

@Gama11 Gama11 added this to the 4.1.0 milestone Feb 26, 2016
@larsiusprime
Copy link
Member Author

@Gama11: I think I got everything you mentioned. Anything else I should hit before squashing?

@Gama11
Copy link
Member

Gama11 commented Feb 27, 2016

The mapping classes still use if( instead of if (. :P

@adrianulima
Copy link
Contributor

@Gama11 Do you have any FlashDevelop or other text editor macro that check this code styles?
Maybe we could have one to execute before make a PR, this would avoid some common errors like:
if(-if ( and if () {- if ()\n{, same for while, for, else ...

@Gama11
Copy link
Member

Gama11 commented Feb 27, 2016

@adrianulima No.. Somebody suggested using checkstyle a while ago to check the code style on Travis.. However I never looked into how well that tool works, and I also dislike idea of having failed Travis builds because of code stlye issues... What's really needed is an auto-formatter for Haxe.

@larsiusprime Squash? :)

@larsiusprime
Copy link
Member Author

@Gama11 here:
#1752

Tried to force push but github two factor auth makes that hard for me to do.

@Gama11
Copy link
Member

Gama11 commented Feb 27, 2016

Actually, checkstyle seems like a great tool, I should've looked into that way earlier...

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