Giter Site home page Giter Site logo

elm-gamepad's People

Contributors

mdevlamynck avatar xarvh avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

elm-gamepad's Issues

"Quick and dirty" API

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?

Restyling docs

Where did the documents about customizing the style end up? -_-

Cull zombie gamepads?

Some gamepads persist even after being physically disconnected.
Remove them when their timestamp becomes too old?

Allow remapping single gamepad

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.

Extend README.md

  • 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.

Make it into a Port

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.

New API with wasClicked and wasReleased

Port blob should provide current and previous states, each with its list of gamepad states and timestamps.
Advantages:

  • Can detect button presses and button releases
  • Can get rid of Destination* type.
  • Can provide both time differences and time stamps
  • Port signature becomes simpler
  • Simpler JS

Encode database to JSON

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:

  • Get ride of regex parsing
  • Use a common format
  • Moots #14

Fix ,,, tests

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?

Automatic remapping uses least squares on sigmoid to detect activated input

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

The Example looks horrid

  • Needs some redesign and restyling
  • Code needs to be more clear and better commented
  • Should tell the user if there are gamepads that can be configured

First `dt` is negative

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.

Allow multiple origins to map to the same destination

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)

PS4 triggers

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!)

Should the `gamepad` argument always be last?

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: clarify API layers

Make more immediately clear that the library has an API for quick usage and another API that gives more control.

Rewrite Remap entirely

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

  • Much easier API, less work to add remapping capability
  • Better UI

Cons

  • Adds a dependency on elm/html

animationFrameTimestamp does not produce an absolute timestamp

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.

Support multiple languages

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.

Remap picks the gamepad

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.

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.