sdlGetKeyFromName function

int sdlGetKeyFromName(
  1. String? name
)

Get a key code from a human-readable name.

\param name the human-readable key name \returns key code, or SDLK_UNKNOWN if the name wasn't recognized; call SDL_GetError() for more information.

\since This function is available since SDL 2.0.0.

\sa SDL_GetKeyFromScancode \sa SDL_GetKeyName \sa SDL_GetScancodeFromName

extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name)

Implementation

int sdlGetKeyFromName(String? name) {
  final sdlGetKeyFromNameLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<Utf8> name),
      int Function(Pointer<Utf8> name)>('SDL_GetKeyFromName');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result = sdlGetKeyFromNameLookupFunction(namePointer);
  calloc.free(namePointer);
  return result;
}