mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2025-01-31 21:32:46 +00:00
handle hardware mouse in trackpad mode
This commit is contained in:
parent
5ab79e73e2
commit
ddfe6201a6
@ -45,7 +45,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isMouseEvent:(UIEvent *)event {
|
||||
#if __IPHONE_13_4
|
||||
if (@available(iOS 13.4, *)) {
|
||||
return event.buttonMask != 0;
|
||||
}
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
if ([self isMouseEvent:event]) {
|
||||
[self startDragging];
|
||||
return;
|
||||
}
|
||||
|
||||
[currentTouches unionSet:touches];
|
||||
if (currentTouches.count == 1) {
|
||||
[self firstTouchBegan:touches.anyObject withEvent:event];
|
||||
@ -67,6 +81,7 @@
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
if ([self isMouseEvent:event]) return;
|
||||
UITouch *touch = touches.anyObject;
|
||||
CGPoint touchLoc = [touch locationInView:self];
|
||||
previousTouchLoc = [touch previousLocationInView:self];
|
||||
@ -91,6 +106,10 @@
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
if ([self isMouseEvent:event]) {
|
||||
[self stopDragging];
|
||||
return;
|
||||
}
|
||||
[currentTouches minusSet:touches];
|
||||
if (currentTouches.count > 0) {
|
||||
return;
|
||||
|
@ -147,8 +147,10 @@ API_AVAILABLE(ios(13.4))
|
||||
|
||||
#ifdef __IPHONE_13_4
|
||||
if (@available(iOS 13.4, *)) {
|
||||
interaction = [[UIPointerInteraction alloc] initWithDelegate: self];
|
||||
[self.view addInteraction:interaction];
|
||||
if (interaction == nil) {
|
||||
interaction = [[UIPointerInteraction alloc] initWithDelegate: self];
|
||||
[self.view addInteraction:interaction];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user