glfwUpdateGamepadMappings function

int glfwUpdateGamepadMappings(
  1. String string
)

! @brief Adds the specified SDL_GameControllerDB gamepad mappings.

This function parses the specified ASCII encoded string and updates the internal list with any gamepad mappings it finds. This string may contain either a single gamepad mapping or many mappings separated by newlines. The parser supports the full format of the gamecontrollerdb.txt source file including empty lines and comments.

See @ref gamepad_mapping for a description of the format.

If there is already a gamepad mapping for a given GUID in the internal list, it will be replaced by the one passed to this function. If the library is terminated and re-initialized the internal list will revert to the built-in default.

@paramin string The string containing the gamepad mappings. @return GLFW_TRUE if successful, or GLFW_FALSE if an error(@ref error_handling) occurred.

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

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

@sa @ref gamepad @sa @ref glfwJoystickIsGamepad @sa @ref glfwGetGamepadName

@since Added in version 3.3.

@ingroup input

GLFWAPI int glfwUpdateGamepadMappings(const char* string)

Implementation

int glfwUpdateGamepadMappings(String string) {
  final glfwUpdateGamepadMappingsLookupFunction = libglfw.lookupFunction<
      Int32 Function(Pointer<Utf8> string),
      int Function(Pointer<Utf8> string)>('glfwUpdateGamepadMappings');
  final stringPointer = string.toNativeUtf8();
  final result = glfwUpdateGamepadMappingsLookupFunction(stringPointer);
  calloc.free(stringPointer);
  return result;
}