mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
(iOS) Fix/refactor iOS major version detection
This commit is contained in:
parent
65ed3ab052
commit
4acd75155f
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Availability.h>
|
#include <Availability.h>
|
||||||
|
#include "RetroArch_Apple.h"
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
#include <UIKit/UIDevice.h>
|
#include <UIKit/UIDevice.h>
|
||||||
#endif
|
#endif
|
||||||
@ -26,19 +27,13 @@
|
|||||||
#include "apple_input.h"
|
#include "apple_input.h"
|
||||||
|
|
||||||
#ifdef IOS
|
#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
|
#endif
|
||||||
|
|
||||||
static void apple_gamecontroller_poll(GCController* controller)
|
static void apple_gamecontroller_poll(GCController* controller)
|
||||||
{
|
{
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
if (!apple_rarch_is_ios7_or_higher())
|
if (!(IOS_IS_VERSION_7_OR_HIGHER()))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (!controller || controller.playerIndex == MAX_PLAYERS)
|
if (!controller || controller.playerIndex == MAX_PLAYERS)
|
||||||
@ -88,7 +83,7 @@ static void apple_gamecontroller_poll(GCController* controller)
|
|||||||
void apple_gamecontroller_poll_all(void)
|
void apple_gamecontroller_poll_all(void)
|
||||||
{
|
{
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
if (!apple_rarch_is_ios7_or_higher())
|
if (!(IOS_IS_VERSION_7_OR_HIGHER()))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
NSArray* controllers = [GCController controllers];
|
NSArray* controllers = [GCController controllers];
|
||||||
@ -100,7 +95,7 @@ void apple_gamecontroller_poll_all(void)
|
|||||||
void apple_gamecontroller_connect(GCController* controller)
|
void apple_gamecontroller_connect(GCController* controller)
|
||||||
{
|
{
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
if (!apple_rarch_is_ios7_or_higher())
|
if (!(IOS_IS_VERSION_7_OR_HIGHER()))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
int32_t slot = apple_joypad_connect_gcapi();
|
int32_t slot = apple_joypad_connect_gcapi();
|
||||||
@ -121,7 +116,7 @@ void apple_gamecontroller_connect(GCController* controller)
|
|||||||
void apple_gamecontroller_disconnect(GCController* controller)
|
void apple_gamecontroller_disconnect(GCController* controller)
|
||||||
{
|
{
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
if (!apple_rarch_is_ios7_or_higher())
|
if (!(IOS_IS_VERSION_7_OR_HIGHER()))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (controller.playerIndex == GCControllerPlayerIndexUnset)
|
if (controller.playerIndex == GCControllerPlayerIndexUnset)
|
||||||
@ -133,7 +128,7 @@ void apple_gamecontroller_disconnect(GCController* controller)
|
|||||||
void apple_gamecontroller_init(void)
|
void apple_gamecontroller_init(void)
|
||||||
{
|
{
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
if (!apple_rarch_is_ios7_or_higher())
|
if (!(IOS_IS_VERSION_7_OR_HIGHER()))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
self.selectedItem = [self itemForIndexPath:indexPath];
|
self.selectedItem = [self itemForIndexPath:indexPath];
|
||||||
bool is_zip = [[self.selectedItem.path pathExtension] isEqualToString:@"zip"];
|
bool is_zip = [[self.selectedItem.path pathExtension] isEqualToString:@"zip"];
|
||||||
|
|
||||||
NSString* button4_name = (get_ios_version_major() >= 7) ? @"AirDrop" : @"Delete";
|
NSString* button4_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"AirDrop" : @"Delete";
|
||||||
NSString* button5_name = (get_ios_version_major() >= 7) ? @"Delete" : nil;
|
NSString* button5_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"Delete" : nil;
|
||||||
|
|
||||||
UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:self.selectedItem.path.lastPathComponent delegate:self
|
UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:self.selectedItem.path.lastPathComponent delegate:self
|
||||||
cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
|
cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
|
||||||
@ -350,7 +350,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
|
|||||||
[alertView show];
|
[alertView show];
|
||||||
}
|
}
|
||||||
#ifdef __IPHONE_7_0
|
#ifdef __IPHONE_7_0
|
||||||
else if ([action isEqualToString:@"AirDrop"] && get_ios_version_major() >= 7)
|
else if ([action isEqualToString:@"AirDrop"] && IOS_IS_VERSION_7_OR_HIGHER())
|
||||||
{
|
{
|
||||||
// TODO: Zip if not already zipped
|
// TODO: Zip if not already zipped
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@ const void* apple_get_frontend_settings(void);
|
|||||||
|
|
||||||
// modes are: keyboard, icade and btstack
|
// modes are: keyboard, icade and btstack
|
||||||
void ios_set_bluetooth_mode(NSString* mode);
|
void ios_set_bluetooth_mode(NSString* mode);
|
||||||
int get_ios_version_major();
|
int get_ios_version_major(void);
|
||||||
|
|
||||||
|
#define IOS_IS_VERSION_7_OR_HIGHER() ((get_ios_version_major() >= 7))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
apple_frontend_settings_t apple_frontend_settings;
|
apple_frontend_settings_t apple_frontend_settings;
|
||||||
|
|
||||||
int get_ios_version_major()
|
#ifdef IOS
|
||||||
|
int get_ios_version_major(void)
|
||||||
{
|
{
|
||||||
static int version = -1;
|
static int version = -1;
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ void ios_set_bluetooth_mode(NSString* mode)
|
|||||||
apple_input_enable_icade([mode isEqualToString:@"icade"]);
|
apple_input_enable_icade([mode isEqualToString:@"icade"]);
|
||||||
btstack_set_poweron([mode isEqualToString:@"btstack"]);
|
btstack_set_poweron([mode isEqualToString:@"btstack"]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const void* apple_get_frontend_settings(void)
|
const void* apple_get_frontend_settings(void)
|
||||||
{
|
{
|
||||||
@ -157,7 +159,7 @@ static void handle_touch_event(NSArray* touches)
|
|||||||
if ([[event allTouches] count])
|
if ([[event allTouches] count])
|
||||||
handle_touch_event([[event allTouches] allObjects]);
|
handle_touch_event([[event allTouches] allObjects]);
|
||||||
|
|
||||||
if (get_ios_version_major() < 7 && [event respondsToSelector:@selector(_gsEvent)])
|
if (!(IOS_IS_VERSION_7_OR_HIGHER()) && [event respondsToSelector:@selector(_gsEvent)])
|
||||||
{
|
{
|
||||||
// Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
|
// 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)]);
|
const uint8_t* eventMem = objc_unretainedPointer([event performSelector:@selector(_gsEvent)]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user