(iOS) Fix iCade again (note to self: don’t test low level APIs on simulator)

This commit is contained in:
meancoot 2013-12-15 19:05:09 -05:00
parent 5dc5193ebc
commit 12c1725ea6

View File

@ -114,8 +114,15 @@ static void handle_touch_event(NSArray* touches)
}
}
@interface UIApplication(Superclass)
- (void)handleKeyUIEvent:(UIEvent*)event;
// iO7 Keyboard support
@interface UIEvent(iOS7Keyboard)
@property(readonly, nonatomic) long long _keyCode;
@property(readonly, nonatomic) _Bool _isKeyDown;
- (struct __IOHIDEvent { }*)_hidEvent;
@end
@interface UIApplication(iOS7Keyboard)
- (id)_keyCommandForEvent:(id)event;
@end
@interface RApplication : UIApplication
@ -123,8 +130,23 @@ static void handle_touch_event(NSArray* touches)
@implementation RApplication
- (void)processKeyEvent:(UIEvent*)event
// Keyboard handler for iOS 7
- (id)_keyCommandForEvent:(UIEvent*)event
{
// If the _hidEvent is null, [event _keyCode] will crash.
if ([event _hidEvent])
apple_input_handle_key_event([event _keyCode], [event _isKeyDown]);
return [super _keyCommandForEvent:event];
}
- (void)sendEvent:(UIEvent *)event
{
[super sendEvent:event];
if ([[event allTouches] count])
handle_touch_event(event.allTouches.allObjects);
if ([event respondsToSelector:@selector(_gsEvent)])
{
// Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
@ -138,23 +160,6 @@ static void handle_touch_event(NSArray* touches)
}
}
// iOS7: This method is called instead of sendEvent for key events
- (void)handleKeyUIEvent:(UIEvent*)event
{
[super handleKeyUIEvent:event];
[self processKeyEvent:event];
}
- (void)sendEvent:(UIEvent *)event
{
[super sendEvent:event];
if ([[event allTouches] count])
handle_touch_event(event.allTouches.allObjects);
[self processKeyEvent:event];
}
@end
@implementation RetroArch_iOS