openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
754 stars 370 forks source link

[html5] gamepad disconnect event is never dispatched #1806

Open bkhtrv opened 3 months ago

bkhtrv commented 3 months ago

updateGameDevices() in lime/_internal/backend/html5/HTML5Application.hx prevents the event from happening

the

  cache.connected = false;

  Joystick.__disconnect(id);
  Gamepad.__disconnect(id);

part never happens because of if (data == null) continue

a dirty fix replacing

if (data == null) continue

with

if (data == null)
{
    if (gameDeviceCache.exists(id))
    {
        gameDeviceCache.remove(id);
        Joystick.__disconnect(id);
        Gamepad.__disconnect(id);
    }
    continue;
}

solved the issue for me