Slight cleanup of mousewheel pr

Fixes theoretical uninitialized variable and micro-optimizes scrollwheel stop code
This commit is contained in:
MSuih 2020-01-03 22:07:40 +02:00 committed by Megamouse
parent 69f11d82d1
commit 049f852a9c
2 changed files with 13 additions and 12 deletions

View File

@ -705,27 +705,27 @@ void keyboard_pad_handler::ThreadProc()
// Releases the wheel buttons 0,1 sec after they've been triggered
// Next activation is set to distant future to avoid activating this on every proc
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
const auto update_treshold = std::chrono::milliseconds(100);
const auto delay = std::chrono::hours(24);
if (now >= m_last_wheel_move_up + update_treshold)
const auto now = std::chrono::steady_clock::now();
const auto update_threshold = now - std::chrono::milliseconds(100);
const auto distant_future = now + std::chrono::hours(24);
if (update_threshold >= m_last_wheel_move_up)
{
Key(mouse::wheel_up, false);
m_last_wheel_move_up = now + delay;
m_last_wheel_move_up = distant_future;
}
if (now >= m_last_wheel_move_down + update_treshold)
if (update_threshold >= m_last_wheel_move_down)
{
Key(mouse::wheel_down, false);
m_last_wheel_move_down = now + delay;
m_last_wheel_move_down = distant_future;
}
if (now >= m_last_wheel_move_left + update_treshold)
if (update_threshold >= m_last_wheel_move_left)
{
Key(mouse::wheel_left, false);
m_last_wheel_move_left = now + delay;
m_last_wheel_move_left = distant_future;
}
if (now >= m_last_wheel_move_right + update_treshold)
if (update_threshold >= m_last_wheel_move_right)
{
Key(mouse::wheel_right, false);
m_last_wheel_move_right = now + delay;
m_last_wheel_move_right = distant_future;
}
}

View File

@ -730,8 +730,9 @@ void pad_settings_dialog::wheelEvent(QWheelEvent *event)
key = mouse::wheel_right;
}
}
if (const int y = direction.y())
else
{
const int y = direction.y();
bool to_up = event->inverted() ? y < 0 : y > 0;
if (to_up)
{