Hi all,
I am using SDL in a game engine, and now I need to map SDK key codes (SDLK_ESCAPE, etc.) to a string. This is so I can get the user to configure their input keys for a game and see the currently selected input keys as a string.
Any ideas?
I have tried the code below (from in a DLL):
Code:
function Window_KeyCodeToStr(KeyCode: Cardinal): PWideChar;
var
KeyName: String;
s : String;
begin
Result := '';
if KeyCode > cMaxKeyCode then Exit;
KeyName := SDL_GetKeyName(KeyCode);
s := 'KEY_'+UpperCase(KeyName);
Result := PWideChar(s);
end;
but it puts garbage characters in KeyName for keys like Escape, CTRL, and other non-printable ascii codes. It works just fine for keys like SDLK_1, letters, and other similar ones.
I have enabled Unicode support by using:
Code:
SDL_EnableUNICODE(1);
but that hasn't helped...
cheers,
Paul
Bookmarks