Files
ReshadePluginsAddon/includes/HotkeysManager.h

45 lines
1.4 KiB
C
Raw Normal View History

2026-01-04 21:27:37 +01:00
#pragma once
#include <Windows.h>
#include <reshade.hpp>
#include <functional>
enum class Modifier {
None = 0,
Alt = 1 << 0,
Ctrl = 1 << 1,
Shift = 1 << 2
};
/**
* @brief Registers a new hotkey for the plugin.
*
* This function adds a hotkey that will be checked every frame via
* `ProcessHotkeys`. When the specified key (with optional modifiers)
* is pressed, the provided callback will be executed.
*
* @param vk The virtual key code (e.g., VK_F1, VK_F2, etc.).
* @param mods The modifier keys required to trigger the hotkey (ALT, CTRL, SHIFT).
* @param callback The function to execute when the hotkey is pressed.
*
* @note The callback should be fast and must not block the main thread.
* @note Hotkeys are only checked when `ProcessHotkeys` is called.
*/
void RegisterHotkey(int vk, Modifier mods, std::function<void()> callback);
/**
* @brief Processes all registered hotkeys and executes their callbacks.
*
* This function should be called **once per frame**, typically in
* `on_reshade_present`, to detect key presses and trigger callbacks.
*
* @param runtime Pointer to the `reshade::api::effect_runtime` object,
* required if a callback manipulates shaders or uniforms.
*
* @note If no hotkey is pressed, this function does nothing.
* @note All hotkeys must have been previously registered with `RegisterHotkey`.
*/
void ProcessHotkeys(reshade::api::effect_runtime* runtime);