likethemammal / gamepad-micro Goto Github PK
View Code? Open in Web Editor NEWMicro library that interfaces with the Gamepad API and publishes gamepad update events.
Home Page: https://www.npmjs.com/package/gamepad-micro
Micro library that interfaces with the Gamepad API and publishes gamepad update events.
Home Page: https://www.npmjs.com/package/gamepad-micro
new
keywordThe 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.
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!)
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.
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.
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.
Add files
list to package.json to ignore most files when publishing to npm. https://www.npmjs.org/doc/files/package.json.html#files
Gamepad.prototype
could be made into a var so it'll be minifiednavigator
and window
can be made into a varsconsole.warn
into variable when its being usedconsole.log
with https://github.com/alanshaw/stripifySource of some helpful tips:
http://www.slideshare.net/nzakas/extreme-javascript-compression-with-yui-compressor
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
Originally reported in likethemammal/daisywheeljs#25
Here's some info:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.