diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-06 00:26:43 +0000 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-06 00:26:43 +0000 |
commit | 8609722958b89ce71e8336e3254fc5a88912a0e8 (patch) | |
tree | 9a586821f313fa41d8ce00f0f991de716159846e /Touchpad.cpp | |
parent | 3683789a25d118f9a82bd1c7eae36af82b9f499d (diff) |
Bugfix
Diffstat (limited to 'Touchpad.cpp')
-rw-r--r-- | Touchpad.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Touchpad.cpp b/Touchpad.cpp index 073fbde..5fe6bf4 100644 --- a/Touchpad.cpp +++ b/Touchpad.cpp @@ -36,6 +36,9 @@ bool Touchpad::is_valid() bool Touchpad::event_available() { + if (!m_valid) { + return false; + } struct pollfd fds{}; fds.fd = m_fd; fds.events = POLLIN; @@ -65,10 +68,10 @@ input_event Touchpad::get_event() bool Touchpad::event_is_button1(const input_event& ev) { - return ev.type == EV_KEY && ev.code == BTN_LEFT; + return ev.type == EV_KEY && ev.code == BTN_LEFT && ev.value == 0; // Press down } bool Touchpad::event_is_button2(const input_event& ev) { - return ev.type == EV_KEY && ev.code == BTN_RIGHT; + return ev.type == EV_KEY && ev.code == BTN_RIGHT && ev.value == 0; // Press down } |