From 956660185b69094e7d24b23b5fae5d65e83d4b6c Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Thu, 10 Aug 2023 06:03:00 +0500 Subject: [PATCH] Added helper functions to determine input type (gamepad or keyboard & mouse) Reduces code length --- src/xrEngine/xr_input.h | 5 ++++- src/xrGame/UIDialogHolder.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xrEngine/xr_input.h b/src/xrEngine/xr_input.h index b8f0e94486c..49e9a2b3c90 100644 --- a/src/xrEngine/xr_input.h +++ b/src/xrEngine/xr_input.h @@ -159,7 +159,10 @@ class ENGINE_API CInput bool IsControllerAvailable() const { return !controllers.empty(); } void EnableControllerSensors(bool enable); - auto GetCurrentInputType() { return currentInputType; } + auto GetCurrentInputType() const { return currentInputType; } + auto IsCurrentInputTypeController() const { return GetCurrentInputType() == InputType::Controller; } + auto IsCurrentInputTypeKeyboardMouse() const { return GetCurrentInputType() == InputType::KeyboardMouse; } + public: void ExclusiveMode(const bool exclusive); bool IsExclusiveMode() const; diff --git a/src/xrGame/UIDialogHolder.cpp b/src/xrGame/UIDialogHolder.cpp index 556c527b102..24d5d5f8c00 100644 --- a/src/xrGame/UIDialogHolder.cpp +++ b/src/xrGame/UIDialogHolder.cpp @@ -225,7 +225,7 @@ void CDialogHolder::OnFrame() { m_b_in_update = true; - if (GetUICursor().IsVisible() && pInput->GetCurrentInputType() == CInput::Controller) + if (GetUICursor().IsVisible() && pInput->IsCurrentInputTypeController()) GetUICursor().UpdateAutohideTiming(); CUIDialogWnd* wnd = TopInputReceiver();