package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.ui.FlxButton;
import flixel.math.FlxMath;
class MenuState extends FlxState
{
private var gamepadList:FlxText;
private var state:FlxText;
private var activeID:Int;
override public function create():Void
{
gamepadList = new FlxText(10, 10, 0, "", 16);
add(gamepadList);
state = new FlxText(10, 100, 0, "", 16);
add(state);
super.create();
}
override public function update(elapsed:Float):Void
{
activeID = FlxG.gamepads.getFirstActiveGamepadID();
gamepadList.text = "";
state.text = "";
for (gamepad in FlxG.gamepads.getActiveGamepads()) {
gamepadList.text += gamepad.detectedModel + ' at ID #' + gamepad.id + '\n';
}
state.text += "Active Gamepads: " + FlxG.gamepads.numActiveGamepads;
state.text += "\nFirst Active Gamepad ID: " + activeID;
if (activeID > -1)
state.text += "\nFlxG.gamepads.getByID(" + activeID + ").pressed.ANY returned " + FlxG.gamepads.getByID(activeID).pressed.ANY;
super.update(elapsed);
}
}
Observed behavior:
Whenever you have more than one controller plugged in, at least two of them need to have a button pressed in order for the code above to return true. Pressing only one controller returns false, for that controller ID. Same goes for justPressed and justReleased. Note that FlxG.gamepads.anyInput() will behave as expected.
Expected behavior:
The controller that is active and pressed to return true.
Code snippet reproducing the issue:
Observed behavior: Whenever you have more than one controller plugged in, at least two of them need to have a button pressed in order for the code above to return
true
. Pressing only one controller returnsfalse
, for that controller ID. Same goes forjustPressed
andjustReleased
. Note thatFlxG.gamepads.anyInput()
will behave as expected.Expected behavior: The controller that is active and pressed to return
true
.Here's an example project exhibiting the issue.