Skip to content

Commit 5faafec

Browse files
author
SeiRyu
committed
Compile: Fix PS2 Paths / Fix PSP to compile on AppleTV
1 parent b23251e commit 5faafec

File tree

140 files changed

+36845
-13310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+36845
-13310
lines changed

Cores/Flycast/cmake/flycast_libretro.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -4838,8 +4838,10 @@
48384838
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
48394839
ARCHS = "$(ARCHS_STANDARD)";
48404840
BUILD_DIR = ../lib;
4841+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
48414842
CODE_SIGN_IDENTITY = "iPhone Developer";
48424843
DEVELOPMENT_TEAM = XXXXXXXXXX;
4844+
GCC_C_LANGUAGE_STANDARD = gnu99;
48434845
GCC_PREPROCESSOR_DEFINITIONS = (
48444846
__APPLE__,
48454847
IOS,

Cores/PPSSPP/PVPPSSPP.xcodeproj/project.pbxproj

+109-370
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
//
2+
// AppleBatteryClient.m
3+
// PPSSPP
4+
//
5+
// Created by Serena on 24/01/2023.
6+
//
7+
8+
#include "Battery.h"
9+
#import <Foundation/Foundation.h>
10+
11+
#if PPSSPP_PLATFORM(MAC)
12+
#include <IOKit/ps/IOPSKeys.h>
13+
#include <IOKit/ps/IOPowerSources.h>
14+
#elif PPSSPP_PLATFORM(IOS)
15+
#import <UIKit/UIKit.h>
16+
#endif
17+
18+
@interface AppleBatteryClient : NSObject
19+
+(instancetype)sharedClient;
20+
-(void)setNeedsToUpdateLevel;
21+
@property int batteryLevel;
22+
@end
23+
24+
void _powerSourceRunLoopCallback(void * __unused ctx) {
25+
// IOKit has told us that battery information has changed, now update the batteryLevel var
26+
[[AppleBatteryClient sharedClient] setNeedsToUpdateLevel];
27+
}
28+
29+
// You may ask,
30+
// "Why an entire class?
31+
// Why not just call the UIDevice/IOKitPowerSource functions every time getCurrentBatteryCapacity() is called?"
32+
// Well, calling the UIDevice/IOKitPowerSource functions very frequently (every second, it seems?) is expensive
33+
// So, instead, I made a class with a cached batteryLevel property
34+
// that only gets set when it needs to.
35+
@implementation AppleBatteryClient
36+
37+
+ (instancetype)sharedClient {
38+
static AppleBatteryClient *client;
39+
static dispatch_once_t onceToken;
40+
dispatch_once(&onceToken, ^{
41+
client = [AppleBatteryClient new];
42+
[client initialSetup];
43+
[client setNeedsToUpdateLevel];
44+
});
45+
46+
return client;
47+
}
48+
49+
-(void)initialSetup {
50+
#if TARGET_OS_IOS
51+
// on iOS, this needs to be true to get the battery level
52+
// and it needs to be set just once, so do it here
53+
UIDevice.currentDevice.batteryMonitoringEnabled = YES;
54+
// Register for when the battery % changes
55+
[[NSNotificationCenter defaultCenter] addObserver:self
56+
selector:@selector(setNeedsToUpdateLevel)
57+
name:UIDeviceBatteryLevelDidChangeNotification object:nil];
58+
#elif TARGET_OS_TV
59+
//
60+
#elif TARGET_OS_MAC
61+
CFRunLoopSourceRef loop = IOPSNotificationCreateRunLoopSource(_powerSourceRunLoopCallback, nil);
62+
CFRunLoopAddSource(CFRunLoopGetMain(), loop, kCFRunLoopDefaultMode);
63+
#endif
64+
}
65+
66+
- (void)setNeedsToUpdateLevel {
67+
#if TARGET_OS_IOS
68+
// `-[UIDevice batteryLevel]` returns the % like '0.(actual %)' (ie, 0.28 when the battery is 28%)
69+
// so multiply it by 100 to get a visually appropriate version
70+
self.batteryLevel = [[UIDevice currentDevice] batteryLevel] * 100;
71+
#elif TARGET_OS_TV
72+
self.batteryLevel = 100;
73+
#elif TARGET_OS_MAC
74+
CFTypeRef snapshot = IOPSCopyPowerSourcesInfo();
75+
NSArray *sourceList = (__bridge NSArray *)IOPSCopyPowerSourcesList(snapshot);
76+
if (!sourceList) {
77+
if (snapshot) CFRelease(snapshot);
78+
return;
79+
}
80+
81+
for (NSDictionary *source in sourceList) {
82+
// kIOPSCurrentCapacityKey = battery level
83+
NSNumber *currentCapacity = [source objectForKey:@(kIOPSCurrentCapacityKey)];
84+
if (currentCapacity) {
85+
// we found what we want
86+
self.batteryLevel = currentCapacity.intValue;
87+
break;
88+
}
89+
}
90+
CFRelease(snapshot);
91+
#endif
92+
}
93+
94+
@end
95+
96+
97+
int getCurrentBatteryCapacity() {
98+
return [[AppleBatteryClient sharedClient] batteryLevel];
99+
}

Cores/PPSSPP/PVPPSSPPCore/Core/PVPPSSPPCore.mm

+8
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,11 @@ void System_LaunchUrl(LaunchUrlType urlType, char const* url) {}
543543
deviceList.empty();
544544
return deviceList;
545545
}
546+
547+
#if TARGET_OS_TV
548+
int getCurrentBatteryCapacity() {
549+
return 100;
550+
}
551+
void _powerSourceRunLoopCallback(void * __unused ctx) {
552+
}
553+
#endif

Cores/PPSSPP/cmake/PPSSPP.xcodeproj/project.pbxproj

+27-19
Large diffs are not rendered by default.

Cores/PPSSPP/cmake/ffmpeg-tv-build.sh

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
#build ffmpeg for all archs and uses lipo to create fat libraries and deletes the originals
3+
4+
set -e
5+
6+
. shared_options.sh
7+
PATH=$(PWD)/gas-preprocessor:$PATH
8+
9+
ARCHS="arm64"
10+
11+
for arch in ${ARCHS}; do
12+
rm -f config.h
13+
14+
ffarch=${arch}
15+
versionmin=6.0
16+
cpu=generic
17+
18+
if [[ ${arch} == "arm64" ]]; then
19+
sdk=appletvos
20+
ffarch=aarch64
21+
versionmin=7.0
22+
elif [[ ${arch} == "i386" ]]; then
23+
sdk=iphonesimulator
24+
ffarch=x86
25+
elif [[ ${arch} == "x86_64" ]]; then
26+
sdk=iphonesimulator
27+
fi
28+
29+
./configure \
30+
--prefix=ios/${arch} \
31+
--enable-cross-compile \
32+
--arch=${ffarch} \
33+
--cc=$(xcrun -f clang) \
34+
--sysroot="$(xcrun --sdk ${sdk} --show-sdk-path)" \
35+
--extra-cflags="-arch ${arch} -D_DARWIN_FEATURE_CLOCK_GETTIME=0 -mtvos-version-min=${versionmin} ${cflags}" \
36+
${CONFIGURE_OPTS} \
37+
--extra-ldflags="-arch ${arch} -isysroot $(xcrun --sdk ${sdk} --show-sdk-path) -mtvos-version-min=${versionmin}" \
38+
--target-os=darwin \
39+
${extraopts} \
40+
--cpu=${cpu} \
41+
--enable-pic
42+
43+
make clean
44+
make -j8 install
45+
done
46+
47+
cd ios
48+
mkdir -p universal/lib
49+
50+
for i in arm64/lib/*.a; do
51+
libname=$(basename $i)
52+
xcrun lipo -create $(
53+
for a in ${ARCHS}; do
54+
echo -arch ${a} ${a}/lib/${libname}
55+
done
56+
) -output universal/lib/${libname}
57+
done
58+
59+
cp -r arm64/include universal/
60+
61+
rm -rf ${ARCHS}

0 commit comments

Comments
 (0)