glfwGetJoystickGUID function

String glfwGetJoystickGUID(
  1. int jid
)

! @brief Returns the SDL compatible GUID of the specified joystick.

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

The GUID is what connects a joystick to a gamepad mapping. A connected joystick will always have a GUID even if there is no gamepad mapping assigned to it.

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.

The GUID uses the format introduced in SDL 2.0.5. This GUID tries to uniquely identify the make and model of a joystick but does not identify a specific unit, e.g. all wired Xbox 360 controllers will have the same GUID on that platform. The GUID for a unit may vary between platforms depending on what hardware information the platform specific APIs provide.

@paramin jid The joystick(@ref joysticks) to query. @return The UTF-8 encoded GUID 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 gamepad

@since Added in version 3.3.

@ingroup input

GLFWAPI const char* glfwGetJoystickGUID(int jid)

Implementation

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