This commit is contained in:
twinaphex 2020-09-15 21:12:27 +02:00
parent ca413ff132
commit e15018a85a

View File

@ -84,7 +84,8 @@ static void rarch_draw_observer(CFRunLoopObserverRef observer,
if (ret == -1)
{
ui_companion_cocoatouch_event_command(NULL, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG);
ui_companion_cocoatouch_event_command(
NULL, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG);
main_exit(NULL);
return;
}
@ -122,13 +123,8 @@ static void handle_touch_event(NSArray* touches)
for (i = 0; i < touches.count && (apple->touch_count < MAX_TOUCHES); i++)
{
CGPoint coord;
UITouch *touch = [touches objectAtIndex:i];
// if (touch.view != [CocoaView get].view)
// continue;
coord = [touch locationInView:[touch view]];
CGPoint coord = [touch locationInView:[touch view]];
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
{
apple->touches[apple->touch_count ].screen_x = coord.x * scale;
@ -138,7 +134,7 @@ static void handle_touch_event(NSArray* touches)
}
#ifndef HAVE_APPLE_STORE
// iOS7 Keyboard support
/* iOS7 Keyboard support */
@interface UIEvent(iOS7Keyboard)
@property(readonly, nonatomic) long long _keyCode;
@property(readonly, nonatomic) _Bool _isKeyDown;
@ -176,8 +172,9 @@ enum
NSDeviceIndependentModifierFlagsMask = 0xffff0000U
};
// This is specifically for iOS 9, according to the private headers
-(void)handleKeyUIEvent:(UIEvent *)event {
/* This is specifically for iOS 9, according to the private headers */
-(void)handleKeyUIEvent:(UIEvent *)event
{
/* This gets called twice with the same timestamp
* for each keypress, that's fine for polling
* but is bad for business with events. */
@ -226,7 +223,7 @@ enum
[super handleKeyUIEvent:event];
}
// This is for iOS versions < 9.0
/* This is for iOS versions < 9.0 */
- (id)_keyCommandForEvent:(UIEvent*)event
{
/* This gets called twice with the same timestamp
@ -296,7 +293,8 @@ enum
/* Keyboard event hack for iOS versions prior to iOS 7.
*
* Derived from:
* http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
* http://nacho4d-nacho4d.blogspot.com/2012/01/
* catching-keyboard-events-in-ios.html
*/
const uint8_t *eventMem = objc_unretainedPointer([event performSelector:@selector(_gsEvent)]);
int eventType = eventMem ? *(int*)&eventMem[8] : 0;
@ -318,13 +316,11 @@ enum
@implementation RetroArch_iOS
#pragma mark - ApplePlatform
-(id)renderView {
return _renderView;
}
-(bool)hasFocus {
return YES;
}
- (void)setViewType:(apple_view_type_t)vt {
-(id)renderView { return _renderView; }
-(bool)hasFocus { return YES; }
- (void)setViewType:(apple_view_type_t)vt
{
if (vt == _vt)
return;
@ -369,37 +365,26 @@ enum
[[_renderView.trailingAnchor constraintEqualToAnchor:rootView.trailingAnchor] setActive:YES];
}
- (apple_view_type_t)viewType {
return _vt;
}
- (apple_view_type_t)viewType { return _vt; }
- (void)setVideoMode:(gfx_ctx_mode_t)mode {
- (void)setVideoMode:(gfx_ctx_mode_t)mode
{
#ifdef HAVE_COCOA_METAL
MetalView *metalView = (MetalView*) _renderView;
CGFloat scale = [[UIScreen mainScreen] scale];
[metalView setDrawableSize:CGSizeMake(
_renderView.bounds.size.width * scale,
_renderView.bounds.size.height * scale
)
];
)];
#endif
}
- (void)setCursorVisible:(bool)v {
// no-op for iOS
}
- (void)setCursorVisible:(bool)v { /* no-op for iOS */ }
- (bool)setDisableDisplaySleep:(bool)disable { /* no-op for iOS */ return NO; }
+ (RetroArch_iOS*)get { return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate]; }
- (bool)setDisableDisplaySleep:(bool)disable {
// no-op for iOS
return NO;
}
+ (RetroArch_iOS*)get
-(NSString*)documentsDirectory
{
return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate];
}
-(NSString*)documentsDirectory {
if (_documentsDirectory == nil)
{
#if TARGET_OS_IOS
@ -428,9 +413,6 @@ enum
[self.window makeKeyAndVisible];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
if (error) {
NSLog(@"Could not set audio session category: %@",error.localizedDescription);
}
[self refreshSystemConfig];
[self showGameView];
@ -446,12 +428,9 @@ enum
extern bool apple_gamecontroller_joypad_init(void *data);
apple_gamecontroller_joypad_init(NULL);
#endif
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationDidEnterBackground:(UIApplication *)application { }
- (void)applicationWillTerminate:(UIApplication *)application
{
@ -465,9 +444,7 @@ enum
settings_t *settings = config_get_ptr();
bool ui_companion_start_on_boot = settings->bools.ui_companion_start_on_boot;
if (ui_companion_start_on_boot)
return;
if (!ui_companion_start_on_boot)
[self showGameView];
}
@ -529,17 +506,16 @@ enum
apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskAll;
if (string_is_equal(apple_frontend_settings.orientations, "landscape"))
apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskLandscape;
apple_frontend_settings.orientation_flags =
UIInterfaceOrientationMaskLandscape;
else if (string_is_equal(apple_frontend_settings.orientations, "portrait"))
apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskPortrait
apple_frontend_settings.orientation_flags =
UIInterfaceOrientationMaskPortrait
| UIInterfaceOrientationMaskPortraitUpsideDown;
#endif
}
- (void)supportOtherAudioSessions
{
}
- (void)supportOtherAudioSessions { }
@end
int main(int argc, char *argv[])