From 23825409a97e344c235d3e35bfecaec0f976cdec Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Aug 2024 02:40:24 +0200 Subject: [PATCH] Added double click --- inputsystem/inputsystem.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/inputsystem/inputsystem.cpp b/inputsystem/inputsystem.cpp index 8c065e523f..4aa89cf5d0 100644 --- a/inputsystem/inputsystem.cpp +++ b/inputsystem/inputsystem.cpp @@ -6,6 +6,7 @@ #include "inputsystem.h" #include "dbg.h" +#include "inputsystem/InputEnums.h" #include "key_translation.h" #include "inputsystem/ButtonCode.h" #include "inputsystem/AnalogCode.h" @@ -14,6 +15,7 @@ #include "tier0/icommandline.h" #include "tier3/tier3.h" #include "vgui/IInput.h" +#include #include #if defined( USE_SDL ) @@ -1364,14 +1366,27 @@ LRESULT CInputSystem::WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP m_mouseRawAccumX += raw->data.mouse.lLastX; m_mouseRawAccumY += raw->data.mouse.lLastY; + static int dblClickTime = 0; + static int dblCurrentClickTime = GetDoubleClickTime(); + if ( raw->data.mouse.usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN ) { + if (GetTickCount() < (dblClickTime + dblCurrentClickTime)) + { + PostButtonPressedEvent( IE_ButtonDoubleClicked, m_nLastSampleTick, MOUSE_LEFT, MOUSE_LEFT ); + } + else + { + dblClickTime = GetTickCount(); + } + PostButtonPressedEvent( IE_ButtonPressed, m_nLastSampleTick, MOUSE_LEFT, MOUSE_LEFT ); } if ( raw->data.mouse.usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP ) { PostButtonReleasedEvent( IE_ButtonReleased, m_nLastSampleTick, MOUSE_LEFT, MOUSE_LEFT ); + PostButtonReleasedEvent( IE_ButtonDoubleClicked, m_nLastSampleTick, MOUSE_LEFT, MOUSE_LEFT ); } if ( raw->data.mouse.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN )