Connectivity / realtime
Lightgun and phone-gyro utilities
WebRTC tools that turn a phone into a lightgun controller or a gyroscope-driven desktop mouse.
Published
- WebRTC
- DeviceOrientation API
- TypeScript
What they are
Two related utilities built on the same connection layer as the MIDI controller. The lightgun utility lets a phone act as a pointing controller for lightgun-style games on arcade.gkheart.ca, with a calibration step. The gyro mouse utility uses the phone's motion sensors to move a desktop pointer.
Calibration
Motion sensors drift and every person holds a phone differently, so raw orientation cannot be mapped straight to the screen. The utility asks the player to aim at known points, records the orientation at each, and builds a mapping from phone angles to screen coordinates.
Smoothing is a trade-off: too little and the cursor shakes, too much and it lags behind the hand. The filter is tuned so small jitter is removed while fast, deliberate movements still come through.