diff --git a/src/lime/ui/Joystick.hx b/src/lime/ui/Joystick.hx index 55bf70cf9c..502eee7c1d 100644 --- a/src/lime/ui/Joystick.hx +++ b/src/lime/ui/Joystick.hx @@ -55,8 +55,19 @@ 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) + { + // 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; } #end