Can I use gamepads with Node-Webkit (NW.js)?

I am creating an NW.js toolbar application (Node -Webkit) that I want to control using a game controller (for example, an XBox 360 controller or Logitech controller).

I call the following onready, but when I debug it without recognizing any game systems.

angular.element(document).ready(function() { if(canGame()) { var prompt = "To begin using your gamepad, connect it and press any button!"; $("#gamepadPrompt").text(prompt); $(window).on("gamepadconnected", function() { $("#gamepadPrompt").html("Gamepad connected!"); console.log("connection event"); }); $(window).on("gamepaddisconnected", function() { console.log("disconnection event"); $("#gamepadPrompt").text(prompt); }); } }); function canGame() { return "getGamepads" in navigator; } 

When I debug the code, it doesn't seem to detect any game consoles. I am also trying:

 navigator.webkitGetGamepads() 

but it does not display any game consoles.

Has anyone successfully used gamepads with the NW.js app?

I would really appreciate help on this.

+6
source share
1 answer

I found the answer to my problem. Gamepads are truly compatible with NW.js. However, I used the old version (~ v0.08).

The code that I published earlier when working with NW.js v0.12.2.

+1
source

Source: https://habr.com/ru/post/987718/


All Articles