Add a flag for gesture begin to ignore unneeded update/end
This commit is contained in:
parent
46e94e99c3
commit
5df590f172
@ -231,30 +231,35 @@ namespace service {
|
|||||||
);
|
);
|
||||||
// start reading lines from input one by one
|
// start reading lines from input one by one
|
||||||
static string sentence;
|
static string sentence;
|
||||||
|
bool flag_begin = false;
|
||||||
while (getline(cin, sentence)) {
|
while (getline(cin, sentence)) {
|
||||||
auto data = sentence.data();
|
auto data = sentence.data();
|
||||||
cmatch matches;
|
cmatch matches;
|
||||||
if (regex_match(data, matches, gesture_begin)) {
|
if (!flag_begin) {
|
||||||
swipe.device = matches[1];
|
if (regex_match(data, matches, gesture_begin)) {
|
||||||
swipe.stamp = matches[2];
|
swipe.device = matches[1];
|
||||||
swipe.fingers = matches[3];
|
swipe.stamp = matches[2];
|
||||||
swipe.on_begin();
|
swipe.fingers = matches[3];
|
||||||
}
|
swipe.on_begin();
|
||||||
else if (regex_match(data, matches, gesture_end)) {
|
flag_begin = true;
|
||||||
swipe.device = matches[1];
|
}
|
||||||
swipe.stamp = matches[2];
|
} else {
|
||||||
swipe.fingers = matches[3];
|
if (regex_match(data, matches, gesture_update)) {
|
||||||
swipe.on_end();
|
swipe.device = matches[1];
|
||||||
}
|
swipe.stamp = matches[2];
|
||||||
else if (regex_match(data, matches, gesture_update)) {
|
swipe.fingers = matches[3];
|
||||||
swipe.device = matches[1];
|
swipe.dx = matches[4];
|
||||||
swipe.stamp = matches[2];
|
swipe.dy = matches[5];
|
||||||
swipe.fingers = matches[3];
|
swipe.udx = matches[6];
|
||||||
swipe.dx = matches[4];
|
swipe.udy = matches[7];
|
||||||
swipe.dy = matches[5];
|
swipe.on_update();
|
||||||
swipe.udx = matches[6];
|
} else if (regex_match(data, matches, gesture_end)) {
|
||||||
swipe.udy = matches[7];
|
swipe.device = matches[1];
|
||||||
swipe.on_update();
|
swipe.stamp = matches[2];
|
||||||
|
swipe.fingers = matches[3];
|
||||||
|
swipe.on_end();
|
||||||
|
flag_begin = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user