Skip to content

Conversation

@meeq
Copy link
Contributor

@meeq meeq commented Dec 16, 2025

Introduces convenience functions to assist with dynamic button mapping.

  • Adds joypad_button_t enum to joypad.h: Button constants mapped to bit positions 0-15
  • Adds accessor functions for getting individual buttons using joypad_button_t:
    • joypad_get_button(port, button): current state
    • joypad_get_button_pressed(port, button): just pressed this frame
    • joypad_get_button_released(port, button): just released this frame
    • joypad_get_button_held(port, button): held across frames
  • Adds joypad_get_axis function for dynamic analog mapping

Example usage:

struct InputMap {
  joypad_button_t jump;
  joypad_button_t attack;
}

struct InputMap inputMap = {
  .jump = JOYPAD_BUTTON_A,
  .attack = JOYPAD_BUTTON_B
};

bool jumping = joypad_get_button_pressed(port, inputMap.jump);
bool attacking = joypad_get_button_pressed(port, inputMap.attack);

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.

1 participant