Skip to content
Back to skills

Input Systems

ASecurity

Use when the user asks about a game input system, action mapping, key rebinding, gamepad input, touch gestures, IME text input, haptics or input latency. Produces device-agnostic input architecture tied to the simulation tick. Not for menu accessibility audits (use design-accessibility) or Unity-specific setup (use unity).

  • 46 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 27, 2026
ai-agentsangularexpress

Works with

  • cursor
  • cli

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned November 27, 2026

npx -y skills add j4flmao/agent-skills --skill input-systems --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Input Systems?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Input Systems
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/j4flmao-input-systems/badge)](https://www.skillsdirectory.com/skills/j4flmao-input-systems)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: input-systems
description: >
  Use when the user asks about a game input system, action mapping, key
  rebinding, gamepad input, touch gestures, IME text input, haptics or input
  latency. Produces device-agnostic input architecture tied to the simulation
  tick. Not for menu accessibility audits (use design-accessibility) or
  Unity-specific setup (use unity).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
last_verified: "2026-11-17"
tags: [game, input, action-mapping, haptics, client-engine]
---

# Input Systems — Deep Engineering Guide

## Purpose
Input is the player's handshake: it must be lag-free, remappable, device-agnostic and deterministic. This skill covers device abstraction, action mapping, raw sampling vs event flows, text/IME, touch/gestures, haptics and the input-to-simulation timing that separates "responsive" from "floaty".

## Agent Protocol

### Trigger
"input system", "action mapping", "key rebinding", "gamepad input", "touch gestures", "IME text input", "haptics", "input latency".

### Input Context
- Engine and platforms (PC, console, mobile)
- Device set (keyboard/mouse, gamepad, touch)
- Networked or local (determinism of input stream)

### Output Artifact
Input architecture and code for sampling, mapping and dispatch. No file unless requested.

### Response Format
```
Devices: {list}
Actions: {action -> bindings}
Timing: {sample point vs sim tick}
Code: {snippet}
Risks: {latency, lost events, rebinding conflicts}
```

## 1. The Three Layers

```
device world (keyboard/mouse/stick/controller/gamepad/touch)
  → InputProvider (concrete device driver)
  → InputSystem (maps physical → logical actions, accumulates)
  → Game (consumes actions; sim at fixed tick)
```

The **action abstraction** is what makes one input system serve every device + remap UIs.

## 2. Device Abstraction

```cpp
struct InputEvent { Device device; DeviceId id; float3 raw; ButtonState state; };
```

| Device | Raw data | Notes |
|--------|----------|-------|
| Keyboard | key codes | layout-aware (AZERTY!) |
| Mouse | dx/dy, buttons, wheel | raw vs OS-corrected |
| Gamepad | axis, buttons, triggers | analog, deadzone |
| Touch | touches[], gesture stream | multitouch |
| VR | controller linear/angular | motion |
| Pen/touchpad | extended | per-OS |

The abstraction must *retain the raw* for remap-sensitive consumers — never bake layout into the engine core (see `device-abstraction.md`).

## 3. Action Mapping (The Remap Surface)

```cpp
// logical: Jump (physical: Space | GamepadA)
// triggered by any binding that matches
struct Action { vector<Binding> bindings; Activation mode; };
```

- Actions express *intent* (`Move`, `Attack`, `Talk`) — the game reads actions only, never key codes.
- Bindings: `{key, gamepadButton, axis-min/max, deadzone, doubleTap, hold, drag}`.
- Conflicts: an action triggered by multiple bound devices — resolve by priority + first-arrival (never two).
- Remap UI edits the bindings; the engine logic never changes.

## 4. Sampling vs Events

| Style | Use | Tradeoff |
|-------|-----|----------|
| **Poll (sample)** every frame / fixed-tick | deterministic sims, netcode | 1 sample/frame |
| **Event (queued)** fired on change | UI, menus, gestures | lossless, ordering |
| **Accumulated (delta)** | mouse movement, scroll | sums raw deltas |

Gameplay = poll the *action state* at the fixed tick (deterministic). UI/menus = events. Mouse = accumulated delta between polls (the "eats the delta" contract).

### 4.1 The Fixed-Tick Braid

```cpp
// sim tick consumes the latest action state — never processes events mid-tick
frame: poll → build actionSamples[tick] → sim(tick) → render
```
Determinism requires: input snapshot per fixed tick, ordered, deduplicated (see `sampling-and-events.md`).

## 5. Text & IME (The Hidden Beast)

- Text input ≠ keydown: a keyboard produces *characters* (layout + modifiers), and CJK uses an **IME** composition window.
- Engine must route through the platform IME: `compositionStart/update/end` + the committed string.
- Differentiator: paste handling, dead-keys, numpad, and per-UI-context focus (chat field vs game).

Details in `text-and-ime.md` — a surprising chunk of "input bugs" live here.

## 6. Touch & Gestures

- Touch = absolute multitouch stream (down/move/up per touch id).
- **Gestures** are recognized *upstream* of game logic: tap, long-press, drag, pinch, double-tap, swipe — each with begin/update/end + a cancel case.
- Never synthesize mouse from touch frames (the mouse is a different device with a cursor concept).

## 7. Haptics & Feel

| Device | Haptics |
|--------|---------|
| Gamepad | rumble (left/right motor), pulse frequencies |
| PS5/VR | adaptive triggers, high-fidelity haptics |
| Mobile | vibration (primitive) |
| Desktop | — (rare) |

Haptic events are *timed impulses* ("hit feedback 20 ms, 60% L / 0% R"), remapped per-device, rate-limited (rumble spam ruins feel). See `haptics-and-tuning.md`.

## 8. Input-to-Sim Latency (The Feel Metric)

| Stage | Budget |
|-------|--------|
| device → provider | OS-level (~1–4 ms console, up to ~poll-rate) |
| provider → poll | < 1 ms |
| poll → sim tick | ≤ 1 tick (16.6 ms @60) |
| sim → render | ≤ 1 frame |
| **full click-to-photon** | measure it (high-speed camera, NVIDIA Reflex Latency Analyzer); at 60 fps many games land around 50–100 ms — every extra queued frame adds ~16.7 ms |

Threads/queue/timing decisions that add a tick of latency are *the* feel killers — measure, don't assume.

## 9. The Input → Simulation Contract (For Netcode)

Serialized online: the polling *must* be fixed-tick snapshot per tick (see `authoritative-server` input authority) with a deterministic order per tick, and redundant presses coalesced. Client prediction replays it identically.

## 10. References

- `references/device-abstraction.md` — drivers, raw data, layout-awareness, device unplug/replug
- `references/action-mapping.md` — bindings, deadzones, modifiers, remap UI, priority/conflicts
- `references/sampling-and-events.md` — poll vs event, accumulated deltas, fixed-tick braid, determinism
- `references/text-and-ime.md` — text input, IME composition, layout, focus routing
- `references/touch-and-gestures.md` — multitouch, gesture recognizers, cancel semantics, areas
- `references/haptics-and-tuning.md` — rumble/haptics model, rate limits, feel calibration

Files in this skill

  • SKILL.md6.3 KB
  • references/action-mapping.md2.7 KB
  • references/device-abstraction.md3.2 KB
  • references/haptics-and-tuning.md3.1 KB
  • references/sampling-and-events.md2.7 KB
  • references/text-and-ime.md3.5 KB
  • references/touch-and-gestures.md3.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.