Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

analog-wasd

Move a player with WASD — but instead of the usual 8 directions, the movement vector is the vector sum of analog key depths read over WebHID from an analog keyboard (Wooting, Razer, …).

Analog vs digital WASD movement demo

Two players run side by side from the same input and the same formula:

input representation result
Analog player (solid) raw depths 0..1 360° direction, variable speed
Digital ghost (dashed) depth >= actuation ? 1 : 0 snaps to 8 directions, always full speed

The only difference between the two trails is the input representation — that divergence is the whole demo.

How it works

Every HID report delivers the four depths $d_W, d_A, d_S, d_D \in [0,1]$:

$$\vec{v} = (d_D - d_A,\ d_S - d_W)$$

$$\text{speed} = \mathrm{clamp}(\lVert\vec{v}\rVert,\ 0,\ 1)^{\gamma} \quad (0 \text{ inside the deadzone})$$

$$\text{velocity} = \frac{\vec{v}}{\lVert\vec{v}\rVert}\cdot\text{speed}\cdot v_{\max}$$

Feed the same formula binary 0/1 depths and it degenerates to 8-way movement by itself — no separate ghost logic needed.

Actuation point, deadzone, gamma, and max speed are adjustable live with sliders.

Running

WebHID needs a secure context, so serve locally:

python3 -m http.server 8000   # http://localhost:8000

Open the page in a Chromium-based browser, click Connect, and pick your analog keyboard. Without one, keys fall back to digital 0/1 — both players then move identically, which is itself the point.

If your device doesn't show up in the picker, open hid-debug.html to inspect what usagePage it exposes (see TROUBLESHOOTING.md for the known Wooting V1→V2 interface change).

Credits

  • Analog input via AnalogSense/JavaScript-SDK (vendored as AnalogSense.js, unmodified).
  • Extracted from the live-visualization part of my keystroke-demo project.

License

MIT

About

360° WASD movement from analog key depths (WebHID) — vector-sum steering with a digital 8-way ghost for comparison

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages