#5983·raylib

[rcore] Raw joystick buttons check

Author: KabcorpCreated Jul 16, 2026Updated Jul 17, 2026
  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

At the moment, joystick support depends on the gamepad mapping system, meaning generic HID joysticks require custom mappings to work correctly.

Exposing direct joystick input through APIs such as: int IsJoystickButtonDown(int joystickId, int button); int IsJoystickAxisDown(int joystickId, int axis, float threshold);

would enable native support for generic HID 1:1 mapped joysticks without requiring gamepad remappings. This would benefit a wide range of devices, especially older or niche controllers commonly used for retro gaming and emulation, while giving developers more direct and flexible access to joystick inputs.

Code Example

It's really simple to implement on GLFW

c
int IsJoystickButtonDown(int joystickId, int button)
{
    if (joystickId < 0 || joystickId >= MAX_GAMEPADS)
        return 0;

    if (button < 0 || button >= MAX_GAMEPAD_BUTTONS)
        return 0;

    if (!glfwJoystickPresent(joystickId))
        return 0;

    int buttonCount = 0;
    const unsigned char* buttons = glfwGetJoystickButtons(joystickId, &buttonCount);

    if (!buttons || button >= buttonCount)
        return 0;

    return buttons[button] == 1;
}

int IsJoystickAxisDown(int joystickId, int axis, float threshold)
{
    if (joystickId < 0 || joystickId >= MAX_GAMEPADS)
        return 0;

    if (axis < 0 || axis >= MAX_GAMEPAD_AXES)
        return 0;

    if (!glfwJoystickPresent(joystickId))
        return 0;

    int axisCount = 0;
    const float* axes = glfwGetJoystickAxes(joystickId, &axisCount);

    if (!axes || axis >= axisCount)
        return 0;

    if (threshold >= 0.0f)
        return axes[axis] >= threshold;
    else
        return axes[axis] <= threshold;
}

Thank you!