# HG changeset patch # User Wuzzy # Date 1595261628 -7200 # Node ID 684838d5fb08e4821ad03205b383e1757aa540fb # Parent 26247a74d823f3a9d8ff569b3afdc742eee5ded8 KeyBindToName: Return HW's internal key name if SDL yields no name diff -r 26247a74d823 -r 684838d5fb08 hedgewars/uInputHandler.pas --- a/hedgewars/uInputHandler.pas Sun Jul 19 23:28:45 2020 +0200 +++ b/hedgewars/uInputHandler.pas Mon Jul 20 18:13:48 2020 +0200 @@ -121,8 +121,6 @@ // Takes a control name (e.g. 'quit') and returns the corresponding // human-readable key name from SDL. -// FIXME: Does not work 100% for all keys yet, but at least it no -// longer hardcodes any key name. // TODO: Localize function KeyBindToName(bind: shortstring): shortstring; var code: LongInt; @@ -141,8 +139,14 @@ KeyBindToName:= name else begin - WriteLnToConsole('Error: KeyBindToName('+bind+') failed to find SDL key name!'); - KeyBindToName:= trmsg[sidUnknownKey]; + if KeyNames[code] <> '' then + // Return Hedgewars internal key name if SDL key name is empty + KeyBindToName:= KeyNames[code] + else + begin + WriteLnToConsole('Error: KeyBindToName('+bind+'): Hedgewars does not have internal key name for given bind!'); + KeyBindToName:= trmsg[sidUnknownKey]; + end; end; end; end;