diff --git a/includes/HotkeysManager.h b/includes/HotkeysManager.h new file mode 100644 index 0000000..382505c --- /dev/null +++ b/includes/HotkeysManager.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include +#include + +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 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); +