mirror of
https://github.com/libretro/RetroArch
synced 2025-02-04 21:40:02 +00:00
(Apple) Style nits - early return instead of encapsulating
entire function into one big int block - make a function out of iOS 7 version detection - might need to be hosed outside of apple_gamecontroller.m someday
This commit is contained in:
parent
2ace9a81a8
commit
ac70e929be
@ -553,9 +553,7 @@ void apple_gfx_ctx_update_window_title(void)
|
||||
(void)text;
|
||||
#ifdef OSX
|
||||
if (got_text)
|
||||
{
|
||||
[[g_view window] setTitle:[NSString stringWithCString:text encoding:NSUTF8StringEncoding]];
|
||||
}
|
||||
#endif
|
||||
if (fps_draw)
|
||||
msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1);
|
||||
@ -568,11 +566,13 @@ bool apple_gfx_ctx_has_focus(void)
|
||||
|
||||
void apple_gfx_ctx_swap_buffers()
|
||||
{
|
||||
if (--g_fast_forward_skips < 0)
|
||||
{
|
||||
bool swap = --g_fast_forward_skips < 0;
|
||||
|
||||
if (!swap)
|
||||
return;
|
||||
|
||||
[g_view display];
|
||||
g_fast_forward_skips = g_is_syncing ? 0 : 3;
|
||||
}
|
||||
}
|
||||
|
||||
gfx_ctx_proc_t apple_gfx_ctx_get_proc_address(const char *symbol_name)
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <Availability.h>
|
||||
#ifdef IOS
|
||||
#include <UIKit/UIDevice.h>
|
||||
static NSArray *versionCompatibility;
|
||||
#endif
|
||||
|
||||
#if defined(__IPHONE_7_0) && !defined(OSX)
|
||||
@ -26,10 +25,20 @@ static NSArray *versionCompatibility;
|
||||
#import <GameController/GameController.h>
|
||||
#include "apple_input.h"
|
||||
|
||||
#ifdef IOS
|
||||
bool apple_rarch_is_ios7_or_higher(void)
|
||||
{
|
||||
NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion
|
||||
componentsSeparatedByString:@(".")];
|
||||
bool ret = [[versionCompatibility objectAtIndex:0] intValue] < 7;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void apple_gamecontroller_poll(GCController* controller)
|
||||
{
|
||||
#ifdef IOS
|
||||
if ( [[versionCompatibility objectAtIndex:0] intValue] < 7 )
|
||||
if (apple_rarch_is_ios7_or_higher())
|
||||
return;
|
||||
#endif
|
||||
if (!controller || controller.playerIndex == MAX_PLAYERS)
|
||||
@ -79,7 +88,7 @@ static void apple_gamecontroller_poll(GCController* controller)
|
||||
void apple_gamecontroller_poll_all(void)
|
||||
{
|
||||
#ifdef IOS
|
||||
if ( [[versionCompatibility objectAtIndex:0] intValue] < 7 )
|
||||
if (apple_rarch_is_ios7_or_higher())
|
||||
return;
|
||||
#endif
|
||||
NSArray* controllers = [GCController controllers];
|
||||
@ -91,7 +100,7 @@ void apple_gamecontroller_poll_all(void)
|
||||
void apple_gamecontroller_connect(GCController* controller)
|
||||
{
|
||||
#ifdef IOS
|
||||
if ( [[versionCompatibility objectAtIndex:0] intValue] < 7 )
|
||||
if (apple_rarch_is_ios7_or_higher())
|
||||
return;
|
||||
#endif
|
||||
int32_t slot = apple_joypad_connect_gcapi();
|
||||
@ -112,7 +121,7 @@ void apple_gamecontroller_connect(GCController* controller)
|
||||
void apple_gamecontroller_disconnect(GCController* controller)
|
||||
{
|
||||
#ifdef IOS
|
||||
if ( [[versionCompatibility objectAtIndex:0] intValue] < 7 )
|
||||
if (apple_rarch_is_ios7_or_higher())
|
||||
return;
|
||||
#endif
|
||||
if (controller.playerIndex == GCControllerPlayerIndexUnset)
|
||||
@ -124,9 +133,7 @@ void apple_gamecontroller_disconnect(GCController* controller)
|
||||
void apple_gamecontroller_init(void)
|
||||
{
|
||||
#ifdef IOS
|
||||
versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
|
||||
|
||||
if ( [[versionCompatibility objectAtIndex:0] intValue] < 7 )
|
||||
if (apple_rarch_is_ios7_or_higher())
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
@ -54,8 +54,11 @@ static void apple_rarch_exited()
|
||||
|
||||
static void do_iteration()
|
||||
{
|
||||
if (iterate_observer && apple_is_running && !g_extern.is_paused)
|
||||
{
|
||||
bool iterate = iterate_observer && apple_is_running && !g_extern.is_paused;
|
||||
|
||||
if (!iterate)
|
||||
return;
|
||||
|
||||
if (main_entry_iterate(0, NULL, NULL))
|
||||
{
|
||||
main_exit(NULL);
|
||||
@ -63,32 +66,32 @@ static void do_iteration()
|
||||
}
|
||||
else
|
||||
CFRunLoopWakeUp(CFRunLoopGetMain());
|
||||
}
|
||||
}
|
||||
|
||||
void apple_start_iteration()
|
||||
{
|
||||
if (!iterate_observer)
|
||||
{
|
||||
if (iterate_observer)
|
||||
return;
|
||||
|
||||
iterate_observer = CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, true, 0, do_iteration, 0);
|
||||
CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, kCFRunLoopCommonModes);
|
||||
}
|
||||
}
|
||||
|
||||
void apple_stop_iteration()
|
||||
{
|
||||
if (iterate_observer)
|
||||
{
|
||||
if (!iterate_observer)
|
||||
return;
|
||||
|
||||
CFRunLoopObserverInvalidate(iterate_observer);
|
||||
CFRelease(iterate_observer);
|
||||
iterate_observer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void apple_run_core(NSString* core, const char* file)
|
||||
{
|
||||
if (!apple_is_running)
|
||||
{
|
||||
if (apple_is_running)
|
||||
return;
|
||||
|
||||
[apple_platform loadingCore:core withFile:file];
|
||||
|
||||
apple_core = core;
|
||||
@ -120,12 +123,10 @@ void apple_run_core(NSString* core, const char* file)
|
||||
char basedir[256];
|
||||
fill_pathname_basedir(basedir, file ? file : "", sizeof(basedir));
|
||||
if (file && access(basedir, R_OK | W_OK | X_OK))
|
||||
apple_display_alert(@"The directory containing the selected file must have write premissions. This will "
|
||||
"prevent zipped content from loading, and will cause some cores to not function.", 0);
|
||||
apple_display_alert(BOXSTRING("The directory containing the selected file must have write premissions. This will prevent zipped content from loading, and will cause some cores to not function."), 0);
|
||||
else
|
||||
apple_display_alert(@"Failed to load content.", 0);
|
||||
apple_display_alert(BOXSTRING("Failed to load content."), 0);
|
||||
|
||||
apple_rarch_exited();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user