XboxButtonIDs in Windows CPP builds seem to be incorrect

239 views
Skip to first unread message

James Grimwood

unread,
Apr 26, 2014, 2:50:06 PM4/26/14
to haxef...@googlegroups.com
I'm using the dev version of Flixel (I updated it about half an hour ago) and on the CPP target in Windows, the joypad support seems broken.

If I run the GamepadTest on my PC with an XBox 360 controller connected, the wrong buttons light up. For example pressing the D-Pad (hat) causes the A,B,X,Y buttons to light up. The right thumbstick seems stuck, and the start/select buttons on the controller are read as the LB and RB buttons.

According to my PC (Windows 7) the buttons map as follows (values come from the watch window in the Flixel debugger when running the GamepadTest program as a Windows build)

A - 10
B - 11
X - 12
Y - 13
LB - 8
RB - 9
Back - 5
Start - 4
DPAD_UP - 0
DPAD_DOWN - 1
DPAD_LEFT - 2
DPAD_RIGHT - 3

Moving the right thumbstick up and down moves its graphic up and down, but it is permanently "stuck" to the left
Pressing LT makes the right thumbstick image move from extreme left to extreme right, depending on how far I push it
Pressing RT appears to do nothing

In the Windows control panel, Controller (XBOX 360 for Windows) properties the controller is mapped like this:

Moving the left thumbstick makes the + in the "X Axis / Y Axis" box move correctly
Moving the right thumbstick left/right increases/decreases the X Rotation
Moving the right thumbstick up/down decreases/increases the Y rotation
Pressing LT increases Z Axis
Pressing RT decreases Z Axis
Moving the DPAD moves the Hat diagram appropriately
A,B,X,Y, LB, RB, Back, Start are buttons 1 through 8
Button 9 is pressing the left thumbstick
Button 10 is pressing the right thumbstick

In my copy of XboxButtonID.hx I'm able to alter the mappings for the buttons and the two thumbpads, but I can't quite figure out the DPAD or the LT/RT buttons.

Gama11

unread,
Apr 26, 2014, 3:45:30 PM4/26/14
to haxef...@googlegroups.com
Wow, this is super weird. It seems like some Lime or OpenFL update must've broken this, as I tested the GamepadTest demo against flixel 3.2.2 where it's broken as well.

James Grimwood

unread,
Apr 26, 2014, 8:13:32 PM4/26/14
to haxef...@googlegroups.com
If it helps (add to the confusion) the joypad works fine in Linux.

Gama11

unread,
Apr 27, 2014, 5:53:17 AM4/27/14
to haxef...@googlegroups.com
Are you sure about that? If that's true for the dpad too, that makes things much worse... :/ (likely not going to be possible to make detection work consistently cross-platform).

James Grimwood

unread,
Apr 27, 2014, 7:10:30 AM4/27/14
to
I was trying it on a VirtualBox installation of Linux Mint, but I'll boot my laptop into proper Linux later and try the GamepadTest demo again.

The more I think about this (and try to make games that work on Windows and OUYA with joypads), shouldn't joypad mappings and axes be abstracted away from us? By the time you've got to HaxeFlixel, shouldn't our entire interaction with controllers simply be "if button 1 on the joypad is pressed ..." "Get the X axis value for the joypad", rather than "if OUYA button O or XBox Button A or weird unknown controller's button with ID number 4 is pressed".

-- Edit --

OK, on my Linux machine the GamepadTest mostly works when compiled as a CPP target. The buttons, left stick and the D-PAD all work. The only weirdness is the right stick's axes are wrong - X is Y, Y is X

However...

Under Chrome (version 32), running the flash GamepadTest from the haxeflixel demo site it's even more messed up than the Windows version! - although isn't Flash joypad support still experimental?

(A, B are seen as the triggers, the 'B' button on the image is permanently on, two of the D-Pad directions are seen as X, Y, start and back do nothing, the triggers are seen as start and back, _pulling down on the right thumbstick makes A light up_ ... about the only consistent thing is the left thumbstick which works fine!)

james@Bender ~ $ haxelib list
flixel-addons: git [dev:/usr/lib/haxe/lib/flixel-addons/git]
flixel-demos: [1.1.0]
flixel-templates: [1.0.2]
flixel-tools: [1.0.2]
flixel-ui: [1.0.2]
flixel: 3.0.4 git 3.1.0 3.3.1 [dev:/usr/lib/haxe/lib/flixel/git]
format: 3.0.4 [3.0.5]
haxelib_client: 3.1.0-rc.3 [3.1.0-rc.4]
hxcpp: [3.1.30]
hxlibc: [1.1.4] 1.1.3
lime-tools: [1.4.0] 1.2.9
lime: 0.9.4 [0.9.7]
ncot: git [dev:/usr/lib/haxe/lib/ncot/git]
openfl-html5: [1.4.1-beta]
openfl-native: 1.2.2 1.2.1 [1.4.0]
openfl-samples: [1.3.0]
openfl: 1.2.2 1.2.1 [1.4.0]
svg: [1.0.7]

Haxe 3.1.3

Curiously, trying to compile the GamepadTest in debug mode (lime build linux -debug) works. Trying to build it without debug gives errors during the c++ compilation.

Gama11

unread,
Apr 27, 2014, 7:07:53 AM4/27/14
to haxef...@googlegroups.com
Yes, definitely. As far as I know, the OpenFL Joystick events don't offer a way to check what gamepad you're dealing with (yet) though.

James Grimwood

unread,
Apr 27, 2014, 7:26:58 AM4/27/14
to haxef...@googlegroups.com


On Sunday, 27 April 2014 12:07:53 UTC+1, Gama11 wrote:
Yes, definitely. As far as I know, the OpenFL Joystick events don't offer a way to check what gamepad you're dealing with (yet) though.

In that case, is there a way for devs using HaxeFlixel to run a utility (the gamepad test with extra bits?), wiggle their joypads to find out what things are called, and then manually map things in their code? Because then we can also create joypad calibration screens in our games and let the users fix the problem for us ;-)

It feels like I could fix this problem on my machine if I had something to tell me

1. What the system (OpenFL?) thinks my left analog stick is called
2. What HaxeFlixel thinks it's called
3. How to map them (at runtime too so I can offer a 'joystick configuration' option to players)

Gama11

unread,
Apr 27, 2014, 8:04:08 AM4/27/14
to haxef...@googlegroups.com
You should be able to write a gamepad config screen with the following functions in FlxGamepad:

firstPressedButtonID()
firstJustPressedButtonID()
firstJustReleasedButtonID()

I guess figuring out the axes might be a bit of a problem as that array is private though...

James Grimwood

unread,
Apr 28, 2014, 3:20:14 AM4/28/14
to haxef...@googlegroups.com
OK, so after some poking in Windows again...

the DPAD is not the hat any more, it's buttons with IDs 
the left thumbstick is Axis 0 and 1
the right thumbstick is Axis 2 and 3
the triggers are axis 4 and 5

And now I actually understand what the XBoxButtonID numbers are.

I'm going to go away and see if I can make some sort of config thing for my joypads.

btw (and this is more a note for others encountering this), if you modify GamepadTest's PlayState.hx - lines 96-101 to be like this

#if !FLX_NO_DEBUG
FlxG.watch.addQuick("pressed ID", _gamePad.firstPressedButtonID());
FlxG.watch.addQuick("released ID", _gamePad.firstJustReleasedButtonID());
FlxG.watch.addQuick("justPressed ID", _gamePad.firstJustPressedButtonID());
FlxG.watch.addQuick("Hat ", _gamePad.hat);
FlxG.watch.addQuick("Axis 0", _gamePad.getAxis(0));
FlxG.watch.addQuick("Axis 1", _gamePad.getAxis(1));
FlxG.watch.addQuick("Axis 2", _gamePad.getAxis(2));
FlxG.watch.addQuick("Axis 3", _gamePad.getAxis(3));
FlxG.watch.addQuick("Axis 4", _gamePad.getAxis(4));
FlxG.watch.addQuick("Axis 5", _gamePad.getAxis(5));
#end

You can at least move things on joypads and figure out what axis & buttons they are represented as.

BumbleBirds

unread,
Apr 29, 2014, 10:44:47 PM4/29/14
to haxef...@googlegroups.com
We just ran into this problem too, very frustrating!

I'm not sure if this is related or not, but it seems like the justPressed function of FlxGamepad isn't working properly either?
When I trace it out on the Windows target it reports true for every frame the button is held.

Gama11

unread,
Apr 30, 2014, 1:28:27 AM4/30/14
to haxef...@googlegroups.com
Try using the dev branch, the IDs should be fixed there.

James Grimwood

unread,
May 17, 2014, 2:59:59 PM5/17/14
to haxef...@googlegroups.com
This has, unfortunately, happened again :-(

Gama11

unread,
May 17, 2014, 3:19:36 PM5/17/14
to haxef...@googlegroups.com
What do you mean?

James Grimwood

unread,
May 17, 2014, 4:18:05 PM5/17/14
to haxef...@googlegroups.com
The Xbox button ids are wrong again. If you run the gamepad test in windows things don't match up any more.

Gama11

unread,
May 17, 2014, 5:01:13 PM5/17/14
to
Are you sure you are on the latest versions? What's the output of haxelib list?

James Grimwood

unread,
May 17, 2014, 6:26:59 PM5/17/14
to haxef...@googlegroups.com
These are my installed versions

Also, is there a simple way to remove old versions of haxe libraries?
And does it matter my "lime" is actually still called "openfl"?

Haxe Compiler 3.1.3 - (C)2005-2014 Haxe Foundation


actuate: 1.6.4 [1.7.2]
firetongue: git [dev:c:\haxetoolkit\haxe\lib/firetongue/git]
flixel-addons: git [dev:c:\haxetoolkit\haxe\lib/flixel-addons/git]
flixel-demos: git [dev:c:\haxetoolkit\haxe\lib/flixel-demos/git]
flixel-templates: git [dev:c:\haxetoolkit\haxe\lib/flixel-templates/git]
flixel-tools: 1.0.0 1.0.1 [1.0.2]
flixel-ui: git [dev:c:\haxetoolkit\haxe\lib/flixel-ui/git]
flixel: 2.0.0-alpha.3 3.0.1 3.0.4 git [dev:c:\haxetoolkit\haxe\lib/flixel/git]
gameconsole: 1.1.0 2.0.0 [3.0.0]
haxelib_client: 3.1.0-rc.3 [3.1.0-rc.4]
hxcpp: 3.0.2 [3.1.30]
hxlibc: 1.0.0 1.1.3 [1.1.4]
hxtools: [1.1.6]
lime-tools: 1.2.5 1.2.9 1.3.2 [1.4.0]
lime: 0.9.1 0.9.4 0.9.6 [0.9.7]
nape: 2.0.14 2.0.15 [2.0.16]
ncot: git [dev:c:\haxetoolkit\haxe\lib/ncot/git]
openfl-compatibility: [1.0.1]
openfl-html5-dom: 1.1.1 1.2.0 1.2.1 [1.2.2]
openfl-html5: 1.0.3 1.0.5 1.1.1-beta 1.4.0-beta 1.4.1-beta [1.4.2-beta]
openfl-native: 1.0.4 1.0.7 1.1.4 1.2.1 1.2.2 1.3.0 [1.4.0]
openfl-samples: 1.0.0 1.0.0-rc.3 1.1.0 1.2.0 1.2.1 [1.3.0]
openfl-tools: [1.0.10] 1.0.4 1.0.9
openfl: 1.0.4 1.0.5 1.0.6 1.1.1 1.2.1 1.2.2 1.3.0 [1.4.0]
random: [1.4.0]
systools: [1.0.0-beta]

Gama11

unread,
May 17, 2014, 6:32:25 PM5/17/14
to haxef...@googlegroups.com
You can remove old versions simply by deleting them in HaxeToolkit/haxe/lib. ;)

My guess is that your git install of flixel is not up to date.

James Grimwood

unread,
May 18, 2014, 3:43:19 AM5/18/14
to haxef...@googlegroups.com
I did a bit of tidying up and now only have the dev version of Flixel (and 3.3.3 but that's not set active).

The ID of the dev version on my PC matches the one currently in github...

$ git rev-parse HEAD
3dfcb04cb6fafd5827e2af0cdc121842c05820fc

$ git pull
Already up-to-date.

I've had a play around with the GamepadTest program and In Windows, the XBox button IDs now map as follows (which feel a bit like how they used to be?)

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;
public static inline var LB:Int = 4;
public static inline var RB:Int = 5;
public static inline var BACK:Int = 6;
public static inline var START:Int = 7;
public static inline var LEFT_ANALOGUE:Int = 8;
public static inline var RIGHT_ANALOGUE:Int = 9;

 /**
* Axis array indicies
 */
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 = 3;
public static inline var RIGHT_ANALOGUE_Y:Int = 4;
public static inline var LEFT_TRIGGER:Int = 2;
public static inline var RIGHT_TRIGGER:Int = 2;

although I'm not sure if the left/right triggers are correct - they're axis 2 with that weird +/- thing depending on which trigger you press.

The d-pad is now gamepad.hat as a FlxPoint so I don't quite know how that matches button IDs 

Gama11

unread,
May 18, 2014, 9:52:45 AM5/18/14
to haxef...@googlegroups.com
All the IDs are working perfectly fine for me on latest dev. Not sure what's going on here, maybe your Xbox controller is not correctly detected as a XInput device.

James Grimwood

unread,
May 19, 2014, 2:47:55 PM5/19/14
to haxef...@googlegroups.com
OK this is interesting and worth mentioning somewhere...

If you just plug an XBox 360 (or compatible) wired pad into a Windows 7 PC it will install drivers automatically and will work perfectly well - but OpenFL/Haxeflixel will see the "wrong" button/axis IDs.

If you install the Microsoft 360 controller driver ( http://www.microsoft.com/hardware/en-gb/d/xbox-360-controller-for-windows ) it then works fine in Haxeflixel (according to the Gamepad test).

And you know if your computer has the MS controller driver installed because pressing the XBox button on the controller makes a little status menu appear.

Now, I'm going to dig around in my box of wires and find the PS2 Dualshock -> USB adaptor I have to see what Haxeflixel makes of a PS2 controller :-) I think Windows sees it as a generic USB joystick.

ra51

unread,
Aug 2, 2015, 6:24:00 PM8/2/15
to HaxeFlixel
I'm actually having this issue too on the CPP target. Has it ever been resolved?
Reply all
Reply to author
Forward
0 new messages