mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-08-17 16:55:38 +00:00
Don't consume stylus events unless they're supported by the host
Fixes #595
This commit is contained in:
parent
6f40922704
commit
951289a802
@ -240,9 +240,15 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
return 90 - MIN(90, altitudeDegs);
|
return 90 - MIN(90, altitudeDegs);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendStylusEvent:(UITouch*)event {
|
- (BOOL)sendStylusEvent:(UITouch*)event {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
|
|
||||||
|
// Don't touch stylus events if the host doesn't support them. We want to pass
|
||||||
|
// them as normal touches for legacy hosts that don't understand pen events.
|
||||||
|
if (!(LiGetHostFeatureFlags() & LI_FF_PEN_TOUCH_EVENTS)) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.phase) {
|
switch (event.phase) {
|
||||||
case UITouchPhaseBegan:
|
case UITouchPhaseBegan:
|
||||||
type = LI_TOUCH_EVENT_DOWN;
|
type = LI_TOUCH_EVENT_DOWN;
|
||||||
@ -257,17 +263,17 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
type = LI_TOUCH_EVENT_CANCEL;
|
type = LI_TOUCH_EVENT_CANCEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGPoint location = [self adjustCoordinatesForVideoArea:[event locationInView:self]];
|
CGPoint location = [self adjustCoordinatesForVideoArea:[event locationInView:self]];
|
||||||
CGSize videoSize = [self getVideoAreaSize];
|
CGSize videoSize = [self getVideoAreaSize];
|
||||||
|
|
||||||
LiSendPenEvent(type, LI_TOOL_TYPE_PEN, 0, location.x / videoSize.width, location.y / videoSize.height,
|
return LiSendPenEvent(type, LI_TOOL_TYPE_PEN, 0, location.x / videoSize.width, location.y / videoSize.height,
|
||||||
(event.force / event.maximumPossibleForce) / sin(event.altitudeAngle),
|
(event.force / event.maximumPossibleForce) / sin(event.altitudeAngle),
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
[self getRotationFromAzimuthAngle:[event azimuthAngleInView:self]],
|
[self getRotationFromAzimuthAngle:[event azimuthAngleInView:self]],
|
||||||
[self getTiltFromAltitudeAngle:event.altitudeAngle]);
|
[self getTiltFromAltitudeAngle:event.altitudeAngle]) != LI_ERR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)sendStylusHoverEvent:(UIHoverGestureRecognizer*)gesture API_AVAILABLE(ios(13.0)) {
|
- (void)sendStylusHoverEvent:(UIHoverGestureRecognizer*)gesture API_AVAILABLE(ios(13.0)) {
|
||||||
@ -329,8 +335,9 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
if (@available(iOS 13.4, *)) {
|
if (@available(iOS 13.4, *)) {
|
||||||
for (UITouch* touch in touches) {
|
for (UITouch* touch in touches) {
|
||||||
if (touch.type == UITouchTypePencil) {
|
if (touch.type == UITouchTypePencil) {
|
||||||
[self sendStylusEvent:touch];
|
if ([self sendStylusEvent:touch]) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -506,8 +513,9 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
if (@available(iOS 13.4, *)) {
|
if (@available(iOS 13.4, *)) {
|
||||||
for (UITouch* touch in touches) {
|
for (UITouch* touch in touches) {
|
||||||
if (touch.type == UITouchTypePencil) {
|
if (touch.type == UITouchTypePencil) {
|
||||||
[self sendStylusEvent:touch];
|
if ([self sendStylusEvent:touch]) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,8 +601,9 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
if (@available(iOS 13.4, *)) {
|
if (@available(iOS 13.4, *)) {
|
||||||
for (UITouch* touch in touches) {
|
for (UITouch* touch in touches) {
|
||||||
if (touch.type == UITouchTypePencil) {
|
if (touch.type == UITouchTypePencil) {
|
||||||
[self sendStylusEvent:touch];
|
if ([self sendStylusEvent:touch]) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user