Allow not capture mouse
This commit is contained in:
1 parent
589ca19e4f
commit
62ae63d7f6
17 files changed
+327
-22
No files matched your search
@@ -46,6 +46,7 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
char _controllerNumbers;
|
||||
bool _multiController;
|
||||
bool _swapABXYButtons;
|
||||
bool _captureMouse;
|
||||
}
|
||||
|
||||
// UPDATE_BUTTON_FLAG(controller, flag, pressed)
|
||||
@@ -864,20 +865,25 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
|
||||
-(void) registerMouseCallbacks:(GCMouse*) mouse API_AVAILABLE(ios(14.0)) {
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float deltaX, float deltaY) {
|
||||
self->accumulatedDeltaX += deltaX / MOUSE_SPEED_DIVISOR;
|
||||
self->accumulatedDeltaY += -deltaY / MOUSE_SPEED_DIVISOR;
|
||||
|
||||
short truncatedDeltaX = (short)self->accumulatedDeltaX;
|
||||
short truncatedDeltaY = (short)self->accumulatedDeltaY;
|
||||
|
||||
if (truncatedDeltaX != 0 || truncatedDeltaY != 0) {
|
||||
LiSendMouseMoveEvent(truncatedDeltaX, truncatedDeltaY);
|
||||
if (_captureMouse){
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float deltaX, float deltaY) {
|
||||
self->accumulatedDeltaX += deltaX / MOUSE_SPEED_DIVISOR;
|
||||
self->accumulatedDeltaY += -deltaY / MOUSE_SPEED_DIVISOR;
|
||||
|
||||
self->accumulatedDeltaX -= truncatedDeltaX;
|
||||
self->accumulatedDeltaY -= truncatedDeltaY;
|
||||
}
|
||||
};
|
||||
short truncatedDeltaX = (short)self->accumulatedDeltaX;
|
||||
short truncatedDeltaY = (short)self->accumulatedDeltaY;
|
||||
|
||||
if (truncatedDeltaX != 0 || truncatedDeltaY != 0) {
|
||||
LiSendMouseMoveEvent(truncatedDeltaX, truncatedDeltaY);
|
||||
|
||||
self->accumulatedDeltaX -= truncatedDeltaX;
|
||||
self->accumulatedDeltaY -= truncatedDeltaY;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
mouse.mouseInput.mouseMovedHandler = nil;
|
||||
}
|
||||
|
||||
|
||||
mouse.mouseInput.leftButton.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
LiSendMouseButtonEvent(pressed ? BUTTON_ACTION_PRESS : BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||
@@ -1120,6 +1126,7 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
}
|
||||
|
||||
_captureMouse = (streamConfig.mouseMode == 0);
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
for (GCMouse* mouse in [GCMouse mice]) {
|
||||
[self registerMouseCallbacks:mouse];
|
||||
|
||||
@@ -48,6 +48,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
double accumulatedMouseDeltaX;
|
||||
double accumulatedMouseDeltaY;
|
||||
|
||||
int mouseMode;
|
||||
|
||||
UIResponder* touchHandler;
|
||||
|
||||
id<UserInteractionDelegate> interactionDelegate;
|
||||
@@ -76,6 +78,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
|
||||
settings = [[[DataManager alloc] init] getSettings];
|
||||
|
||||
mouseMode = streamConfig.mouseMode;
|
||||
|
||||
keysDown = [[NSMutableSet alloc] init];
|
||||
keyInputField = [[KeyboardInputField alloc] initWithFrame:CGRectZero];
|
||||
[keyInputField setKeyboardType:UIKeyboardTypeDefault];
|
||||
@@ -869,7 +873,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
regionForRequest:(UIPointerRegionRequest *)request
|
||||
defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)) {
|
||||
if (@available(iOS 14.0, *)) {
|
||||
if ([GCMouse current] != nil) {
|
||||
if ([GCMouse current] != nil && mouseMode == 0) {
|
||||
// We'll handle this with GCMouse. Do nothing here.
|
||||
return nil;
|
||||
}
|
||||
@@ -897,8 +901,11 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
}
|
||||
|
||||
- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)) {
|
||||
// Always hide the mouse cursor over our stream view
|
||||
return [UIPointerStyle hiddenPointerStyle];
|
||||
if(mouseMode != 2){
|
||||
return [UIPointerStyle hiddenPointerStyle];
|
||||
}else{
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseWheelMovedContinuous:(UIPanGestureRecognizer *)gesture {
|
||||
|
||||
Reference in new issue
Block a user