Gamepad detection in HTML5
- Haxe version: 4.0.3
- Flixel version: 4.7.0
- OpenFL version: 8.9.6
- Lime version: 7.7.0
- Affected targets: HTML5 (Linux at least)
Code snippet reproducing the issue:
package;
import flixel.FlxState;
import flixel.FlxG;
class PlayState extends FlxState
{
override public function create():Void
{
trace(FlxG.gamepads.numActiveGamepads); // Always returns 0
}
}
Observed behavior: No gamepads are detected in a browser. However, in pure JS it works.
Expected behavior: Gamepads should be detected and the event should be dispatched from JS because the browser registers the gamepad after pressing a button in "ongamepadconnected" window event. This could be also a problem between JS and OpenFL but might also be between OpenFL and Flixel.
Hmm, have you looked at the demo here: https://haxeflixel.com/demos/GamepadTest/
Personally, it works fine on my Mac with a PS4 controller and a Wired Xbox 360 one, but it would be good to know what the demo says for you.
In Html5 you have to interact with the gamepad after the game starts for flixel to know it exists, where, in other targets, controllers will be active if you connected them and pressed a button before the program started
Apparently, it's not a Flixel issue - it's Lime.
I see you made a lime issue, linking it here
https://github.com/haxelime/lime/issues/1431