Gamepad Mac ID issues

46 views
Skip to first unread message

Eric Bernier

unread,
Apr 5, 2014, 11:28:07 AM4/5/14
to haxef...@googlegroups.com


This is my first post here, as I just switched over to HaxeFlixel, after using Flashpunk for years. I figured that I'd preface this post by saying that I really love HaxeFlixel so far :D

So I started messing around with an XBox 360 USB gamepad on my Mac and noticed the recorded IDs of the buttons when pressed don't match up with the IDs listed in #elseif mac block of the XBoxButtonID.hx class:

#elseif mac
 
/**
 * Button IDs (DPAD values are obtained from FlxGamepad.hat)
 */

 
public static inline var A:Int = 11;
 
public static inline var B:Int = 12;
 
public static inline var X:Int = 13;
 
public static inline var Y:Int = 14;
 
public static inline var LB:Int = 8;
 
public static inline var RB:Int = 9;
 
public static inline var BACK:Int = 5;
 
public static inline var START:Int = 4;
 
public static inline var LEFT_ANALOGUE:Int = 6;
 
public static inline var RIGHT_ANALOGUE:Int = 7;


 
/**
 * Axis array indicies
 *
 * If TRIGGER axis returns value > 0 then LT is being pressed, and if it's < 0 then RT is being pressed
 */

 
public static inline var TRIGGER:Int = 4;
 
public static inline var LEFT_ANALOGUE_X:Int = 0;
 
public static inline var LEFT_ANALOGUE_Y:Int = 1;
 
public static inline var RIGHT_ANALOGUE_X:Int = 2;
 
public static inline var RIGHT_ANALOGUE_Y:Int = 3;

I'm tracing the IDs upon being pressed as so:

 if (_gamepad.anyButton())
 
{
     trace
("We pressed " + _gamepad.firstPressedButtonID());
 
}

If I press the buttons A, B, X, Y in that order I get the following output:

Player.hx:241: We pressed 0
Player.hx:241: We pressed 1
Player.hx:241: We pressed 2
Player.hx:241: We pressed 3

These numbers match the #else block of the XBoxButtonIDs.hx class perfectly:

 public static inline var A:Int = 0;
 
public static inline var B:Int = 1;
 
public static inline var X:Int = 2;
 
public static inline var Y:Int = 3;

I'm pretty new to the community, so I figured I'd post this thread. I could fork the repository and contribute the change myself if wanted. 

Thanks!

Gama11

unread,
Apr 5, 2014, 1:41:35 PM4/5/14
to
I figured that I'd preface this post by saying that I really love HaxeFlixel so far :D

Great to hear!

Thanks for posting about this issue. These #if mac conditionals always looked weird to me. I don't think any of the core contributors own both a mac and a Xbox 360 controller, so we're in need of help from the community for these sorta things.

I could fork the repository and contribute the change myself if wanted. 

Does that mean you don't want to? ;) Either way, pull requests are always welcome. 

So, the takeaway message from this is that the IDs for A, B, X and Y are the same on both windows and mac? Are there any issues with the remaining IDs?

Eric Bernier

unread,
Apr 5, 2014, 7:56:54 PM4/5/14
to
It appears the Windows IDs actually map just fine to Mac. I'll test it a bit more later, when I have time to confirm, and submit the change on Github.

Gama11

unread,
Apr 6, 2014, 4:00:03 AM4/6/14
to haxef...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages