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