Access to the feature "gamepad" is disallowed by permissions policy.

1293
1
07-26-2023 04:24 PM
ChrisSmith7
Frequent Contributor

My organization recently implemented a permissions policy disallowing gamepad. I am not including any of the gamepad input modules in our application; it is not something we are actively using. I tried disabling gamepad in the MapView using gamepad: false; however, the map chokes on load and the console reports an error.

Here's the error and call stack:

Uncaught DOMException: Failed to execute 'getGamepads' on 'Navigator': Access to the feature "gamepad" is disallowed by permissions policy.
    at w._forEachGamepad (https://js.arcgis.com/4.27/esri/views/MapView.js:284:66)
    at new z (https://js.arcgis.com/4.27/esri/views/MapView.js:281:154)
    at new g (https://js.arcgis.com/4.27/esri/views/MapView.js:271:90)
    at F._connect (https://js.arcgis.com/4.27/esri/views/MapView.js:236:292)
    at https://js.arcgis.com/4.27/esri/views/MapView.js:236:48
    at z (https://js.arcgis.com/4.27/:1717:105)
    at G.notify (https://js.arcgis.com/4.27/:182:158)
    at d (https://js.arcgis.com/4.27/:178:400)
    at F.l [as callback] (https://js.arcgis.com/4.27/:179:7)
    at d (https://js.arcgis.com/4.27/:187:15)

 

I can fix the issue by reverting the policy, but that is a last resort option for our organization. Any ideas on how to prevent the map from trying to call getGamepads?

0 Kudos
1 Reply
JoelBennett
MVP Regular Contributor

It's possible you may have shortened your description for simplicity, but disabling the gamepad according to the documentation is shown here under the description of the navigation property.

If you've done that and it still doesn't solve your problem, you may have to resort to overwriting the _forEachGamepad function so it doesn't cause the problem.  To do so, you'd need something like this prior to creating your MapView:

require(["esri/views/input/gamepad/GamepadSource"], function(g) {
	g.GamepadSource.prototype._forEachGamepad = function(m) { console.warn("Prevented gamepad access..."); };
});

 

0 Kudos