Add a flag for gesture begin to ignore unneeded update/end

This commit is contained in:
Rico Tiongson 2019-02-07 03:39:27 +08:00
parent 46e94e99c3
commit 5df590f172

View File

@ -231,22 +231,20 @@ namespace service {
);
// start reading lines from input one by one
static string sentence;
bool flag_begin = false;
while (getline(cin, sentence)) {
auto data = sentence.data();
cmatch matches;
if (!flag_begin) {
if (regex_match(data, matches, gesture_begin)) {
swipe.device = matches[1];
swipe.stamp = matches[2];
swipe.fingers = matches[3];
swipe.on_begin();
flag_begin = true;
}
else if (regex_match(data, matches, gesture_end)) {
swipe.device = matches[1];
swipe.stamp = matches[2];
swipe.fingers = matches[3];
swipe.on_end();
}
else if (regex_match(data, matches, gesture_update)) {
} else {
if (regex_match(data, matches, gesture_update)) {
swipe.device = matches[1];
swipe.stamp = matches[2];
swipe.fingers = matches[3];
@ -255,6 +253,13 @@ namespace service {
swipe.udx = matches[6];
swipe.udy = matches[7];
swipe.on_update();
} else if (regex_match(data, matches, gesture_end)) {
swipe.device = matches[1];
swipe.stamp = matches[2];
swipe.fingers = matches[3];
swipe.on_end();
flag_begin = false;
}
}
}
}