Add Hotkeys and OSD manager libs

This commit is contained in:
2026-01-04 21:28:36 +01:00
parent 526028dcc2
commit 2ae5d4462f
2 changed files with 65 additions and 0 deletions

32
libs/HotkeysManager.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include "HotkeysManager.h"
#include <vector>
struct Hotkey {
int vk;
Modifier mods;
std::function<void()> callback;
bool wasPressed = false;
};
static std::vector<Hotkey> g_hotkeys;
static bool IsModifierDown(reshade::api::effect_runtime* rt, Modifier m) {
if ((int)m & (int)Modifier::Alt && !rt->is_key_down(VK_MENU)) return false;
if ((int)m & (int)Modifier::Ctrl && !rt->is_key_down(VK_CONTROL)) return false;
if ((int)m & (int)Modifier::Shift && !rt->is_key_down(VK_SHIFT)) return false;
return true;
}
void RegisterHotkey(int vk, Modifier mods, std::function<void()> callback) {
g_hotkeys.push_back({ vk, mods, std::move(callback) });
}
void ProcessHotkeys(reshade::api::effect_runtime* runtime) {
for (auto& hotkey : g_hotkeys) {
bool pressed = IsModifierDown(runtime, hotkey.mods) && runtime->is_key_down(hotkey.vk);
if (pressed && !hotkey.wasPressed) hotkey.callback();
hotkey.wasPressed = pressed;
}
}