GithubHelp home page GithubHelp logo

kallaspriit / html5-javascript-gamepad-controller-library Goto Github PK

View Code? Open in Web Editor NEW
128.0 13.0 37.0 613 KB

Library for accessing gamepads in modern browsers.

Home Page: http://kallaspriit.github.com/HTML5-JavaScript-Gamepad-Controller-Library/

JavaScript 81.64% CSS 18.36%

html5-javascript-gamepad-controller-library's People

Contributors

bassarisse avatar cvan avatar deanputney avatar dertseha avatar kallaspriit avatar lazd avatar leobalter avatar mildmojo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

html5-javascript-gamepad-controller-library's Issues

Use objects instead of arrays for buttons/axes mappings

It's kind of hard to read (count) the indices in the arrays to figure out which buttons/axes are mapped to which indices. It would be nice if we could specify the buttons and axes mappings as an object with each key being the constant string (e.g., 'LEFT_TOP_SHOULDER') instead of the index (e.g., 4).

Buttons:
https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library/blob/af601ac2/gamepad.js#L481
https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library/blob/af601ac2/gamepad.js#L424-L430

Axes:
https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library/blob/af601ac2/gamepad.js#L484
https://github.com/kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library/blob/af601ac2/gamepad.js#L438

Document the button names

I was confused about FACE_1, FACE_2, FACE_3, and FACE_4 until I read http://www.html5rocks.com/en/tutorials/doodles/gamepad/ and used http://www.html5rocks.com/en/tutorials/doodles/gamepad/gamepad-tester/tester.html

I'm still unsure of SELECT_BACK and START_FORWARD. The aforementioned tutorial refers to SELECT and START only; what would back and forward do on particular controllers?

And what should HOME do (I thought this would be similar to Select, but I'm probably just unfamiliar with controllers that have Home buttons).

getGamepad will now require Secure Context

Hi all, for several weeks the chrome console has been returning the following message: "gamepad.js: 34 getGamepad will now require Secure Context. Please update your application accordingly. For more information see w3c/gamepad#120 "
Does anyone know how to fix. Thanks

Not work in last Chrome (73.0.3683.86)

Heya!
The problem is that when you press any button, the gamepad is disconnected and reconnected
This happens on Button up event, for some reason "gamepads.indexOf(gamepad)" return -1 and disconnect gamepads.
When "this.knownGamepads[i]" has the gamepads Array
it's very strange, I don't understand why this is happening
Code example in the repository also does not work, the problem is in the library
Please help solve this problem

Standardize button names reported by library

As a user of the library, I don't want to be concerned what kind of gamepad is connected; I don't care whether the button is called "A" or "SQUARE" for instance.

While the spec does not specify the names, the HTML5Rocks page has a nice image showcasing example names.

Any device specific names could then be layered over them should a UI need them. But the technical names should be unified.

Consider firing synthetic events

Maybe if a special option is passed, the Gamepad could synthesise gamepadconnected and gamepaddisconnected events. Using a requestAnimationFrame loop, we would just check the state of navigator.getGamepads().

Not sure if this is a good idea, but it would fix #21 and could be useful for devs since I'm sure many devs have to do this themselves anyway.

Linux, Firefox (Nightly 17.0a1 2012-07-17), (old) Logitech Gamepad: different mapping

I've got an older Logitech gamepad, which is reported as
"Gamepad #0: 046d-c216-Logitech Logitech Dual Action (logitech)"
and looks like this one: http://www.geeks.com/details.asp?invtid=963292-0403
Notable difference to current ones: ABXY buttons are labelled 2314 (and no vibration function)

The button layout for this one is identical to WEBKIT_LOGITECH and is thus mixed up in the current FIREFOX_LOGITECH.
Yet there are several factors playing together:

  • I'm using the old gamepad-introductory build of Firefox for testing here, I don't know whether there are more current supporting versions that perhaps have a different mapping
  • It's an older gampead, yet I doubt they changed the button layout

What to do?

Library does not support XBOX 360 Controller Under Linux

The Library fails to detect the XBOX 360 Gamepad as an XBOX gamepad and supports it as an unknown controller.

Here's the ID Info. Dumped through Chrome 26.0.1410.63.

Unsupported controller connected
Gamepad {buttons: Array[17], axes: Array[4], timestamp: 1351764, index: 0, id: "©Microsoft Corporation Controller (STANDARD GAMEPAD Vendor: 045e Product: 028e)"…}
axes: Array[4]
0: 0.08609271794557571
1: -0.056611835956573486
2: 0.013000885024666786
3: 0.08087404817342758
length: 4
proto: Array[0]
buttons: Array[17]
0: 0
1: 0
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
16: 0
length: 17
proto: Array[0]
id: "©Microsoft Corporation Controller (STANDARD GAMEPAD Vendor: 045e Product: 028e)"
index: 0
timestamp: 1351764
type: "unsupported"
proto: Gamepad

This is using an official gamepad connected via USB.

Contribution guidelines & scripts?

I have a few ideas to enhance the library, and instead of rolling my own (and yet another), I'd like to contribute here.

But before I do that, I'd like to ask for some guidelines, specifically .jshintrc and .jsbeautifyrc files.
Furthermore I'd like to have the build scripts as part of the repository as well; I don't know what you are using, but I'd be happy to add a grunt based setup.

Demo not working in Chrome

I could be missing something, but the demo doesn't work in Chrome stable (Version 35.0.1916.153) nor Chrome Canary (Version 38.0.2093.3 canary [64-bit]).

Since Chrome doesn't fire gamepadconnected or gamepaddisconnected events like Firefox does, it doesn't look like we initialise a gamepad.

At least for demo purposes, could we poll using requestAnimationFrame to detect when a game pad is connected, and then initialise the demo?

controller connects twice if connected with both bluetooth and wire

Software used:
Chrome
Hardware used:
PS3 controller and charging cable

When PS3 controller is connected to the computer via both wire and bluetooth, browser will connect the same controller up twice but only report events for the newest gamepad connection.

This is a problem when playing a one player game as the code for the game wont ever reference a second gamepad and the only way to resolve this is to disconnect one of the connections and then restart the browser.

mapping of buttons

how can I make mappings ? is there any guide or tutorial ?? an example maybe ?!

Linux & xbox controller

Hi,

Awesome project! Saves me a lot of time.
I've got it working on windows, but the mapping in chrome / linux with my xbox 360 controller is wrong.

I've been looking at the code for a way to override the mapping for linux, but am I right in saying that currently there is no filter for platform? mac / windows / linux?

Many thanks,
Thijs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.