openfl / lime

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

Failed to execute 'getGamepads' on 'Navigator': Access to the feature "gamepad" is disallowed by permissions policy. #1727

Closed andrew-git closed 7 months ago

andrew-git commented 7 months ago

Latest Chrome Instant games gives issue: Failed to execute 'getGamepads' on 'Navigator': Access to the feature "gamepad" is disallowed by permissions policy.

Possible fix in src/lime/ui/Joystick.hx

    #if (js && html5)
    @:noCompletion private static function __getDeviceData():Array<Dynamic>
    {
        var res:Dynamic = null;

        try 
        {
            res = (untyped navigator.getGamepads) ? untyped navigator.getGamepads() : (untyped navigator.webkitGetGamepads) ? untyped navigator.webkitGetGamepads() : null;
        }
        catch (err:Dynamic)
        {
            trace("Gamepad access issue");
        }

        return res;
    }
    #end

Or maybe also add new flag to prevent call updateGameDevices() each frame in src/lime/_internal/backend/html5/HTML5Application.hx if we don't need this feature?