From 2cfdecde236f9caaa0bdab9c8dd8cf8e344846bc Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 3 Dec 2024 12:55:47 -0800 Subject: [PATCH] Added "axis" attribute. --- src/config/config.cpp | 27 ++++--- src/config/config.h | 13 ++-- src/config/xml-config-loader.cpp | 5 +- src/daemon/daemon-client.cpp | 5 +- src/daemon/daemon-server.cpp | 3 +- src/daemon/dbus.h | 3 + src/gesture-controller/gesture-controller.cpp | 15 +++- src/gesture-controller/gesture-controller.h | 5 +- src/gesture-gatherer/libinput-handler.cpp | 6 ++ src/gesture-gatherer/libinput-handler.h | 5 ++ .../libinput-pinch-handler.cpp | 32 ++++++-- src/gesture-gatherer/libinput-pinch-handler.h | 2 + .../libinput-touch-handler.cpp | 15 ++-- src/gesture-gatherer/libinput-touch-handler.h | 3 + src/gesture/gesture-axis.h | 77 +++++++++++++++++++ src/gesture/gesture.h | 25 ++++++ 16 files changed, 203 insertions(+), 38 deletions(-) mode change 100755 => 100644 src/config/config.cpp mode change 100755 => 100644 src/config/config.h mode change 100755 => 100644 src/gesture-controller/gesture-controller.cpp mode change 100755 => 100644 src/gesture-controller/gesture-controller.h create mode 100644 src/gesture/gesture-axis.h diff --git a/src/config/config.cpp b/src/config/config.cpp old mode 100755 new mode 100644 index 666aaaa7..21f8061a --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -46,27 +46,31 @@ std::string Config::getGlobalSetting(const std::string &name) const { void Config::saveGestureConfig( const std::string &application, GestureType gestureType, const std::string &numFingers, GestureDirection gestureDirection, - ActionType actionType, + GestureAxis gestureAxis, ActionType actionType, const std::unordered_map &actionSettings) { std::string key = Config::getConfigKey(application, gestureType, numFingers, - gestureDirection); + gestureDirection, gestureAxis); this->config[key] = std::make_pair(actionType, actionSettings); } bool Config::hasGestureConfig(const std::string &application, GestureType gestureType, int numFingers, - GestureDirection gestureDirection) const { - std::string key = Config::getConfigKey( - application, gestureType, std::to_string(numFingers), gestureDirection); + GestureDirection gestureDirection, + GestureAxis gestureAxis) const { + std::string key = Config::getConfigKey(application, + gestureType, std::to_string(numFingers), + gestureDirection, gestureAxis); return (this->config.count(key) == 1); } std::pair> Config::getGestureConfig(const std::string &application, GestureType gestureType, int numFingers, - GestureDirection gestureDirection) const { - std::string key = Config::getConfigKey( - application, gestureType, std::to_string(numFingers), gestureDirection); + GestureDirection gestureDirection, + GestureAxis gestureAxis) const { + std::string key = Config::getConfigKey(application, + gestureType, std::to_string(numFingers), + gestureDirection, gestureAxis); return this->config.at(key); } @@ -78,9 +82,12 @@ void Config::loadDefaultGlobalSettings() { std::string Config::getConfigKey(const std::string &application, GestureType gestureType, const std::string &numFingers, - GestureDirection gestureDirection) { + GestureDirection gestureDirection, + GestureAxis gestureAxis) { auto gestureTypeInt = static_cast(gestureType); auto gestureDirectionInt = static_cast(gestureDirection); + auto gestureAxisInt = static_cast(gestureAxis); return toLower(application) + "_" + std::to_string(gestureTypeInt) + "_" + - numFingers + "_" + std::to_string(gestureDirectionInt); + numFingers + "_" + std::to_string(gestureDirectionInt) + "_" + + std::to_string(gestureAxisInt); } diff --git a/src/config/config.h b/src/config/config.h old mode 100755 new mode 100644 index 0165d4e4..e9bc91d6 --- a/src/config/config.h +++ b/src/config/config.h @@ -23,6 +23,7 @@ #include #include "actions/action-type.h" +#include "gesture/gesture-axis.h" #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" @@ -66,22 +67,23 @@ class Config { void saveGestureConfig( const std::string &application, GestureType gestureType, const std::string &numFingers, GestureDirection gestureDirection, - ActionType actionType, + GestureAxis gestureAxis, ActionType actionType, const std::unordered_map &actionSettings); /** * @returns If there is an action configured for the gesture. */ bool hasGestureConfig(const std::string &application, GestureType gestureType, - int numFingers, - GestureDirection gestureDirection) const; + int numFingers, GestureDirection gestureDirection, + GestureAxis gestureAxis) const; /** * @returns The action configured for the gesture. */ std::pair> getGestureConfig(const std::string &application, GestureType gestureType, - int numFingers, GestureDirection gestureDirection) const; + int numFingers, GestureDirection gestureDirection, + GestureAxis gestureAxis) const; private: /** @@ -113,7 +115,8 @@ class Config { static std::string getConfigKey(const std::string &application, GestureType gestureType, const std::string &numFingers, - GestureDirection gestureDirection); + GestureDirection gestureDirection, + GestureAxis gestureAxis); }; #endif // CONFIG_CONFIG_H_ diff --git a/src/config/xml-config-loader.cpp b/src/config/xml-config-loader.cpp index b708d267..b5aecaf1 100644 --- a/src/config/xml-config-loader.cpp +++ b/src/config/xml-config-loader.cpp @@ -101,6 +101,7 @@ void XmlConfigLoader::parseApplicationXmlNodes(const pugi::xml_node &rootNode) { const std::string gestureType = gestureNode.attribute("type").value(); const std::string fingers = gestureNode.attribute("fingers").value(); const std::string direction = gestureNode.attribute("direction").value(); + const std::string axis = gestureNode.attribute("axis").value(); pugi::xml_node actionNode = gestureNode.child("action"); const std::string actionType = actionNode.attribute("type").value(); @@ -116,8 +117,8 @@ void XmlConfigLoader::parseApplicationXmlNodes(const pugi::xml_node &rootNode) { for (const std::string &application : applications) { this->config->saveGestureConfig( trim(application), gestureTypeFromStr(gestureType), fingers, - gestureDirectionFromStr(direction), actionTypeFromStr(actionType), - actionSettings); + gestureDirectionFromStr(direction), gestureAxisFromStr(axis), + actionTypeFromStr(actionType), actionSettings); } } } diff --git a/src/daemon/daemon-client.cpp b/src/daemon/daemon-client.cpp index 2f8d25a9..c5f768cf 100644 --- a/src/daemon/daemon-client.cpp +++ b/src/daemon/daemon-client.cpp @@ -122,15 +122,16 @@ std::unique_ptr DaemonClient::makeGestureFromSignalParams( GVariant *signalParameters) { GestureType type = GestureType::NOT_SUPPORTED; GestureDirection direction = GestureDirection::UNKNOWN; + GestureAxis axis = GestureAxis::UNKNOWN; double percentage = -1; int fingers = -1; DeviceType deviceType = DeviceType::UNKNOWN; uint64_t elapsedTime = -1; g_variant_get(signalParameters, // NOLINT - "(uudiut)", &type, &direction, &percentage, &fingers, + "(uuudiut)", &type, &direction, &axis, &percentage, &fingers, &deviceType, &elapsedTime); - return std::make_unique(type, direction, percentage, fingers, + return std::make_unique(type, direction, axis, percentage, fingers, deviceType, elapsedTime); } diff --git a/src/daemon/daemon-server.cpp b/src/daemon/daemon-server.cpp index 0fbb25cb..e228c6de 100644 --- a/src/daemon/daemon-server.cpp +++ b/src/daemon/daemon-server.cpp @@ -116,9 +116,10 @@ void DaemonServer::send(const std::string &signalName, // Copy every gesture field into the signal parameters for serialization GVariant *signalParams = - g_variant_new("(uudiut)", // NOLINT + g_variant_new("(uuudiut)", // NOLINT static_cast(gesture->type()), // u static_cast(gesture->direction()), // u + static_cast(gesture->axis()), // u gesture->percentage(), // d gesture->fingers(), // i static_cast(gesture->performedOnDeviceType()), // u diff --git a/src/daemon/dbus.h b/src/daemon/dbus.h index 9e9f1924..be47012f 100644 --- a/src/daemon/dbus.h +++ b/src/daemon/dbus.h @@ -38,6 +38,7 @@ constexpr auto DBUS_INTROSPECTION_XML = " " " " " " + " " " " " " " " @@ -46,6 +47,7 @@ constexpr auto DBUS_INTROSPECTION_XML = " " " " " " + " " " " " " " " @@ -54,6 +56,7 @@ constexpr auto DBUS_INTROSPECTION_XML = " " " " " " + " " " " " " " " diff --git a/src/gesture-controller/gesture-controller.cpp b/src/gesture-controller/gesture-controller.cpp old mode 100755 new mode 100644 index 5801c963..b76903a7 --- a/src/gesture-controller/gesture-controller.cpp +++ b/src/gesture-controller/gesture-controller.cpp @@ -25,6 +25,7 @@ #include "actions/action-type.h" #include "actions/action.h" #include "config/config.h" +#include "gesture/gesture-axis.h" #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" #include "gesture/gesture.h" @@ -36,12 +37,18 @@ GestureController::GestureController(const Config &config, : config(config), windowSystem(windowSystem) {} void GestureController::onGestureBegin(std::unique_ptr gesture) { + // Deduce axis from direction when possible + if (gesture->axis() == GestureAxis::UNKNOWN) { + gesture->setAxis(gestureAxisFromDirection(gesture->direction())); + } + tlg::debug << "Gesture begin detected" << std::endl; tlg::debug << "\tGesture information:" << std::endl; tlg::debug << "\t\tFingers: " << gesture->fingers() << std::endl; tlg::debug << "\t\tType: " << gestureTypeToStr(gesture->type()) << std::endl; tlg::debug << "\t\tDirection: " << gestureDirectionToStr(gesture->direction()) << std::endl; + tlg::debug << "\t\tAxis: " << gestureAxisToStr(gesture->axis()) << std::endl; this->rotatedDirection = this->windowSystem.calculateRotation( gesture->type(), gesture->performedOnDeviceType(), gesture->direction()); @@ -49,6 +56,7 @@ void GestureController::onGestureBegin(std::unique_ptr gesture) { tlg::debug << "\t\tDirection after rotation: " << gestureDirectionToStr(this->rotatedDirection) << std::endl; gesture->setDirection(this->rotatedDirection); + gesture->setAxis(gestureAxisFromDirection(this->rotatedDirection)); } this->window = this->windowSystem.getWindowUnderCursor(); @@ -102,18 +110,19 @@ std::unique_ptr GestureController::getActionForGesture( const GestureType gestureType = gesture.type(); int fingers = gesture.fingers(); const GestureDirection direction = gesture.direction(); + const GestureAxis axis = gesture.axis(); // First check if there is an specific application gesture application = this->windowSystem.getWindowClassName(window); tlg::debug << "\tGesture performed on app: " << application << std::endl; hasAction = this->config.hasGestureConfig(application, gestureType, fingers, - direction); + direction, axis); // If no gesture was configured, check the global gestures if (!hasAction) { application = "All"; hasAction = this->config.hasGestureConfig(application, gestureType, fingers, - direction); + direction, axis); } if (!hasAction) { @@ -124,7 +133,7 @@ std::unique_ptr GestureController::getActionForGesture( tlg::debug << "\tAction configured for this gesture" << std::endl; auto pair = this->config.getGestureConfig(application, gestureType, fingers, - direction); + direction, axis); ActionType actionType = pair.first; std::unordered_map actionSettings = pair.second; diff --git a/src/gesture-controller/gesture-controller.h b/src/gesture-controller/gesture-controller.h old mode 100755 new mode 100644 index e9dc6bdc..1af51d86 --- a/src/gesture-controller/gesture-controller.h +++ b/src/gesture-controller/gesture-controller.h @@ -60,10 +60,11 @@ class GestureController : public GestureControllerDelegate { bool executeAction = false; /** - * If the screen is rotated, this values is set on gesture begin to match the - * screen rotation. + * If the screen is rotated, these values are set on gesture begin to match + * the screen rotation. */ GestureDirection rotatedDirection = GestureDirection::UNKNOWN; + GestureAxis rotatedAxis = GestureAxis::UNKNOWN; /** * @returns The action associated to a gesture or nullptr. diff --git a/src/gesture-gatherer/libinput-handler.cpp b/src/gesture-gatherer/libinput-handler.cpp index f09a22b8..d6623b58 100644 --- a/src/gesture-gatherer/libinput-handler.cpp +++ b/src/gesture-gatherer/libinput-handler.cpp @@ -58,6 +58,12 @@ GestureDirection LininputHandler::calculateSwipeDirection(double deltaX, return (deltaY > 0) ? GestureDirection::DOWN : GestureDirection::UP; } +GestureAxis LininputHandler::calculatePinchAxis(double deltaX, + double deltaY) { + return (std::abs(deltaX) > std::abs(deltaY)) ? + GestureAxis::HORIZONTAL : GestureAxis::VERTICAL; +} + double LininputHandler::calculateSwipeAnimationPercentage( const LibinputDeviceInfo &info, GestureDirection direction, double deltaX, double deltaY) { diff --git a/src/gesture-gatherer/libinput-handler.h b/src/gesture-gatherer/libinput-handler.h index bf7ac02a..0d82d600 100644 --- a/src/gesture-gatherer/libinput-handler.h +++ b/src/gesture-gatherer/libinput-handler.h @@ -54,6 +54,11 @@ class LininputHandler { */ static GestureDirection calculateSwipeDirection(double deltaX, double deltaY); + /** + * @returns The primary axis of a pinch gesture. + */ + static GestureAxis calculatePinchAxis(double deltaX, double deltaY); + /** * @returns The percentage (between 0 and 100) of the gesture animation. */ diff --git a/src/gesture-gatherer/libinput-pinch-handler.cpp b/src/gesture-gatherer/libinput-pinch-handler.cpp index 189fd8d6..bdbbc01d 100644 --- a/src/gesture-gatherer/libinput-pinch-handler.cpp +++ b/src/gesture-gatherer/libinput-pinch-handler.cpp @@ -22,8 +22,19 @@ #include "gesture/device-type.h" -void LininputPinchHandler::handlePinchBegin(struct libinput_event * /*event*/) { +void LininputPinchHandler::handlePinchBegin(struct libinput_event *event) { this->state.reset(); + + struct libinput_event_gesture *gestureEvent = + libinput_event_get_gesture_event(event); + if ( + std::abs(libinput_event_gesture_get_dx(gestureEvent)) + > std::abs(libinput_event_gesture_get_dy(gestureEvent)) + ) { + this->state.axis = GestureAxis::HORIZONTAL; + } else { + this->state.axis = GestureAxis::VERTICAL; + } } void LininputPinchHandler::handlePinchUpdate(struct libinput_event *event) { @@ -36,14 +47,19 @@ void LininputPinchHandler::handlePinchUpdate(struct libinput_event *event) { this->state.startTimestamp = LininputHandler::getTimestamp(); this->state.direction = (this->state.delta > 1) ? GestureDirection::OUT : GestureDirection::IN; + this->state.axis = (std::abs(libinput_event_gesture_get_dx(gestureEvent)) > + std::abs(libinput_event_gesture_get_dy(gestureEvent))) + ? GestureAxis::HORIZONTAL + : GestureAxis::VERTICAL; this->state.percentage = LininputHandler::calculatePinchAnimationPercentage( this->state.direction, this->state.delta); this->state.fingers = libinput_event_gesture_get_finger_count(gestureEvent); uint64_t elapsedTime = 0; auto gesture = std::make_unique( - GestureType::PINCH, this->state.direction, this->state.percentage, - this->state.fingers, DeviceType::TOUCHPAD, elapsedTime); + GestureType::PINCH, this->state.direction, this->state.axis, + this->state.percentage, this->state.fingers, DeviceType::TOUCHPAD, + elapsedTime); this->gestureController->onGestureBegin(std::move(gesture)); } else { this->state.percentage = LininputHandler::calculatePinchAnimationPercentage( @@ -52,8 +68,9 @@ void LininputPinchHandler::handlePinchUpdate(struct libinput_event *event) { LininputHandler::calculateElapsedTime(this->state.startTimestamp); auto gesture = std::make_unique( - GestureType::PINCH, this->state.direction, this->state.percentage, - this->state.fingers, DeviceType::TOUCHPAD, elapsedTime); + GestureType::PINCH, this->state.direction, this->state.axis, + this->state.percentage, this->state.fingers, DeviceType::TOUCHPAD, + elapsedTime); this->gestureController->onGestureUpdate(std::move(gesture)); } } @@ -69,8 +86,9 @@ void LininputPinchHandler::handlePinchEnd(struct libinput_event *event) { LininputHandler::calculateElapsedTime(this->state.startTimestamp); auto gesture = std::make_unique( - GestureType::PINCH, this->state.direction, this->state.percentage, - this->state.fingers, DeviceType::TOUCHPAD, elapsedTime); + GestureType::PINCH, this->state.direction, this->state.axis, + this->state.percentage, this->state.fingers, DeviceType::TOUCHPAD, + elapsedTime); this->gestureController->onGestureEnd(std::move(gesture)); } diff --git a/src/gesture-gatherer/libinput-pinch-handler.h b/src/gesture-gatherer/libinput-pinch-handler.h index 78a7a428..16a1a986 100644 --- a/src/gesture-gatherer/libinput-pinch-handler.h +++ b/src/gesture-gatherer/libinput-pinch-handler.h @@ -32,6 +32,7 @@ struct LibinputPinchState { uint64_t startTimestamp = 0; double delta = 1; GestureDirection direction = GestureDirection::UNKNOWN; + GestureAxis axis = GestureAxis::UNKNOWN; double percentage = 0; int fingers = 0; @@ -40,6 +41,7 @@ struct LibinputPinchState { startTimestamp = 0; delta = 1; direction = GestureDirection::UNKNOWN; + axis = GestureAxis::UNKNOWN; percentage = 0; fingers = 0; } diff --git a/src/gesture-gatherer/libinput-touch-handler.cpp b/src/gesture-gatherer/libinput-touch-handler.cpp index 2f8b3837..d35fae41 100644 --- a/src/gesture-gatherer/libinput-touch-handler.cpp +++ b/src/gesture-gatherer/libinput-touch-handler.cpp @@ -124,10 +124,12 @@ void LibinputTouchHandler::handleTouchMotion(struct libinput_event *event) { this->state.startFingers = this->state.currentFingers; this->state.startTimestamp = LininputHandler::getTimestamp(); this->state.type = this->getGestureType(); - this->state.direction = - (this->state.type == GestureType::SWIPE) - ? LininputHandler::calculateSwipeDirection(deltaX, deltaY) - : this->calculatePinchDirection(); + if (this->state.type == GestureType::SWIPE) { + this->state.direction = LininputHandler::calculateSwipeDirection(deltaX, deltaY); + } else { + this->state.direction = this->calculatePinchDirection(); + this->state.axis = this->calculatePinchAxis(deltaX, deltaY); + } // Once the direction is calculated, save the currentX/Y as startX/Y so // the startThreshold is not included in the percentage calculations @@ -136,8 +138,9 @@ void LibinputTouchHandler::handleTouchMotion(struct libinput_event *event) { this->state.startY = this->state.currentY; auto gesture = std::make_unique( - this->state.type, this->state.direction, percentage, - this->state.startFingers, DeviceType::TOUCHSCREEN, 0); + this->state.type, this->state.direction, this->state.axis, + percentage, this->state.startFingers, DeviceType::TOUCHSCREEN, + 0); this->gestureController->onGestureBegin(std::move(gesture)); } } else { diff --git a/src/gesture-gatherer/libinput-touch-handler.h b/src/gesture-gatherer/libinput-touch-handler.h index ccd5333f..daf1be38 100644 --- a/src/gesture-gatherer/libinput-touch-handler.h +++ b/src/gesture-gatherer/libinput-touch-handler.h @@ -22,6 +22,7 @@ #include #include "gesture-gatherer/libinput-handler.h" +#include "gesture/gesture-axis.h" #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" @@ -32,6 +33,7 @@ struct LibinputTouchState { bool started = false; GestureType type = GestureType::NOT_SUPPORTED; GestureDirection direction = GestureDirection::UNKNOWN; + GestureAxis axis = GestureAxis::UNKNOWN; uint64_t startTimestamp = 0; int startFingers = 0; std::unordered_map startX; @@ -45,6 +47,7 @@ struct LibinputTouchState { started = false; type = GestureType::NOT_SUPPORTED; direction = GestureDirection::UNKNOWN; + axis = GestureAxis::UNKNOWN; startTimestamp = 0; startFingers = 0; tapFingers = 0; diff --git a/src/gesture/gesture-axis.h b/src/gesture/gesture-axis.h new file mode 100644 index 00000000..f7b84579 --- /dev/null +++ b/src/gesture/gesture-axis.h @@ -0,0 +1,77 @@ +/** + * Copyright 2011 - 2022 José Expósito + * + * This file is part of Touchégg. + * + * Touchégg is free software: you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * Touchégg is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Touchégg. If not, see . + */ +#ifndef GESTURE_GESTURE_AXIS_H_ +#define GESTURE_GESTURE_AXIS_H_ + +#include +#include "gesture-direction.h" + +enum class GestureAxis { + // A gesture may have an unknown axis until we have more information + UNKNOWN = 0, + + HORIZONTAL = 1, + VERTICAL = 2 + // DISTAL = 3 + + // Adding a new GestureDirection? Don't forget to add it in + // gestureAxisToStr and gestureAxisFromStr as well +}; + +inline std::string gestureAxisToStr(GestureAxis gestureAxis) { + switch (gestureAxis) { + case GestureAxis::HORIZONTAL: + return "HORIZONTAL"; + case GestureAxis::VERTICAL: + return "VERTICAL"; + // case GestureAxis::DISTAL: + // return "DISTAL"; + default: + return "UNKNOWN"; + } +} + +inline GestureAxis gestureAxisFromStr(const std::string &str) { + if (str == "HORIZONTAL") { + return GestureAxis::HORIZONTAL; + } + if (str == "VERTICAL") { + return GestureAxis::VERTICAL; + } + // if (str == "DISTAL") { + // return GestureAxis::DISTAL; + // } + return GestureAxis::UNKNOWN; +} + +inline GestureAxis gestureAxisFromDirection(GestureDirection gestureDirection) { + switch (gestureDirection) { + case GestureDirection::UP: + return GestureAxis::VERTICAL; + case GestureDirection::DOWN: + return GestureAxis::VERTICAL; + case GestureDirection::LEFT: + return GestureAxis::HORIZONTAL; + case GestureDirection::RIGHT: + return GestureAxis::HORIZONTAL; + default: + return GestureAxis::UNKNOWN; + } +} + +#endif // GESTURE_GESTURE_AXIS_H_ diff --git a/src/gesture/gesture.h b/src/gesture/gesture.h index 8a7e320d..57446405 100644 --- a/src/gesture/gesture.h +++ b/src/gesture/gesture.h @@ -21,6 +21,7 @@ #include #include "gesture/device-type.h" +#include "gesture/gesture-axis.h" #include "gesture/gesture-direction.h" #include "gesture/gesture-type.h" @@ -34,6 +35,17 @@ class Gesture { int fingers, DeviceType performedOnDeviceType, uint64_t elapsedTime) : gestureType(type), gestureDirection(direction), + gestureAxis(gestureAxisFromDirection(direction)), + gesturePercentage(percentage), + gestureFingers(fingers), + deviceType(performedOnDeviceType), + gestureElapsedTime(elapsedTime) {} + Gesture(GestureType type, GestureDirection direction, GestureAxis axis, + double percentage, int fingers, DeviceType performedOnDeviceType, + uint64_t elapsedTime) + : gestureType(type), + gestureDirection(direction), + gestureAxis(axis), gesturePercentage(percentage), gestureFingers(fingers), deviceType(performedOnDeviceType), @@ -51,6 +63,12 @@ class Gesture { */ GestureDirection direction() const { return this->gestureDirection; } + /** + * @returns The gesture axis. + * @see GestureAxis + */ + GestureAxis axis() const { return this->gestureAxis; } + /** * Percentage of the gesture performed, used for animations. * @return Value between 0 and 100. @@ -81,9 +99,16 @@ class Gesture { this->gestureDirection = direction; } + /** + * Set the gesture axis. + * @see GestureAxis + */ + void setAxis(GestureAxis axis) { this->gestureAxis = axis; } + protected: GestureType gestureType = GestureType::NOT_SUPPORTED; GestureDirection gestureDirection = GestureDirection::UNKNOWN; + GestureAxis gestureAxis = GestureAxis::UNKNOWN; double gesturePercentage = -1; int gestureFingers = -1; DeviceType deviceType = DeviceType::UNKNOWN;