MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CheckMatch

Method CheckMatch

src/hotkeys.cpp:301–311  ·  view source on GitHub ↗

* Check if a keycode is bound to something. * @param keycode The keycode that was pressed * @param global_only Limit the search to hotkeys defined as 'global'. * @return The number of the matching hotkey or -1. */

Source from the content-addressed store, hash-verified

299 * @return The number of the matching hotkey or -1.
300 */
301int HotkeyList::CheckMatch(uint16_t keycode, bool global_only) const
302{
303 for (const Hotkey &hotkey : this->items) {
304 auto begin = hotkey.keycodes.begin();
305 auto end = hotkey.keycodes.end();
306 if (std::find(begin, end, keycode | WKC_GLOBAL_HOTKEY) != end || (!global_only && std::find(begin, end, keycode) != end)) {
307 return hotkey.num;
308 }
309 }
310 return -1;
311}
312
313
314static void SaveLoadHotkeys(bool save)

Callers 3

HandleKeypressFunction · 0.80
HandleGlobalHotkeysFunction · 0.80
IsQuitKeyFunction · 0.80

Calls 3

findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected