Git Product home page Git Product logo

gamepad-micro's People

Contributors

likethemammal 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

Watchers

 avatar  avatar  avatar

Forkers

jaforbes bsparks

gamepad-micro's Issues

Helpful warnings and errors

  • Error when no callback is given to onUpdate
  • Error when GamepadMicro is called with new keyword
  • Warn when onUpdate is called when Gamepad API isn't supported

Allow more sensitive button presses

The way the button pressed is written now, the button on fires if it was pressed completely (to value 1.0) and then released. This should be given more lenience.

There should also be a way of telling if a button is being held, and if multiple buttons are being pressed/held.

  • Pressed
    • On keyup, if not held
  • Held
    • On keydown, after 50ms delay

Ability to clear released buttons explicitly.

Would you accept a pull request for a function that clears the released buttons from the gamepad object?

The gamepad object is so conveniently structured that it is helpful to use it as the actual games storage of that data. But this leads to stale data for released.

Currently the released property can be true for an infinite amount of frames even though the button has long been released. It will only be updated when a new event occurs.

It'd be helpful if there was a function we could call like gp.clear() that gives the library permission to clear all released values and buttons. That way the developer can let you know they have processed the user input and you don't need to wait for the next action.

This could be done on a per game/application basis. But seeing as this library is already pretty high level, I hoped it could be implemented directly.

It also may be more performant to do so in the library as there is more information about what buttons need to be cleared, and this could remove the need to loop over the structure.

(Great library btw!)

Support non-standard gamepads

Not sure when a gamepad might be non-standard, but the code explicitly checks that its standard so this may be causing bugs for ppl with unpopular controllers.

W3C Spec on 'standard' mapping type:
https://w3c.github.io/gamepad/#idl-def-GamepadMappingType

Because non-standards may have weird axis, dpads, and what not this will require some investigation, and maybe some reworking of how the raw gamepads are parsed.

Sort gamepads in array, not by indices

The gamepads are sorted by their indices given by the Gamepad API. This is great and all but it leads to trouble when you try to loop over the gamepads. All the gamepads should be pushed to an array in order and their indices should be track on the gamepad object itself.

Cleanup gamepadConnected

Theres two different values for tracking whether a gamepad has connected or not. Theres some bugs related to this, so its worth just consolidating gamepadconnected into gamepadConnected, and having that one source of truth.

Keep the library micro but readable

  • Some of the utility functions can be moved to vars so they'll be minified
  • Gamepad.prototype could be made into a var so it'll be minified
  • navigator and window can be made into a vars
  • create variables for any strings ('gamepadconnected', 'gamepaddisconnected')
  • turn multiple traversals into objects into variables
  • Replace instances of true and false with trusted immutable variables
  • Only one var statement per func
  • console.warn into variable when its being used
  • strip out console.log with https://github.com/alanshaw/stripify

Source of some helpful tips:
http://www.slideshare.net/nzakas/extreme-javascript-compression-with-yui-compressor

Testing

Add some testing to the lib. Whatever type of testing will work. Need more confidence that the library is stable.

Tape sounds like a good option

Devices might not get detected

Originally reported in likethemammal/daisywheeljs#25

Here's some info:

  • Platform: Windows
  • Browsers tested: Google Chrome 63.0.3239.84 (64b) and Firefox 57.0 (64b)
  • Controllers tested: Generic Xbox 360 controller and Hori RAP 4 (DS4-emulative)
  • http://html5gamepad.com/ recognizes the controllers properly, even when both of them are plugged in
  • http://likethemammal.github.io/gamepad-micro/example.html recognizes neither, even one by one
  • Steam is likely to be interfering with the controllers, but I didn't find any difference with it being off

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.