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);
27 const std::string name;
29 std::set<uint16_t> keycodes;
38 typedef EventState (*GlobalHotkeyHandlerFunc)(
int hotkey);
40 HotkeyList(
const std::string &ini_group,
const std::vector<Hotkey> &items, GlobalHotkeyHandlerFunc global_hotkey_handler =
nullptr);
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;
65void HandleGlobalHotkeys(
char32_t key, uint16_t keycode);
99template<
class ItemType,
class ListType>
103 size_t step_back = list.size() - 1;
104 auto get_relative_index_step = [list, current_item](
size_t step) -> std::tuple<size_t, size_t> {
105 size_t index = std::distance(list.begin(), std::ranges::find(list, current_item));
106 return {(index + step) % list.size(), step};
110 default: NOT_REACHED();
115 return {list.size() - 1, step_back};
118 return get_relative_index_step(step_back);
121 return get_relative_index_step(1);
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Types related to the graphics and/or input devices.
static constexpr int SPECIAL_HOTKEY_BIT
Bit which denotes that hotkey isn't bound to UI button.
void LoadHotkeysFromConfig()
Load the hotkeys from the config file.
std::tuple< size_t, size_t > GetListIndexStep(SpecialListHotkeys hotkey, const ListType &list, const ItemType ¤t_item)
Gets the first index in the list for given hotkey and the step to look for another if first is invali...
bool IsQuitKey(uint16_t keycode)
Does the given keycode match one of the keycodes bound to 'quit game'?
void SaveHotkeysToConfig()
Save the hotkeys to the config file.
SpecialListHotkeys
Indexes for special hotkeys to navigate in lists.
@ NextItem
Hotkey to select next item in the list.
@ FirstItem
Hotkey to select first item in the list.
@ LastItem
Hotkey to select last item in the list.
@ PreviousItem
Hotkey to select previous item in the list.
bool IsSpecialHotkey(const int &hotkey)
Checks if hotkey index is special or not.
void Save(IniFile &ini) const
Save HotkeyList to IniFile.
HotkeyList(const HotkeyList &other)
Dummy private copy constructor to prevent compilers from copying the structure, which fails due to _h...
int CheckMatch(uint16_t keycode, bool global_only=false) const
Check if a keycode is bound to something.
void Load(const IniFile &ini)
Load HotkeyList from IniFile.
Hotkey(uint16_t default_keycode, const std::string &name, int num)
Create a new Hotkey object with a single default keycode.
void AddKeycode(uint16_t keycode)
Add a keycode to this hotkey, from now that keycode will be matched in addition to any previously add...
Ini file that supports both loading and saving.
Types related to windows.
EventState
State of handling an event.