2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
8 /** @file hotkeys.h %Hotkey related functions. */
13 #include "core/smallvec_type.hpp"
15 #include "window_type.h"
16 #include "string_type.h"
19 * All data for a single hotkey. The name (for saving/loading a configfile),
20 * a list of keycodes and a number to help identifying this hotkey.
23 Hotkey(uint16 default_keycode
, const char *name
, int num
);
24 Hotkey(const uint16
*default_keycodes
, const char *name
, int num
);
26 void AddKeycode(uint16 keycode
);
30 std::vector
<uint16
> keycodes
;
33 #define HOTKEY_LIST_END Hotkey((uint16)0, nullptr, -1)
38 * List of hotkeys for a window.
41 typedef EventState (*GlobalHotkeyHandlerFunc
)(int hotkey
);
43 HotkeyList(const char *ini_group
, Hotkey
*items
, GlobalHotkeyHandlerFunc global_hotkey_handler
= nullptr);
46 void Load(IniFile
*ini
);
47 void Save(IniFile
*ini
) const;
49 int CheckMatch(uint16 keycode
, bool global_only
= false) const;
51 GlobalHotkeyHandlerFunc global_hotkey_handler
;
53 const char *ini_group
;
57 * Dummy private copy constructor to prevent compilers from
58 * copying the structure, which fails due to _hotkey_lists.
60 HotkeyList(const HotkeyList
&other
);
63 bool IsQuitKey(uint16 keycode
);
65 void LoadHotkeysFromConfig();
66 void SaveHotkeysToConfig();
69 void HandleGlobalHotkeys(WChar key
, uint16 keycode
);
71 #endif /* HOTKEYS_H */