FlxGamepad / XboxButtonID broken in windows?

118 views
Skip to first unread message

Luciano McBride

unread,
Dec 26, 2014, 11:24:15 PM12/26/14
to haxef...@googlegroups.com
Hi, awesome people using/making HaxeFlixel! Happy holidays everyone :)

I'm having some trouble with my xbox gamepad and HaxeFlixel.

Everything was working just fine somewhere between HaxeFlixel 3.3.1 and 3.3.3. After updating back then (and not touching my input management code at all), the gamepad stopped working in my windows build. Now I'm running 3.3.6 and the flash build is still working as expected, but FlxGamepad.pressed() returns false for whatever XboxButtonId I pass as parameter.

I compiled the GamepadTest demo and I got even weirder results: the A, B, X and Y buttons are detected as the DPAD, the DPAD does nothing at all, R and L are Select and Start, and so on.

My haxelib list:

actuate: [1.7.5]
fb-haxe-android: [dev:d:\Projects\openfl\fb-haxe-android]
flixel-addons: [1.1.0]
flixel-demos: [1.1.1]
flixel-templates: [1.0.2]
flixel-tools: [1.0.2]
flixel-ui: [1.0.2]
flixel: 3.3.4 3.3.5 [3.3.6]
hxcpp: 3.1.39 [3.1.48]
lime-tools: [1.5.7]
lime: 2.0.0 2.0.0-alpha.5 2.0.0-alpha.6 2.0.0-alpha.7 2.0.0-alpha.8 2.0.1 [2.0.2]
nape: [2.0.16]
openfl: 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 [2.1.8]
softkeyboardhelper: [dev:d:\Projects\openfl\softkeyboardhelper]



The way I'm getting the input is pretty straightforward:

1. I get a gamepad ID here
https://github.com/stinkfist-/battlepong/blob/master/source/game/Court.hx#L106


2.
I get the gamepad with that ID in my input manager, here:
https://github.com/stinkfist-/battlepong/blob/master/source/input/InputHandler.hx#L20


3.
I check for input this way:
https://github.com/stinkfist-/battlepong/blob/master/source/input/InputHandler.hx#L28


4. The player asks its input manager if a button is pressed like this:
https://github.com/stinkfist-/battlepong/blob/master/source/game/Player.hx#L81

Am I doing something wrong?

It works fine in flash. It does nothing in windows. I'll try a linux build tomorrow, as well as downgrading HaxeFlixel/Lime/OpenFL to previous versions.

Thanks in advance!

Gama11

unread,
Dec 27, 2014, 11:12:42 AM12/27/14
to haxef...@googlegroups.com
The latest lime / openfl versions seem to have messed with the Xbox mappings (again! :/).  Downgrading to lime 2.0.1 fixes it.

Luciano McBride

unread,
Dec 27, 2014, 3:27:03 PM12/27/14
to
Well, you're kind of right.

Downgrading to lime 2.0.1 fixed the demo but I still get no input from the gamepad in my game...

I tried a linux build and it doesn't work either. I tried putting this line

trace(FlxG.gamepads.firstActive.firstPressedButtonID());

in several places (for example, in the update() method of my Player and my PlayState) and I always get a -1 as output (which I assume it means there's no input) no matter what button I press...

I have no idea what could be wrong... Mainly since the flash target works perfectly.

Gama11

unread,
Dec 28, 2014, 6:43:56 AM12/28/14
to haxef...@googlegroups.com
If the demo works fine but your game doesn't, chances are it's someting with your code. What does it look like? Are you doing everything exactly like in the gamepad demo?


On Saturday, December 27, 2014 9:27:03 PM UTC+1, Luciano McBride wrote:
Well, you're kind of right.

Downgrading to lime 2.0.1 fixed the demo but I still get no input from the gamepad in my game...

I tried a linux build and it doesn't work either. I tried putting this line

trace(FlxG.gamepads.firstActive.firstPressedButtonID());

in several places (for example, in the update() method of my Player and my PlayState) and I always get a -1 as output (which I assume it means there's no input) no matter what button I press...

I have no idea what could be wrong... Mainly since the flash target works perfectly.

On Saturday, December 27, 2014 1:12:42 PM UTC-3, Gama11 wrote:

Luciano McBride

unread,
Dec 28, 2014, 9:24:40 PM12/28/14
to haxef...@googlegroups.com
Well, I would think the same, but as I said earlier

trace(FlxG.gamepads.firstActive.firstPressedButtonID());

outputs -1 no matter what I press and where I put it in my code. I really don't know what could be wrong.

In my first post there's a step by step of what I do to get the input (which works as expected in flash), as well as a link to the repository for the whole game

And don't get me wrong: by that I don't mean that I expect you to look at my entire code but rather that there you have as much context as you like (in case my step by step falls short).

Gama11

unread,
Dec 29, 2014, 7:20:44 AM12/29/14
to haxef...@googlegroups.com
I had a look at the code. You are using firstActive and lastActive in constructors, as opposed to the demo which is doing this every time in update(). These properties don't hold gamepads that are connected (in fact, the latest flixel release doesn't even listen to gamepad connected / disconnected events on native targets) - they hold gamepads which have been used (button press, axis move..) recently.

Either way, the easiest fix is to simply assign gamepad IDs 0 and 1 for player 1 and 2 respectively (provided that works in flash, I can't seem to get that to work at all currently for some reason). The only issue with that is that you can't handle gamepads being dis- and reconnected properly without the improvements from the dev branch.

Nice game, btw! :) You might want to make use of the startFullscreen option in Main.hx instead of setting FlxG.fullscreen in your PlayState - that way the transition from windowed to fullscreen is less noticable.

Luciano McBride

unread,
Dec 29, 2014, 9:38:54 PM12/29/14
to haxef...@googlegroups.com
Well, if I manually assign 0 and 1 as gamepad IDs, I get my players to move :)

Now I'll see how can I get the ID of the xbox gamepad that first got connected to assign it to player 1 (player 2 got ID 0 and player 1 got ID 1 in my quick test), but I guess that's my job :P

And I'm glad you liked the game. I still got to work a lot on it, but my playtesting sessions are going pretty well (people even seem to enjoy it and everything) :) I hope I kind of finish it in january and you guys will be the first to hear about it :)

thanks! :D

James Grimwood

unread,
Jan 1, 2015, 10:06:39 AM1/1/15
to haxef...@googlegroups.com
On Saturday, 27 December 2014 16:12:42 UTC, Gama11 wrote:
The latest lime / openfl versions seem to have messed with the Xbox mappings (again! :/).  Downgrading to lime 2.0.1 fixes it.

Argh, not again.

Having just spent a confusing 20 minutes with the GamepadTest program, here's some things that'll help
Oh yeah, beware the XBox button, it seems to emit ID 0, just like the A button does, but with the added fun that it pops up the little XBox dialog-thing :-/

XboxButtonID.hx

Right at the bottom, 

#else // windows

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_ANALOG:Int = 8;
public static inline var RIGHT_ANALOG:Int = 9;

public static inline var XBOX:Int = 14;

And then

/**
* Axis array indicies
*/
public static var LEFT_ANALOG_STICK(default, null):FlxGamepadAnalogStick = [FlxAxes.X => 0, FlxAxes.Y => 1];
public static var RIGHT_ANALOG_STICK(default, null):FlxGamepadAnalogStick = [FlxAxes.X => 3, FlxAxes.Y => 4];
public static inline var LEFT_TRIGGER:Int = 2;
public static inline var RIGHT_TRIGGER:Int = 5;

And for added excitement, you need to do this now for the DPad

var dpadLeft = _gamePad.hat.x < 0;
var dpadRight = _gamePad.hat.x > 0;
var dpadUp = _gamePad.hat.y < 0;
var dpadDown = _gamePad.hat.y > 0;

Which is nice, and like the OUYA
Reply all
Reply to author
Forward
0 new messages