variables["DOUBLE_TAP"] = generateTapFunction(2);
variables["TRIPLE_TAP"] = generateTapFunction(3);
- auto generateFlickFunction = [&](int dx, int dy, int steps) {
- return EvaluationValueFunction{ [ &, dx, dy, steps](EvaluationValue fingers) -> EvaluationValue {
+ enum class FlickKind {
+ down, up, left, right
+ };
+ auto generateFlickFunction = [&](FlickKind kind, int steps) {
+ return EvaluationValueFunction{ [ &, kind, steps](EvaluationValue fingers) -> EvaluationValue {
+ int dx, dy;
+ auto size = executeOnMainThread([&]()
+ {
+ return Singleton<UniversalSwitch>::instance().getMainWindow()->getDimensions().size;
+ });
+
+ // 280 = 360 - 2 * 40 ( 40 - left margin to emulate regular flick but not flick from side of the screen )
+ // 250 = 360 - 2 * 55 ( 55 - top margin to emulate regular flick but not flick from side of the screen )
+ // 360 x 360 - dimensions of wearable screen
+ auto width = size.width * 280 / 360;
+ auto height = size.height * 250 / 360;
+
+ switch (kind)
+ {
+ case FlickKind::right:
+ dx = width;
+ dy = 0;
+ break;
+ case FlickKind::left:
+ dx = -width;
+ dy = 0;
+ break;
+ case FlickKind::up:
+ dx = 0;
+ dy = -height;
+ break;
+ case FlickKind::down:
+ dx = 0;
+ dy = height;
+ break;
+ }
auto root = getVisibleRoot();
if (!root) throw EvaluationFailure{} << "no visible root (context changed didn't happen)";
ASSERT(root->getObject());
}, { { "fingers", 1 } } };
};
- auto size = Singleton<UniversalSwitch>::instance().getMainWindow()->getDimensions().size;
-
- // 280 = 360 - 2 * 40 ( 40 - left margin to emulate regular flick but not flick from side of the screen )
- // 250 = 360 - 2 * 55 ( 55 - top margin to emulate regular flick but not flick from side of the screen )
- // 360 x 360 - dimensions of wearable screen
- auto width = size.width * 280 / 360;
- auto height = size.height * 250 / 360;
-
// For flick gesture we set the step value to 20.
- variables["FLICK_RIGHT"] = generateFlickFunction(width, 0, 20);
- variables["FLICK_LEFT"] = generateFlickFunction(-width, 0, 20);
- variables["FLICK_UP"] = generateFlickFunction(0, -height, 20);
- variables["FLICK_DOWN"] = generateFlickFunction(0, height, 20);
+ variables["FLICK_RIGHT"] = generateFlickFunction(FlickKind::right, 20);
+ variables["FLICK_LEFT"] = generateFlickFunction(FlickKind::left, 20);
+ variables["FLICK_UP"] = generateFlickFunction(FlickKind::up, 20);
+ variables["FLICK_DOWN"] = generateFlickFunction(FlickKind::down, 20);
// For drag gesture we set the step value to 60.
- variables["DRAG_RIGHT"] = generateFlickFunction(width, 0, 60);
- variables["DRAG_LEFT"] = generateFlickFunction(-width, 0, 60);
- variables["DRAG_UP"] = generateFlickFunction(0, -height, 60);
- variables["DRAG_DOWN"] = generateFlickFunction(0, height, 60);
+ variables["DRAG_RIGHT"] = generateFlickFunction(FlickKind::right, 60);
+ variables["DRAG_LEFT"] = generateFlickFunction(FlickKind::left, 60);
+ variables["DRAG_UP"] = generateFlickFunction(FlickKind::up, 60);
+ variables["DRAG_DOWN"] = generateFlickFunction(FlickKind::down, 60);
auto generateWheelTurnFunction = [&]() {
return EvaluationValueFunction{ [&](bool clockwise, int multiplicity) -> EvaluationValue {