From 459773802e3f0dfe9a2747362e2a32d434b5cd18 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 5 Oct 2024 01:30:19 -0400 Subject: [PATCH] add: OnKeyPress Signal --- Code/hooks/include/DInputHook.hpp | 3 +++ Code/hooks/src/DInputHook.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Code/hooks/include/DInputHook.hpp b/Code/hooks/include/DInputHook.hpp index 2823bfd..f68f8eb 100644 --- a/Code/hooks/include/DInputHook.hpp +++ b/Code/hooks/include/DInputHook.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include namespace TiltedPhoques @@ -21,6 +22,8 @@ namespace TiltedPhoques void Update() const noexcept; + Signal OnKeyPress; + private: DInputHook() noexcept; diff --git a/Code/hooks/src/DInputHook.cpp b/Code/hooks/src/DInputHook.cpp index acda073..83dbe94 100644 --- a/Code/hooks/src/DInputHook.cpp +++ b/Code/hooks/src/DInputHook.cpp @@ -98,9 +98,14 @@ namespace TiltedPhoques { for (DWORD i = 0; i < *outDataLen; ++i) { - if (input.IsToggleKey(outData[i].dwOfs) && outData[i].dwData & 0x80) + if (outData[i].dwData & 0x80) { - DInputHook::Get().SetEnabled(true); + if (input.IsToggleKey(outData[i].dwOfs)) + { + input.SetEnabled(true); + } + + input.OnKeyPress.Emit(outData[i].dwOfs); } } } @@ -183,7 +188,6 @@ namespace TiltedPhoques DInputHook::DInputHook() noexcept { - SetToggleKeys({ DIK_F2, DIK_RCONTROL }); } void DInputHook::SetToggleKeys(std::initializer_list aKeys) noexcept