/dm-game:touch-controlsfrom dm-game
Touch controls for browser action games on phones and tablets: switching to touch on the first touch rather than by sniffing the device; pointer events with one pointerId per control, released on every way a touch can end; the CSS that stops scroll, zoom, callouts and pull-to-refresh; floating versus fixed virtual sticks, dead zones without a jump; the 'third input' problem of firing on a phone (stick threshold, hold button, auto-fire, tap-on-target) and what each costs; button size, spacing and thumb reach; rotate cards, missing fullscreen and missing vibration on iPhone; and what emulated touch can and cannot verify. Use when adding touch play to a game, reviewing a mobile build, or when players say 'it scrolls instead of moving', 'my thumb slid off the stick', 'the stick stays stuck after a call', 'I can't aim and shoot at once', 'the buttons are too small', 'it zoomed in when I tapped twice' or 'it doesn't fill the screen on my iPhone'. Keyboard and pad input are input-bindings'.
Ships in dm-game. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Purpose: A thumb on glass gets the same game a pad gets: it can move and aim at once, it can't drift or stick, and nothing on the page scrolls, zooms or pops up a menu under it. Touch is a third device for input-bindings' actions, not a second game.
Sources:
Corpus (survey of the Gorewood games, 2026-10-12). Four have real touch play:
src/view/touch.ts: floating twin sticks on pointer events, a
stick-threshold fire, DOM buttons, a rotate card, safe-area insets, and
scripts/touch-check.mjs (CDP multi-touch emulation at four phone and tablet
sizes). Its real-phone feel test is still open.touch-adapter.ts: fixed canvas-drawn sticks and hold buttons on
legacy touch events, with 31 tests including "releases touches on cancel (like
incoming phone call)".setPointerCapture, a "HOLD TO FIRE" aim stick
that fires past 0.18 deflection, and separate phone and tablet layouts.Only one unreleased corpus game vibrates. Numbers marked corpus value are posture A for the game that ships them and posture B for yours (Numbers Policy).
Feral Interactive, "Dev Dive": Lara Croft and the Guardian of Light, mobile (feralinteractive.com, read 2026-10-12): the three-stage fire stick and the three schemes they rejected. It gives no numeric thresholds.
Game Accessibility Guidelines (Basic): interactive elements and virtual controls large and well spaced, especially on small or touch screens. It cites ~0.96 cm as the phone minimum (2.4 cm ideal but impractical), to be treated as a floor. Intermediate: keep accuracy-dependent controls in fixed positions.
WCAG 2.2 SC 2.5.8 Target Size (Minimum), AA: 24×24 CSS px, or 24 px spacing. That is a floor for web UI, far below a game control.
iPhone platform gaps, from WebKit bug reports, developer forums and MDN's
compatibility notes (2026), and confirmed by Hard Deck's notes: no element
Fullscreen API on iPhone (iPad has it, prefixed); navigator.vibrate exists on
iOS but does nothing; the web-manifest orientation is ignored.
Typed sketch: references/touch.ts. It covers the dead-zone mapping, the floating
twin stick with per-pointer ownership, and release on cancel, blur and hide.
| Failure | Root cause | Rule |
|---|---|---|
| Swiping the stick scrolls or zooms the page | No touch-action: none on the play surface | 3 |
| A tap also fires the mouse cannon or requests pointer lock | Compatibility mouse events after the touch | 2 |
| A stick stays held after a call or a notification | pointercancel and page-hide not handled | 2 |
| A touch laptop shows sticks over mouse play | Detecting the device instead of the input | 1 |
| The thumb slides off a fixed stick | Fixed base, no follow | 4 |
| The ship creeps with a resting thumb, or jumps out of the dead zone | No dead zone, or one that clips instead of rescaling | 4 |
| "I can't aim and shoot at once" | A separate fire button takes the aiming thumb | 5 |
| Buttons mis-hit | Too small, too close, or out of thumb reach | 6 |
| A portrait phone shows a letterboxed sliver | No rotate card; the manifest's orientation is ignored on iOS | 7 |
pointerdown with pointerType === 'touch' turns touch play on; a
pointermove with pointerType === 'mouse' or any pad input turns it off (Hard
Deck's padEndsTouch: otherwise the idle touch aim overwrites the pad's aim on a
tablet with a controller). This is input-bindings' last-device rule with a
third device.'ontouchstart' in window || navigator.maxTouchPoints > 0, so a touch-screen
laptop gets sticks while it's played with a mouse. (pointer: coarse) is fine for
layout (bigger menu targets), not for choosing the input.click()s
after tapping has left touch mode. Tap in the harness (Hard Deck's notes).pointerId per finger. redshifted's legacy touch events work too, but cost a
second code path.pointerId. A stick claims the first touch on its half
and ignores the rest until it is released, so a third finger can't steal it
(Hard Deck, the twin-stick prototype). Track moves and ups on window, not the element, so a
thumb that leaves the stick's area keeps driving it. Alternatively call
setPointerCapture (the twin-stick prototype, free-horses) and then also handle
lostpointercapture.pointerup, pointercancel, page hide and window blur. A call, a
notification or a system gesture cancels the touch, and a hidden page may never
see the up. redshifted tests the cancel. The sketch adds hide and blur (ADDED).
Match the pointerId on release: the twin-stick prototype's notes record a fix for releasing
the wrong stick.preventDefault() on the touch pointerdown over the play surface. This
suppresses the compatibility mousedown/mouseup, so a cannon on mousedown
doesn't also fire (Hard Deck). It does not suppress click: any click
handler that fires or requests pointer lock must check pointerType itself.
Hard Deck's pointer-lock click handler carries exactly that guard (pointer-lock
says the same).pointerType === 'touch'; pointer-lock owns the rest).| Property | On | Why |
|---|---|---|
touch-action: none | Canvas, play surface, every control | No scroll, pan or double-tap zoom under a thumb (Hard Deck, free-horses, the twin-stick prototype; redshifted instead calls preventDefault in non-passive touch listeners) |
user-select: none, -webkit-touch-callout: none | Play surface and controls | No text selection or iOS callout on a long press (Hard Deck) |
overscroll-behavior: none | html, body | No pull-to-refresh or rubber-band (the twin-stick prototype) |
viewport-fit=cover plus env(safe-area-inset-*) | Viewport meta; control positions | Use the full screen, keep controls out of the notch and home bar (Hard Deck). Both halves are needed: free-horses uses env() without viewport-fit=cover, so its insets read zero on iPhone |
touch-action: manipulation | Menu and tap-only UIs | Kills the double-tap-zoom delay but keeps pinch zoom (timberwolf, royal-inbox) |
user-scalable=no on the whole page (redshifted does).
touch-action: none on the play surface already stops zoom there, and menus and
text stay zoomable for players who need it. UNSOURCED as a corpus finding; it
follows from the accessibility goal of keeping text resizable.Emulation.setSafeAreaInsetsOverride, per Hard Deck's notes). A notch test needs
the override or a real phone.| Shape | How it works | Corpus | Use when |
|---|---|---|---|
| Floating | The base spawns where the thumb lands, on its half of the screen; it follows a thumb dragged past the rim | Hard Deck | Action games; thumbs never miss it, and it can't run out |
| Fixed | A drawn base at a set position; it activates within a radius | redshifted (activation 2× radius), the twin-stick prototype | The stick's position is part of the HUD, or the screen is crowded |
stickVector). A dead zone that just clips makes the ship lurch to 12%
speed the moment it moves.applyTouch). Wire the stick straight to the turret and it snaps.A phone has two thumbs and a twin-stick game wants three inputs: move, aim, fire. Every scheme gives something up:
| Scheme | Corpus or precedent | Cost |
|---|---|---|
| Aim stick fires past a threshold (below it, aim only) | Hard Deck (FIRE_AT 0.5); the twin-stick prototype (0.18); Feral's shipped "three-stage" stick: faint at rest, a slight push aims, further fires, with a haptic pulse at the switch | Players must find the threshold; the cue that marks it must be felt or seen |
| Separate hold-to-fire button | redshifted, free-horses | Feral rejected it: players had to stop aiming to shoot |
| Auto-fire while aiming at a target in range | Feral tried it; Hard Deck has proposed it as the touch default, awaiting the operator's decision | Where ammo is finite, Feral's testers kept running out. Hard Deck's cannon is unlimited, so that cost doesn't apply there. It removes the decision to shoot |
| Tap-and-hold on an enemy | Feral tried it | Comfortable, ammo-safe, but lost the twin-stick feel |
pointerdown (game-feel's act-on-press), with
preventDefault. DOM menu buttons keep the native click.orientation,
and no corpus game calls screen.orientation.lock. Hard Deck shows a card when
(orientation: portrait) and (max-width: 600px) and (pointer: coarse) matches. It
pauses the run, carries a Quit button for players with a rotation lock, and is
skipped with a URL flag. Through game-shell, it's one more auto-pause source.webkit prefix as a fallback. iPhone Safari has no element fullscreen, so
hide the button there rather than offering one that fails. "Add to Home Screen"
with display: standalone is the iPhone's way to lose the browser chrome.pointerdown, once (Hard Deck). Safari resumes an
audio context only inside a gesture. game-shell owns the unlock.navigator.vibrate silently does
nothing on iOS. Gate it behind a setting and feature detection (the corpus game that vibrates:
haptics && 'vibrate' in navigator, on by default), and always pair it with a
visual or audio cue.pointercancel, which rule 2 handles. That's unverified;
check on a real iPad.Each line names what the check cannot see.
EventTarget and plain events
suffice): left and right thumbs claim their sticks; a third finger is
ignored; cancel releases only its own stick; hide and blur release all; a
mouse move and endTouch() leave touch mode; a mouse pointerdown spawns
nothing; after destroy() no event moves a stick. Mutation-check each.
Blind to: real event order on devices.click-bound action and
requests no pointer lock.touch-check.mjs: 844×390, 390×844, 1180×820, 820×1180). Hard
Deck states its own blind spots: emulated touch on a desktop GPU, not a phone;
no thumb ergonomics or feel; one seed. Set safe-area insets explicitly.Three tight links. Everything else routes through the map, so adding a skill
touches one file rather than twenty: references/routing-map.md (in
game-design).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub rbergman/dark-matter-marketplace --plugin dm-game40 skills in this plugin
/accessibility-designUse when designing any player-facing feature, evaluating a game for accessibility, responding to accessibility feedback, designing difficulty or assist options, adding subtitle/caption systems, implementing input remapping, or when a player reports they can't play. Covers the four accessibility pillars (visual, auditory, motor, cognitive), implementation tiers, colorblind design, subtitle standards, input accessibility, and testing methodology. Accessibility is a design discipline, not a post-launch checklist./async-and-socialSocial and competitive design that does not require players to be online together: ghost/replay data, leaderboards, asynchronous PvP, offline vulnerability, and anti-snowball mechanics. Use when adding leaderboards or high-score tables, designing ghost races or replay challenges, letting players attack or compete against absent opponents, deciding what social signal a single-player game should carry, or when matches and runs feel decided in the first minutes. Anti-snowball applies to single-player roguelikes and simulations too, not just PvP. For real-time multiplayer architecture, matchmaking, guilds, and moderation, this skill deliberately does not cover them — those are large specialities and belong in dedicated references.