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.
source share