From 2b2ca3e3522e1886a8f14da9c66fcdb009f76746 Mon Sep 17 00:00:00 2001 From: Dominik Madarasz Date: Wed, 30 Sep 2026 16:13:55 +0200 Subject: [PATCH 1/4] Input: Reuse framework events and physical camera controls --- code/client/src/core/application.h | 4 + .../client/src/core/ui/devs/camera_studio.cpp | 20 ++--- code/client/src/game/helpers/game_input.cpp | 48 ------------ code/client/src/game/helpers/game_input.h | 73 +------------------ 4 files changed, 17 insertions(+), 128 deletions(-) diff --git a/code/client/src/core/application.h b/code/client/src/core/application.h index d17c8832..a8b88b0c 100644 --- a/code/client/src/core/application.h +++ b/code/client/src/core/application.h @@ -98,6 +98,10 @@ namespace MafiaMP::Core { return _input.get(); } + bool IsLocalInputAvailable() const override { + return !AreControlsLocked() && Framework::Integrations::Client::Instance::IsLocalInputAvailable(); + } + std::shared_ptr GetInput() const { return _input; } diff --git a/code/client/src/core/ui/devs/camera_studio.cpp b/code/client/src/core/ui/devs/camera_studio.cpp index 6a79107b..3dc560fa 100644 --- a/code/client/src/core/ui/devs/camera_studio.cpp +++ b/code/client/src/core/ui/devs/camera_studio.cpp @@ -1,3 +1,5 @@ +#include + #include "camera_studio.h" #include @@ -188,7 +190,7 @@ namespace MafiaMP::Core::UI::Devs { GetCursorPos(&mouse); if (!_frozen) { - if ((GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0) { + if (Framework::Input::PhysicalKeyState::IsDown(VK_RBUTTON)) { _yaw += static_cast(mouse.x - _lastMousePos.x) * _sensitivity; _pitch -= static_cast(mouse.y - _lastMousePos.y) * _sensitivity; _pitch = std::clamp(_pitch, -kMaxPitch, kMaxPitch); @@ -198,10 +200,10 @@ namespace MafiaMP::Core::UI::Devs { const SDK::ue::sys::math::C_Vector right = {std::cos(_yaw), -std::sin(_yaw), 0.0f}; float speed = _moveSpeed; - if (GetAsyncKeyState(VK_SHIFT) & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown(VK_SHIFT)) { speed *= 3.0f; } - if (GetAsyncKeyState(VK_CONTROL) & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown(VK_CONTROL)) { speed *= 0.25f; } const float step = speed * deltaTime; @@ -212,22 +214,22 @@ namespace MafiaMP::Core::UI::Devs { _position.z += v.z * s; }; - if (GetAsyncKeyState('W') & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown('W')) { move(forward, step); } - if (GetAsyncKeyState('S') & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown('S')) { move(forward, -step); } - if (GetAsyncKeyState('D') & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown('D')) { move(right, step); } - if (GetAsyncKeyState('A') & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown('A')) { move(right, -step); } - if (GetAsyncKeyState(VK_SPACE) & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown(VK_SPACE)) { _position.z += step; } - if (GetAsyncKeyState('C') & 0x8000) { + if (Framework::Input::PhysicalKeyState::IsDown('C')) { _position.z -= step; } } diff --git a/code/client/src/game/helpers/game_input.cpp b/code/client/src/game/helpers/game_input.cpp index e40216d7..a8a13c6d 100644 --- a/code/client/src/game/helpers/game_input.cpp +++ b/code/client/src/game/helpers/game_input.cpp @@ -3,54 +3,6 @@ #include "core/application.h" namespace MafiaMP::Game { - void GameInput::Update() { - for (int i = 0; i < 256; i++) { - _keysPressed[i] = false; - _keysReleased[i] = false; - } - - for (int i = 0; i < 5; i++) { - _buttonsPressed[i] = false; - _buttonsReleased[i] = false; - } - } - - uint32_t GameInput::MapKey(uint32_t key) const { - return key; // we map WndProc VK keys 1:1 to our input keys - } - - void GameInput::ProcessEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) { - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - _keysDown[wParam] = true; - _keysPressed[wParam] = true; - break; - case WM_KEYUP: - case WM_SYSKEYUP: - _keysDown[wParam] = false; - _keysReleased[wParam] = true; - break; - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - _buttonsDown[wParam] = true; - _buttonsPressed[wParam] = true; - break; - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - _buttonsDown[wParam] = false; - _buttonsReleased[wParam] = true; - break; - case WM_MOUSEMOVE: - _mousePosition[0] = LOWORD(lParam); - _mousePosition[1] = HIWORD(lParam); - break; - default: break; - } - } - bool GameInput::IsInputLocked() const { return Core::gApplication->AreControlsLocked(); } diff --git a/code/client/src/game/helpers/game_input.h b/code/client/src/game/helpers/game_input.h index d1e6d24e..92e681b8 100644 --- a/code/client/src/game/helpers/game_input.h +++ b/code/client/src/game/helpers/game_input.h @@ -2,20 +2,14 @@ #include -#include +#include namespace MafiaMP::Game { - class GameInput: public Framework::Input::IInput { + class GameInput final: public Framework::Input::WindowInput { public: GameInput() {} ~GameInput() = default; - void Update() override; - - void GetMousePosition(int &x, int &y) const override { - x = _mousePosition[0]; - y = _mousePosition[1]; - }; void SetMousePosition(int x, int y) override {}; void SetMouseVisible(bool visible) override { SetInputLocked(visible); @@ -29,68 +23,5 @@ namespace MafiaMP::Game { }; void SetInputLocked(bool locked) override; bool IsInputLocked() const override; - - bool IsKeyDown(int key) const override { - if (key < 0 || key > 255) { - return false; - } - return _keysDown[MapKey(key)]; - }; - bool IsKeyUp(int key) const override { - if (key < 0 || key > 255) { - return false; - } - return !_keysDown[MapKey(key)]; - }; - bool IsKeyPressed(int key) const override { - if (key < 0 || key > 255) { - return false; - } - return _keysPressed[MapKey(key)]; - }; - bool IsKeyReleased(int key) const override { - if (key < 0 || key > 255) { - return false; - } - return _keysReleased[MapKey(key)]; - }; - - bool IsMouseButtonDown(int button) const override { - if (button < 0 || button > 4) { - return false; - } - return _buttonsDown[button]; - }; - bool IsMouseButtonUp(int button) const override { - if (button < 0 || button > 4) { - return false; - } - return !_buttonsDown[button]; - }; - bool IsMouseButtonPressed(int button) const override { - if (button < 0 || button > 4) { - return false; - } - return _buttonsPressed[button]; - }; - bool IsMouseButtonReleased(int button) const override { - if (button < 0 || button > 4) { - return false; - } - return _buttonsReleased[button]; - }; - - uint32_t MapKey(uint32_t key) const override; - - void ProcessEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - private: - bool _keysDown[256] = {false}; - bool _keysPressed[256] = {false}; - bool _keysReleased[256] = {false}; - bool _buttonsDown[5] = {false}; - bool _buttonsPressed[5] = {false}; - bool _buttonsReleased[5] = {false}; - int _mousePosition[2] = {}; }; } // namespace MafiaMP::Game From b1298e0a9231bfbebf6de67d166f740fb3e09efa Mon Sep 17 00:00:00 2001 From: Dominik Madarasz Date: Wed, 30 Sep 2026 16:13:55 +0200 Subject: [PATCH 2/4] Build: Pin the shared native input framework dependency --- FRAMEWORK_PIN | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 FRAMEWORK_PIN diff --git a/FRAMEWORK_PIN b/FRAMEWORK_PIN new file mode 100644 index 00000000..440cd666 --- /dev/null +++ b/FRAMEWORK_PIN @@ -0,0 +1,3 @@ +# Framework source required by this input adapter migration. +# Framework PR #292; replace with its merged commit before release. +263476c3709aa66cc6680fdc029b01321a4b2984 From 219ca4fc0fbfc6c77e9aa17cf66a74f108afd869 Mon Sep 17 00:00:00 2001 From: Dominik Madarasz Date: Wed, 30 Sep 2026 17:22:01 +0200 Subject: [PATCH 3/4] Input: Use unified key queries and framework key macros --- .../client/src/core/ui/devs/camera_studio.cpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/code/client/src/core/ui/devs/camera_studio.cpp b/code/client/src/core/ui/devs/camera_studio.cpp index 3dc560fa..f041419f 100644 --- a/code/client/src/core/ui/devs/camera_studio.cpp +++ b/code/client/src/core/ui/devs/camera_studio.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "camera_studio.h" @@ -189,8 +190,9 @@ namespace MafiaMP::Core::UI::Devs { POINT mouse = {}; GetCursorPos(&mouse); - if (!_frozen) { - if (Framework::Input::PhysicalKeyState::IsDown(VK_RBUTTON)) { + const auto *input = Framework::CoreModules::GetInput(); + if (!_frozen && input) { + if (input->IsKeyDown(FW_KEY_RBUTTON)) { _yaw += static_cast(mouse.x - _lastMousePos.x) * _sensitivity; _pitch -= static_cast(mouse.y - _lastMousePos.y) * _sensitivity; _pitch = std::clamp(_pitch, -kMaxPitch, kMaxPitch); @@ -200,10 +202,10 @@ namespace MafiaMP::Core::UI::Devs { const SDK::ue::sys::math::C_Vector right = {std::cos(_yaw), -std::sin(_yaw), 0.0f}; float speed = _moveSpeed; - if (Framework::Input::PhysicalKeyState::IsDown(VK_SHIFT)) { + if (input->IsKeyDown(FW_KEY_SHIFT)) { speed *= 3.0f; } - if (Framework::Input::PhysicalKeyState::IsDown(VK_CONTROL)) { + if (input->IsKeyDown(FW_KEY_CONTROL)) { speed *= 0.25f; } const float step = speed * deltaTime; @@ -214,22 +216,22 @@ namespace MafiaMP::Core::UI::Devs { _position.z += v.z * s; }; - if (Framework::Input::PhysicalKeyState::IsDown('W')) { + if (input->IsKeyDown('W')) { move(forward, step); } - if (Framework::Input::PhysicalKeyState::IsDown('S')) { + if (input->IsKeyDown('S')) { move(forward, -step); } - if (Framework::Input::PhysicalKeyState::IsDown('D')) { + if (input->IsKeyDown('D')) { move(right, step); } - if (Framework::Input::PhysicalKeyState::IsDown('A')) { + if (input->IsKeyDown('A')) { move(right, -step); } - if (Framework::Input::PhysicalKeyState::IsDown(VK_SPACE)) { + if (input->IsKeyDown(FW_KEY_SPACE)) { _position.z += step; } - if (Framework::Input::PhysicalKeyState::IsDown('C')) { + if (input->IsKeyDown('C')) { _position.z -= step; } } From c8956bdac0d06a1a9f7500a6d9ec3571c9ffb5ea Mon Sep 17 00:00:00 2001 From: Dominik Madarasz Date: Wed, 30 Sep 2026 17:22:01 +0200 Subject: [PATCH 4/4] Framework: Pin unified IInput query implementation --- FRAMEWORK_PIN | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FRAMEWORK_PIN b/FRAMEWORK_PIN index 440cd666..3a2189ad 100644 --- a/FRAMEWORK_PIN +++ b/FRAMEWORK_PIN @@ -1,3 +1,3 @@ -# Framework source required by this input adapter migration. +# Framework source required by the unified IInput adapter migration. # Framework PR #292; replace with its merged commit before release. -263476c3709aa66cc6680fdc029b01321a4b2984 +689c27139ba8e0123e33cfb54f869d27f15c7001