rebind
A library for binding input keys to actions, and modifying mouse behaviour. Keys can be bound to
actions, and then translated during runtime. Keys
are mapped to Actions
using a HashMap
, so
lookup time is constant.
Api Example
extern crate glutin_window;
extern crate piston;
extern crate rebind;
use GlutinWindow;
use Events;
use Event;
use Keyboard;
use Key;
use WindowSettings;
use ;
rebind_plugins
This library has a companion crate called rebind_plugins
. If you are using the nighly compiler, then
you can use this crate, which contains a special derive
annotation for declaring Action
s:
// ... rest of example as normal
Example Application
A sample application which shows off the main features (and the main method used to drive design decisions
about this library) is available in the example/
folder. The example builds on stable, although you can
build it to use the rebind_plugins
package by passing --features "rebind_plugins"
along with the Cargo
incantation you usually use.
Main improvements to be made:
- Implement conversion from InputTranslator to InputRebind
- Improve the API: Is the distinction between InputRebind and InputTranslator necessary or useful?
- Add serialisation
- Add mouse sensitivity options
- Add more tests/benchmarks
- Improve documentation
- Add double press detection
- Change the internal lookup from a
HashMap
to an array, where actions are stored in an array at positions corresponding to the numeric value of the key. This should be faster than using aHashMap
and collisions/ algorithmic DOS attacks are not a concern, although the size of the map is usually very small and lookups are relatively quick, so this is probably not a problem in practice.
Contributions welcome.