GLFW操纵杆输入问题

GLFW joystick input issues

本文关键字:问题 输入 操纵杆 GLFW      更新时间:2023-10-16

我试图从GLFW的操纵杆(Thrustmaster Hotas x,如果它重要的话)获得输入,但使用glfwGetJoystickAxes和Buttons不像预期的那样工作。轴输出为00007FF77FC0D820,没有关于按钮状态的信息。我在这里做错了什么?

const float* Joystick::getAxesState()
{
    axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axesCount);
    return axes;
}
const unsigned char* Joystick::getButtonState()
{
    buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttonCount);
    return buttons;
}

glfwGetJoystickAxes(<joystick>,<count>)返回float[<count>]数组

glfwGetJoystickButtons(<joystick>,<count>)返回unsigned char[<count>]数组

尝试使用<axes_return>[index]<buttons_return>[index]访问它们。

也正如@Quentin提到的,你应该只调用这些函数一次,因为返回值是指向glfw内部存储状态的指针。