fix SonarPen for iOS
This commit is contained in:
@@ -341,12 +341,20 @@ std::set<UITouch*> ignored_touch;
|
||||
|
||||
CGPoint touchLocation = [touch locationInView:self.view];
|
||||
float scale = self.view.contentScaleFactor;
|
||||
|
||||
float force = touch.force;
|
||||
AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
||||
if ([app sonarpen_present])
|
||||
force = [app sonarpen_pressure];
|
||||
|
||||
kEventSource source = ((touch.type == UITouchType::UITouchTypeStylus) || [app sonarpen_present]) ?
|
||||
kEventSource::Stylus : kEventSource::Touch;
|
||||
|
||||
kEventSource source = touch.type == UITouchType::UITouchTypeStylus ? kEventSource::Stylus : kEventSource::Touch;
|
||||
if (source == kEventSource::Stylus)
|
||||
// apple pencil
|
||||
if (touch.type == UITouchType::UITouchTypeStylus)
|
||||
pen_down = true;
|
||||
|
||||
App::I->ui_task_async([touchLocation, scale, f=touch.force, source] {
|
||||
App::I->ui_task_async([touchLocation, scale, f=force, source] {
|
||||
App::I->mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, f, source, 0);
|
||||
});
|
||||
t_count = 1;
|
||||
@@ -394,7 +402,7 @@ std::set<UITouch*> ignored_touch;
|
||||
App::I->ui_task_async([tt0=t0.type,tt1=t1.type,p0,p1,f0=t0.force,f1=t1.force] {
|
||||
if (tt0 == UITouchType::UITouchTypeStylus)
|
||||
App::I->mouse_move(p0.x, p0.y, f0, kEventSource::Stylus, 0);
|
||||
if (tt1 == UITouchType::UITouchTypeStylus)
|
||||
else if (tt1 == UITouchType::UITouchTypeStylus)
|
||||
App::I->mouse_move(p1.x, p1.y, f1, kEventSource::Stylus, 0);
|
||||
});
|
||||
}
|
||||
@@ -416,8 +424,9 @@ std::set<UITouch*> ignored_touch;
|
||||
UITouch *touch = valid_touches[0];
|
||||
CGPoint touchLocation = [touch locationInView:self.view];
|
||||
float force = touch.type == UITouchType::UITouchTypeStylus ? touch.force : 1.0f;
|
||||
//AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
||||
//force = [app sonarpen_pressure];
|
||||
AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
||||
if ([app sonarpen_present])
|
||||
force = [app sonarpen_pressure];
|
||||
if (t_count == 2)
|
||||
{
|
||||
//App::I->gesture_end();
|
||||
@@ -425,7 +434,8 @@ std::set<UITouch*> ignored_touch;
|
||||
}
|
||||
else
|
||||
{
|
||||
kEventSource source = touch.type == UITouchType::UITouchTypeStylus ? kEventSource::Stylus : kEventSource::Touch;
|
||||
kEventSource source = ((touch.type == UITouchType::UITouchTypeStylus) || [app sonarpen_present]) ?
|
||||
kEventSource::Stylus : kEventSource::Touch;
|
||||
App::I->ui_task_async([touchLocation, scale, source, force] {
|
||||
App::I->mouse_move(touchLocation.x * scale, touchLocation.y * scale, force, source, 0);
|
||||
});
|
||||
@@ -480,6 +490,7 @@ std::set<UITouch*> ignored_touch;
|
||||
input_enabled = NO;
|
||||
App::I = new App;
|
||||
App::I->ios_view = self;
|
||||
App::I->ios_app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
||||
App::I->initLog();
|
||||
|
||||
//self.preferredFramesPerSecond = 60;
|
||||
|
||||
Reference in New Issue
Block a user