sdlGetKeyFromName function keyboard
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.
\threadsafety This function is not thread safe.
\since This function is available since SDL 3.2.0.
\sa SDL_GetKeyFromScancode \sa SDL_GetKeyName \sa SDL_GetScancodeFromName
extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name)
Implementation
int sdlGetKeyFromName(String? name) {
final sdlGetKeyFromNameLookupFunction = _libSdl
.lookupFunction<
Uint32 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;
}