2013-07-27 15:40:21 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2012-2014 - Jason Fetters
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2014-2015 - Jay McCarthy
|
2013-07-27 15:40:21 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2013-07-27 15:45:56 +00:00
|
|
|
* * You should have received a copy of the GNU General Public License along with RetroArch.
|
2013-07-27 15:40:21 +00:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
2015-07-25 12:50:40 +00:00
|
|
|
#include <unistd.h>
|
2013-07-27 15:40:21 +00:00
|
|
|
|
2015-04-18 19:14:30 +00:00
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
2017-01-30 16:35:00 +00:00
|
|
|
#include <mach/mach_host.h>
|
|
|
|
|
2015-06-14 17:26:53 +00:00
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
|
|
#include <CoreFoundation/CFArray.h>
|
|
|
|
|
2016-09-11 12:54:34 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-06-14 17:26:53 +00:00
|
|
|
#ifdef __OBJC__
|
|
|
|
#include <Foundation/NSPathUtilities.h>
|
2016-01-13 19:48:56 +00:00
|
|
|
#include <objc/message.h>
|
2015-06-14 17:26:53 +00:00
|
|
|
#endif
|
|
|
|
|
2015-04-18 13:07:04 +00:00
|
|
|
#if defined(OSX)
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#include <IOKit/ps/IOPowerSources.h>
|
|
|
|
#include <IOKit/ps/IOPSKeys.h>
|
2015-04-20 12:05:55 +00:00
|
|
|
|
|
|
|
#include <sys/sysctl.h>
|
2015-04-21 10:15:42 +00:00
|
|
|
#elif defined(IOS)
|
|
|
|
#include <UIKit/UIDevice.h>
|
2015-04-20 12:05:55 +00:00
|
|
|
#endif
|
|
|
|
|
2015-11-23 11:07:00 +00:00
|
|
|
#include <boolean.h>
|
2016-09-14 12:10:39 +00:00
|
|
|
#include <compat/apple_compat.h>
|
2017-11-23 03:33:48 +00:00
|
|
|
#include <retro_assert.h>
|
2015-06-14 17:26:53 +00:00
|
|
|
#include <retro_miscellaneous.h>
|
|
|
|
#include <file/file_path.h>
|
2017-12-14 19:05:46 +00:00
|
|
|
#include <streams/file_stream.h>
|
2015-06-14 17:26:53 +00:00
|
|
|
#include <rhash.h>
|
2019-03-14 12:37:52 +00:00
|
|
|
#include <features/features_cpu.h>
|
2020-02-13 23:24:03 +00:00
|
|
|
#include <string/stdstring.h>
|
2015-06-14 17:26:53 +00:00
|
|
|
|
2016-09-08 09:22:08 +00:00
|
|
|
#ifdef HAVE_MENU
|
|
|
|
#include "../../menu/menu_driver.h"
|
|
|
|
#endif
|
|
|
|
|
2015-06-14 17:26:53 +00:00
|
|
|
#include "../frontend_driver.h"
|
2016-05-01 13:28:45 +00:00
|
|
|
#include "../../file_path_special.h"
|
2016-09-05 16:52:52 +00:00
|
|
|
#include "../../configuration.h"
|
2016-03-22 02:13:33 +00:00
|
|
|
#include "../../defaults.h"
|
2017-05-11 07:11:46 +00:00
|
|
|
#include "../../retroarch.h"
|
2015-11-23 11:07:00 +00:00
|
|
|
#include "../../verbosity.h"
|
2016-03-22 02:13:33 +00:00
|
|
|
#include "../../ui/ui_companion_driver.h"
|
2015-06-14 17:26:53 +00:00
|
|
|
|
2015-10-19 20:48:50 +00:00
|
|
|
#if 1
|
2015-07-18 15:36:06 +00:00
|
|
|
#define RELEASE_BUILD
|
|
|
|
#endif
|
|
|
|
|
2015-04-20 12:05:55 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2015-04-20 19:00:40 +00:00
|
|
|
CFApplicationDirectory = 1, /* Supported applications (Applications) */
|
|
|
|
CFDemoApplicationDirectory = 2, /* Unsupported applications, demonstration versions (Demos) */
|
|
|
|
CFDeveloperApplicationDirectory = 3, /* Developer applications (Developer/Applications). DEPRECATED - there is no one single Developer directory. */
|
|
|
|
CFAdminApplicationDirectory = 4, /* System and network administration applications (Administration) */
|
|
|
|
CFLibraryDirectory = 5, /* various documentation, support, and configuration files, resources (Library) */
|
|
|
|
CFDeveloperDirectory = 6, /* developer resources (Developer) DEPRECATED - there is no one single Developer directory. */
|
|
|
|
CFUserDirectory = 7, /* User home directories (Users) */
|
|
|
|
CFDocumentationDirectory = 8, /* Documentation (Documentation) */
|
|
|
|
CFDocumentDirectory = 9, /* Documents (Documents) */
|
|
|
|
CFCoreServiceDirectory = 10, /* Location of CoreServices directory (System/Library/CoreServices) */
|
|
|
|
CFAutosavedInformationDirectory = 11, /* Location of autosaved documents (Documents/Autosaved) */
|
|
|
|
CFDesktopDirectory = 12, /* Location of user's desktop */
|
|
|
|
CFCachesDirectory = 13, /* Location of discardable cache files (Library/Caches) */
|
|
|
|
CFApplicationSupportDirectory = 14, /* Location of application support files (plug-ins, etc) (Library/Application Support) */
|
|
|
|
CFDownloadsDirectory = 15, /* Location of the user's "Downloads" directory */
|
|
|
|
CFInputMethodsDirectory = 16, /* Input methods (Library/Input Methods) */
|
|
|
|
CFMoviesDirectory = 17, /* Location of user's Movies directory (~/Movies) */
|
|
|
|
CFMusicDirectory = 18, /* Location of user's Music directory (~/Music) */
|
|
|
|
CFPicturesDirectory = 19, /* Location of user's Pictures directory (~/Pictures) */
|
|
|
|
CFPrinterDescriptionDirectory = 20, /* Location of system's PPDs directory (Library/Printers/PPDs) */
|
|
|
|
CFSharedPublicDirectory = 21, /* Location of user's Public sharing directory (~/Public) */
|
|
|
|
CFPreferencePanesDirectory = 22, /* Location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes) */
|
|
|
|
CFApplicationScriptsDirectory = 23, /* Location of the user scripts folder for the calling application (~/Library/Application Scripts/code-signing-id) */
|
|
|
|
CFItemReplacementDirectory = 99, /* For use with NSFileManager's URLForDirectory:inDomain:appropriateForURL:create:error: */
|
|
|
|
CFAllApplicationsDirectory = 100, /* all directories where applications can occur */
|
|
|
|
CFAllLibrariesDirectory = 101, /* all directories where resources can occur */
|
|
|
|
CFTrashDirectory = 102 /* location of Trash directory */
|
2015-04-20 12:05:55 +00:00
|
|
|
} CFSearchPathDirectory;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2015-04-20 19:00:40 +00:00
|
|
|
CFUserDomainMask = 1, /* user's home directory --- place to install user's personal items (~) */
|
|
|
|
CFLocalDomainMask = 2, /* local to the current machine --- place to install items available to everyone on this machine (/Library) */
|
|
|
|
CFNetworkDomainMask = 4, /* publically available location in the local area network --- place to install items available on the network (/Network) */
|
|
|
|
CFSystemDomainMask = 8, /* provided by Apple, unmodifiable (/System) */
|
|
|
|
CFAllDomainsMask = 0x0ffff /* All domains: all of the above and future items */
|
2015-04-20 12:05:55 +00:00
|
|
|
} CFDomainMask;
|
|
|
|
|
2020-02-13 23:19:54 +00:00
|
|
|
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
|
|
|
|
static int speak_pid = 0;
|
|
|
|
#endif
|
|
|
|
|
2019-02-23 22:29:08 +00:00
|
|
|
static char darwin_cpu_model_name[64] = {0};
|
|
|
|
|
2015-04-20 12:05:55 +00:00
|
|
|
static NSSearchPathDirectory NSConvertFlagsCF(unsigned flags)
|
|
|
|
{
|
2015-04-20 12:07:45 +00:00
|
|
|
switch (flags)
|
|
|
|
{
|
|
|
|
case CFDocumentDirectory:
|
2019-01-30 10:35:51 +00:00
|
|
|
#if TARGET_OS_TV
|
|
|
|
return NSCachesDirectory;
|
|
|
|
#else
|
|
|
|
return NSDocumentDirectory;
|
|
|
|
#endif
|
2015-04-20 12:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-04-20 12:05:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static NSSearchPathDomainMask NSConvertDomainFlagsCF(unsigned flags)
|
|
|
|
{
|
2015-04-20 12:07:45 +00:00
|
|
|
switch (flags)
|
|
|
|
{
|
|
|
|
case CFUserDomainMask:
|
|
|
|
return NSUserDomainMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-04-20 12:05:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 12:07:45 +00:00
|
|
|
static void CFSearchPathForDirectoriesInDomains(unsigned flags,
|
|
|
|
unsigned domain_mask, unsigned expand_tilde,
|
2015-06-02 16:28:51 +00:00
|
|
|
char *s, size_t len)
|
2015-04-20 12:05:55 +00:00
|
|
|
{
|
|
|
|
CFTypeRef array_val = (CFTypeRef)CFBridgingRetainCompat(
|
|
|
|
NSSearchPathForDirectoriesInDomains(NSConvertFlagsCF(flags),
|
|
|
|
NSConvertDomainFlagsCF(domain_mask), (BOOL)expand_tilde));
|
|
|
|
CFArrayRef array = array_val ? CFRetain(array_val) : NULL;
|
|
|
|
CFTypeRef path_val = (CFTypeRef)CFArrayGetValueAtIndex(array, 0);
|
|
|
|
CFStringRef path = path_val ? CFRetain(path_val) : NULL;
|
|
|
|
if (!path || !array)
|
|
|
|
return;
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2015-06-02 16:28:51 +00:00
|
|
|
CFStringGetCString(path, s, len, kCFStringEncodingUTF8);
|
2015-04-20 12:05:55 +00:00
|
|
|
CFRelease(path);
|
|
|
|
CFRelease(array);
|
|
|
|
}
|
|
|
|
|
2015-06-02 16:28:51 +00:00
|
|
|
static void CFTemporaryDirectory(char *s, size_t len)
|
2015-04-20 12:05:55 +00:00
|
|
|
{
|
|
|
|
#if __has_feature(objc_arc)
|
2015-04-20 12:07:45 +00:00
|
|
|
CFStringRef path = (__bridge_retained CFStringRef)NSTemporaryDirectory();
|
2015-04-20 12:05:55 +00:00
|
|
|
#else
|
2015-04-20 12:07:45 +00:00
|
|
|
CFStringRef path = (CFStringRef)NSTemporaryDirectory();
|
2015-04-18 13:07:04 +00:00
|
|
|
#endif
|
2015-06-02 16:28:51 +00:00
|
|
|
CFStringGetCString(path, s, len, kCFStringEncodingUTF8);
|
2015-04-20 12:05:55 +00:00
|
|
|
}
|
2015-04-18 13:07:04 +00:00
|
|
|
|
|
|
|
#if defined(IOS)
|
2015-04-13 16:25:04 +00:00
|
|
|
void get_ios_version(int *major, int *minor);
|
|
|
|
#endif
|
|
|
|
|
2015-04-18 13:07:04 +00:00
|
|
|
#if defined(OSX)
|
2015-04-18 14:42:49 +00:00
|
|
|
|
2015-04-18 13:07:04 +00:00
|
|
|
#define PMGMT_STRMATCH(a,b) (CFStringCompare(a, b, 0) == kCFCompareEqualTo)
|
|
|
|
#define PMGMT_GETVAL(k,v) CFDictionaryGetValueIfPresent(dict, CFSTR(k), (const void **) v)
|
|
|
|
|
|
|
|
/* Note that AC power sources also include a laptop battery it is charging. */
|
|
|
|
static void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery,
|
2015-04-20 12:07:45 +00:00
|
|
|
bool * charging, int *seconds, int *percent)
|
2015-04-18 13:07:04 +00:00
|
|
|
{
|
2015-04-20 12:07:45 +00:00
|
|
|
CFStringRef strval; /* don't CFRelease() this. */
|
|
|
|
CFBooleanRef bval;
|
|
|
|
CFNumberRef numval;
|
|
|
|
bool charge = false;
|
|
|
|
bool choose = false;
|
|
|
|
bool is_ac = false;
|
|
|
|
int secs = -1;
|
|
|
|
int maxpct = -1;
|
|
|
|
int pct = -1;
|
|
|
|
|
|
|
|
if ((PMGMT_GETVAL(kIOPSIsPresentKey, &bval)) && (bval == kCFBooleanFalse))
|
2015-04-20 19:00:40 +00:00
|
|
|
return;
|
2015-04-20 12:07:45 +00:00
|
|
|
|
|
|
|
if (!PMGMT_GETVAL(kIOPSPowerSourceStateKey, &strval))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (PMGMT_STRMATCH(strval, CFSTR(kIOPSACPowerValue)))
|
|
|
|
is_ac = *have_ac = true;
|
|
|
|
else if (!PMGMT_STRMATCH(strval, CFSTR(kIOPSBatteryPowerValue)))
|
|
|
|
return; /* not a battery? */
|
|
|
|
|
|
|
|
if ((PMGMT_GETVAL(kIOPSIsChargingKey, &bval)) && (bval == kCFBooleanTrue))
|
|
|
|
charge = true;
|
|
|
|
|
|
|
|
if (PMGMT_GETVAL(kIOPSMaxCapacityKey, &numval))
|
|
|
|
{
|
|
|
|
SInt32 val = -1;
|
|
|
|
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
|
|
|
|
if (val > 0)
|
|
|
|
{
|
|
|
|
*have_battery = true;
|
|
|
|
maxpct = (int) val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PMGMT_GETVAL(kIOPSMaxCapacityKey, &numval))
|
|
|
|
{
|
|
|
|
SInt32 val = -1;
|
|
|
|
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
|
|
|
|
if (val > 0)
|
|
|
|
{
|
|
|
|
*have_battery = true;
|
|
|
|
maxpct = (int) val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PMGMT_GETVAL(kIOPSTimeToEmptyKey, &numval))
|
|
|
|
{
|
|
|
|
SInt32 val = -1;
|
|
|
|
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
|
|
|
|
|
|
|
|
/* Mac OS X reports 0 minutes until empty if you're plugged in. :( */
|
|
|
|
if ((val == 0) && (is_ac))
|
|
|
|
val = -1; /* !!! FIXME: calc from timeToFull and capacity? */
|
|
|
|
|
|
|
|
secs = (int) val;
|
|
|
|
if (secs > 0)
|
|
|
|
secs *= 60; /* value is in minutes, so convert to seconds. */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PMGMT_GETVAL(kIOPSCurrentCapacityKey, &numval))
|
|
|
|
{
|
|
|
|
SInt32 val = -1;
|
|
|
|
CFNumberGetValue(numval, kCFNumberSInt32Type, &val);
|
|
|
|
pct = (int) val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pct > 0) && (maxpct > 0))
|
|
|
|
pct = (int) ((((double) pct) / ((double) maxpct)) * 100.0);
|
|
|
|
|
|
|
|
if (pct > 100)
|
|
|
|
pct = 100;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We pick the battery that claims to have the most minutes left.
|
|
|
|
* (failing a report of minutes, we'll take the highest percent.)
|
|
|
|
*/
|
|
|
|
if ((secs < 0) && (*seconds < 0))
|
|
|
|
{
|
|
|
|
if ((pct < 0) && (*percent < 0))
|
|
|
|
choose = true; /* at least we know there's a battery. */
|
|
|
|
if (pct > *percent)
|
|
|
|
choose = true;
|
|
|
|
}
|
|
|
|
else if (secs > *seconds)
|
|
|
|
choose = true;
|
|
|
|
|
|
|
|
if (choose)
|
|
|
|
{
|
|
|
|
*seconds = secs;
|
|
|
|
*percent = pct;
|
|
|
|
*charging = charge;
|
|
|
|
}
|
2015-04-18 13:07:04 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-06-02 16:28:51 +00:00
|
|
|
static void frontend_darwin_get_name(char *s, size_t len)
|
2015-04-07 17:18:36 +00:00
|
|
|
{
|
2015-04-18 19:52:45 +00:00
|
|
|
#if defined(IOS)
|
2015-04-20 12:07:45 +00:00
|
|
|
struct utsname buffer;
|
|
|
|
|
|
|
|
if (uname(&buffer) != 0)
|
|
|
|
return;
|
|
|
|
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, buffer.machine, len);
|
2015-04-18 19:52:45 +00:00
|
|
|
#elif defined(OSX)
|
2015-04-20 12:07:45 +00:00
|
|
|
size_t length = 0;
|
2016-01-13 19:32:42 +00:00
|
|
|
sysctlbyname("hw.model", NULL, &length, NULL, 0);
|
|
|
|
if (length)
|
|
|
|
sysctlbyname("hw.model", s, &length, NULL, 0);
|
2015-04-07 17:30:24 +00:00
|
|
|
#endif
|
2015-04-07 17:18:36 +00:00
|
|
|
}
|
|
|
|
|
2015-06-02 16:28:51 +00:00
|
|
|
static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor)
|
2015-04-13 16:05:55 +00:00
|
|
|
{
|
2015-04-18 19:52:45 +00:00
|
|
|
#if defined(IOS)
|
2015-04-20 12:07:45 +00:00
|
|
|
get_ios_version(major, minor);
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "iOS", len);
|
2015-04-18 19:52:45 +00:00
|
|
|
#elif defined(OSX)
|
2018-11-05 13:52:31 +00:00
|
|
|
|
|
|
|
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 // MAC_OS_X_VERSION_10_13
|
|
|
|
NSOperatingSystemVersion version = NSProcessInfo.processInfo.operatingSystemVersion;
|
|
|
|
*major = (int)version.majorVersion;
|
|
|
|
*minor = (int)version.minorVersion;
|
|
|
|
#else
|
2018-06-21 04:29:53 +00:00
|
|
|
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)])
|
|
|
|
{
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
NSInteger majorVersion;
|
|
|
|
NSInteger minorVersion;
|
|
|
|
NSInteger patchVersion;
|
|
|
|
} NSMyOSVersion;
|
|
|
|
NSMyOSVersion version = ((NSMyOSVersion(*)(id, SEL))objc_msgSend_stret)([NSProcessInfo processInfo], @selector(operatingSystemVersion));
|
2018-06-21 05:34:27 +00:00
|
|
|
*major = (int)version.majorVersion;
|
|
|
|
*minor = (int)version.minorVersion;
|
2018-06-21 04:29:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Gestalt(gestaltSystemVersionMinor, (SInt32*)minor);
|
|
|
|
Gestalt(gestaltSystemVersionMajor, (SInt32*)major);
|
|
|
|
}
|
2018-11-05 13:52:31 +00:00
|
|
|
#endif
|
2015-06-02 16:28:51 +00:00
|
|
|
strlcpy(s, "OSX", len);
|
2015-04-13 16:25:04 +00:00
|
|
|
#endif
|
2015-04-13 16:05:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:19:51 +00:00
|
|
|
static void frontend_darwin_get_environment_settings(int *argc, char *argv[],
|
2014-10-07 02:43:59 +00:00
|
|
|
void *args, void *params_data)
|
|
|
|
{
|
|
|
|
CFURLRef bundle_url;
|
2015-01-09 01:12:08 +00:00
|
|
|
CFStringRef bundle_path;
|
2015-06-12 21:38:46 +00:00
|
|
|
char temp_dir[PATH_MAX_LENGTH] = {0};
|
|
|
|
char bundle_path_buf[PATH_MAX_LENGTH] = {0};
|
|
|
|
char home_dir_buf[PATH_MAX_LENGTH] = {0};
|
2014-10-07 02:43:59 +00:00
|
|
|
CFBundleRef bundle = CFBundleGetMainBundle();
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2015-03-13 00:22:20 +00:00
|
|
|
(void)temp_dir;
|
2015-01-09 01:12:08 +00:00
|
|
|
|
2014-10-07 02:43:59 +00:00
|
|
|
if (!bundle)
|
|
|
|
return;
|
2015-01-09 01:12:08 +00:00
|
|
|
|
|
|
|
bundle_url = CFBundleCopyBundleURL(bundle);
|
|
|
|
bundle_path = CFURLCopyPath(bundle_url);
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2014-10-18 02:36:02 +00:00
|
|
|
CFStringGetCString(bundle_path, bundle_path_buf, sizeof(bundle_path_buf), kCFStringEncodingUTF8);
|
2014-10-07 14:51:25 +00:00
|
|
|
(void)home_dir_buf;
|
2015-03-13 00:21:20 +00:00
|
|
|
|
2017-05-23 17:43:58 +00:00
|
|
|
CFSearchPathForDirectoriesInDomains(CFDocumentDirectory,
|
|
|
|
CFUserDomainMask, 1, home_dir_buf, sizeof(home_dir_buf));
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2017-11-23 03:33:48 +00:00
|
|
|
#if TARGET_OS_IPHONE
|
|
|
|
char resolved_home_dir_buf[PATH_MAX_LENGTH] = {0};
|
|
|
|
if (realpath(home_dir_buf, resolved_home_dir_buf)) {
|
|
|
|
retro_assert(strlcpy(home_dir_buf,
|
|
|
|
resolved_home_dir_buf,
|
|
|
|
sizeof(home_dir_buf)) < sizeof(home_dir_buf));
|
|
|
|
}
|
2019-07-13 02:35:49 +00:00
|
|
|
char resolved_bundle_dir_buf[PATH_MAX_LENGTH] = {0};
|
|
|
|
if (realpath(bundle_path_buf, resolved_bundle_dir_buf))
|
|
|
|
{
|
|
|
|
retro_assert(strlcpy(bundle_path_buf,
|
|
|
|
resolved_bundle_dir_buf,
|
|
|
|
sizeof(bundle_path_buf)) < sizeof(bundle_path_buf));
|
|
|
|
}
|
2017-11-23 03:33:48 +00:00
|
|
|
#endif
|
|
|
|
|
2015-04-20 12:07:45 +00:00
|
|
|
strlcat(home_dir_buf, "/RetroArch", sizeof(home_dir_buf));
|
2018-07-15 22:56:47 +00:00
|
|
|
#ifdef HAVE_METAL
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER],
|
|
|
|
home_dir_buf, "shaders_slang",
|
|
|
|
sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
|
|
|
|
#else
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER],
|
|
|
|
home_dir_buf, "shaders_glsl",
|
|
|
|
sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
|
2018-07-15 22:56:47 +00:00
|
|
|
#endif
|
2019-01-26 23:18:32 +00:00
|
|
|
#if TARGET_OS_IOS
|
2016-07-10 19:02:40 +00:00
|
|
|
int major, minor;
|
|
|
|
get_ios_version(&major, &minor);
|
2017-05-23 17:43:58 +00:00
|
|
|
if (major >= 10 )
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE],
|
|
|
|
bundle_path_buf, "modules", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
|
|
|
else
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE],
|
|
|
|
home_dir_buf, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
2019-01-26 23:18:32 +00:00
|
|
|
#elif TARGET_OS_TV
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE],
|
|
|
|
bundle_path_buf, "modules", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
2016-07-10 19:02:40 +00:00
|
|
|
#else
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], home_dir_buf, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
2016-07-10 19:02:40 +00:00
|
|
|
#endif
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], home_dir_buf, "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], home_dir_buf, "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY]));
|
2019-04-16 16:41:06 +00:00
|
|
|
#ifdef HAVE_VIDEO_LAYOUT
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], home_dir_buf, "layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT]));
|
|
|
|
#endif
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], home_dir_buf, "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], home_dir_buf, "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], home_dir_buf, "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], home_dir_buf, "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], home_dir_buf, "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], home_dir_buf, "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], home_dir_buf, "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], home_dir_buf, "cht", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], home_dir_buf, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], home_dir_buf, "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], home_dir_buf, "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE]));
|
2017-05-23 23:56:09 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG], home_dir_buf, "records_config", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_CONFIG]));
|
2017-05-24 14:48:45 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT], home_dir_buf, "records", sizeof(g_defaults.dirs[DEFAULT_DIR_RECORD_OUTPUT]));
|
2019-03-25 17:22:59 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_LOGS], home_dir_buf, "logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS]));
|
2016-05-01 13:30:25 +00:00
|
|
|
#if defined(IOS)
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], home_dir_buf, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST]));
|
2016-05-01 13:30:25 +00:00
|
|
|
#endif
|
2015-07-18 21:41:42 +00:00
|
|
|
#if defined(OSX)
|
2016-05-02 11:23:47 +00:00
|
|
|
char application_data[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
fill_pathname_application_data(application_data, sizeof(application_data));
|
|
|
|
|
2015-07-18 21:41:42 +00:00
|
|
|
#ifdef HAVE_CG
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], home_dir_buf, "shaders_cg", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
|
2015-07-18 21:41:42 +00:00
|
|
|
#endif
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], home_dir_buf, "audio_filters", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], home_dir_buf, "video_filters", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], application_data, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], application_data, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], application_data, "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP]));
|
2017-05-24 18:19:48 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], application_data, "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]));
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], application_data, "screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT]));
|
2015-10-21 21:40:23 +00:00
|
|
|
#if defined(RELEASE_BUILD)
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], bundle_path_buf, "Contents/Resources/shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], bundle_path_buf, "Contents/Resources/cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], bundle_path_buf, "Contents/Resources/info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], bundle_path_buf, "Contents/Resources/overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY]));
|
2019-04-16 16:41:06 +00:00
|
|
|
#ifdef HAVE_VIDEO_LAYOUT
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], bundle_path_buf, "Contents/Resources/layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT]));
|
|
|
|
#endif
|
2017-05-23 17:43:58 +00:00
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], bundle_path_buf, "Contents/Resources/autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], bundle_path_buf, "Contents/Resources/assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], bundle_path_buf, "Contents/Resources/database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], bundle_path_buf, "Contents/Resources/database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR]));
|
|
|
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
|
2015-07-18 21:41:42 +00:00
|
|
|
#endif
|
2015-07-18 15:36:06 +00:00
|
|
|
#endif
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2019-08-27 01:43:12 +00:00
|
|
|
#if TARGET_OS_IPHONE
|
2016-01-13 12:00:25 +00:00
|
|
|
char assets_zip_path[PATH_MAX_LENGTH];
|
2019-08-27 01:43:12 +00:00
|
|
|
#if TARGET_OS_IOS
|
2015-10-31 16:54:31 +00:00
|
|
|
if (major > 8)
|
|
|
|
strlcpy(g_defaults.path.buildbot_server_url, "http://buildbot.libretro.com/nightly/apple/ios9/latest/", sizeof(g_defaults.path.buildbot_server_url));
|
2019-08-27 01:43:12 +00:00
|
|
|
#endif
|
2016-01-10 00:48:41 +00:00
|
|
|
|
2016-01-10 01:21:35 +00:00
|
|
|
fill_pathname_join(assets_zip_path, bundle_path_buf, "assets.zip", sizeof(assets_zip_path));
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2019-05-31 04:43:20 +00:00
|
|
|
if (path_is_valid(assets_zip_path))
|
2016-01-10 01:21:35 +00:00
|
|
|
{
|
2016-01-13 12:00:25 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
2016-01-10 12:23:02 +00:00
|
|
|
RARCH_LOG("Assets ZIP found at [%s], setting up bundle assets extraction...\n", assets_zip_path);
|
|
|
|
RARCH_LOG("Extraction dir will be: %s\n", home_dir_buf);
|
2019-05-31 04:43:20 +00:00
|
|
|
strlcpy(settings->arrays.bundle_assets_src,
|
|
|
|
assets_zip_path, sizeof(settings->arrays.bundle_assets_src));
|
|
|
|
strlcpy(settings->arrays.bundle_assets_dst,
|
|
|
|
home_dir_buf, sizeof(settings->arrays.bundle_assets_dst));
|
2017-04-28 19:18:35 +00:00
|
|
|
settings->uints.bundle_assets_extract_version_current = 130; /* TODO/FIXME: Just hardcode this for now */
|
2016-01-10 01:21:35 +00:00
|
|
|
}
|
2015-10-31 16:54:31 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-13 00:33:45 +00:00
|
|
|
CFTemporaryDirectory(temp_dir, sizeof(temp_dir));
|
2017-05-23 17:43:58 +00:00
|
|
|
strlcpy(g_defaults.dirs[DEFAULT_DIR_CACHE],
|
|
|
|
temp_dir,
|
|
|
|
sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE]));
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2014-10-07 02:43:59 +00:00
|
|
|
path_mkdir(bundle_path_buf);
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2014-10-07 02:55:14 +00:00
|
|
|
if (access(bundle_path_buf, 0755) != 0)
|
2014-10-07 02:43:59 +00:00
|
|
|
RARCH_ERR("Failed to create or access base directory: %s\n", bundle_path_buf);
|
2015-04-20 12:07:45 +00:00
|
|
|
else
|
|
|
|
{
|
2017-05-23 17:43:58 +00:00
|
|
|
path_mkdir(g_defaults.dirs[DEFAULT_DIR_SYSTEM]);
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2017-05-23 17:43:58 +00:00
|
|
|
if (access(g_defaults.dirs[DEFAULT_DIR_SYSTEM], 0755) != 0)
|
|
|
|
RARCH_ERR("Failed to create or access system directory: %s.\n", g_defaults.dirs[DEFAULT_DIR_SYSTEM]);
|
2015-04-20 12:07:45 +00:00
|
|
|
}
|
2014-10-07 02:43:59 +00:00
|
|
|
|
|
|
|
CFRelease(bundle_path);
|
|
|
|
CFRelease(bundle_url);
|
2014-05-03 05:11:23 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:19:51 +00:00
|
|
|
static void frontend_darwin_load_content(void)
|
2014-10-17 01:55:16 +00:00
|
|
|
{
|
2015-12-05 08:55:13 +00:00
|
|
|
ui_companion_driver_notify_content_loaded();
|
2014-10-17 01:55:16 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:19:51 +00:00
|
|
|
static int frontend_darwin_get_rating(void)
|
2014-05-16 20:20:33 +00:00
|
|
|
{
|
2015-06-12 21:38:46 +00:00
|
|
|
char model[PATH_MAX_LENGTH] = {0};
|
2015-04-07 18:57:20 +00:00
|
|
|
|
2015-04-20 15:19:51 +00:00
|
|
|
frontend_darwin_get_name(model, sizeof(model));
|
2015-04-07 18:57:20 +00:00
|
|
|
|
|
|
|
/* iPhone 4 */
|
|
|
|
#if 0
|
|
|
|
if (strstr(model, "iPhone3"))
|
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* iPad 1 */
|
|
|
|
#if 0
|
|
|
|
if (strstr(model, "iPad1,1"))
|
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
|
2015-04-07 18:42:48 +00:00
|
|
|
/* iPhone 4S */
|
|
|
|
if (strstr(model, "iPhone4,1"))
|
2015-04-07 18:57:20 +00:00
|
|
|
return 8;
|
|
|
|
|
2015-04-07 18:42:48 +00:00
|
|
|
/* iPad 2/iPad Mini 1 */
|
|
|
|
if (strstr(model, "iPad2"))
|
2015-04-07 18:57:20 +00:00
|
|
|
return 9;
|
|
|
|
|
|
|
|
/* iPhone 5/5C */
|
|
|
|
if (strstr(model, "iPhone5"))
|
|
|
|
return 13;
|
|
|
|
|
|
|
|
/* iPhone 5S */
|
|
|
|
if (strstr(model, "iPhone6,1") || strstr(model, "iPhone6,2"))
|
|
|
|
return 14;
|
|
|
|
|
2015-04-07 19:02:34 +00:00
|
|
|
/* iPad Mini 2/3 */
|
|
|
|
if ( strstr(model, "iPad4,4")
|
|
|
|
|| strstr(model, "iPad4,5")
|
|
|
|
|| strstr(model, "iPad4,6")
|
|
|
|
|| strstr(model, "iPad4,7")
|
|
|
|
|| strstr(model, "iPad4,8")
|
|
|
|
|| strstr(model, "iPad4,9")
|
2015-04-20 12:07:45 +00:00
|
|
|
)
|
2015-04-07 19:07:09 +00:00
|
|
|
return 15;
|
|
|
|
|
|
|
|
/* iPad Air */
|
|
|
|
if ( strstr(model, "iPad4,1")
|
|
|
|
|| strstr(model, "iPad4,2")
|
|
|
|
|| strstr(model, "iPad4,3")
|
|
|
|
)
|
2015-04-07 19:02:34 +00:00
|
|
|
return 16;
|
2015-04-07 18:57:20 +00:00
|
|
|
|
|
|
|
/* iPhone 6, iPhone 6 Plus */
|
|
|
|
if (strstr(model, "iPhone7"))
|
2015-04-07 19:02:34 +00:00
|
|
|
return 17;
|
2015-04-07 18:57:20 +00:00
|
|
|
|
2015-04-07 18:42:48 +00:00
|
|
|
/* iPad Air 2 */
|
|
|
|
if (strstr(model, "iPad5,3") || strstr(model, "iPad5,4"))
|
2015-04-07 18:59:06 +00:00
|
|
|
return 18;
|
2015-04-07 18:57:20 +00:00
|
|
|
|
2019-08-13 04:28:39 +00:00
|
|
|
/* iPad Pro (12.9 Inch) */
|
|
|
|
if (strstr(model, "iPad6,7") || strstr(model, "iPad6,8"))
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad Pro (9.7 Inch) */
|
|
|
|
if (strstr(model, "iPad6,3") || strstr(model, "iPad6,4"))
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad 5th Generation */
|
|
|
|
if (strstr(model, "iPad6,11") || strstr(model, "iPad6,12"))
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad Pro (12.9 Inch 2nd Generation) */
|
|
|
|
if (strstr(model, "iPad7,1") || strstr(model, "iPad7,2"))
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad Pro (10.5 Inch) */
|
|
|
|
if (strstr(model, "iPad7,3") || strstr(model, "iPad7,4"))
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad Pro 6th Generation) */
|
|
|
|
if (strstr(model, "iPad7,5") || strstr(model, "iPad7,6"))
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad Pro (11 Inch) */
|
|
|
|
if ( strstr(model, "iPad8,1")
|
|
|
|
|| strstr(model, "iPad8,2")
|
|
|
|
|| strstr(model, "iPad8,3")
|
|
|
|
|| strstr(model, "iPad8,4")
|
|
|
|
)
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad Pro (12.9 3rd Generation) */
|
|
|
|
if ( strstr(model, "iPad8,5")
|
|
|
|
|| strstr(model, "iPad8,6")
|
|
|
|
|| strstr(model, "iPad8,7")
|
|
|
|
|| strstr(model, "iPad8,8")
|
|
|
|
)
|
|
|
|
return 19;
|
|
|
|
|
|
|
|
/* iPad Air 3rd Generation) */
|
|
|
|
if ( strstr(model, "iPad11,3")
|
|
|
|
|| strstr(model, "iPad11,4"))
|
|
|
|
return 19;
|
|
|
|
|
2019-02-03 23:49:35 +00:00
|
|
|
/* TODO/FIXME -
|
2015-04-07 18:57:20 +00:00
|
|
|
- more ratings for more systems
|
|
|
|
- determine rating more intelligently*/
|
2014-05-16 20:20:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2015-04-07 17:18:36 +00:00
|
|
|
|
2015-04-20 15:19:51 +00:00
|
|
|
static enum frontend_powerstate frontend_darwin_get_powerstate(int *seconds, int *percent)
|
2015-04-18 13:07:04 +00:00
|
|
|
{
|
2015-04-18 13:09:03 +00:00
|
|
|
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
|
2015-04-18 13:07:04 +00:00
|
|
|
#if defined(OSX)
|
2015-04-18 13:09:03 +00:00
|
|
|
CFIndex i, total;
|
|
|
|
CFArrayRef list;
|
|
|
|
bool have_ac, have_battery, charging;
|
|
|
|
CFTypeRef blob = IOPSCopyPowerSourcesInfo();
|
|
|
|
|
|
|
|
*seconds = -1;
|
|
|
|
*percent = -1;
|
|
|
|
|
|
|
|
if (!blob)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
list = IOPSCopyPowerSourcesList(blob);
|
|
|
|
|
|
|
|
if (!list)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
/* don't CFRelease() the list items, or dictionaries! */
|
|
|
|
have_ac = false;
|
|
|
|
have_battery = false;
|
|
|
|
charging = false;
|
|
|
|
total = CFArrayGetCount(list);
|
|
|
|
|
|
|
|
for (i = 0; i < total; i++)
|
|
|
|
{
|
|
|
|
CFTypeRef ps = (CFTypeRef)CFArrayGetValueAtIndex(list, i);
|
|
|
|
CFDictionaryRef dict = IOPSGetPowerSourceDescription(blob, ps);
|
|
|
|
if (dict)
|
|
|
|
checkps(dict, &have_ac, &have_battery, &charging,
|
|
|
|
seconds, percent);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!have_battery)
|
|
|
|
ret = FRONTEND_POWERSTATE_NO_SOURCE;
|
|
|
|
else if (charging)
|
|
|
|
ret = FRONTEND_POWERSTATE_CHARGING;
|
|
|
|
else if (have_ac)
|
|
|
|
ret = FRONTEND_POWERSTATE_CHARGED;
|
|
|
|
else
|
|
|
|
ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
|
|
|
|
|
|
|
CFRelease(list);
|
|
|
|
end:
|
|
|
|
if (blob)
|
|
|
|
CFRelease(blob);
|
2019-01-26 23:18:32 +00:00
|
|
|
#elif TARGET_OS_IOS
|
2015-04-21 10:15:42 +00:00
|
|
|
float level;
|
|
|
|
UIDevice *uidev = [UIDevice currentDevice];
|
|
|
|
|
|
|
|
if (!uidev)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
[uidev setBatteryMonitoringEnabled:true];
|
|
|
|
|
|
|
|
switch (uidev.batteryState)
|
|
|
|
{
|
|
|
|
case UIDeviceBatteryStateCharging:
|
|
|
|
ret = FRONTEND_POWERSTATE_CHARGING;
|
|
|
|
break;
|
|
|
|
case UIDeviceBatteryStateFull:
|
|
|
|
ret = FRONTEND_POWERSTATE_CHARGED;
|
|
|
|
break;
|
|
|
|
case UIDeviceBatteryStateUnplugged:
|
|
|
|
ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
|
|
|
break;
|
|
|
|
case UIDeviceBatteryStateUnknown:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
level = uidev.batteryLevel;
|
|
|
|
|
|
|
|
*percent = ((level < 0.0f) ? -1 : ((int)((level * 100) + 0.5f)));
|
|
|
|
|
|
|
|
[uidev setBatteryMonitoringEnabled:false];
|
2015-04-18 13:07:04 +00:00
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
2015-04-13 16:05:55 +00:00
|
|
|
|
2015-06-14 17:26:53 +00:00
|
|
|
#define DARWIN_ARCH_X86_64 0x23dea434U
|
|
|
|
#define DARWIN_ARCH_X86 0x0b88b8cbU
|
|
|
|
#define DARWIN_ARCH_POWER_MAC 0xba3772d8U
|
|
|
|
|
2015-04-20 20:53:56 +00:00
|
|
|
static enum frontend_architecture frontend_darwin_get_architecture(void)
|
2015-04-18 18:03:59 +00:00
|
|
|
{
|
2015-04-18 19:14:30 +00:00
|
|
|
struct utsname buffer;
|
2015-06-14 17:26:53 +00:00
|
|
|
uint32_t buffer_hash;
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2015-04-18 19:14:30 +00:00
|
|
|
if (uname(&buffer) != 0)
|
|
|
|
return FRONTEND_ARCH_NONE;
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2015-06-14 17:26:53 +00:00
|
|
|
(void)buffer_hash;
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2015-04-18 19:14:30 +00:00
|
|
|
#ifdef OSX
|
2015-06-14 17:26:53 +00:00
|
|
|
buffer_hash = djb2_calculate(buffer.machine);
|
|
|
|
|
|
|
|
switch (buffer_hash)
|
|
|
|
{
|
2015-06-14 17:28:20 +00:00
|
|
|
case DARWIN_ARCH_X86_64:
|
2015-06-14 17:26:53 +00:00
|
|
|
return FRONTEND_ARCH_X86_64;
|
|
|
|
case DARWIN_ARCH_X86:
|
|
|
|
return FRONTEND_ARCH_X86;
|
|
|
|
case DARWIN_ARCH_POWER_MAC:
|
|
|
|
return FRONTEND_ARCH_PPC;
|
|
|
|
}
|
2015-04-20 12:07:45 +00:00
|
|
|
|
2015-04-18 18:03:59 +00:00
|
|
|
return FRONTEND_ARCH_NONE;
|
2016-05-18 20:09:01 +00:00
|
|
|
#else
|
|
|
|
/* TODO/FIXME - make this more flexible */
|
|
|
|
return FRONTEND_ARCH_ARMV7;
|
|
|
|
#endif
|
2015-04-18 18:03:59 +00:00
|
|
|
}
|
2015-04-13 16:05:55 +00:00
|
|
|
|
2017-05-26 13:52:38 +00:00
|
|
|
static int frontend_darwin_parse_drive_list(void *data, bool load_content)
|
2015-06-15 20:45:02 +00:00
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
#if TARGET_OS_IPHONE
|
2015-06-18 08:13:29 +00:00
|
|
|
#ifdef HAVE_MENU
|
2015-06-15 20:45:02 +00:00
|
|
|
file_list_t *list = (file_list_t*)data;
|
2015-08-10 16:12:11 +00:00
|
|
|
CFURLRef bundle_url;
|
|
|
|
CFStringRef bundle_path;
|
|
|
|
char bundle_path_buf[PATH_MAX_LENGTH] = {0};
|
|
|
|
char home_dir_buf[PATH_MAX_LENGTH] = {0};
|
|
|
|
CFBundleRef bundle = CFBundleGetMainBundle();
|
2017-05-26 13:52:38 +00:00
|
|
|
enum msg_hash_enums enum_idx = load_content ?
|
|
|
|
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR :
|
2019-12-31 12:32:32 +00:00
|
|
|
MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY;
|
2015-08-10 16:12:11 +00:00
|
|
|
|
|
|
|
bundle_url = CFBundleCopyBundleURL(bundle);
|
|
|
|
bundle_path = CFURLCopyPath(bundle_url);
|
|
|
|
|
|
|
|
CFStringGetCString(bundle_path, bundle_path_buf, sizeof(bundle_path_buf), kCFStringEncodingUTF8);
|
|
|
|
(void)home_dir_buf;
|
|
|
|
|
|
|
|
CFSearchPathForDirectoriesInDomains(CFDocumentDirectory, CFUserDomainMask, 1, home_dir_buf, sizeof(home_dir_buf));
|
2015-06-15 20:45:02 +00:00
|
|
|
|
2016-07-12 23:17:09 +00:00
|
|
|
menu_entries_append_enum(list,
|
2016-12-13 00:32:41 +00:00
|
|
|
home_dir_buf,
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
2017-05-26 13:52:38 +00:00
|
|
|
enum_idx,
|
2017-05-26 14:45:28 +00:00
|
|
|
FILE_TYPE_DIRECTORY, 0, 0);
|
2016-12-13 00:32:41 +00:00
|
|
|
menu_entries_append_enum(list, "/",
|
|
|
|
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
2017-05-26 13:52:38 +00:00
|
|
|
enum_idx,
|
2017-05-26 14:45:28 +00:00
|
|
|
FILE_TYPE_DIRECTORY, 0, 0);
|
2015-06-15 20:45:02 +00:00
|
|
|
|
|
|
|
ret = 0;
|
2015-08-10 16:12:11 +00:00
|
|
|
|
2015-08-10 16:11:28 +00:00
|
|
|
CFRelease(bundle_path);
|
|
|
|
CFRelease(bundle_url);
|
2015-06-18 08:13:29 +00:00
|
|
|
#endif
|
2015-06-15 20:45:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-06-12 11:49:00 +00:00
|
|
|
static uint64_t frontend_darwin_get_mem_total(void)
|
|
|
|
{
|
2016-06-12 12:16:49 +00:00
|
|
|
#if defined(OSX)
|
2016-06-12 11:49:00 +00:00
|
|
|
uint64_t size;
|
|
|
|
int mib[2] = { CTL_HW, HW_MEMSIZE };
|
|
|
|
u_int namelen = sizeof(mib) / sizeof(mib[0]);
|
|
|
|
size_t len = sizeof(size);
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2016-06-12 11:49:00 +00:00
|
|
|
if (sysctl(mib, namelen, &size, &len, NULL, 0) < 0)
|
|
|
|
return 0;
|
|
|
|
return size;
|
2016-06-12 12:16:49 +00:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
2016-06-12 11:49:00 +00:00
|
|
|
}
|
|
|
|
|
2016-06-12 18:50:03 +00:00
|
|
|
static uint64_t frontend_darwin_get_mem_used(void)
|
2016-06-12 16:42:03 +00:00
|
|
|
{
|
2016-09-09 13:56:56 +00:00
|
|
|
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
|
2016-06-12 16:42:03 +00:00
|
|
|
vm_size_t page_size;
|
|
|
|
vm_statistics64_data_t vm_stats;
|
|
|
|
mach_port_t mach_port = mach_host_self();
|
|
|
|
mach_msg_type_number_t count = sizeof(vm_stats) / sizeof(natural_t);
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2016-06-12 16:42:03 +00:00
|
|
|
if (KERN_SUCCESS == host_page_size(mach_port, &page_size) &&
|
|
|
|
KERN_SUCCESS == host_statistics64(mach_port, HOST_VM_INFO,
|
|
|
|
(host_info64_t)&vm_stats, &count))
|
|
|
|
{
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2016-06-12 16:42:03 +00:00
|
|
|
long long used_memory = ((int64_t)vm_stats.active_count +
|
|
|
|
(int64_t)vm_stats.inactive_count +
|
|
|
|
(int64_t)vm_stats.wire_count) * (int64_t)page_size;
|
|
|
|
return used_memory;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-23 22:29:08 +00:00
|
|
|
static const char* frontend_darwin_get_cpu_model_name(void)
|
|
|
|
{
|
|
|
|
cpu_features_get_model_name(darwin_cpu_model_name, sizeof(darwin_cpu_model_name));
|
|
|
|
return darwin_cpu_model_name;
|
|
|
|
}
|
|
|
|
|
2020-02-13 23:17:55 +00:00
|
|
|
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
|
|
|
|
static char* accessibility_mac_language_code(const char* language)
|
|
|
|
{
|
|
|
|
if (string_is_equal(language,"en"))
|
|
|
|
return "Alex";
|
|
|
|
else if (string_is_equal(language,"it"))
|
|
|
|
return "Alice";
|
|
|
|
else if (string_is_equal(language,"sv"))
|
|
|
|
return "Alva";
|
|
|
|
else if (string_is_equal(language,"fr"))
|
|
|
|
return "Amelie";
|
|
|
|
else if (string_is_equal(language,"de"))
|
|
|
|
return "Anna";
|
|
|
|
else if (string_is_equal(language,"he"))
|
|
|
|
return "Carmit";
|
|
|
|
else if (string_is_equal(language,"id"))
|
|
|
|
return "Damayanti";
|
|
|
|
else if (string_is_equal(language,"es"))
|
|
|
|
return "Diego";
|
|
|
|
else if (string_is_equal(language,"nl"))
|
|
|
|
return "Ellen";
|
|
|
|
else if (string_is_equal(language,"ro"))
|
|
|
|
return "Ioana";
|
|
|
|
else if (string_is_equal(language,"pt_pt"))
|
|
|
|
return "Joana";
|
|
|
|
else if (string_is_equal(language,"pt_bt") || string_is_equal(language,"pt"))
|
|
|
|
return "Luciana";
|
|
|
|
else if (string_is_equal(language,"th"))
|
|
|
|
return "Kanya";
|
|
|
|
else if (string_is_equal(language,"ja"))
|
|
|
|
return "Kyoko";
|
|
|
|
else if (string_is_equal(language,"sk"))
|
|
|
|
return "Laura";
|
|
|
|
else if (string_is_equal(language,"hi"))
|
|
|
|
return "Lekha";
|
|
|
|
else if (string_is_equal(language,"ar"))
|
|
|
|
return "Maged";
|
|
|
|
else if (string_is_equal(language,"hu"))
|
|
|
|
return "Mariska";
|
|
|
|
else if (string_is_equal(language,"zh_tw") || string_is_equal(language,"zh"))
|
|
|
|
return "Mei-Jia";
|
|
|
|
else if (string_is_equal(language,"el"))
|
|
|
|
return "Melina";
|
|
|
|
else if (string_is_equal(language,"ru"))
|
|
|
|
return "Milena";
|
|
|
|
else if (string_is_equal(language,"nb"))
|
|
|
|
return "Nora";
|
|
|
|
else if (string_is_equal(language,"da"))
|
|
|
|
return "Sara";
|
|
|
|
else if (string_is_equal(language,"fi"))
|
|
|
|
return "Satu";
|
|
|
|
else if (string_is_equal(language,"zh_hk"))
|
|
|
|
return "Sin-ji";
|
|
|
|
else if (string_is_equal(language,"zh_cn"))
|
|
|
|
return "Ting-Ting";
|
|
|
|
else if (string_is_equal(language,"tr"))
|
|
|
|
return "Yelda";
|
|
|
|
else if (string_is_equal(language,"ko"))
|
|
|
|
return "Yuna";
|
|
|
|
else if (string_is_equal(language,"pl"))
|
|
|
|
return "Zosia";
|
|
|
|
else if (string_is_equal(language,"cs"))
|
|
|
|
return "Zuzana";
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool is_narrator_running_macos(void)
|
|
|
|
{
|
|
|
|
return (kill(speak_pid, 0) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool accessibility_speak_macos(int speed,
|
|
|
|
const char* speak_text, int priority)
|
|
|
|
{
|
|
|
|
int pid;
|
|
|
|
const char *voice = get_user_language_iso639_1(false);
|
|
|
|
char* language_speaker = accessibility_mac_language_code(voice);
|
|
|
|
char* speeds[10] = {"80", "100", "125", "150", "170", "210", "260", "310", "380", "450"};
|
|
|
|
|
|
|
|
if (speed < 1)
|
|
|
|
speed = 1;
|
|
|
|
else if (speed > 10)
|
|
|
|
speed = 10;
|
|
|
|
|
|
|
|
if (priority < 10 && speak_pid > 0)
|
|
|
|
{
|
|
|
|
/* check if old pid is running */
|
|
|
|
if (is_narrator_running_macos())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (speak_pid > 0)
|
|
|
|
{
|
|
|
|
/* Kill the running say */
|
|
|
|
kill(speak_pid, SIGTERM);
|
|
|
|
speak_pid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pid = fork();
|
|
|
|
if (pid < 0)
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
RARCH_LOG("ERROR: could not fork for say command.\n");
|
|
|
|
}
|
|
|
|
else if (pid > 0)
|
|
|
|
{
|
|
|
|
/* parent process */
|
|
|
|
speak_pid = pid;
|
|
|
|
|
|
|
|
/* Tell the system that we'll ignore the exit status of the child
|
|
|
|
* process. This prevents zombie processes. */
|
|
|
|
signal(SIGCHLD,SIG_IGN);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* child process: replace process with the say command */
|
|
|
|
if (strlen(language_speaker)> 0)
|
|
|
|
{
|
|
|
|
char* cmd[] = {"say", "-v", NULL,
|
|
|
|
NULL, "-r", NULL, NULL};
|
|
|
|
cmd[2] = language_speaker;
|
|
|
|
cmd[3] = (char *) speak_text;
|
|
|
|
cmd[5] = speeds[speed-1];
|
|
|
|
execvp("say", cmd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char* cmd[] = {"say", NULL, "-r", NULL, NULL};
|
|
|
|
cmd[1] = (char*) speak_text;
|
|
|
|
cmd[3] = speeds[speed-1];
|
|
|
|
execvp("say",cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-07-27 01:44:28 +00:00
|
|
|
frontend_ctx_driver_t frontend_ctx_darwin = {
|
2015-04-20 15:19:51 +00:00
|
|
|
frontend_darwin_get_environment_settings,
|
2013-07-27 15:40:21 +00:00
|
|
|
NULL, /* init */
|
|
|
|
NULL, /* deinit */
|
|
|
|
NULL, /* exitspawn */
|
|
|
|
NULL, /* process_args */
|
|
|
|
NULL, /* exec */
|
2014-10-02 19:39:29 +00:00
|
|
|
NULL, /* set_fork */
|
2015-04-20 15:10:28 +00:00
|
|
|
NULL, /* shutdown */
|
2015-04-20 15:19:51 +00:00
|
|
|
frontend_darwin_get_name,
|
|
|
|
frontend_darwin_get_os,
|
|
|
|
frontend_darwin_get_rating,
|
|
|
|
frontend_darwin_load_content,
|
|
|
|
frontend_darwin_get_architecture,
|
|
|
|
frontend_darwin_get_powerstate,
|
2015-06-15 20:45:02 +00:00
|
|
|
frontend_darwin_parse_drive_list,
|
2016-06-12 11:49:00 +00:00
|
|
|
frontend_darwin_get_mem_total,
|
2016-06-12 18:50:03 +00:00
|
|
|
frontend_darwin_get_mem_used,
|
2016-07-08 00:10:40 +00:00
|
|
|
NULL, /* install_signal_handler */
|
2016-07-08 00:20:42 +00:00
|
|
|
NULL, /* get_sighandler_state */
|
2016-07-08 10:48:01 +00:00
|
|
|
NULL, /* set_sighandler_state */
|
2016-07-08 00:24:56 +00:00
|
|
|
NULL, /* destroy_signal_handler_state */
|
2016-10-09 15:15:50 +00:00
|
|
|
NULL, /* attach_console */
|
|
|
|
NULL, /* detach_console */
|
2018-01-31 10:23:57 +00:00
|
|
|
NULL, /* watch_path_for_changes */
|
|
|
|
NULL, /* check_for_path_changes */
|
2018-06-21 04:29:53 +00:00
|
|
|
NULL, /* set_sustained_performance_mode */
|
2019-04-16 03:14:49 +00:00
|
|
|
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
|
2019-03-03 02:51:36 +00:00
|
|
|
frontend_darwin_get_cpu_model_name,
|
2019-04-16 03:14:49 +00:00
|
|
|
#else
|
2019-03-03 02:51:36 +00:00
|
|
|
NULL,
|
2019-04-16 03:14:49 +00:00
|
|
|
#endif
|
|
|
|
NULL, /* get_user_language */
|
2020-02-13 23:17:55 +00:00
|
|
|
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
|
|
|
|
is_narrator_running_macos, /* is_narrator_running */
|
|
|
|
accessibility_speak_macos, /* accessibility_speak */
|
|
|
|
#else
|
|
|
|
NULL, /* is_narrator_running */
|
|
|
|
NULL, /* accessibility_speak */
|
|
|
|
#endif
|
2015-04-20 15:19:51 +00:00
|
|
|
"darwin",
|
2013-07-27 15:40:21 +00:00
|
|
|
};
|