sdlxGetGamepadMapping function gamepad

String? sdlxGetGamepadMapping(
  1. Pointer<SdlGamepad> gamepad
)

Get the current mapping of a gamepad.

Details about mappings are discussed with SDL_AddGamepadMapping().

\param gamepad the gamepad you want to get the current mapping for. \returns a string that has the gamepad's mapping or NULL if no mapping is available; call SDL_GetError() for more information. This should be freed with SDL_free() when it is no longer needed.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.2.0.

\sa SDL_AddGamepadMapping \sa SDL_GetGamepadMappingForID \sa SDL_GetGamepadMappingForGUID \sa SDL_SetGamepadMapping

extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad)

Implementation

String? sdlxGetGamepadMapping(Pointer<SdlGamepad> gamepad) {
  String? result;
  final stringPointer = sdlGetGamepadMapping(gamepad);
  if (stringPointer != nullptr) {
    result = stringPointer.cast<Utf8>().toDartString();
    sdlFree(stringPointer.cast<Void>());
  }
  return result;
}