Hello -
I saw Eric Bidelmans excellent "The Edge of HTML5" slide deck
(
http://html5-demos.appspot.com/static/html5-therealbleedingedge/
template/index.html#27)
and its references to the gamepad API, i.e.
navigator.webkitGamepads || navigator.MozGamepads
and the events
window.addEventListener('webkitgamepadconnected', onConnected,
false);
window.addEventListener('webkitgamepaddisconnected',
onDisconnected, false);
window.addEventListener('MozGamepadDisconnected', onDisconnected,
false);
window.addEventListener('MozGamepadConnected', onConnected, false);
I am on a Mac, latest Snow Leopard, with latest Chromium Canary
(18.0.1025.6) and am trying to get this to work.
Specifically I would love to be able to drive the Google Earth browser
plugin with a 3DConnexion Space Navigator (
http://www.3dconnexion.com/
products/spacenavigator.html) or a Logitech Wingman Extreme 3D
joystick.
Both work in the regular Google Earth App, so I know they are
connected as far as OS is concerned.
In chromium, I can reference the navigator.webkitGamepads property and
get:
GamepadList
0: undefined
1: undefined
2: undefined
3: undefined
length: 4
Not sure what that length 4 array means. But anyway, I cannot get
those events to fire (wildly moving joystick and pressing buttons) and
therefore anything to work. (I also tried in latest Firefox Nightly
13.0a1 2012-02-06, same nothing)
Is it supposed to work already and I am making a mistake or is it just
not quite there yet ?
BTW, I DID enable Gamepad (and Pointer lock) in about:flags in my
Canary
Any tips (or implementation timeline) appreciated !
Also, is the gamepad API going to make it into webkit nightlies and
perhaps Safari ? Just thinking about deployed base of this feature...
THANKS !
---
PS my test script (just in case i screwed that up and someone spots
it)
navigator.gamepads = navigator.webkitGamepads ||
navigator.MozGamepads;
var controllers = {}; // Stash connected controllers.
var reqId = null;
function onConnected(e)
{
console.log( "Controller connected !" );
console.log( e );
controllers[e.gamepad.index] = e.gamepad;
}
function onDisconnected(e)
{
console.log( "Controller DISconnected !" );
console.log( e );
delete controllers[e.gamepad.index];
}
window.addEventListener('webkitgamepadconnected', onConnected, false);
window.addEventListener('webkitgamepaddisconnected', onDisconnected,
false);
window.addEventListener('MozGamepadDisconnected', onDisconnected,
false);
window.addEventListener('MozGamepadConnected', onConnected, false);