lime
lime copied to clipboard
HTML5 Gamepad API - no event is dispatched to Lime
- Haxe version: 4.0.3
- OpenFL version: 8.9.6
- Lime version: 7.7.0 (as well as latest)
- Affected targets: HTML5
Code snippet:
#if js
Browser.window.addEventListener("gamepadconnected", (e) ->
{
var event = cast(e, GamepadEvent);
var gamepad = event.gamepad;
_gamepads.set(gamepad.index, gamepad);
Console.log("Gamepad " + gamepad.id + " connected at " + gamepad.index); // This code executes
});
Browser.window.addEventListener("gamepaddisconnected", (e) ->
{
var event = cast(e, GamepadEvent);
var index = event.gamepad.index;
_gamepads.remove(index);
});
#end
trace("Creating..."); // Prints "Creating..."
trace(lime.ui.Gamepad.devices); // Produces empty array
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. Lime apparently does not attach to that event (or is unsubscribed at some point).