glfwGetJoystickButtons function

Pointer<Uint8> glfwGetJoystickButtons(
  1. int jid,
  2. Pointer<Int32> count
)

! @brief Returns the state of all buttons of the specified joystick.

This function returns the state of all buttons of the specified joystick. Each element in the array is either GLFW_PRESS or GLFW_RELEASE.

For backward compatibility with earlier versions that did not have @ref glfwGetJoystickHats, the button array also includes all hats, each represented as four buttons. The hats are in the same order as returned by glfwGetJoystickHats and are in the order up, right, down and left. To disable these extra buttons, set the @ref GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.

If the specified joystick is not present this function will return NULL but will not generate an error. This can be used instead of first calling @ref glfwJoystickPresent.

@paramin jid The joystick(@ref joysticks) to query. @paramout count Where to store the number of button states in the returned array. This is set to zero if the joystick is not present or an error occurred. @return An array of button states, or NULL if the joystick is not present or an error(@ref error_handling) occurred.

@errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.

@pointer_lifetime The returned array is allocated and freed by GLFW. You should not free it yourself. It is valid until the specified joystick is disconnected or the library is terminated.

@thread_safety This function must only be called from the main thread.

@sa @ref joystick_button

@since Added in version 2.2. @glfw3 Changed to return a dynamic array.

@ingroup input

GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)

Implementation

Pointer<Uint8> glfwGetJoystickButtons(int jid, Pointer<Int32> count) {
  final glfwGetJoystickButtonsLookupFunction = libglfw.lookupFunction<
      Pointer<Uint8> Function(Int32 jid, Pointer<Int32> count),
      Pointer<Uint8> Function(
          int jid, Pointer<Int32> count)>('glfwGetJoystickButtons');
  return glfwGetJoystickButtonsLookupFunction(jid, count);
}