Files
Nebula-Core/node_modules/@nebulaproject/core-input/README.md
T
andrew 987ff560f5 Add initial Nebula Core packages and docs
Import initial monorepo structure for Nebula Core: add packages (@nebula/core, core-glyphs, core-input, core-navigation, core-theme, core-ui, core-utils) with source, dist, tests and assets. Expand README with overview, quick start and API snippets, and add package-level documentation files. Add jsconfig.json for path mapping, package.json and lockfiles to bootstrap the repo. This commit sets up the project layout, docs, and local package links for further development.
2026-01-31 22:57:16 +13:00

1.1 KiB

@nebula/core-input

Action-based input abstraction for controller-first apps. Convert raw device events into app-level actions.

Why it exists

Controller-focused apps should reason in terms of actions (confirm, back, pause) rather than physical inputs. This package lets you plug in your own device adapters and map them to actions consistently.

Usage

import { createActionMapper } from "@nebula/core-input";

const mapper = createActionMapper({
  bindings: {
    confirm: [
      { source: "gamepad", control: "a" },
      { source: "keyboard", control: "Enter" }
    ],
    back: [
      { source: "gamepad", control: "b" },
      { source: "keyboard", control: "Escape" }
    ]
  }
});

mapper.onAction((update) => {
  if (update.action === "confirm" && update.active) {
    console.log("Confirm action");
  }
});

mapper.mapEvent({
  source: "gamepad",
  control: "a",
  type: "pressed",
  value: 1
});

SteamOS / Steam Deck notes

Pair this with a thin adapter that translates Steam Input or Gamepad API events into InputEvent objects. Keep bindings action-first so Deck, Xbox, and PlayStation controllers share the same behavior.