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. */
14 #include "window_type.h"
15 #include "string_type.h"
18 * All data for a single hotkey. The name (for saving/loading a configfile),
19 * a list of keycodes and a number to help identifying this hotkey.
22 Hotkey(uint16_t default_keycode
, const std::string
&name
, int num
);
23 Hotkey(const std::vector
<uint16_t> &default_keycodes
, const std::string
&name
, int num
);
25 void AddKeycode(uint16_t keycode
);
27 const std::string name
;
29 std::set
<uint16_t> keycodes
;
35 * List of hotkeys for a window.
38 typedef EventState (*GlobalHotkeyHandlerFunc
)(int hotkey
);
40 HotkeyList(const std::string
&ini_group
, const std::vector
<Hotkey
> &items
, GlobalHotkeyHandlerFunc global_hotkey_handler
= nullptr);
43 void Load(const IniFile
&ini
);
44 void Save(IniFile
&ini
) const;
46 int CheckMatch(uint16_t keycode
, bool global_only
= false) const;
48 GlobalHotkeyHandlerFunc global_hotkey_handler
;
50 const std::string ini_group
;
51 std::vector
<Hotkey
> items
;
54 * Dummy private copy constructor to prevent compilers from
55 * copying the structure, which fails due to _hotkey_lists.
57 HotkeyList(const HotkeyList
&other
);
60 bool IsQuitKey(uint16_t keycode
);
62 void LoadHotkeysFromConfig();
63 void SaveHotkeysToConfig();
66 void HandleGlobalHotkeys(char32_t key
, uint16_t keycode
);
68 #endif /* HOTKEYS_H */