From 8d210b8562451120e1c1869011628e4a36ccf045 Mon Sep 17 00:00:00 2001 From: andrew-git Date: Thu, 30 Nov 2023 19:36:42 +0200 Subject: [PATCH 1/2] Prevents stuck if we don't have access to gamepad Original issue: Failed to execute 'getGamepads' on 'Navigator': Access to the feature "gamepad" is disallowed by permissions policy. --- src/lime/ui/Joystick.hx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lime/ui/Joystick.hx b/src/lime/ui/Joystick.hx index 55bf70cf9c..15f5926b2c 100644 --- a/src/lime/ui/Joystick.hx +++ b/src/lime/ui/Joystick.hx @@ -55,8 +55,18 @@ class Joystick #if (js && html5) @:noCompletion private static function __getDeviceData():Array { - return - (untyped navigator.getGamepads) ? untyped navigator.getGamepads() : (untyped navigator.webkitGetGamepads) ? untyped navigator.webkitGetGamepads() : null; + 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 From 8f0d1a40801b1d3e4034cbd8685821b4cdd674cd Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 1 Dec 2023 09:12:20 -0800 Subject: [PATCH 2/2] Joystick: remove trace and add comment --- src/lime/ui/Joystick.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lime/ui/Joystick.hx b/src/lime/ui/Joystick.hx index 15f5926b2c..502eee7c1d 100644 --- a/src/lime/ui/Joystick.hx +++ b/src/lime/ui/Joystick.hx @@ -63,7 +63,8 @@ class Joystick } catch (err:Dynamic) { - trace("Gamepad access issue"); + // if something went wrong, treat it the same as when navigator.getGamepads doesn't exist + // we probably don't have permission to use this feature } return res;