glfwGetJoystickName function

String glfwGetJoystickName(
  1. int jid
)

! @brief Returns the name of the specified joystick.

This function returns the name, encoded as UTF-8, of the specified joystick. The returned string is allocated and freed by GLFW. You should not free it yourself.

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. @return The UTF-8 encoded name of the joystick, 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 string 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_name

@since Added in version 3.0.

@ingroup input

GLFWAPI const char* glfwGetJoystickName(int jid)

Implementation

String glfwGetJoystickName(int jid) {
  final glfwGetJoystickNameLookupFunction = libglfw.lookupFunction<
      Pointer<Utf8> Function(Int32 jid),
      Pointer<Utf8> Function(int jid)>('glfwGetJoystickName');
  return glfwGetJoystickNameLookupFunction(jid).toDartString();
}