sdlGameControllerGetStringForButton function

String? sdlGameControllerGetStringForButton(
  1. int button
)

Convert from an SDL_GameControllerButton enum to a string.

The caller should not SDL_free() the returned string.

\param button an enum value for a given SDL_GameControllerButton \returns a string for the given button, or NULL if an invalid button is specified. The string returned is of the format used by SDL_GameController mapping strings.

\since This function is available since SDL 2.0.0.

\sa SDL_GameControllerGetButtonFromString

extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button)

Implementation

String? sdlGameControllerGetStringForButton(int button) {
  final sdlGameControllerGetStringForButtonLookupFunction =
      libSdl2.lookupFunction<
          Pointer<Utf8> Function(Int32 button),
          Pointer<Utf8> Function(
              int button)>('SDL_GameControllerGetStringForButton');
  final result = sdlGameControllerGetStringForButtonLookupFunction(button);
  if (result == nullptr) {
    return null;
  }
  return result.toDartString();
}