From 890df659702badf50ee9983a3dceebdff8e47ae8 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 11 Jan 2026 22:34:57 +0100 Subject: [PATCH] Add input `GamepadButtonDown` and `GamepadButtonUp` events #3626 --- Source/Engine/Input/Input.cpp | 15 +++++++++++++++ Source/Engine/Input/Input.h | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/Source/Engine/Input/Input.cpp b/Source/Engine/Input/Input.cpp index 8438977b1..7048140ef 100644 --- a/Source/Engine/Input/Input.cpp +++ b/Source/Engine/Input/Input.cpp @@ -80,6 +80,8 @@ Delegate Input::MouseDoubleClick; Delegate Input::MouseWheel; Delegate Input::MouseMove; Action Input::MouseLeave; +Delegate Input::GamepadButtonDown; +Delegate Input::GamepadButtonUp; Delegate Input::TouchDown; Delegate Input::TouchMove; Delegate Input::TouchUp; @@ -1027,6 +1029,19 @@ void InputService::Update() break; } } + // TODO: route gamepad button events into global InputEvents queue to improve processing + for (int32 i = 0; i < Input::Gamepads.Count(); i++) + { + auto gamepad = Input::Gamepads[i]; + for (int32 buttonIdx = 1; buttonIdx < (int32)GamepadButton::MAX; buttonIdx++) + { + GamepadButton button = (GamepadButton)buttonIdx; + if (gamepad->GetButtonDown(button)) + Input::GamepadButtonDown((InputGamepadIndex)i, button); + else if (gamepad->GetButtonUp(button)) + Input::GamepadButtonUp((InputGamepadIndex)i, button); + } + } // Update all actions for (int32 i = 0; i < Input::ActionMappings.Count(); i++) diff --git a/Source/Engine/Input/Input.h b/Source/Engine/Input/Input.h index 8cc1b2106..73e87f5f0 100644 --- a/Source/Engine/Input/Input.h +++ b/Source/Engine/Input/Input.h @@ -113,6 +113,16 @@ public: /// API_EVENT() static Action MouseLeave; + /// + /// Event fired when gamepad button goes down. + /// + API_EVENT() static Delegate GamepadButtonDown; + + /// + /// Event fired when gamepad button goes up. + /// + API_EVENT() static Delegate GamepadButtonUp; + /// /// Event fired when touch action begins. ///