sdlGetScancodeName function
Get a human-readable name for a scancode.
Warning: The returned name is by design not stable across platforms,
e.g. the name for SDL_SCANCODE_LGUI
is "Left GUI" under Linux but "Left
Windows" under Microsoft Windows, and some scancodes like
SDL_SCANCODE_NONUSBACKSLASH
don't have any name at all. There are even
scancodes that share names, e.g. SDL_SCANCODE_RETURN
and
SDL_SCANCODE_RETURN2
(both called "Return"). This function is therefore
unsuitable for creating a stable cross-platform two-way mapping between
strings and scancodes.
\param scancode the desired SDL_Scancode to query. \returns a pointer to the name for the scancode. If the scancode doesn't have a name this function returns an empty string ("").
\threadsafety This function is not thread safe.
\since This function is available since SDL 3.1.3.
\sa SDL_GetScancodeFromKey \sa SDL_GetScancodeFromName \sa SDL_SetScancodeName
extern SDL_DECLSPEC const char * SDLCALL SDL_GetScancodeName(SDL_Scancode scancode)
Implementation
String? sdlGetScancodeName(int scancode) {
final sdlGetScancodeNameLookupFunction = libSdl3.lookupFunction<
Pointer<Utf8> Function(Int32 scancode),
Pointer<Utf8> Function(int scancode)>('SDL_GetScancodeName');
final result = sdlGetScancodeNameLookupFunction(scancode);
if (result == nullptr) {
return null;
}
return result.toDartString();
}