diff --git a/.gitignore b/.gitignore
index 4753a05..50ab143 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
# C++ generated headers
*.gch
+
+# IDE-specific
+.vscode
diff --git a/lib/comfortable_swipe b/lib/comfortable_swipe
index 3316ca4..97db145 100644
--- a/lib/comfortable_swipe
+++ b/lib/comfortable_swipe
@@ -28,6 +28,8 @@ along with this program. If not, see .
#include "gesture/xdo_gesture.cpp"
#include "gesture/swipe_gesture.cpp"
#include "gesture/swipe_gesture.regex.cpp"
+#include "gesture/pinch_gesture.cpp"
+#include "gesture/pinch_gesture.regex.cpp"
#include "service/autostart.cpp"
#include "service/buffer.cpp"
#include "service/debug.cpp"
diff --git a/lib/gesture/pinch_gesture.cpp b/lib/gesture/pinch_gesture.cpp
index f32f144..8f4ab8b 100644
--- a/lib/gesture/pinch_gesture.cpp
+++ b/lib/gesture/pinch_gesture.cpp
@@ -80,11 +80,21 @@ namespace comfortable_swipe::gesture
const float EPSILON = this->threshold;
if (delta_radius > EPSILON)
{
- // TODO: pinch out
+ if (this->previous_gesture != 0)
+ {
+ // TODO
+ std::cout << "PINCH OUT" << std::endl;
+ this->previous_gesture = 0;
+ }
}
else if (delta_radius < -EPSILON)
{
- // TODO: pinch in
+ if (this->previous_gesture != 1)
+ {
+ // TODO
+ std::cout << "PINCH IN" << std::endl;
+ this->previous_gesture = 1;
+ }
}
}
diff --git a/lib/gesture/pinch_gesture.regex.cpp b/lib/gesture/pinch_gesture.regex.cpp
index 271a09d..71bce84 100644
--- a/lib/gesture/pinch_gesture.regex.cpp
+++ b/lib/gesture/pinch_gesture.regex.cpp
@@ -21,12 +21,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+#include "pinch_gesture.h"
+
namespace comfortable_swipe::gesture
{
/**
* Regex pattern for the libinput entry for start of pinch.
* Extracts one match for the number of fingers used during the pionch.
- *
+ *
* eg. event15 GESTURE_PINCH_BEGIN +34.33s 3
* ^
* fingers
@@ -43,7 +45,7 @@ namespace comfortable_swipe::gesture
/**
* Regex pattern for the libinput entry for the end of swipe.
* Extracts one match for the number of fingers used during the swipe.
- *
+ *
* eg. event15 GESTURE_PINCH_END +35.03s 3
* ^
* fingers
@@ -67,7 +69,7 @@ namespace comfortable_swipe::gesture
* Regex pattern for the libinput entry for during a pinch.
* Extracts number of fingers used and the speed (normal and accelerated) of the pinch.
* Extracts radius and rotational velocity of the pinch motion as well.
- *
+ *
* eg. event8 GESTURE_PINCH_UPDATE +128.15s 3 -1.64/ 2.08 (-4.43/ 5.62 unaccelerated) 1.40 @ -0.14
* ^ ^ ^ ^ ^ ^ ^
* fingers dx dy udx udy radius omega
diff --git a/lib/gesture/swipe_gesture.regex.cpp b/lib/gesture/swipe_gesture.regex.cpp
index a39fbeb..7dd1d04 100644
--- a/lib/gesture/swipe_gesture.regex.cpp
+++ b/lib/gesture/swipe_gesture.regex.cpp
@@ -19,12 +19,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+#include "swipe_gesture.h"
+
namespace comfortable_swipe::gesture
{
/**
* Regex pattern for the libinput entry for start of swipe.
* Extracts one match for the number of fingers used during the swipe.
- *
+ *
* eg. event15 GESTURE_SWIPE_BEGIN +34.33s 3
* ^
* fingers
@@ -41,7 +43,7 @@ namespace comfortable_swipe::gesture
/**
* Regex pattern for the libinput entry for the end of swipe.
* Extracts one match for the number of fingers used during the swipe.
- *
+ *
* eg. event15 GESTURE_SWIPE_END +35.03s 3
* ^
* fingers
@@ -64,7 +66,7 @@ namespace comfortable_swipe::gesture
/**
* Regex pattern for the libinput entry for during a swipe.
* Extracts number of fingers used and the speed (normal and accelerated) of the swipe.
- *
+ *
* eg. event15 GESTURE_SWIPE_UPDATE +34.70s 3 -0.12/ 4.99 (-0.33/13.50 unaccelerated)
* ^ ^ ^ ^ ^
* fingers dx dy udx udy
diff --git a/lib/index.hpp b/lib/index.hpp
index 21a36a7..7e92ad1 100644
--- a/lib/index.hpp
+++ b/lib/index.hpp
@@ -36,6 +36,7 @@ along with this program. If not, see .
*/
#include "gesture/xdo_gesture.h"
#include "gesture/swipe_gesture.h"
+#include "gesture/pinch_gesture.h"
extern "C"
{
namespace comfortable_swipe
diff --git a/lib/service/buffer.cpp b/lib/service/buffer.cpp
index 14b421a..5cda2e5 100644
--- a/lib/service/buffer.cpp
+++ b/lib/service/buffer.cpp
@@ -46,15 +46,23 @@ namespace comfortable_swipe::service
config["down4"].c_str()
);
+ comfortable_swipe::gesture::pinch_gesture pinch_gesture_handler
+ (
+ config.count("threshold") ? std::stof(config["threshold"]) : 0.0,
+ config["pinch_in3"].c_str(),
+ config["pinch_in4"].c_str(),
+ config["pinch_out3"].c_str(),
+ config["pinch_out4"].c_str()
+ );
+
// prepare data containers
- static const int MAX_LINE_LENGTH = 256;
- static char data[MAX_LINE_LENGTH];
+ std::array line;
// start reading lines from input one by one
- while (fgets_unlocked(data, MAX_LINE_LENGTH, stdin) != NULL)
+ while (fgets_unlocked(line.data(), line.size(), stdin) != NULL)
{
- // attempt to parse swipe gestures
- swipe_gesture_handler.parse_line(data);
+ swipe_gesture_handler.parse_line(line.data()) ||
+ pinch_gesture_handler.parse_line(line.data());
}
}
}