overlay: create a dedicated thread for polling hotkeys (#864)

## 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
This commit is contained in:
bicarus
2026-08-12 20:04:59 -07:00
committed by GitHub
parent 3b29227dbc
commit 82e0c053d0
18 changed files with 272 additions and 207 deletions
+25
View File
@@ -3,6 +3,7 @@
#include <algorithm>
#include <chrono>
#include <cstdarg>
#include <iterator>
#include <map>
#include <thread>
#include <utility>
@@ -2543,6 +2544,30 @@ rawinput::Device *rawinput::RawInputManager::devices_get(const std::string &name
return nullptr;
}
bool rawinput::RawInputManager::keyboard_combo_pressed(uint16_t first, uint16_t second) {
if (first >= 256 || second >= 256) {
return false;
}
std::lock_guard<std::recursive_mutex> devices_lock(this->devices_mutex);
for (auto &device : this->devices) {
if (device.type != rawinput::KEYBOARD ||
device.keyboardInfo == nullptr ||
device.mutex == nullptr) {
continue;
}
std::lock_guard<std::mutex> device_lock(*device.mutex);
const auto &states = device.keyboardInfo->key_states;
for (size_t page = 0; page < std::size(states); page += 256) {
if (states[page + first] && states[page + second]) {
return true;
}
}
}
return false;
}
void rawinput::RawInputManager::add_callback_add(void *data, std::function<void (void *, Device *)> callback) {
this->callback_add.push_back(DeviceCallback {
.data = data,
+1
View File
@@ -171,6 +171,7 @@ namespace rawinput {
void __stdcall devices_print();
Device *devices_get(const std::string &name, bool updated = false);
bool keyboard_combo_pressed(uint16_t first, uint16_t second);
inline std::list<Device> &devices_get() {
return devices;