## Link to GitHub Issue or related Pull Request, if one exists n/a ## Description of change Create a new thread that polls for the following hotkeys: * super exit (both alt+f4 and bound key) * coin insert * screenshot The goal is to make the capture of these more reliable, because before this PR it wasn't. ## Testing
44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
#include "superexit.h"
|
|
|
|
#include "windows.h"
|
|
|
|
#include "cfg/configurator.h"
|
|
#include "launcher/shutdown.h"
|
|
#include "touch/touch.h"
|
|
#include "util/logging.h"
|
|
|
|
namespace superexit {
|
|
|
|
bool has_focus() {
|
|
HWND fg_wnd = GetForegroundWindow();
|
|
if (fg_wnd == NULL) {
|
|
return false;
|
|
}
|
|
if (fg_wnd == SPICETOUCH_TOUCH_HWND) {
|
|
return true;
|
|
}
|
|
DWORD fg_pid;
|
|
GetWindowThreadProcessId(fg_wnd, &fg_pid);
|
|
return fg_pid == GetCurrentProcessId();
|
|
}
|
|
|
|
void handle_hotkeys(bool alt_f4, bool mapped_exit) {
|
|
if (!alt_f4 && !mapped_exit) {
|
|
return;
|
|
}
|
|
if (cfg::CONFIGURATOR_STANDALONE) {
|
|
return;
|
|
}
|
|
if (!has_focus()) {
|
|
return;
|
|
}
|
|
if (alt_f4) {
|
|
log_info("superexit", "detected ALT+F4, exiting...");
|
|
launcher::shutdown();
|
|
return;
|
|
}
|
|
log_info("superexit", "detected Force Exit Game overlay shortcut, exiting...");
|
|
launcher::shutdown();
|
|
}
|
|
}
|