xarvh / elm-gamepad Goto Github PK
View Code? Open in Web Editor NEWPainless Elm library to use & configure gamepads and game controllers
License: BSD 3-Clause "New" or "Revised" License
Painless Elm library to use & configure gamepads and game controllers
License: BSD 3-Clause "New" or "Revised" License
Since there isn't an official way of previewing docs before publishing, I tested the links on https://elm-doc-preview.netlify.com/ which apparently interprets them differently than elm-package.
This is not going to get fixed until there will be a way to test links before publishing.
? newlyConnectedGamepads : Blob -> List Int
? newlyDisconnectedGamepads : Blob -> List Int
Because the library can't distinguish between a number changing because the user deliberately activated a control, or just moved the gamepad.
Elm Gamepad is mostly used for personal-use apps, apps that don't need to be usable by everyone on the internet.
It should be possible for Elm Gamepad to provide a minimal gamepad (a single stick and a single button) without any need for remapping.
Even if this wouldn't be reliable, it would allow people to put together quick-and-dirty apps without any need to wire in the remapping tool and persist remapping data.
Is this a good thing to add?
How would the API look like?
How would it be possible to make it clear that the API is not reliable?
unreliableGetGamepads : Blob -> List MinimalGamepad
?
Where did the documents about customizing the style end up? -_-
If a gamepad is disconnected or replaced during remapping, Gamepad.Remap should inform the user and, if the right gamepad becomes available again, it should be able to resume the remapping.
Some gamepads persist even after being physically disconnected.
Remove them when their timestamp becomes too old?
This is a good discussion of the current state of mapping support and its issues, would be useful to link it in the README.md
https://bugzilla.mozilla.org/show_bug.cgi?id=855364#c9
Gamepad.Remap
will complain that the gamepad is disconnected.
Fix in #9
A mapping should store also the gamepad index.
When searching for a mapping, first search one with the correct index.
Absent than, use any with the correct id.
It should contain a minimal example without database and a full example with loading the db from flags.
It should explain that gamepads won't be detected until they are touched.
It's easier to use if I just provide an elm package with decoders and maybe a guess function, and provide a function to cut & paste as port, so that the package can be published.
Skipping all controls should mark a gamepad as "disabled by the user"
Port blob should provide current and previous states, each with its list of gamepad states and timestamps.
Advantages:
Destination*
type.Since a large, comprehensive gamepad database is not practical, size is not an issue any more.
Because of that, it's better to serialise the database in JSON format.
Advantages:
The triple comma ,,,
is used in the serialised version of a db entry to divide the gamepad identifier from the button map.
Fuzzy testing will sometimes produce a gamepad identifier containing exactly that, making the test fail.
Is ,,,
a legitimate separator?
Should I just tell the fuzzer not to produce that, and hope that no gamepad identifier will ever contain ,,,
?
Is there a better way to serialise the database entry so that this cannot happen?
"You need this stuff only if you plan to write your own gamepad remapping functions."
"Gamepad.Remap
is actually written using only the stuff here (no special access to Gamepad opaque types"
Use a robust non-linear regression against a sigmoid function to detect the input actually activated by the user during automated remapping.
This might overcome both #41 and #25 but needs to be tested extensively as it would be a much more complicated algorithm, more prone to unexpected behaviour.
https://scipy-cookbook.readthedocs.io/items/robust_regression.html
https://github.com/scipy/scipy/blob/v1.3.0/scipy/optimize/_lsq/least_squares.py#L240-L939
It looks like performance.now()
returns a timestamp that's a few milliseconds ahead of the first timestamp
giveno to window.requestAnimationFrame
's callback; the result is that the first dt
passed to the subscription is negative, ie about -10ms instead than the usual +16ms.
For example: map both A and DpadUp buttons to the same "Jump Up" action.
This is made trivially possible by the advanced configuration menu that will be added to fix #41
(Also, since we're here: turn the Origin
type into a record and un-opaque it, since it's not exposed at all)
looking at the advanced example, the "Left Trigger / Left Analog Lever" flips to True when i pull the trigger on the controller. however, "Left Trigger (analog)" stays at 0.
if i pull the right trigger on the controller, both "Right Trigger (analog)" and "Left Trigger (analog)" show the value from the right trigger.
(lots left to do, but i think i'll get this integrated into a game. thanks!)
There are too many stupid edge cases that the remapping tool needs to be aware of.
They should be covered via tests.
The gamepad getters take the gamepad
as first argument, and the control name as second.
This is done because it was convenient in many situations in my own code.
However there were as many cases that would have benefited from having gamepad
last.
It would be interesting to collect more use cases.
Docs should link to http://html5gamepad.com/
https://bugzilla.mozilla.org/show_bug.cgi?id=1434408#c1
This screws up with the origin estimation function.
Fix: have the origin estimation consider two consecutive frames instead than just 1?
Make more immediately clear that the library has an API for quick usage and another API that gives more control.
This will have to wait until #41 is addressed.
Gamepad.Remap is a pain to wire in and still does nothing.
It's much better to provide the full TEA machinery for a top-of-the-notch remapping UI that can be plugged in any app.
Pros
Cons
Find an image with the named buttons and slap it in README.md
It shouldn't.
Per https://w3c.github.io/gamepad/#usage-examples it might be better to poll right after the call to requestAnimationFrame()
Gamepad.animationFrameTimestamp
produces time via the window.requestAnimationFrame
callback, which is given a DOMHighResTimeStamp
.
This seems to produce a time relative to window init instead than an absolute time, which a Posix date should always be.
Further, the docs sell Gamepad.animationFrameTimestamp
as a drop-in replacement for Browser.Events.onAnimationFrame
, which is not true.
Fix: the port module should use Date.now()
, per https://github.com/elm/browser/blob/1.0.0/src/Elm/Kernel/Browser.js#L265 as the timestamp value.
The remap tool is giving instruction to the user in English, which severely limit the tool's accessibility.
A simple way to address this would be to add a remapViewWithLanguage
function that allows to specify a alternate text content for each of the remap messages.
Currently, Remap.init
must be provided with the index of the gamepad to remap.
There is little value in letting the user code manage this.
The most user friendly behaviour seems to be to just let the gamepad user press a button to indicate which gamepad is to be remapped, and Remap should implement it.
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.