-
-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile: Fix PS2 Paths / Fix PSP to compile on AppleTV
- Loading branch information
SeiRyu
committed
May 7, 2024
1 parent
b23251e
commit 35b8e4f
Showing
140 changed files
with
36,855 additions
and
13,322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// | ||
// AppleBatteryClient.m | ||
// PPSSPP | ||
// | ||
// Created by Serena on 24/01/2023. | ||
// | ||
|
||
#include "Battery.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
#if PPSSPP_PLATFORM(MAC) | ||
#include <IOKit/ps/IOPSKeys.h> | ||
#include <IOKit/ps/IOPowerSources.h> | ||
#elif PPSSPP_PLATFORM(IOS) | ||
#import <UIKit/UIKit.h> | ||
#endif | ||
|
||
@interface AppleBatteryClient : NSObject | ||
+(instancetype)sharedClient; | ||
-(void)setNeedsToUpdateLevel; | ||
@property int batteryLevel; | ||
@end | ||
|
||
void _powerSourceRunLoopCallback(void * __unused ctx) { | ||
// IOKit has told us that battery information has changed, now update the batteryLevel var | ||
[[AppleBatteryClient sharedClient] setNeedsToUpdateLevel]; | ||
} | ||
|
||
// You may ask, | ||
// "Why an entire class? | ||
// Why not just call the UIDevice/IOKitPowerSource functions every time getCurrentBatteryCapacity() is called?" | ||
// Well, calling the UIDevice/IOKitPowerSource functions very frequently (every second, it seems?) is expensive | ||
// So, instead, I made a class with a cached batteryLevel property | ||
// that only gets set when it needs to. | ||
@implementation AppleBatteryClient | ||
|
||
+ (instancetype)sharedClient { | ||
static AppleBatteryClient *client; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
client = [AppleBatteryClient new]; | ||
[client initialSetup]; | ||
[client setNeedsToUpdateLevel]; | ||
}); | ||
|
||
return client; | ||
} | ||
|
||
-(void)initialSetup { | ||
#if TARGET_OS_IOS | ||
// on iOS, this needs to be true to get the battery level | ||
// and it needs to be set just once, so do it here | ||
UIDevice.currentDevice.batteryMonitoringEnabled = YES; | ||
// Register for when the battery % changes | ||
[[NSNotificationCenter defaultCenter] addObserver:self | ||
selector:@selector(setNeedsToUpdateLevel) | ||
name:UIDeviceBatteryLevelDidChangeNotification object:nil]; | ||
#elif TARGET_OS_TV | ||
// | ||
#elif TARGET_OS_MAC | ||
CFRunLoopSourceRef loop = IOPSNotificationCreateRunLoopSource(_powerSourceRunLoopCallback, nil); | ||
CFRunLoopAddSource(CFRunLoopGetMain(), loop, kCFRunLoopDefaultMode); | ||
#endif | ||
} | ||
|
||
- (void)setNeedsToUpdateLevel { | ||
#if TARGET_OS_IOS | ||
// `-[UIDevice batteryLevel]` returns the % like '0.(actual %)' (ie, 0.28 when the battery is 28%) | ||
// so multiply it by 100 to get a visually appropriate version | ||
self.batteryLevel = [[UIDevice currentDevice] batteryLevel] * 100; | ||
#elif TARGET_OS_TV | ||
self.batteryLevel = 100; | ||
#elif TARGET_OS_MAC | ||
CFTypeRef snapshot = IOPSCopyPowerSourcesInfo(); | ||
NSArray *sourceList = (__bridge NSArray *)IOPSCopyPowerSourcesList(snapshot); | ||
if (!sourceList) { | ||
if (snapshot) CFRelease(snapshot); | ||
return; | ||
} | ||
|
||
for (NSDictionary *source in sourceList) { | ||
// kIOPSCurrentCapacityKey = battery level | ||
NSNumber *currentCapacity = [source objectForKey:@(kIOPSCurrentCapacityKey)]; | ||
if (currentCapacity) { | ||
// we found what we want | ||
self.batteryLevel = currentCapacity.intValue; | ||
break; | ||
} | ||
} | ||
CFRelease(snapshot); | ||
#endif | ||
} | ||
|
||
@end | ||
|
||
|
||
int getCurrentBatteryCapacity() { | ||
return [[AppleBatteryClient sharedClient] batteryLevel]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
#build ffmpeg for all archs and uses lipo to create fat libraries and deletes the originals | ||
|
||
set -e | ||
|
||
. shared_options.sh | ||
PATH=$(PWD)/gas-preprocessor:$PATH | ||
|
||
ARCHS="arm64" | ||
|
||
for arch in ${ARCHS}; do | ||
rm -f config.h | ||
|
||
ffarch=${arch} | ||
versionmin=6.0 | ||
cpu=generic | ||
|
||
if [[ ${arch} == "arm64" ]]; then | ||
sdk=appletvos | ||
ffarch=aarch64 | ||
versionmin=7.0 | ||
elif [[ ${arch} == "i386" ]]; then | ||
sdk=iphonesimulator | ||
ffarch=x86 | ||
elif [[ ${arch} == "x86_64" ]]; then | ||
sdk=iphonesimulator | ||
fi | ||
|
||
./configure \ | ||
--prefix=ios/${arch} \ | ||
--enable-cross-compile \ | ||
--arch=${ffarch} \ | ||
--cc=$(xcrun -f clang) \ | ||
--sysroot="$(xcrun --sdk ${sdk} --show-sdk-path)" \ | ||
--extra-cflags="-arch ${arch} -D_DARWIN_FEATURE_CLOCK_GETTIME=0 -mtvos-version-min=${versionmin} ${cflags}" \ | ||
${CONFIGURE_OPTS} \ | ||
--extra-ldflags="-arch ${arch} -isysroot $(xcrun --sdk ${sdk} --show-sdk-path) -mtvos-version-min=${versionmin}" \ | ||
--target-os=darwin \ | ||
${extraopts} \ | ||
--cpu=${cpu} \ | ||
--enable-pic | ||
|
||
make clean | ||
make -j8 install | ||
done | ||
|
||
cd ios | ||
mkdir -p universal/lib | ||
|
||
for i in arm64/lib/*.a; do | ||
libname=$(basename $i) | ||
xcrun lipo -create $( | ||
for a in ${ARCHS}; do | ||
echo -arch ${a} ${a}/lib/${libname} | ||
done | ||
) -output universal/lib/${libname} | ||
done | ||
|
||
cp -r arm64/include universal/ | ||
|
||
rm -rf ${ARCHS} |
Oops, something went wrong.