glfwGetGamepadName function

String glfwGetGamepadName(
  1. int jid
)

! @brief Returns the human-readable gamepad name for the specified joystick.

This function returns the human-readable name of the gamepad from the gamepad mapping assigned to the specified joystick.

If the specified joystick is not present or does not have a gamepad mapping this function will return NULL but will not generate an error. Call @ref glfwJoystickPresent to check whether it is present regardless of whether it has a mapping.

@paramin jid The joystick(@ref joysticks) to query. @return The UTF-8 encoded name of the gamepad, or NULL if the joystick is not present, does not have a mapping or an error(@ref error_handling) occurred.

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

@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, the gamepad mappings are updated or the library is terminated.

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

@sa @ref gamepad @sa @ref glfwJoystickIsGamepad

@since Added in version 3.3.

@ingroup input

GLFWAPI const char* glfwGetGamepadName(int jid)

Implementation

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