From 76b82d92fcd02303c621557ca2df0a739ef3ba78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Mon, 6 Jun 2016 20:13:02 +0200 Subject: [PATCH] don't try to handle physical keyboard events on iOS <9 --- Mini vMac/MNVMApplication.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Mini vMac/MNVMApplication.m b/Mini vMac/MNVMApplication.m index ec58736..82756d3 100644 --- a/Mini vMac/MNVMApplication.m +++ b/Mini vMac/MNVMApplication.m @@ -101,7 +101,16 @@ static int8_t usb_to_adb_scancode[] = { - (void)handleKeyUIEvent:(UIEvent *)event { [super handleKeyUIEvent:event]; - if ([event isKindOfClass:keyboardEventClass]) { + static dispatch_once_t onceToken; + static BOOL handleKeyboardEvents = YES; + dispatch_once(&onceToken, ^{ + if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) { + handleKeyboardEvents = [NSProcessInfo processInfo].operatingSystemVersion.majorVersion >= 9; + } else { + handleKeyboardEvents = NO; + } + }); + if ([event isKindOfClass:keyboardEventClass] && handleKeyboardEvents) { [self handleKeyboardEvent:(UIPhysicalKeyboardEvent*)event]; } }