<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS JavaScript API 4.30 using Gamepad in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1537498#M85656</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/576373"&gt;@MarcoGianaLXRP&lt;/a&gt;,&amp;nbsp;thanks for posting your question here. I have collected some information that will (hopefully) be useful.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The ArcGIS Maps SDK for JavaScript ignores gamepad events if the app is hosted in an insecure context (e.g. via "http")&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Gamepads may not work as expected if using an online app sharing site like CodePen. This is because apps are hosted in an iFrame with additional security.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A browser may need to be restarted if a new gamepad is connected to the computer.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Due to new anti-fingerprinting provisions, gamepads are only discoverable after they are used (e.g. button pressed or joystick moved).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Gamepad interaction is enabled by default in both &lt;SPAN&gt;MapView&lt;/SPAN&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;SPAN&gt;SceneView&lt;/SPAN&gt;&lt;SPAN&gt;. No coding is required to "fly" in 2D or 3D provided your app is hosted in a secure context.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If more than one gamepad is connected to your computer then all gamepads are recognized and can be used to navigate. If more than one gamepad is connected to your computer, but you want a specific device to be used for navigation, then we recommend utilizing the &lt;SPAN&gt;view.input.gamepad.devices&lt;/SPAN&gt;&lt;SPAN&gt; collection. This collection can be monitored for changes as gamepads are recognized by the browser. For example, if my computer has two gamepads connected, one standard and one spaceMouse gamepad, but I only want the spaceMouse to be used for navigation, then I can use the following snippet:&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const { devices } = view.input.gamepad;
devices.on("change", () =&amp;gt; {
const spaceMouse = devices.find(({ deviceType }) =&amp;gt; deviceType === "spacemouse");

// Assign the spacemouse (if any)
view.navigation.gamepad.device = spaceMouse;

// Only enable gamepad navigation if a spacemouse is found.
view.navigation.gamepad.enabled = !!spaceMouse;
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2024 19:14:12 GMT</pubDate>
    <dc:creator>Noah-Sager</dc:creator>
    <dc:date>2024-09-11T19:14:12Z</dc:date>
    <item>
      <title>ArcGIS JavaScript API 4.30 using Gamepad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1537210#M85654</link>
      <description>&lt;P&gt;Hi, has anyone successfully used a gamepad with&amp;nbsp;ArcGIS JavaScript API 4.30?&lt;BR /&gt;From what I have read I understand the following,&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-navigation-gamepad-GamepadSettings.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-navigation-gamepad-GamepadSettings.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I am using Edge and Chrome on Windows 10.&lt;/P&gt;&lt;P&gt;* Gamepad for navigation is activated by default.&lt;BR /&gt;* When a gamepad is connected it should pick it up automatically and the mapping done for navigation&lt;/P&gt;&lt;P&gt;I have connected a gamepad and tested using the Tester in this page&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-input-gamepad-GamepadInputDevice.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-input-gamepad-GamepadInputDevice.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and all is working fine.&lt;/P&gt;&lt;P&gt;After the the gamepad has connected I check the&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN&gt;view&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;navigation&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;gamepad&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;device&lt;/STRONG&gt; which is null according to this&amp;nbsp;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-navigation-gamepad-GamepadSettings.html#device" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-navigation-gamepad-GamepadSettings.html#device&lt;/A&gt;&lt;BR /&gt;"i&lt;SPAN&gt;f unspecified then all connected gamepads will be able to navigate." so should be good.&lt;BR /&gt;But nothing is happening on my SceneView.&lt;BR /&gt;&lt;BR /&gt;So I check&amp;nbsp;&lt;STRONG&gt;view.input.gamepad.devices&lt;/STRONG&gt; but this has no devices in it.&lt;BR /&gt;&lt;BR /&gt;So I explicitly set&lt;STRONG&gt;&amp;nbsp;view.navigation.gamepad.device&lt;/STRONG&gt; to a device, but still&amp;nbsp;&lt;STRONG&gt;view.input.gamepad.devices&lt;/STRONG&gt;&amp;nbsp;has not devices. I am assuming a device her has to be set for gamepad to interact with the SceneView.&lt;BR /&gt;&lt;BR /&gt;Any example I have come across is old such as from 2018 and requires the developer to set gamepad mappings to the SceneView commands, but I thought this was all handled out of the box now.&lt;BR /&gt;&lt;BR /&gt;Any information, examples would be much appreciated.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Marco Giana&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 07:28:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1537210#M85654</guid>
      <dc:creator>MarcoGianaLXRP</dc:creator>
      <dc:date>2024-09-11T07:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript API 4.30 using Gamepad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1537498#M85656</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/576373"&gt;@MarcoGianaLXRP&lt;/a&gt;,&amp;nbsp;thanks for posting your question here. I have collected some information that will (hopefully) be useful.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The ArcGIS Maps SDK for JavaScript ignores gamepad events if the app is hosted in an insecure context (e.g. via "http")&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Gamepads may not work as expected if using an online app sharing site like CodePen. This is because apps are hosted in an iFrame with additional security.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A browser may need to be restarted if a new gamepad is connected to the computer.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Due to new anti-fingerprinting provisions, gamepads are only discoverable after they are used (e.g. button pressed or joystick moved).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Gamepad interaction is enabled by default in both &lt;SPAN&gt;MapView&lt;/SPAN&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;SPAN&gt;SceneView&lt;/SPAN&gt;&lt;SPAN&gt;. No coding is required to "fly" in 2D or 3D provided your app is hosted in a secure context.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If more than one gamepad is connected to your computer then all gamepads are recognized and can be used to navigate. If more than one gamepad is connected to your computer, but you want a specific device to be used for navigation, then we recommend utilizing the &lt;SPAN&gt;view.input.gamepad.devices&lt;/SPAN&gt;&lt;SPAN&gt; collection. This collection can be monitored for changes as gamepads are recognized by the browser. For example, if my computer has two gamepads connected, one standard and one spaceMouse gamepad, but I only want the spaceMouse to be used for navigation, then I can use the following snippet:&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const { devices } = view.input.gamepad;
devices.on("change", () =&amp;gt; {
const spaceMouse = devices.find(({ deviceType }) =&amp;gt; deviceType === "spacemouse");

// Assign the spacemouse (if any)
view.navigation.gamepad.device = spaceMouse;

// Only enable gamepad navigation if a spacemouse is found.
view.navigation.gamepad.enabled = !!spaceMouse;
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 19:14:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1537498#M85656</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2024-09-11T19:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript API 4.30 using Gamepad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1538080#M85666</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/169842"&gt;@Noah-Sager&lt;/a&gt;&amp;nbsp;thank you for the information.&lt;BR /&gt;Given what you mentioned I assume that using an ArcGIS Online SceneView should be able to pick up the gamepad as it uses ArcGIS JavaScript API 4.30 I tried the following Scene&lt;BR /&gt;&lt;A href="https://www.arcgis.com/home/webscene/viewer.html?layers=71a855fc39fb4ac7ad063f174dc1399e" target="_self"&gt;https://www.arcgis.com/home/webscene/viewer.html?layers=71a855fc39fb4ac7ad063f174dc1399e&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but unfortunately it still doesn't work.&lt;BR /&gt;I have attached an animation to demonstrate that the controller is recognised by the browser via the tester.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GamepadtestArcGIS.gif" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/114975iAD0AC628A4177383/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GamepadtestArcGIS.gif" alt="GamepadtestArcGIS.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 23:26:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1538080#M85666</guid>
      <dc:creator>MarcoGianaLXRP</dc:creator>
      <dc:date>2024-09-12T23:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript API 4.30 using Gamepad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1540262#M85711</link>
      <description>&lt;P&gt;Hi, I contacted ESRI Australia support and they just confirmed what the document states that only certain devices are supported&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-input-gamepad-GamepadInputDevice.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-input-gamepad-GamepadInputDevice.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;which fine but does not explain why. I went into browser debug mode and discovered that for a gamepad to connect it seeks the mapping property of the gamepad object to be set to "standard"&lt;BR /&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/mapping" target="_blank"&gt;https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/mapping&lt;/A&gt;&lt;BR /&gt;On closer investigation my controller input is actually not mapped to the :"standard" as per&amp;nbsp;&lt;BR /&gt;&lt;A href="https://w3c.github.io/gamepad/#dom-gamepad-mapping" target="_blank"&gt;https://w3c.github.io/gamepad/#dom-gamepad-mapping&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I am good with that, I just need to figure out how to adjust the mapping so the browser recognise it as "standard"&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Marco Giana&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 08:08:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-api-4-30-using-gamepad/m-p/1540262#M85711</guid>
      <dc:creator>MarcoGianaLXRP</dc:creator>
      <dc:date>2024-09-19T08:08:10Z</dc:date>
    </item>
  </channel>
</rss>

