mirror of
https://github.com/libretro/RetroArch
synced 2025-01-18 13:23:40 +00:00
(iOS) Refactor get_ios_version_major
This commit is contained in:
parent
d6d8d32edd
commit
2c53d57e9e
@ -337,10 +337,15 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
|
||||
if (idx_path)
|
||||
{
|
||||
int major, minor;
|
||||
bool is_zip;
|
||||
UIActionSheet *menu;
|
||||
NSString *button4_name = (get_ios_version_major() >= 7) ? BOXSTRING("AirDrop") : BOXSTRING("Delete");
|
||||
NSString *button5_name = (get_ios_version_major() >= 7) ? BOXSTRING("Delete") : nil;
|
||||
NSString *button4_name, *button5_name;
|
||||
|
||||
get_ios_version_major(&major, &minor);
|
||||
|
||||
button4_name = (major >= 7) ? BOXSTRING("AirDrop") : BOXSTRING("Delete");
|
||||
button5_name = (major >= 7) ? BOXSTRING("Delete") : nil;
|
||||
|
||||
self.selectedItem = [self itemForIndexPath:idx_path];
|
||||
is_zip = !(strcmp(self.selectedItem.path.pathExtension.UTF8String, "zip"));
|
||||
@ -357,8 +362,14 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
/* Called by the action sheet created in (void)fileAction: */
|
||||
- (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||
{
|
||||
int major, minor;
|
||||
NSString* target = self.selectedItem.path;
|
||||
NSString* action = [actionSheet buttonTitleAtIndex:buttonIndex];
|
||||
|
||||
get_ios_version_major(&major, &minor);
|
||||
|
||||
(void)major;
|
||||
(void)minor;
|
||||
|
||||
if (!strcmp(action.UTF8String, "Unzip"))
|
||||
{
|
||||
@ -382,7 +393,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
||||
[alertView show];
|
||||
}
|
||||
#ifdef __IPHONE_7_0
|
||||
else if (!strcmp(action.UTF8String, "AirDrop") && (get_ios_version_major() >= 7))
|
||||
else if (!strcmp(action.UTF8String, "AirDrop") && (major >= 7))
|
||||
{
|
||||
/* TODO: ZIP if not already zipped. */
|
||||
NSURL *url = [NSURL fileURLWithPath:self.selectedItem.path isDirectory:self.selectedItem.isDirectory];
|
||||
|
@ -49,6 +49,6 @@ extern apple_frontend_settings_t apple_frontend_settings;
|
||||
- (void)refreshSystemConfig;
|
||||
@end
|
||||
|
||||
int get_ios_version_major(void);
|
||||
void get_ios_version_major(int *major, int *minor);
|
||||
|
||||
#endif
|
||||
|
@ -68,14 +68,14 @@ void apple_rarch_exited(void)
|
||||
|
||||
apple_frontend_settings_t apple_frontend_settings;
|
||||
|
||||
int get_ios_version_major(void)
|
||||
void get_ios_version_major(int *major, int *minor)
|
||||
{
|
||||
static int version = -1;
|
||||
|
||||
if (version < 0)
|
||||
version = (int)[[[UIDevice currentDevice] systemVersion] floatValue];
|
||||
|
||||
return version;
|
||||
NSArray *decomposed_os_version = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
|
||||
|
||||
if (major && decomposed_os_version.count > 0)
|
||||
*major = [decomposed_os_version[0] integerValue];
|
||||
if (minor && decomposed_os_version.count > 1)
|
||||
*minor = [decomposed_os_version[1] integerValue];
|
||||
}
|
||||
|
||||
extern float apple_gfx_ctx_get_native_scale(void);
|
||||
@ -200,12 +200,15 @@ enum
|
||||
|
||||
- (void)sendEvent:(UIEvent *)event
|
||||
{
|
||||
int major, minor;
|
||||
[super sendEvent:event];
|
||||
|
||||
if (event.allTouches.count)
|
||||
handle_touch_event(event.allTouches.allObjects);
|
||||
|
||||
if (!(get_ios_version_major() >= 7) && [event respondsToSelector:@selector(_gsEvent)])
|
||||
get_ios_version_major(&major, &minor);
|
||||
|
||||
if (!(major >= 7) && [event respondsToSelector:@selector(_gsEvent)])
|
||||
{
|
||||
// Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
|
||||
const uint8_t *eventMem = objc_unretainedPointer([event performSelector:@selector(_gsEvent)]);
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#import <GameController/GameController.h>
|
||||
#include <boolean.h>
|
||||
#include "mfi_hid.h"
|
||||
#include "../../input/drivers/apple_input.h"
|
||||
|
||||
@ -23,9 +24,12 @@ enum
|
||||
GCCONTROLLER_PLAYER_INDEX_UNSET = -1,
|
||||
};
|
||||
|
||||
static BOOL apple_gamecontroller_available(void)
|
||||
static bool apple_gamecontroller_available(void)
|
||||
{
|
||||
if (get_ios_version_major() <= 6)
|
||||
int major, minor;
|
||||
get_ios_version_major(&major, &minor);
|
||||
|
||||
if (major <= 6)
|
||||
return false;
|
||||
/* by checking for extern symbols defined by the framework, we can check for its
|
||||
* existence at runtime. This is the Apple endorsed way of dealing with this */
|
||||
|
Loading…
Reference in New Issue
Block a user