Skip to content

Comments

Issue 13: Minimal libpad (SIO2/PAD) stubs, input mapping and tests#69

Open
Whoneon wants to merge 3 commits intoran-j:mainfrom
Whoneon:issue-13-pad
Open

Issue 13: Minimal libpad (SIO2/PAD) stubs, input mapping and tests#69
Whoneon wants to merge 3 commits intoran-j:mainfrom
Whoneon:issue-13-pad

Conversation

@Whoneon
Copy link
Contributor

@Whoneon Whoneon commented Feb 20, 2026

Summary

This PR wants to add a minimal libpad layer to unblock basic controller input in the runtime. It focuses on functional stubs, simple input mapping and test coverage. Remaining part of issue #13

What’s included

  • Basic libpad stubs (scePadInit, scePadPortOpen, scePadGetState, etc.)
  • scePadRead implementation that maps:
    • gamepad input via raylib
    • keyboard fallback (arrow keys + WASD + basic buttons)
  • Deterministic override hooks for tests
  • New test suite PadInput added to ps2x_tests

What’s NOT included (out of scope)

  • Full SIO2 protocol emulation
  • DualShock pressure / actuators
  • DMA-level pad polling
  • Game-specific compatibility tuning

Tests

  • Local: ps2x_tests (52/52 passed). in details:
    • scePadRead uses override state: verifies that the override hook correctly fills button mask + analog axes.
    • scePadRead button bits are active-low: ensures that each button is cleared (0) when pressed.
    • scePadGetButtonMask returns all buttons: expects 0xFFFF.
    • basic pad init/port/state functions return expected values: checks return codes for init/open/state helpers.
    • pad info and mode helpers return consistent values: validates info/mode APIs return stable, reasonable values.
    • pad setters return success: ensures setters return success codes.
    • pad string helpers map state codes: verifies scePadStateIntToStr / scePadReqIntToStr output expected strings.
    • scePadGetFrameCount increments: checks increasing frame count.

Notes

The next step is a real SIO2 implementation and packet-level emulation, if more accurate behavior is needed

Add a minimal libpad implementation backed by raylib input
Provide override hooks for deterministic tests
Add pad input tests and link runtime into test target
void TODO_NAMED(const char *name, uint8_t *rdram, R5900Context *ctx, PS2Runtime *runtime);

// Test hook: override pad input for scePadRead.
void setPadOverrideState(uint16_t buttons, uint8_t lx, uint8_t ly, uint8_t rx, uint8_t ry);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move this to ps2_call_list.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants