sdlSetScancodeName function

bool sdlSetScancodeName(
  1. int scancode,
  2. String? name
)

Set a human-readable name for a scancode.

\param scancode the desired SDL_Scancode. \param name the name to use for the scancode, encoded as UTF-8. The string is not copied, so the pointer given to this function must stay valid while SDL is being used. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function is not thread safe.

\since This function is available since SDL 3.1.3.

\sa SDL_GetScancodeName

extern SDL_DECLSPEC bool SDLCALL SDL_SetScancodeName(SDL_Scancode scancode, const char *name)

Implementation

bool sdlSetScancodeName(int scancode, String? name) {
  final sdlSetScancodeNameLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Int32 scancode, Pointer<Utf8> name),
      int Function(int scancode, Pointer<Utf8> name)>('SDL_SetScancodeName');
  final namePointer = name != null ? name.toNativeUtf8() : nullptr;
  final result = sdlSetScancodeNameLookupFunction(scancode, namePointer) == 1;
  calloc.free(namePointer);
  return result;
}