bsnes/higan/target-bsnes/input/hotkeys.cpp
Tim Allen 393c2395bb Update to v106r48 release.
byuu says:

The problems with the Windows and Qt4 ports have all been resolved,
although there's a fairly gross hack on a few Qt widgets to not destruct
once Application::quit() is called to avoid a double free crash (I'm
unsure where Qt is destructing the widgets internally.) The Cocoa port
compiles again at least, though it's bound to have endless problems. I
improved the Label painting in the GTK ports, which fixes the background
color on labels inside TabFrame widgets.

I've optimized the Makefile system even further.

I added a "redo state" command to bsnes, which is created whenever you
load the undo state. There are also hotkeys for both now, although I
don't think they're really something you want to map hotkeys to.

I moved the nall::Locale object inside hiro::Application, so that it can
be used to translate the BrowserDialog and MessageDialog window strings.

I improved the Super Game Boy emulation of `MLT_REQ`, fixing Pokemon
Yellow's custom border and probably more stuff.

Lots of other small fixes and improvements. Things are finally stable
once again after the harrowing layout redesign catastrophe.

Errata:

  - ICD::joypID should be set to 3 on reset(). joypWrite() may as well
    take uint1 instead of bool.
  - hiro/Qt: remove pWindow::setMaximumSize() comment; found a
    workaround for it
  - nall/GNUmakefile: don't set object.path if it's already set (allow
    overrides before including the file)
2018-07-16 16:16:26 +10:00

89 lines
2.6 KiB
C++

auto InputManager::bindHotkeys() -> void {
static int stateSlot = 1;
hotkeys.append(InputHotkey("Toggle Fullscreen Mode").onPress([] {
presentation->toggleFullscreenMode();
}));
hotkeys.append(InputHotkey("Toggle Mouse Capture").onPress([] {
input->acquired() ? input->release() : input->acquire();
}));
hotkeys.append(InputHotkey("Toggle Cheat Codes").onPress([] {
toolsWindow->cheatEditor.enableCheats.setChecked(
!toolsWindow->cheatEditor.enableCheats.checked()
);
toolsWindow->cheatEditor.enableCheats.doToggle();
}));
hotkeys.append(InputHotkey("Save State").onPress([&] {
program->saveState({"quick/slot ", stateSlot});
}));
hotkeys.append(InputHotkey("Load State").onPress([&] {
program->loadState({"quick/slot ", stateSlot});
}));
hotkeys.append(InputHotkey("Load Undo State").onPress([&] {
program->loadState("quick/undo");
}));
hotkeys.append(InputHotkey("Load Redo State").onPress([&] {
program->loadState("quick/redo");
}));
hotkeys.append(InputHotkey("Increment State Slot").onPress([&] {
if(--stateSlot < 1) stateSlot = 9;
program->showMessage({"Selected state slot ", stateSlot});
}));
hotkeys.append(InputHotkey("Decrement State Slot").onPress([&] {
if(++stateSlot > 9) stateSlot = 1;
program->showMessage({"Selected state slot ", stateSlot});
}));
hotkeys.append(InputHotkey("Capture Screenshot").onPress([] {
program->captureScreenshot();
}));
hotkeys.append(InputHotkey("Fast Forward").onPress([] {
video->setBlocking(false);
audio->setBlocking(false);
}).onRelease([] {
video->setBlocking(settings["Video/Blocking"].boolean());
audio->setBlocking(settings["Audio/Blocking"].boolean());
}));
hotkeys.append(InputHotkey("Pause Emulation").onPress([] {
presentation->pauseEmulation.setChecked(!presentation->pauseEmulation.checked());
}));
hotkeys.append(InputHotkey("Frame Advance").onPress([] {
presentation->frameAdvance.doActivate();
}));
hotkeys.append(InputHotkey("Reset Emulation").onPress([] {
program->reset();
}));
hotkeys.append(InputHotkey("Quit Emulator").onPress([] {
program->quit();
}));
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->focused()) return;
for(auto& hotkey : hotkeys) {
auto 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;
}
}