1 /* $Id: hotkeys.h 25669 2013-08-05 20:36:28Z michi_cc $ */
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file hotkeys.h %Hotkey related functions. */
15 #include "core/smallvec_type.hpp"
17 #include "window_type.h"
18 #include "string_type.h"
21 * All data for a single hotkey. The name (for saving/loading a configfile),
22 * a list of keycodes and a number to help identifying this hotkey.
25 Hotkey(uint16 default_keycode
, const char *name
, int num
);
26 Hotkey(const uint16
*default_keycodes
, const char *name
, int num
);
28 void AddKeycode(uint16 keycode
);
32 SmallVector
<uint16
, 1> keycodes
;
35 #define HOTKEY_LIST_END Hotkey((uint16)0, NULL, -1)
40 * List of hotkeys for a window.
43 typedef EventState (*GlobalHotkeyHandlerFunc
)(int hotkey
);
45 HotkeyList(const char *ini_group
, Hotkey
*items
, GlobalHotkeyHandlerFunc global_hotkey_handler
= NULL
);
48 void Load(IniFile
*ini
);
49 void Save(IniFile
*ini
) const;
51 int CheckMatch(uint16 keycode
, bool global_only
= false) const;
53 GlobalHotkeyHandlerFunc global_hotkey_handler
;
55 const char *ini_group
;
59 * Dummy private copy constructor to prevent compilers from
60 * copying the structure, which fails due to _hotkey_lists.
62 HotkeyList(const HotkeyList
&other
);
65 bool IsQuitKey(uint16 keycode
);
67 void LoadHotkeysFromConfig();
68 void SaveHotkeysToConfig();
71 void HandleGlobalHotkeys(WChar key
, uint16 keycode
);
73 #endif /* HOTKEYS_H */