implement canvas touch lock

This commit is contained in:
2017-08-19 13:18:35 +01:00
parent ac3857b697
commit da4bfff69b
12 changed files with 56 additions and 27 deletions

View File

@@ -115,7 +115,8 @@ glm::vec2 t_pos;
CGPoint touchLocation = [touch locationInView:self.view];
float scale = self.view.contentScaleFactor;
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, touch.force);
kEventSource source = touch.type == UITouchType::UITouchTypeStylus ? kEventSource::Stylus : kEventSource::Touch;
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, touch.force, source);
t_count = 1;
t_pos = {touchLocation.x * scale, touchLocation.y * scale};
}
@@ -162,7 +163,8 @@ glm::vec2 t_pos;
}
else
{
App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale, force);
kEventSource source = touch.type == UITouchType::UITouchTypeStylus ? kEventSource::Stylus : kEventSource::Touch;
App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale, force, source);
}
}
t_pos = {tl0.x * scale, tl0.y * scale};
@@ -172,11 +174,13 @@ glm::vec2 t_pos;
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
float scale = self.view.contentScaleFactor;
kEventSource source = touch.type == UITouchType::UITouchTypeStylus ? kEventSource::Stylus : kEventSource::Touch;
if (t_count == 2)
App::I.gesture_end();
else
App::I.mouse_up(0, touchLocation.x * scale, touchLocation.y * scale);
App::I.mouse_up(0, touchLocation.x * scale, touchLocation.y * scale, source);
t_count = 0;
t_pos = {touchLocation.x * scale, touchLocation.y * scale};
}