-
-
Notifications
You must be signed in to change notification settings - Fork 307
Add Touchpad gesture action for tracked MT swipes #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,238 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <TouchpadDevice.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <system_error> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <algorithm> | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| extern "C" | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <libevdev/libevdev.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <libevdev/libevdev-uinput.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| #include <linux/input.h> | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| using namespace logid; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| namespace { | ||||||||||||||||||||||||||||||||||||||||||||||
| int clamp_value(int value, int min_value, int max_value) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return std::max(min_value, std::min(value, max_value)); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| TouchpadDevice::TouchpadDevice(const char* name, int width, int height, int slots) : | ||||||||||||||||||||||||||||||||||||||||||||||
| _name(name), | ||||||||||||||||||||||||||||||||||||||||||||||
| _range_x(width > 0 ? width : default_width), | ||||||||||||||||||||||||||||||||||||||||||||||
| _range_y(height > 0 ? height : default_height), | ||||||||||||||||||||||||||||||||||||||||||||||
| _max_slots(slots > 0 ? slots : default_slots), | ||||||||||||||||||||||||||||||||||||||||||||||
| _active(false), | ||||||||||||||||||||||||||||||||||||||||||||||
| _active_fingers(0), | ||||||||||||||||||||||||||||||||||||||||||||||
| _next_tracking_id(1) { | ||||||||||||||||||||||||||||||||||||||||||||||
| _createDevice(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| TouchpadDevice::~TouchpadDevice() { | ||||||||||||||||||||||||||||||||||||||||||||||
| _destroyDevice(); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| void TouchpadDevice::setRange(int width, int height) { | ||||||||||||||||||||||||||||||||||||||||||||||
| const int next_width = width > 0 ? width : default_width; | ||||||||||||||||||||||||||||||||||||||||||||||
| const int next_height = height > 0 ? height : default_height; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| std::lock_guard<std::mutex> lock(_input_mutex); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (_range_x == next_width && _range_y == next_height) | ||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| _endContactsLocked(); | ||||||||||||||||||||||||||||||||||||||||||||||
| _range_x = next_width; | ||||||||||||||||||||||||||||||||||||||||||||||
| _range_y = next_height; | ||||||||||||||||||||||||||||||||||||||||||||||
| _destroyDevice(); | ||||||||||||||||||||||||||||||||||||||||||||||
| _createDevice(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+47
|
||||||||||||||||||||||||||||||||||||||||||||||
| _range_x = next_width; | |
| _range_y = next_height; | |
| _destroyDevice(); | |
| _createDevice(); | |
| const int prev_width = _range_x; | |
| const int prev_height = _range_y; | |
| _range_x = next_width; | |
| _range_y = next_height; | |
| _destroyDevice(); | |
| try { | |
| _createDevice(); | |
| } catch (...) { | |
| // Roll back to the previous range and try to restore the original device. | |
| _range_x = prev_width; | |
| _range_y = prev_height; | |
| try { | |
| _createDevice(); | |
| } catch (...) { | |
| // Leave the exception visible to the caller. | |
| throw; | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing GPL license header. All other files in this codebase include a copyright notice and GPL v3 license header at the top of the file. This file should include the same standard header for consistency.