tap-android-dpad
/tap-android-dpad
Build a D-Pad style controller on Android with a Tap — swipes for directions, short pinches to select, pinch-hold that locks into rotate (twist) or drag (move), fist-hold to hide. Use for D-Pad, menu navigation, drag and drop, or game controls. Needs the framed BLE protocol (current TapXR developer firmware; TapBand uses the same API). Requires tap-android-getting-started order: getDefault, registerTapListener, resume and pause.
- Author
- tapwithus ↗
- Repository
- tap-android-sdk ↗
- Licence
- Apache-2.0
- Last repository change
- 21.10.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 1
- HTML comments
- 0
- URLs in SKILL.md
- 2
No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
- 1 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: java/DpadStateMachine.java
What it does and when to use it
Build a D-Pad style controller on Android with a Tap — swipes for directions, short pinches to select, pinch-hold that locks into rotate (twist) or drag (move), fist-hold to hide. Use for D-Pad, menu navigation, drag and drop, or game controls. Needs the framed BLE protocol (current TapXR developer firmware; TapBand uses the same API). Requires tap-android-getting-started order: getDefault, registerTapListener, resume and pause.
Original author description
Build a D-Pad style controller on Android with a Tap — swipes for directions, short pinches to select, pinch-hold that locks into rotate (twist) or drag (move), fist-hold to hide. Use for D-Pad, menu navigation, drag and drop, or game controls. Needs the framed BLE protocol (current TapXR developer firmware; TapBand uses the same API). Requires tap-android-getting-started order: getDefault, registerTapListener, resume and pause.
How it works
- Interaction
- Use the template
- Tuning
- Ideas
SKILL.md preview
---
name: tap-android-dpad
description: >-
Build a D-Pad style controller on Android with a Tap — swipes for
directions, short pinches to select, pinch-hold that locks into rotate
(twist) or drag (move), fist-hold to hide. Use for D-Pad, menu navigation,
drag and drop, or game controls. Needs the framed BLE protocol (current
TapXR developer firmware; TapBand uses the same API). Requires
tap-android-getting-started order: getDefault, registerTapListener, resume
and pause.
---
# D-Pad (swipe, pinch, hold to rotate or drag)
Needs the framed protocol (`sdk.isV2Tap(id)`): air gestures and IMU motion. This is the same interaction as the D-Pad page in the TAP_EV sandbox (https://tapwithus.github.io/TAP_EV/).
TapBand uses the same BLE API as TapXR and is coming soon: https://www.tapwithus.com/tapband-waitlist/. Current TapXR developer firmware includes swipes, pinches with hold, and fist with hold.
The template consumes **raw** `UnifiedAirGesture` codes (the detections every Tap SDK sees). On Android you can also listen to processed `onXRAirGestureReceived` (`SWIPE_*`, `CLICK_*`, `DRAG_*`, `DROP`, `FIST_BEGIN` / `FIST_END`) for UI that does not need the 1 s rotate-vs-drag lock.
## Interaction
| User does | Codes | Event |
|-----------|-------|-------|
| Swipe left / right / up / down | 101–104 | `direction` + `left` / `right` / `up` / `down` |
| Short pinch thumb + index / middle / ring / pinky | 105–108 (AB–AE) | `pinch` index 0–3 (only when nothing is held) |
| Hold a pinch | 110–113 | `hold`, mode `pending` |
| …and twist 25° or more within 1 s | IMU roll | mode `rotate`, then `rotate` degrees |
| …and do not twist | — | after 1 s mode `drag`, then `drag` dx, dy |
| Relax the hand | 4 × 100 (`NONE`) | `release` |
| Hold a fist | 114 | `hide`; then 2 × `NONE` gives `show` |
Repeats of the same code within 40 ms are ignored. Gesture packets stream continuously.
## Use the template
Copy [java/DpadStateMachine.java](java/DpadStateMachine.java) (package `com.tapwithus.tapsdk.sample`). It has no Android or SDK imports.
- `onGesture(code, nowNanos)` feeds air-gesture codes.
- `onMotion(dx, dy, roll, nowNanos)` feeds IMU motion.
- `tick(nowNanos)` locks drag mode on time if motion packets stop. Call it from a frame loop if you want the 1 s timeout even when the hand is still.
- `held`, `mode`, `hidden` are the current state for drawing.
`nowNanos` is `System.nanoTime()`.
Required device setup after `onTapConnected` when `sdk.isV2Tap(id)`:
```java
sdk.startXRAirMouseState(id); // AIR_GESTURE + STREAM
sdk.setFeature(id, DeviceFeature.IMU_MOTION_DATA, true);
sdk.setFeature(id, DeviceFeature.MODEL_DETECTION, true);
```
Wiring:
```java
DpadStateMachine dpad = new DpadStateMachine();
void onAir(String id, AirMousePacket data) {
UnifiedAirGesture gesture = UnifiedAirGesture.fromCode(data.gesture.getInt());
if (gesture == null) return;
for (DpadStateMachine.Event event : dpad.onGesture(gesture.getCode(), System.nanoTime())) {
if ("hold".equals(event.kind) || "mode".equals(event.kind) || "pinch".equals(event.kind)) {
sdk.vibrate(id, new int[]{40});
}
apply(event);
}
}
void onMotion(ImuMotionPacket packet) {
for (DpadStateMachine.Event event : dpad.onMotion(packet.dx, packet.dy, packet.roll, System.nanoTime())) {
apply(event);
}
}
```
If `isV2Tap` is false, the connected device is on classic firmware. Offer tap combos (`tap-android-tapping`) instead of this recipe.
## Tuning
| Argument | Default | Effect |
|----------|---------|--------|
| `rotateLockDeg` | 25 | Roll travel needed to choose rotate. Raise it if drag is chosen too rarely. |
| `lockWindowNs` | 1 second | Time to decide between rotate and drag. |
| `releaseAfter` | 4 | `NONE` packets before release. |
| `showAfter` | 2 | `NONE` packets after a fist before showing again. |
| `debounceNs` | 40 ms | Ignore repeats of the same code in this window. |
- `drag` deltas are raw device units. Multiply by a gain and clamp to the screen.
- `rotate` degrees are relative to the start of the hold.
- If a drag should not stay after release, snap the item back on `release`.
## Ideas
- In-app grid: swipes move focus, pinch AB = OK, pinch AC = back, fist = close.
- Photo viewer: swipes = next / previous, hold + twist = rotate, hold + drag = pan.
See also `tap-android-knob` and `tap-android-vision-models`.
Files in this package (2)
- SKILL.md 4 KB
- java/DpadStateMachine.java 6 KB
Versions
The database has no other skills named tap-android-dpad.
Database snapshot: 13.11.2026 · package version bbbe55085ebc (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100tap-dpad
Build a D-Pad style controller with a Tap - swipes for directions, short pinches to select, pinch-hold that locks into rotate (twist) or drag (move) mode, fist-hold to hide. Use for D-Pad, menu navigation, select and move, drag and drop, rotate objects, or game controls with gestures. - 100tapkit-dpad
Build a D-Pad style controller on TapXR or TapBand. Swipes move, short clicks select, a pinch-hold locks into rotate or drag, and a fist hides. Use for menus, select and move, drag, rotate, or game controls. - 100tap-android-knob
Build a virtual knob on Android with a Tap — hold a pinch and twist the wrist to turn a value up or down (volume, brightness, zoom, scroll). Use for knob, dial, twist, rotate-to-adjust, or continuous value control. Needs the framed BLE protocol (current TapXR developer firmware;… - 95tap-android-vision-models
Switch a Tap vision model on Android between TAPPING and AIR_GESTURE, decode raw UnifiedAirGesture (swipes, pinches, holds, fist), and handle processed XRAirGesture (click, drag, drop, fist, swipe). Use for air gestures, pinch, swipe, fist, model switching, or classic… - 100tap-vision-models
Switch the TapXR / TapBand vision model between TAPPING and AIR_GESTURE, set the op mode, and decode UnifiedAirGestures (swipes, pinches, holds, fist). Use for air gestures, pinch, swipe, fist, model switching, or AirGestures on Tap Strap. - 95tapkit-air-gestures
Handle TAPXRAirGesture (processed click, drag, drop, fist, swipe) on TapXR and TapBand, document raw firmware class indexes, switch tapping vs air-gesture models, and handle Tap Strap TAPAirGesture. Use for air gestures, pinch, swipe, fist, TAPXRState, or raw detections.