1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
auto InputManager::createHotkeys() -> void {
static bool fastForwardVideoBlocking;
static bool fastForwardAudioBlocking;
static bool fastForwardAudioDynamic;
hotkeys.append(InputHotkey("Toggle Fullscreen").onPress([&] {
program.videoFullScreenToggle();
}));
hotkeys.append(InputHotkey("Toggle Mouse Capture").onPress([&] {
if(!emulator) return;
if(!ruby::input.acquired()) {
ruby::input.acquire();
} else {
ruby::input.release();
}
}));
hotkeys.append(InputHotkey("Fast Forward").onPress([&] {
if(!emulator || program.rewinding) return;
program.fastForwarding = true;
fastForwardVideoBlocking = ruby::video.blocking();
fastForwardAudioBlocking = ruby::audio.blocking();
fastForwardAudioDynamic = ruby::audio.dynamic();
ruby::video.setBlocking(false);
ruby::audio.setBlocking(false);
ruby::audio.setDynamic(false);
}).onRelease([&] {
if(!emulator) return;
program.fastForwarding = false;
ruby::video.setBlocking(fastForwardVideoBlocking);
ruby::audio.setBlocking(fastForwardAudioBlocking);
ruby::audio.setDynamic(fastForwardAudioDynamic);
}));
hotkeys.append(InputHotkey("Rewind").onPress([&] {
if(!emulator || program.fastForwarding) return;
if(program.rewind.frequency == 0) {
return program.showMessage("Please enable rewind support in the emulator settings first.");
}
program.rewinding = true;
program.rewindSetMode(Program::Rewind::Mode::Rewinding);
}).onRelease([&] {
if(!emulator) return;
program.rewinding = false;
program.rewindSetMode(Program::Rewind::Mode::Playing);
}));
hotkeys.append(InputHotkey("Capture Screenshot").onPress([&] {
if(!emulator) return;
program.requestScreenshot = true;
}));
hotkeys.append(InputHotkey("Save State").onPress([&] {
if(!emulator) return;
program.stateSave(program.state.slot);
}));
hotkeys.append(InputHotkey("Load State").onPress([&] {
if(!emulator) return;
program.stateLoad(program.state.slot);
}));
hotkeys.append(InputHotkey("Decrement State Slot").onPress([&] {
if(!emulator) return;
if(program.state.slot == 1) program.state.slot = 9;
else program.state.slot--;
program.showMessage({"Selected state slot ", program.state.slot});
}));
hotkeys.append(InputHotkey("Increment State Slot").onPress([&] {
if(!emulator) return;
if(program.state.slot == 9) program.state.slot = 1;
else program.state.slot++;
program.showMessage({"Selected state slot ", program.state.slot});
}));
hotkeys.append(InputHotkey("Pause Emulation").onPress([&] {
if(!emulator) return;
program.pause(!program.paused);
}));
hotkeys.append(InputHotkey("Quit Emulator").onPress([&] {
program.quit();
}));
}
auto InputManager::pollHotkeys() -> void {
if(Application::modal()) return;
if(!presentation.focused() && !ruby::video.fullScreen()) return;
for(auto& hotkey : hotkeys) {
auto state = hotkey.value();
if(hotkey.state == 0 && state == 1 && hotkey.press) hotkey.press();
if(hotkey.state == 1 && state == 0 && hotkey.release) hotkey.release();
hotkey.state = state;
}
}
|