Skip to content

About

Gear VR bluez/uinput driver made with AI

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

GearMouse

Lean Linux air-mouse driver for the Samsung Gear VR Controller. Uses Bluetooth LE (via bleak) and a kernel virtual device (via evdev / uinput).

Design decisions, architecture, and agent notes: DESIGN.md.

Gyro always moves the cursor (EMA + optional response expo). Trigger = left click, back = right click, touchpad slides = 2D scroll, touchpad press = recenter cursor, home = Super/Windows key.

Requirements

  • Linux (X11 or Wayland)
  • Python 3.10+
  • Bluetooth adapter + Gear VR Controller paired in the system Bluetooth settings
  • Access to /dev/uinput

Install

cd /path/to/gearmouse
python3 -m venv --system-site-packages .venv
source .venv/bin/activate
pip install -r requirements.txt

On Fedora Atomic / Bazzite, evdev often needs a C build (python3-devel). Prefer the distro package and a venv with --system-site-packages (as above), e.g. rpm-ostree install python3-evdev if it is not already present.

uinput permissions

Either run once as root, or (recommended) grant the input group access:

echo 'KERNEL=="uinput", MODE="0660", GROUP="input"' | \
  sudo tee /etc/udev/rules.d/99-uinput.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
sudo usermod -aG input "$USER"

Log out and back in so the group membership applies.

Temporary workaround:

sudo chmod 0666 /dev/uinput

Run

  1. Power on the Gear VR Controller (and ensure it is paired). Pair once in system settings or with bluetoothctl. No sudo is required for Bluetooth; your user only needs normal BlueZ access (and /dev/uinput for the virtual mouse).
  2. Confirm the controller shows up: bluetoothctl devices (look for Gear VR Controller…).
  3. Start the driver:
source .venv/bin/activate   # if using a venv
python -m gearmouse

Optional config path:

python -m gearmouse --config /path/to/config.yaml
  1. Hold the controller still until calibration finishes (tray shows “Hold still…” / “Calibrating…”, then “Active”).
  2. Point to move the cursor. Quit from the tray menu or with Ctrl+C.

If discovery still fails, set device_address in config.yaml to the MAC from bluetoothctl devices.

This is a foreground app (tray + Bluetooth need your user session). To start it at login, see Autostart below.

Autostart

Copy the included desktop entry into your autostart folder (it launches run-gearmouse.sh, which always loads this project’s config.yaml):

mkdir -p ~/.config/autostart
cp /home/ateapot/Desktop/gearmouse/gearmouse.desktop ~/.config/autostart/
chmod +x ~/.config/autostart/gearmouse.desktop /home/ateapot/Desktop/gearmouse/run-gearmouse.sh

On KDE: System Settings → Autostart → Add → Login Script… and choose run-gearmouse.sh (prefer this over “Application” if you pick the .desktop file itself — that mis-wires Exec).

Optional: a user systemd unit (still after login) if you prefer journals over a desktop entry:

mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/gearmouse.service <<'EOF'
[Unit]
Description=GearMouse (Gear VR air mouse)
After=graphical-session.target bluetooth.target
PartOf=graphical-session.target

[Service]
Type=simple
WorkingDirectory=/home/ateapot/Desktop/gearmouse
ExecStart=/home/ateapot/Desktop/gearmouse/.venv/bin/python -m gearmouse --config /home/ateapot/Desktop/gearmouse/config.yaml
Restart=on-failure
RestartSec=3

[Install]
WantedBy=graphical-session.target
EOF
systemctl --user daemon-reload
systemctl --user enable --now gearmouse.service

Do not run it as a system (root) service — /dev/uinput and BlueZ should stay under your logged-in user.

Tray icon

With tray: true (default), a status icon appears in the system tray:

Color / title Meaning
Grey — Scanning Looking for the controller
Amber — Hold still… / Calibrating… Waiting for stillness or sampling gyro bias
Green — Active Mouse mapping running

Right-click → Quit stops the driver cleanly. Set tray: false in config.yaml to disable (or if pystray / Pillow are missing).

Configuration

Edit config.yaml:

Key Role
gyro_x_sens / gyro_y_sens Cursor speed
scan_timeout_sec BLE advertisement scan window
connect_timeout_sec BlueZ connect + GATT timeout (raise if connect is flaky)
warmup_timeout_sec Reconnect if warming up never finishes
packet_silence_sec No sensor notifies → re-init sensors, then reconnect
gyro_scale Extra gyro multiplier
gyro_deadzone Ignore small gyro values
smoothing_alpha EMA on gyro rates (1.0 = off, lower = smoother)
response_expo Response curve (1.0 = linear; >1 shrinks small moves, grows large)
response_expo_scale Magnitude used to normalize deltas before the expo curve
drift_correction Ongoing bias tracking while still
scroll_sens / scroll_deadzone Touchpad scroll
trigger_activation_ms How long trigger must be held before left-click (digital button)
trigger_click_lock_ms Suppress gyro briefly after click so presses don’t drag
auto_recalibrate Re-sample gyro bias when the controller rests still
auto_recalibrate_after_ms Still duration before auto-recalib
auto_recalibrate_cooldown_ms Minimum gap between auto-recalibrations
bindings Remap trigger / back / home targets

Initial connect calibration always runs. Set auto_recalibrate: false if you do not want idle auto-recalib.

Controls

Controller Action
Gyro Mouse move
Trigger Left button (after trigger_activation_ms)
Back Right button
Touchpad slide Horizontal / vertical scroll
Touchpad press Recenter cursor (screen center)
Volume + / − Higher / lower gyro sensitivity; 0 = gyro off (if vol_up / vol_down unbound)
Home Super (Windows) key

Set bindings.vol_up / bindings.vol_down to a key or mouse button to override the sensitivity nudge.

Notes

  • Pair the controller once with your desktop Bluetooth UI (or bluetoothctl).
  • The driver rescans automatically if the controller disconnects or powers off.

About

Gear VR bluez/uinput driver made with AI

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages