Skip to content

feat(input): physical game-controller support (Xbox / gamepads / joysticks) #97

Description

@relmer

Summary

Apple II joystick/paddle input is currently synthesized from the keyboard (arrows → joystick) and mouse (paddle/mouse) via the split input model + device selector. Add support for physical game controllers — Xbox controllers, generic USB gamepads, and joysticks — mapped onto the Apple II analog stick.

Mapping target

The Apple II game port is 2 analog axes + 2 buttons:

  • Left stick X/Y → PDL0 / PDL1 (paddle timing at $C064/$C065, 0–255).
  • Two face buttons → PB0 / PB1 ($C061 / $C062), same targets Open/Solid-Apple already drive.

Reading the device

DirectInput is a fine fit for this use case: mapping to the Apple II stick only needs the left-stick axes + two face buttons, all of which DirectInput exposes for both Xbox-class and generic controllers. (The one well-known DirectInput gotcha — Xbox triggers collapsed onto a shared Z axis — doesn't matter here, since the Apple II game port has no triggers.) XInput is worth revisiting later only if we want proper Xbox extras (correct triggers, Guide button, rumble); not required for v1.

Scope

  • Enumerate controllers; hot-plug connect/disconnect detection.
  • Poll the selected device each frame; axes → paddle values, buttons → PB0/PB1.
  • Deadzone + axis→paddle scaling / centering calibration.
  • Surface it in the existing device selector (a physical controller becomes the "joystick" source, coexisting with / overriding arrows→joystick).
  • Persist the selection via the existing input-mapping prefs.

Notes

Fits the existing input model (Keys / Pointer split) — it's a new source feeding the existing paddle/button state, no new game-port hardware model needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions