flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Gamepad detection in HTML5

Open thefurfel opened this issue 5 years ago • 4 comments

  • 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.

thefurfel avatar May 20 '20 16:05 thefurfel

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.

RichardBray avatar Jun 15 '20 16:06 RichardBray

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

Geokureli avatar Sep 04 '20 01:09 Geokureli

Apparently, it's not a Flixel issue - it's Lime.

pfoof avatar Sep 05 '20 07:09 pfoof

I see you made a lime issue, linking it here

https://github.com/haxelime/lime/issues/1431

Geokureli avatar Sep 06 '20 15:09 Geokureli