Bootstrap pinch gesture
This commit is contained in:
parent
0fdf94b723
commit
a47c7f8115
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
# C++ generated headers
|
||||
*.gch
|
||||
|
||||
# IDE-specific
|
||||
.vscode
|
||||
|
||||
@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#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"
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,12 +21,14 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
@ -19,12 +19,14 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "gesture/xdo_gesture.h"
|
||||
#include "gesture/swipe_gesture.h"
|
||||
#include "gesture/pinch_gesture.h"
|
||||
extern "C"
|
||||
{
|
||||
namespace comfortable_swipe
|
||||
|
||||
@ -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<char, 256> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user