Add key combo support
This commit is contained in:
1 parent
62ae63d7f6
commit
a0f13881bf
4 files changed
+71
No files matched your search
@@ -248,6 +248,9 @@
|
|||||||
case UIKeyboardHIDUsageKeyboardRightAlt:
|
case UIKeyboardHIDUsageKeyboardRightAlt:
|
||||||
keyCode = 0xA5;
|
keyCode = 0xA5;
|
||||||
break;
|
break;
|
||||||
|
case UIKeyboardHIDUsageKeyboardErrorUndefined:
|
||||||
|
NSLog(@"Undefined key pressed");
|
||||||
|
return false;
|
||||||
case 669: // This value corresponds to the "Globe" or "Language" key on most Apple branded iPad keyboards.
|
case 669: // This value corresponds to the "Globe" or "Language" key on most Apple branded iPad keyboards.
|
||||||
keyCode = 0x1B; // This value corresponds to "Escape", which is missing from most Apple branded iPad keyboards.
|
keyCode = 0x1B; // This value corresponds to "Escape", which is missing from most Apple branded iPad keyboards.
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
- (void) userInteractionBegan;
|
- (void) userInteractionBegan;
|
||||||
- (void) userInteractionEnded;
|
- (void) userInteractionEnded;
|
||||||
|
- (void) streamExitRequested;
|
||||||
|
- (void) toggleStatsOverlay;
|
||||||
|
- (void) toggleMouseCapture;
|
||||||
|
- (void) toggleMouseVisible;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -64,12 +64,15 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
UIHoverGestureRecognizer *stylusHoverRecognizer;
|
UIHoverGestureRecognizer *stylusHoverRecognizer;
|
||||||
#endif
|
#endif
|
||||||
CGFloat HeightViewLiftedTo;
|
CGFloat HeightViewLiftedTo;
|
||||||
|
|
||||||
|
UIKeyModifierFlags comboKeyModifierFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
||||||
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
|
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
|
||||||
config:(StreamConfiguration*)streamConfig
|
config:(StreamConfiguration*)streamConfig
|
||||||
streamFrameTopLayerView:(UIView* )topLayerView{
|
streamFrameTopLayerView:(UIView* )topLayerView{
|
||||||
|
self->comboKeyModifierFlags = (UIKeyModifierControl|UIKeyModifierAlternate|UIKeyModifierShift);
|
||||||
|
|
||||||
self->streamFrameTopLayerView = topLayerView;
|
self->streamFrameTopLayerView = topLayerView;
|
||||||
self.streamFrameTopLayerView = topLayerView; // this will be used as a read-only pointer for other class
|
self.streamFrameTopLayerView = topLayerView; // this will be used as a read-only pointer for other class
|
||||||
@@ -755,11 +758,34 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
else if(![onScreenControls handleTouchMovedEvent:touches]) [touchHandler touchesMoved:touches withEvent:event];
|
else if(![onScreenControls handleTouchMovedEvent:touches]) [touchHandler touchesMoved:touches withEvent:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) handleKeyCombos:(UIPress*) press{
|
||||||
|
if(press.key.modifierFlags != comboKeyModifierFlags){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (press.key.keyCode) {
|
||||||
|
case UIKeyboardHIDUsageKeyboardQ:
|
||||||
|
[interactionDelegate streamExitRequested];
|
||||||
|
break;
|
||||||
|
case UIKeyboardHIDUsageKeyboardS:
|
||||||
|
[interactionDelegate toggleStatsOverlay];
|
||||||
|
break;
|
||||||
|
case UIKeyboardHIDUsageKeyboardM:
|
||||||
|
[interactionDelegate toggleMouseCapture];
|
||||||
|
break;
|
||||||
|
case UIKeyboardHIDUsageKeyboardC:
|
||||||
|
[interactionDelegate toggleMouseVisible];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
|
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event {
|
||||||
BOOL handled = NO;
|
BOOL handled = NO;
|
||||||
|
|
||||||
if (@available(iOS 13.4, tvOS 13.4, *)) {
|
if (@available(iOS 13.4, tvOS 13.4, *)) {
|
||||||
for (UIPress* press in presses) {
|
for (UIPress* press in presses) {
|
||||||
|
[self handleKeyCombos:press];
|
||||||
// For now, we'll treated it as handled if we handle at least one of the
|
// For now, we'll treated it as handled if we handle at least one of the
|
||||||
// UIPress events inside the set.
|
// UIPress events inside the set.
|
||||||
if ([KeyboardSupport sendKeyEventForPress:press down:YES]) {
|
if ([KeyboardSupport sendKeyEventForPress:press down:YES]) {
|
||||||
|
|||||||
@@ -936,6 +936,44 @@
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)toggleStatsOverlay{
|
||||||
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
|
Settings *currentSettings = [dataMan retrieveSettings];
|
||||||
|
|
||||||
|
currentSettings.statsOverlay = !currentSettings.statsOverlay;
|
||||||
|
|
||||||
|
[dataMan saveData];
|
||||||
|
[self reConfigStreamViewRealtime];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)toggleMouseCapture{
|
||||||
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
|
Settings *currentSettings = [dataMan retrieveSettings];
|
||||||
|
|
||||||
|
if(currentSettings.mouseMode.intValue == 0){
|
||||||
|
currentSettings.mouseMode = @1;
|
||||||
|
}else{
|
||||||
|
currentSettings.mouseMode = @0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dataMan saveData];
|
||||||
|
[self reConfigStreamViewRealtime];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)toggleMouseVisible{
|
||||||
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
|
Settings *currentSettings = [dataMan retrieveSettings];
|
||||||
|
|
||||||
|
if(currentSettings.mouseMode.intValue == 2){
|
||||||
|
currentSettings.mouseMode = @1;
|
||||||
|
}else{
|
||||||
|
currentSettings.mouseMode = @2;
|
||||||
|
}
|
||||||
|
|
||||||
|
[dataMan saveData];
|
||||||
|
[self reConfigStreamViewRealtime];
|
||||||
|
}
|
||||||
|
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
// Require a confirmation when streaming to activate a system gesture
|
// Require a confirmation when streaming to activate a system gesture
|
||||||
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
|
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures {
|
||||||
|
|||||||
Reference in new issue
Block a user