Add accelerometer support (DeviceMotionEvent & DeviceOrientationEvent)
Awesome library!
Would be great to add motion support, via:
https://developer.mozilla.org/en-US/docs/Web/API/Detecting_device_orientation
I had planned to add this but can you give me an example of how you'd expect the events to be named?
HI.on('tilt:left', doTiltLeft); // Maybe?
Also curious what sorts of thresholds/settings it should have.
Yeah, there's a lot to consider here, especially if you take into account three dimensional space. Maybe aircraft motion types? Pitch, yaw, roll? coupled with "gestures" like "flick" or "shake"
That's actually a great point: Accelerometers work a bit like joystick axes. Since that's the case I should be able to just mimick how the Gamepad plugin handles it:
HI.on('gpad:axis:1', moveBackAndForth); // Something similar to this
To keep things simple for everyone I'll see if I can add support for all the common ways to represent axes:
pitch == tilt:forward / tilt:back
roll == tilt:left / tilt:right
yaw == rotate:left / rotate:right
That way you could do HI.on('pitch', forwardBack) or HI.on('tilt', tiltControl) or get more specific and do things like HI.on('tilt:left', doTiltLeft);
Once those basics are complete I can add support for gestures like shake, spin, flip, and tossdevice. The latter could be a cool way for manufacturers to demonstrate the robustness of their phones/tablets by writing a game that detects when the device is thrown (HI.on('tossdevice', playWheeSound)) and lands in a designated bin (HI.on('suddenstop', locationCheck)) :smile: