Bootstrap pinch gesture

This commit is contained in:
Rico Tiongson 2019-02-12 21:39:53 +08:00
parent 0fdf94b723
commit a47c7f8115
7 changed files with 41 additions and 13 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
# C++ generated headers
*.gch
# IDE-specific
.vscode

View File

@ -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"

View File

@ -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;
}
}
}

View File

@ -21,6 +21,8 @@ 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
{
/**

View File

@ -19,6 +19,8 @@ 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
{
/**

View File

@ -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

View File

@ -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());
}
}
}