auto InputManager::appendHotkeys() -> void { static int quickStateSlot = 1; { auto hotkey = new InputHotkey; hotkey->name = "Toggle Fullscreen"; hotkey->press = [] { presentation->toggleFullScreen(); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Toggle Mouse Capture"; hotkey->press = [] { input->acquired() ? input->release() : input->acquire(); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Save Quick State"; hotkey->press = [] { program->saveState(quickStateSlot); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Load Quick State"; hotkey->press = [&] { program->loadState(quickStateSlot); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Decrement Quick State"; hotkey->press = [&] { if(--quickStateSlot < 1) quickStateSlot = 5; program->showMessage({"Selected quick state slot ", quickStateSlot}); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Increment Quick State"; hotkey->press = [&] { if(++quickStateSlot > 5) quickStateSlot = 1; program->showMessage({"Selected quick state slot ", quickStateSlot}); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Pause Emulation"; hotkey->press = [] { program->pause = !program->pause; }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Fast Forward"; hotkey->press = [] { video->set(Video::Synchronize, false); audio->set(Audio::Synchronize, false); }; hotkey->release = [] { video->set(Video::Synchronize, settings["Video/Synchronize"].boolean()); audio->set(Audio::Synchronize, settings["Audio/Synchronize"].boolean()); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Power Cycle"; hotkey->press = [] { program->powerCycle(); }; hotkeys.append(hotkey); } { auto hotkey = new InputHotkey; hotkey->name = "Rotate Display"; hotkey->press = [] { program->rotateDisplay(); }; hotkeys.append(hotkey); } for(auto& hotkey : hotkeys) { hotkey->path = string{"Hotkey/", hotkey->name}.replace(" ", ""); hotkey->assignment = settings(hotkey->path).text(); hotkey->bind(); } } auto InputManager::pollHotkeys() -> void { if(program->allowInput(true)) { for(auto& hotkey : hotkeys) { int16 state = hotkey->poll(); if(hotkey->state == 0 && state == 1 && hotkey->press) hotkey->press(); if(hotkey->state == 1 && state == 0 && hotkey->release) hotkey->release(); hotkey->state = state; } } }