Skip to content

feat(input): GamepadEvent type + pollGamepadEvents/describeGamepads on InputInterface (Phase 0) #18

@apotema

Description

@apotema

Phase 0 of controller-support epic: labelle-toolkit/labelle-engine#609

Goal

Add the cross-backend gamepad event source to InputInterface (labelle-core/src/input.zig). No engine behavior change yet — this is the contract Phase 1 backends implement against.

Scope

  1. Define a GamepadEvent value type (copied data, no borrowed slices — it crosses a ring buffer):
    pub const GamepadEvent = struct {
        kind: enum { connected, disconnected },
        slot: u32,
        name: BoundedArray(u8, 63) = .{},      // empty if backend can't supply
        guid: ?[16]u8 = null,                   // stable reconnection key where available
        source_class: enum { gamepad, dpad_remote, unknown } = .unknown, // TV remote vs pad
        type_hint: enum { unknown, xbox, playstation, nintendo, generic } = .unknown,
    };
  2. Add optional decls, wrapped with @hasDecl(Impl, ...) like the existing gamepad methods:
    • pub fn pollGamepadEvents(out: []GamepadEvent) usize — drain pending hotplug events; returns count.
    • pub fn describeGamepads(out) usize (diagnostic) — enumerate currently-visible devices incl. an unavailable_reason (e.g. permission denied on Linux) for logging.
  3. Default behavior when a backend declares neither: return 0 (no events) — preserves today's "nothing happens" for null/sokol until Phase 1 wires platform sources.

Acceptance criteria

  • GamepadEvent + describeGamepads result type defined and documented.
  • InputInterface exposes pollGamepadEvents / describeGamepads with @hasDecl fallbacks returning 0.
  • Existing poll methods (isGamepadAvailable, etc.) untouched.
  • zspec coverage for the fallback (a backend with no decls yields 0 events).

Non-goals

  • No backend implementations (Phase 1). No engine wiring (#610).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions