fix framebuffer read

This commit is contained in:
2018-05-09 12:04:29 +02:00
parent af0e588a94
commit f16adb8fcc
6 changed files with 57 additions and 13 deletions

View File

@@ -188,6 +188,7 @@ NSThread* lock_thread;
t_count = 0;
}
std::set<UITouch*> ignored_touch;
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
@@ -198,6 +199,10 @@ NSThread* lock_thread;
kEventSource source = touch.type == UITouchType::UITouchTypeStylus ? kEventSource::Stylus : kEventSource::Touch;
if (source == kEventSource::Stylus)
pen_down = true;
if (touch.majorRadius > 25.f)
ignored_touch.insert(touch);
NSLog(@"touch down size %f", touch.majorRadius);
[self async_lock];
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, touch.force, source);
[self async_unlock];
@@ -209,16 +214,34 @@ NSThread* lock_thread;
NSUInteger n = [[event allTouches] count];
float scale = self.view.contentScaleFactor;
std::vector<UITouch*> valid_touches;
for (int i = 0; i < n; i++)
{
auto t = [[[event allTouches] allObjects] objectAtIndex:i];
auto it = ignored_touch.find(t);
if (it == ignored_touch.end())
{
valid_touches.push_back(t);
}
else
{
NSLog(@"ignored moved");
}
}
n = valid_touches.size();
if (n == 0)
return;
UITouch* t0 = nullptr;
UITouch* t1 = nullptr;
t0 = [[[event allTouches] allObjects] objectAtIndex:0];
t0 = valid_touches[0];
CGPoint tl0 = [t0 locationInView:self.view];
glm::vec2 p0 = glm::vec2(tl0.x * scale, tl0.y * scale);
glm::vec2 p1;
if (n > 1)
{
t1 = [[[event allTouches] allObjects] objectAtIndex:1];
t1 = valid_touches[1];
CGPoint tl1 = [t1 locationInView:self.view];
p1 = glm::vec2(tl1.x * scale, tl1.y * scale);
}
@@ -244,7 +267,7 @@ NSThread* lock_thread;
}
else if (n == 1)
{
UITouch *touch = [[event allTouches] anyObject];
UITouch *touch = valid_touches[0];
CGPoint touchLocation = [touch locationInView:self.view];
//auto p = glm::vec2(touchLocation.x * scale, touchLocation.y * scale);
float force = touch.type == UITouchType::UITouchTypeStylus ? touch.force : 1.0f;
@@ -267,6 +290,12 @@ NSThread* lock_thread;
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
float scale = self.view.contentScaleFactor;
if (ignored_touch.count(touch))
{
ignored_touch.erase(touch);
NSLog(@"remove ignored");
}
kEventSource source = touch.type == UITouchType::UITouchTypeStylus ? kEventSource::Stylus : kEventSource::Touch;
pen_down = false;