Gamepad

700 views
Skip to first unread message

Raymond Camden

unread,
May 31, 2012, 2:30:01 PM5/31/12
to chromium...@chromium.org
I read that the Gamepad API was just recently added to Chromium, but I'm still not seeing proper support for it. I see a flag, but any code that checks for detection, or button events, is never firing. Can someone please confirm/deny this really works?

Scott Graham

unread,
May 31, 2012, 3:46:13 PM5/31/12
to raymon...@gmail.com, chromium...@chromium.org
It should work on all platforms.

There's currently no events (connected/disconnected) as listed in the
spec. However, you can read navigator.webkitGamepads[] to get data.
Elements of that array will be undefined until a gamepad is connected
and interacted with.

Note that you need to press a face button on the gamepad before data
will be available. This is due to fingerprinting concerns.

scott
> --
> Chromium Discussion mailing list: chromium...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-discuss

Raymond Camden

unread,
May 31, 2012, 3:56:44 PM5/31/12
to Scott Graham, chromium...@chromium.org
Hmm - I can't get anything to show up in navgiator.webkitGamepads[].

This is what I'm using now - and I'm assuming the events won't work at
all. (Any reason why?)

http://www.raymondcamden.com/demos/2012/may/31/test3.html
--
===========================================================================
Raymond Camden, Adobe Developer Evangelist

Email : raymon...@gmail.com
Blog : www.raymondcamden.com
Twitter: cfjedimaster

Scott Graham

unread,
May 31, 2012, 4:12:31 PM5/31/12
to Raymond Camden, chromium...@chromium.org
On Thu, May 31, 2012 at 12:56 PM, Raymond Camden
<raymon...@gmail.com> wrote:
> Hmm - I can't get anything to show up in navgiator.webkitGamepads[].

You could perhaps try http://jsbin.com/acuhig to confirm that it's not
a hardware/driver problem.

> This is what I'm using now - and I'm assuming the events won't work at
> all. (Any reason why?)

They're not implemented yet.

Raymond Camden

unread,
May 31, 2012, 4:24:10 PM5/31/12
to Scott Graham, chromium...@chromium.org
Wow - that did work. So what the heck... digging...

Raymond Camden

unread,
May 31, 2012, 4:31:58 PM5/31/12
to Scott Graham, chromium...@chromium.org
Ok - what I don't get is this. Assuming my code is 100% wrong. In
console in your link, I can console.dir(navigator.webkitGamepads) and
I see my gamepad. In my demo, I don't. Shouldn't it show in the DOM
(after hitting a few buttons, moving things, etc) on both?

Raymond Camden

unread,
May 31, 2012, 4:35:22 PM5/31/12
to Scott Graham, chromium...@chromium.org
Wow... so when I slowly merge in your code - I see a gamepad. It's
like the act of asking for webkitGamepads actually gets the gamepad.

Is that... is that how it is meant to be?

Scott Graham

unread,
May 31, 2012, 4:42:35 PM5/31/12
to Raymond Camden, chromium...@chromium.org
On Thu, May 31, 2012 at 1:35 PM, Raymond Camden <raymon...@gmail.com> wrote:
> Wow... so when I slowly merge in your code - I see a gamepad. It's
> like the act of asking for webkitGamepads actually gets the gamepad.
>
> Is that... is that how it is meant to be?

I'm not sure what you're asking.

Reading webkitGamepads will get you the current values for the
gamepads connected to the system.

Raymond Camden

unread,
May 31, 2012, 4:45:08 PM5/31/12
to Scott Graham, chromium...@chromium.org
On Thu, May 31, 2012 at 3:42 PM, Scott Graham <sco...@chromium.org> wrote:
> On Thu, May 31, 2012 at 1:35 PM, Raymond Camden <raymon...@gmail.com> wrote:
>> Wow... so when I slowly merge in your code - I see a gamepad. It's
>> like the act of asking for webkitGamepads actually gets the gamepad.
>>
>> Is that... is that how it is meant to be?

What I meant is this. Imagine an HTML page with no content (ok,
minimal content). I'd imagine that if I go to console and do

console.dir(navigator.webkitGamepads);

I'd see my gamepad. Right? But if you go to my demo and try that it
doesn't work. I mean you get an array of 4 empty items. But you don't
get my gamepad. When you hit my demo - disregarding the Firefox event
based code which won't work in Chrome - you won't see your gamepad.
Right?

Then you take your code - which loops over the arrays and just gets
basic data out of it. That _does_ work.

That is what doesn't make sense to me.

>
> I'm not sure what you're asking.
>
> Reading webkitGamepads will get you the current values for the
> gamepads connected to the system.
>
>>
>> On Thu, May 31, 2012 at 3:31 PM, Raymond Camden <raymon...@gmail.com> wrote:
>>> Ok - what I don't get is this. Assuming my code is 100% wrong. In
>>> console in your link, I can console.dir(navigator.webkitGamepads) and
>>> I see my gamepad. In my demo, I don't. Shouldn't it show in the DOM
>>> (after hitting a few buttons, moving things, etc) on both?
>>>
>>> On Thu, May 31, 2012 at 3:24 PM, Raymond Camden <raymon...@gmail.com> wrote:
>>>> Wow - that did work. So what the heck... digging...
>>>>
>>>> On Thu, May 31, 2012 at 3:12 PM, Scott Graham <sco...@chromium.org> wrote:
>>>>> On Thu, May 31, 2012 at 12:56 PM, Raymond Camden
>>>>> <raymon...@gmail.com> wrote:
>>>>>> Hmm - I can't get anything to show up in navgiator.webkitGamepads[].



Scott Graham

unread,
May 31, 2012, 4:55:27 PM5/31/12
to Raymond Camden, chromium...@chromium.org
On Thu, May 31, 2012 at 1:45 PM, Raymond Camden <raymon...@gmail.com> wrote:
> On Thu, May 31, 2012 at 3:42 PM, Scott Graham <sco...@chromium.org> wrote:
>> On Thu, May 31, 2012 at 1:35 PM, Raymond Camden <raymon...@gmail.com> wrote:
>>> Wow... so when I slowly merge in your code - I see a gamepad. It's
>>> like the act of asking for webkitGamepads actually gets the gamepad.
>>>
>>> Is that... is that how it is meant to be?
>
> What I meant is this. Imagine an HTML page with no content (ok,
> minimal content). I'd imagine that if I go to console and do
>
> console.dir(navigator.webkitGamepads);
>
> I'd see my gamepad. Right? But if you go to my demo and try that it
> doesn't work. I mean you get an array of 4 empty items. But you don't
> get my gamepad. When you hit my demo - disregarding the Firefox event
> based code which won't work in Chrome - you won't see your gamepad.
> Right?
>
> Then you take your code - which loops over the arrays and just gets
> basic data out of it. That _does_ work.
>
> That is what doesn't make sense to me.

I'm not able to reproduce this. For example, if I go to about:blank,
press a button and then enter 'navigator.webkitGamepads' at the
console, I get one element in the array containing valid data.

I've logged a bug here, let's continue the investigation there:
https://code.google.com/p/chromium/issues/detail?id=130633

Thanks.

Raymond Camden

unread,
May 31, 2012, 4:59:31 PM5/31/12
to chromium...@chromium.org, Raymond Camden
Sounds fine... by the way - thank you very much. I was able to get my super important critical paddle game demo working. ;) I appreciate it. (I didn't update the remote url I published earlier - still local to my machine.)

Raymond Camden

unread,
Jul 31, 2012, 5:41:11 PM7/31/12
to chromium...@chromium.org
Just thought I'd update this thread. Today the Chromium Blog announced support for the Gamepad API ( http://blog.chromium.org/2012/07/introducing-getusermedia-and-javascript.html ), however, I am still not seeing support for events ( https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html ) which is in the spec. You can certainly use the gamepad (via a requestAnimationFrame), but is there any reason why the event API isn't there?

Scott Graham

unread,
Jul 31, 2012, 5:44:44 PM7/31/12
to raymon...@gmail.com, chromium...@chromium.org
On Tue, Jul 31, 2012 at 2:41 PM, Raymond Camden <raymon...@gmail.com> wrote:
Just thought I'd update this thread. Today the Chromium Blog announced support for the Gamepad API ( http://blog.chromium.org/2012/07/introducing-getusermedia-and-javascript.html ), however, I am still not seeing support for events ( https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html ) which is in the spec. You can certainly use the gamepad (via a requestAnimationFrame), but is there any reason why the event API isn't there?

No reason, it just hasn't been implemented yet.
 


On Thursday, May 31, 2012 1:30:01 PM UTC-5, Raymond Camden wrote:
I read that the Gamepad API was just recently added to Chromium, but I'm still not seeing proper support for it. I see a flag, but any code that checks for detection, or button events, is never firing. Can someone please confirm/deny this really works?

--

Scott Graham

unread,
Jul 31, 2012, 5:50:58 PM7/31/12
to Raymond Camden, Chromium-discuss
On Tue, Jul 31, 2012 at 2:48 PM, Raymond Camden <raymon...@gmail.com> wrote:
Ah cool. So the expectation is that it _will_ be at some point
probably, right?

Yes.
 
I.e., there isn't some philosophical reason against
that part of the spec.

Not at all.

Raymond Camden

unread,
Jul 31, 2012, 5:58:30 PM7/31/12
to Scott Graham, Chromium-discuss
Thanks Scott. Didn't expect a response so quickly. :) In case you are
curious, my incredibly exciting/I'm going to retire soon demo:

http://raymondcamden.com/demos/2012/jul/31/test3.html
Reply all
Reply to author
Forward
0 new messages