[FindMyMouse]Account for low double click settings (#14291)

This commit is contained in:
Jaime Bernardo 2021-11-08 11:36:38 +00:00 committed by GitHub
parent 019c05c8e4
commit c9dca6802e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,6 +55,7 @@ protected:
POINT m_sonarPos = ptNowhere;
// Only consider double left control click if at least 100ms passed between the clicks, to avoid keyboards that might be sending rapid clicks.
// At actual check, time a fifth of the current double click setting might be used instead to take into account users who might have low values.
static const int MIN_DOUBLE_CLICK_TIME = 100;
static constexpr int SonarRadius = 100;
@ -312,9 +313,10 @@ void SuperSonar<D>::OnSonarKeyboardInput(RAWINPUT const& input)
auto now = GetTickCount();
auto doubleClickInterval = now - m_lastKeyTime;
POINT ptCursor{};
auto doubleClickTimeSetting = GetDoubleClickTime();
if (GetCursorPos(&ptCursor) &&
doubleClickInterval >= MIN_DOUBLE_CLICK_TIME &&
doubleClickInterval <= GetDoubleClickTime() &&
doubleClickInterval >= min(MIN_DOUBLE_CLICK_TIME, doubleClickTimeSetting / 5) &&
doubleClickInterval <= doubleClickTimeSetting &&
IsEqual(m_lastKeyPos, ptCursor))
{
m_sonarState = SonarState::ControlDown2;