close engine shortcut, from the discussion in
issue #317
--- a/hedgewars/uInputHandler.pas Mon Oct 29 00:36:40 2012 +0100
+++ b/hedgewars/uInputHandler.pas Mon Oct 29 04:26:44 2012 +0100
@@ -57,7 +57,7 @@
RCTRL = $4000;
var tkbd: array[0..cKbdMaxIndex] of boolean;
- quitKeyCode: Byte;
+ quitKeyCode, closeKeyCode: Byte;
KeyNames: array [0..cKeyMaxIndex] of string[15];
CurrentBinds: TBinds;
@@ -134,7 +134,23 @@
{$ELSE}
if tkbd[KeyNameToCode('left_ctrl')] or tkbd[KeyNameToCode('right_ctrl')] then
{$ENDIF}
- ParseCommand('halt', true);
+ ParseCommand('halt', true);
+ end;
+
+// ctrl/cmd + w to close engine
+if(KeyDown and (code = closeKeyCode)) then
+ begin
+{$IFDEF DARWIN}
+ // on OS X it this is expected behaviour
+ if tkbd[KeyNameToCode('left_meta')] or tkbd[KeyNameToCode('right_meta')] then
+{$ELSE}
+ // on other systems use this shortcut only if the keys are not bound to any command
+ if tkbd[KeyNameToCode('left_ctrl')] or tkbd[KeyNameToCode('right_ctrl')] then
+ if ((CurrentBinds([KeyNameToCode('left_ctrl')]:= '') or
+ CurrentBinds([KeyNameToCode('right_ctrl')]:= '')) and
+ CurrentBinds([closeKeyCode]:= '') then
+{$ENDIF}
+ ParseCommand('forcequit', true);
end;
if CurrentBinds[code][0] <> #0 then
@@ -216,6 +232,7 @@
end;
quitKeyCode:= KeyNameToCode(_S'q');
+closeKeyCode:= KeyNameToCode(_S'w');
// get the size of keyboard array
SDL_GetKeyState(@k);