steal key events if handled by emulator

fixes #45 somewhat, but not for ⌘-Q or ⌘-H
This commit is contained in:
Jesús A. Álvarez 2023-02-01 18:11:49 +01:00
parent 1cfc5bd94f
commit ceb0813eee
1 changed files with 2 additions and 1 deletions

View File

@ -100,7 +100,6 @@ static int8_t usb_to_adb_scancode[] = {
}
- (void)handleKeyUIEvent:(UIEvent *)event {
[super handleKeyUIEvent:event];
static dispatch_once_t onceToken;
static BOOL handleKeyboardEvents = YES;
dispatch_once(&onceToken, ^{
@ -113,6 +112,8 @@ static int8_t usb_to_adb_scancode[] = {
BOOL emulatorIsFrontmost = [AppDelegate sharedEmulator].running && [AppDelegate sharedInstance].window.rootViewController.presentedViewController == nil;
if ([event isKindOfClass:keyboardEventClass] && handleKeyboardEvents && emulatorIsFrontmost) {
[self handleKeyboardEvent:(UIPhysicalKeyboardEvent*)event];
} else {
[super handleKeyUIEvent:event];
}
}