diff --git a/Pomelo.wiki/Home.md b/Pomelo.wiki/Home.md new file mode 100644 index 0000000..affbf72 --- /dev/null +++ b/Pomelo.wiki/Home.md @@ -0,0 +1,4 @@ +Welcome to the Pomelo wiki! + + +This will be for guides in setting up Pomelo! \ No newline at end of file diff --git a/Pomelo.wiki/Installing-With-Xcode-(Without-Paid-Dev-Acc).md b/Pomelo.wiki/Installing-With-Xcode-(Without-Paid-Dev-Acc).md new file mode 100644 index 0000000..fee66b1 --- /dev/null +++ b/Pomelo.wiki/Installing-With-Xcode-(Without-Paid-Dev-Acc).md @@ -0,0 +1,82 @@ + + + +## **THIS REQUIRES MACOS(VM’s/hackintosh works aswell)** + +**Vulkan(1.3.275.0):** + +**[ON INSTALL CHECK VULKAN MEMORY ALLOCATOR HEADER]** + +https://sdk.lunarg.com/sdk/download/1.3.275.0/mac/vulkansdk-macos-1.3.275.0.dmg + +**[“$”means run in a command line, do not include “$” in the command.]** + +**Homebrew:** + +**Open terminal copy/paste** +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + +$ Brew install wget + +**Boost:** + +**Open terminal copy/paste** + +$ wget -O boost1.84.zip https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.zip + +$ unzip boost1.84.zip + +$ cd boost_1_84_0 + +$ sh bootstrap.sh --prefix=/usr/local + +$ sudo ./b2 --prefix=/usr/local install + +[it will as for your mac password after this command, it will be hidden so type it properly the first time.] + + + +**[Main Pomelo Instructions]:** + +**Open terminal copy/paste** + +$ git clone https://github.com/stossy11/Pomelo.git + +To build the `Pomelo.xcodeproj` project file and work with it, you'll need to follow these steps: + +1. **Install Xcode 15:** + First, ensure you have Xcode 15 installed on your macOS device. You can download and install Xcode 15 from the Mac App Store using the following link: [Xcode 15](https://apps.apple.com/us/app/xcode/id497799835?mt=12). + +2. **Open Pomelo and the Project File:** + Once Xcode 15 is installed, launch the application. Then, open the Pomelo project by following these steps: + - Open Finder and locate the Pomelo folder. + - Navigate into the Pomelo folder and find the `Pomelo.xcodeproj` file. + - Double-click on `Pomelo.xcodeproj` to open it in Xcode 15. + - Plug in your Device + +3. **Reset Cache and Update Packages:** + After opening the project in Xcode 15, it's a good practice to reset the cache and update packages to ensure everything is up-to-date and functioning properly. Here's how to do it: + - Go to the "Product" menu in the Xcode menu bar. + - Choose "Clean Build Folder" to clear the build cache. + - After cleaning the build folder, navigate to the "File" menu. + - Choose "Swift Packages" and then select "Update to Latest Package Versions" to update all Swift packages used in the project. + +4. **Build the Project:** + Once you've reset the cache and updated packages, you're ready to build the project: + - Click the Pomelo text with the little blue appstore icon that should be on the right bar + - Then click Signing and Capabilities + - If you havent logged in to Xcode yet click "None" on the team dropdown and click Add Account then login with your Apple ID. + - You will need to change the Bundle Identifier to "com.XXXX.XXXX". (the X's mean that you can put whatever you want) + - You will need to go to the Pomelo text at the top in the Xcode toolbar it should have an arrow next to it then Select your device. (you may need to Install the iOS SDK / Simulator) + - Click on the "Build" button (a play button icon) on the Xcode toolbar. + - Xcode will compile the project, and if there are no errors, it will generate the executable or the desired output. + +5. **Run the Project:** + After successfully building the project, you can run it by following these steps: + - Select the target device or simulator from the scheme dropdown menu located beside the build and stop buttons. + - Click on the "Run" button (a play button icon) in the Xcode toolbar. + - Xcode will deploy the project to the selected device, and you should see the application running. + - After you close the App on your Device you will need to Enable JIT by pressing the Debug menu in the Xcode menu bar then pressing Attach to Process PID or Name. + +By following these steps, you'll be able to install Xcode 15, open the `Pomelo.xcodeproj` project file, reset the cache, update packages, build the project, and run it on your iOS Device. + diff --git a/Pomelo.wiki/Post-Setup-Guide.md b/Pomelo.wiki/Post-Setup-Guide.md new file mode 100644 index 0000000..0c999ca --- /dev/null +++ b/Pomelo.wiki/Post-Setup-Guide.md @@ -0,0 +1,16 @@ +# Post Setup Guides + +## Where to put Keys + +In the Apple Files App choose Pomelo and put your keys into the **keys** folder + +## Where to put Roms + +In the Apple Files App choose Pomelo and put your roms into the **roms** folder + + +## Setup the Home Menu (Where to put your firmware) + +### NOTE: This will be required for all games soon not just the home menu + +In the Apple Files App choose Pomelo then you will need to put it into these folders inside each other **nand > system > Contents > registered** (if they don't exist create them) \ No newline at end of file diff --git a/Pomelo.xcodeproj/project.pbxproj b/Pomelo.xcodeproj/project.pbxproj index 5ca201d..1e79dd3 100644 --- a/Pomelo.xcodeproj/project.pbxproj +++ b/Pomelo.xcodeproj/project.pbxproj @@ -8,13 +8,8 @@ /* Begin PBXBuildFile section */ 38020F302C43568500029E9A /* AdvancedSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38020F2F2C43567F00029E9A /* AdvancedSettingsView.swift */; }; - 38020F352C43720200029E9A /* NavView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38020F342C4371FC00029E9A /* NavView.swift */; }; - 38020F412C43754700029E9A /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 38020F3B2C43754700029E9A /* LICENSE */; }; - 38020F422C43754700029E9A /* JITEnabler.m in Sources */ = {isa = PBXBuildFile; fileRef = 38020F3F2C43754700029E9A /* JITEnabler.m */; }; 38020F432C43754700029E9A /* EnableJIT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38020F362C43754700029E9A /* EnableJIT.swift */; }; 38020F442C43754700029E9A /* DetectServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38020F372C43754700029E9A /* DetectServer.swift */; }; - 38020F452C43754700029E9A /* fishhook.c in Sources */ = {isa = PBXBuildFile; fileRef = 38020F392C43754700029E9A /* fishhook.c */; }; - 38020F462C43754700029E9A /* utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 38020F3E2C43754700029E9A /* utils.m */; }; 38020F562C43A02100029E9A /* BootOSView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38020F552C43A01D00029E9A /* BootOSView.swift */; }; 38020F5A2C43AFFA00029E9A /* CoreSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38020F592C43AFF300029E9A /* CoreSettingsView.swift */; }; 3841946A2C4E4D2B00396613 /* MetalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 384194652C4E4D2B00396613 /* MetalView.swift */; }; @@ -83,16 +78,26 @@ 4E4AF12F2C927E8E00BBF2DE /* libdynarmic.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 38C846BB2C1DCE8900331706 /* libdynarmic.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4E4AF1302C92867F00BBF2DE /* libteakra.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 38C846C82C1DCE8900331706 /* libteakra.xcframework */; }; 4E4AF1312C92867F00BBF2DE /* libteakra.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 38C846C82C1DCE8900331706 /* libteakra.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 4E5855E32CB6770F00047C2A /* AskForJIT.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E5855E22CB6770F00047C2A /* AskForJIT.swift */; }; + 4E5855E62CB6776C00047C2A /* utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5855E52CB6776C00047C2A /* utils.m */; }; + 4EA0AA602CB6845700B51C64 /* JITEnabler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA0AA5F2CB6845700B51C64 /* JITEnabler.m */; }; 4EC662B02CAA1229000DBC5F /* SwiftUIJoystick in Frameworks */ = {isa = PBXBuildFile; productRef = 4EC662AF2CAA1229000DBC5F /* SwiftUIJoystick */; }; 4EC662B42CAA1257000DBC5F /* JoystickView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EC662B32CAA1254000DBC5F /* JoystickView.swift */; }; + 4EE462B52CB548E800BF268E /* MTLViewExtentions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE462B42CB548E200BF268E /* MTLViewExtentions.swift */; }; + 4EE462B92CB54F2100BF268E /* ScreenShotListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE462B82CB54F1800BF268E /* ScreenShotListView.swift */; }; + 4EE462BC2CB5552900BF268E /* MotionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE462BB2CB5552900BF268E /* MotionManager.swift */; }; + 4EE462BF2CB5708800BF268E /* Zoomable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE462BE2CB5708800BF268E /* Zoomable.swift */; }; + 4EE462C42CB576F400BF268E /* BottomMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE462C32CB576F400BF268E /* BottomMenuView.swift */; }; + 4EE462C62CB5770700BF268E /* TopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE462C52CB5770700BF268E /* TopBarView.swift */; }; + 4EE462C92CB5774900BF268E /* GameGridView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE462C82CB5774900BF268E /* GameGridView.swift */; }; 4EE593FF2C5FA1D1000939C4 /* AppIconProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE593FE2C5FA1D1000939C4 /* AppIconProvider.swift */; }; 4EEA0CFA2CA376AB0029A55D /* Zip in Frameworks */ = {isa = PBXBuildFile; productRef = 4EEA0CF92CA376AB0029A55D /* Zip */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 38C50CF22C1DCEA40007A953 /* PBXContainerItemProxy */ = { + 4EA0AA5D2CB6785B00B51C64 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 384F23C32C1DCBCC0073375C /* Sudachi.xcodeproj */; + containerPortal = 4EA0AA592CB6785B00B51C64 /* Sudachi.xcodeproj */; proxyType = 2; remoteGlobalIDString = E63583612B95822D00D35422; remoteInfo = Sudachi; @@ -124,15 +129,8 @@ /* Begin PBXFileReference section */ 38020F2F2C43567F00029E9A /* AdvancedSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsView.swift; sourceTree = ""; }; - 38020F342C4371FC00029E9A /* NavView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavView.swift; sourceTree = ""; }; 38020F362C43754700029E9A /* EnableJIT.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnableJIT.swift; sourceTree = ""; }; 38020F372C43754700029E9A /* DetectServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetectServer.swift; sourceTree = ""; }; - 38020F392C43754700029E9A /* fishhook.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = fishhook.c; sourceTree = ""; }; - 38020F3A2C43754700029E9A /* fishhook.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fishhook.h; sourceTree = ""; }; - 38020F3B2C43754700029E9A /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; - 38020F3D2C43754700029E9A /* utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = ""; }; - 38020F3E2C43754700029E9A /* utils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = utils.m; sourceTree = ""; }; - 38020F3F2C43754700029E9A /* JITEnabler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JITEnabler.m; sourceTree = ""; }; 38020F552C43A01D00029E9A /* BootOSView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BootOSView.swift; sourceTree = ""; }; 38020F592C43AFF300029E9A /* CoreSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreSettingsView.swift; sourceTree = ""; }; 384194612C4E4D2B00396613 /* ControllerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ControllerView.swift; sourceTree = ""; }; @@ -143,7 +141,6 @@ 384F188A2C1DCB4F0073375C /* Pomelo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pomelo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 384F18912C1DCB520073375C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 384F18962C1DCB520073375C /* Pomelo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Pomelo.entitlements; sourceTree = ""; }; - 384F23C32C1DCBCC0073375C /* Sudachi.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Sudachi.xcodeproj; path = Sudachi/Sudachi.xcodeproj; sourceTree = ""; }; 386F6ED92C42E0B900C62EBE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 386F6EDA2C42E0B900C62EBE /* FileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileManager.swift; sourceTree = ""; }; 386F6EDC2C42E0B900C62EBE /* SudachiGame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SudachiGame.swift; sourceTree = ""; }; @@ -191,8 +188,20 @@ 499A5E0E2C74A22D00EC0925 /* GameButtonListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameButtonListView.swift; sourceTree = ""; }; 4E4AF11A2C919C0F00BBF2DE /* Haptics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Haptics.swift; sourceTree = ""; }; 4E4AF12C2C926BBD00BBF2DE /* FolderMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderMonitor.swift; sourceTree = ""; }; + 4E5855E22CB6770F00047C2A /* AskForJIT.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AskForJIT.swift; sourceTree = ""; }; + 4E5855E42CB6776C00047C2A /* utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = ""; }; + 4E5855E52CB6776C00047C2A /* utils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = utils.m; sourceTree = ""; }; 4E7E03662C9667D200C10AFD /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.0.sdk/System/Library/Frameworks/OpenGLES.framework; sourceTree = DEVELOPER_DIR; }; + 4EA0AA592CB6785B00B51C64 /* Sudachi.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Sudachi.xcodeproj; path = Sudachi/Sudachi.xcodeproj; sourceTree = ""; }; + 4EA0AA5F2CB6845700B51C64 /* JITEnabler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JITEnabler.m; sourceTree = ""; }; 4EC662B32CAA1254000DBC5F /* JoystickView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoystickView.swift; sourceTree = ""; }; + 4EE462B42CB548E200BF268E /* MTLViewExtentions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MTLViewExtentions.swift; sourceTree = ""; }; + 4EE462B82CB54F1800BF268E /* ScreenShotListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenShotListView.swift; sourceTree = ""; }; + 4EE462BB2CB5552900BF268E /* MotionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MotionManager.swift; sourceTree = ""; }; + 4EE462BE2CB5708800BF268E /* Zoomable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Zoomable.swift; sourceTree = ""; }; + 4EE462C32CB576F400BF268E /* BottomMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomMenuView.swift; sourceTree = ""; }; + 4EE462C52CB5770700BF268E /* TopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopBarView.swift; sourceTree = ""; }; + 4EE462C82CB5774900BF268E /* GameGridView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameGridView.swift; sourceTree = ""; }; 4EE593FE2C5FA1D1000939C4 /* AppIconProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconProvider.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -253,14 +262,6 @@ path = AdvancedSettings; sourceTree = ""; }; - 38020F332C4371ED00029E9A /* NavigationManager */ = { - isa = PBXGroup; - children = ( - 38020F342C4371FC00029E9A /* NavView.swift */, - ); - path = NavigationManager; - sourceTree = ""; - }; 38020F382C43754700029E9A /* SideJITServer */ = { isa = PBXGroup; children = ( @@ -270,23 +271,13 @@ path = SideJITServer; sourceTree = ""; }; - 38020F3C2C43754700029E9A /* fishhook */ = { - isa = PBXGroup; - children = ( - 38020F392C43754700029E9A /* fishhook.c */, - 38020F3A2C43754700029E9A /* fishhook.h */, - 38020F3B2C43754700029E9A /* LICENSE */, - ); - path = fishhook; - sourceTree = ""; - }; 38020F402C43754700029E9A /* Trollstore */ = { isa = PBXGroup; children = ( - 38020F3C2C43754700029E9A /* fishhook */, - 38020F3D2C43754700029E9A /* utils.h */, - 38020F3E2C43754700029E9A /* utils.m */, - 38020F3F2C43754700029E9A /* JITEnabler.m */, + 4E5855E42CB6776C00047C2A /* utils.h */, + 4E5855E52CB6776C00047C2A /* utils.m */, + 4EA0AA5F2CB6845700B51C64 /* JITEnabler.m */, + 4E5855E22CB6770F00047C2A /* AskForJIT.swift */, ); path = Trollstore; sourceTree = ""; @@ -310,6 +301,7 @@ 384194622C4E4D2B00396613 /* ControllerView */ = { isa = PBXGroup; children = ( + 4EE462BA2CB5552000BF268E /* Gyro */, 4E4AF1182C919C0700BBF2DE /* Haptics */, 384194612C4E4D2B00396613 /* ControllerView.swift */, 4EC662B12CAA1245000DBC5F /* Joystick */, @@ -366,7 +358,7 @@ isa = PBXGroup; children = ( 38F284CB2C2683A000994A77 /* Makefile */, - 384F23C32C1DCBCC0073375C /* Sudachi.xcodeproj */, + 4EA0AA592CB6785B00B51C64 /* Sudachi.xcodeproj */, 384F188C2C1DCB4F0073375C /* Pomelo */, 384F188B2C1DCB4F0073375C /* Products */, 38C50D132C1DD4570007A953 /* Frameworks */, @@ -385,12 +377,13 @@ 384F188C2C1DCB4F0073375C /* Pomelo */ = { isa = PBXGroup; children = ( + 4EE462B62CB54F0400BF268E /* ScreenshotManager */, + 4EE462B32CB548D800BF268E /* Extentions */, 384194692C4E4D2B00396613 /* Emulation */, 386F6F352C42E9D200C62EBE /* JITClasses */, 386F6EEB2C42E0C800C62EBE /* PomeloApp.swift */, 386F6ED92C42E0B900C62EBE /* ContentView.swift */, 38020F472C4375C300029E9A /* BootOSManager */, - 38020F332C4371ED00029E9A /* NavigationManager */, 386F6F2E2C42E62200C62EBE /* SettingsViews */, 386F6EDB2C42E0B900C62EBE /* FilesManager */, 386F6EDD2C42E0B900C62EBE /* GameManager */, @@ -440,6 +433,8 @@ 386F6EE32C42E0B900C62EBE /* LibraryViews */ = { isa = PBXGroup; children = ( + 4EE462C72CB5774300BF268E /* GameGrid */, + 4EE462C22CB576E700BF268E /* Menu */, 386F6EDF2C42E0B900C62EBE /* GameButton */, 386F6EE12C42E0B900C62EBE /* GameList */, 386F6EE22C42E0B900C62EBE /* LibraryView.swift */, @@ -485,14 +480,6 @@ path = AirPlay; sourceTree = ""; }; - 38C50CEF2C1DCEA10007A953 /* Products */ = { - isa = PBXGroup; - children = ( - 38C50CF32C1DCEA40007A953 /* libSudachi.a */, - ); - name = Products; - sourceTree = ""; - }; 38C50D132C1DD4570007A953 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -571,6 +558,14 @@ path = FolderMonitor; sourceTree = ""; }; + 4EA0AA5A2CB6785B00B51C64 /* Products */ = { + isa = PBXGroup; + children = ( + 4EA0AA5E2CB6785B00B51C64 /* libSudachi.a */, + ); + name = Products; + sourceTree = ""; + }; 4EC662B12CAA1245000DBC5F /* Joystick */ = { isa = PBXGroup; children = ( @@ -579,6 +574,48 @@ path = Joystick; sourceTree = ""; }; + 4EE462B32CB548D800BF268E /* Extentions */ = { + isa = PBXGroup; + children = ( + 4EE462B42CB548E200BF268E /* MTLViewExtentions.swift */, + ); + path = Extentions; + sourceTree = ""; + }; + 4EE462B62CB54F0400BF268E /* ScreenshotManager */ = { + isa = PBXGroup; + children = ( + 4EE462BE2CB5708800BF268E /* Zoomable.swift */, + 4EE462B82CB54F1800BF268E /* ScreenShotListView.swift */, + ); + path = ScreenshotManager; + sourceTree = ""; + }; + 4EE462BA2CB5552000BF268E /* Gyro */ = { + isa = PBXGroup; + children = ( + 4EE462BB2CB5552900BF268E /* MotionManager.swift */, + ); + path = Gyro; + sourceTree = ""; + }; + 4EE462C22CB576E700BF268E /* Menu */ = { + isa = PBXGroup; + children = ( + 4EE462C52CB5770700BF268E /* TopBarView.swift */, + 4EE462C32CB576F400BF268E /* BottomMenuView.swift */, + ); + path = Menu; + sourceTree = ""; + }; + 4EE462C72CB5774300BF268E /* GameGrid */ = { + isa = PBXGroup; + children = ( + 4EE462C82CB5774900BF268E /* GameGridView.swift */, + ); + path = GameGrid; + sourceTree = ""; + }; 4EE593FD2C5FA1C4000939C4 /* AppIcon */ = { isa = PBXGroup; children = ( @@ -654,8 +691,8 @@ projectDirPath = ""; projectReferences = ( { - ProductGroup = 38C50CEF2C1DCEA10007A953 /* Products */; - ProjectRef = 384F23C32C1DCBCC0073375C /* Sudachi.xcodeproj */; + ProductGroup = 4EA0AA5A2CB6785B00B51C64 /* Products */; + ProjectRef = 4EA0AA592CB6785B00B51C64 /* Sudachi.xcodeproj */; }, ); projectRoot = ""; @@ -666,11 +703,11 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 38C50CF32C1DCEA40007A953 /* libSudachi.a */ = { + 4EA0AA5E2CB6785B00B51C64 /* libSudachi.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = libSudachi.a; - remoteRef = 38C50CF22C1DCEA40007A953 /* PBXContainerItemProxy */; + remoteRef = 4EA0AA5D2CB6785B00B51C64 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXReferenceProxy section */ @@ -680,7 +717,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 38020F412C43754700029E9A /* LICENSE in Resources */, 384F18922C1DCB520073375C /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -693,8 +729,8 @@ buildActionMask = 2147483647; files = ( 4EE593FF2C5FA1D1000939C4 /* AppIconProvider.swift in Sources */, - 38020F352C43720200029E9A /* NavView.swift in Sources */, 386F6EEC2C42E0C800C62EBE /* PomeloApp.swift in Sources */, + 4E5855E32CB6770F00047C2A /* AskForJIT.swift in Sources */, 384194702C4E540500396613 /* SudachiEmulationHandler.swift in Sources */, 38020F562C43A02100029E9A /* BootOSView.swift in Sources */, 38020F302C43568500029E9A /* AdvancedSettingsView.swift in Sources */, @@ -702,26 +738,32 @@ 386F6F302C42E64000C62EBE /* SettingsView.swift in Sources */, 4EC662B42CAA1257000DBC5F /* JoystickView.swift in Sources */, 386F6EE62C42E0B900C62EBE /* ContentView.swift in Sources */, + 4EE462B52CB548E800BF268E /* MTLViewExtentions.swift in Sources */, 499A5E0C2C74A1B200EC0925 /* GameListView.swift in Sources */, 4E4AF11B2C919C0F00BBF2DE /* Haptics.swift in Sources */, 386F6EE82C42E0B900C62EBE /* LibraryView.swift in Sources */, 386F6EE92C42E0B900C62EBE /* FileManager.swift in Sources */, + 4E5855E62CB6776C00047C2A /* utils.m in Sources */, 386F6F342C42E98700C62EBE /* InfoView.swift in Sources */, 3841946A2C4E4D2B00396613 /* MetalView.swift in Sources */, 3841946B2C4E4D2B00396613 /* SudachiEmulationScreenView.swift in Sources */, 499A5E0F2C74A22D00EC0925 /* GameButtonListView.swift in Sources */, + 4EE462BF2CB5708800BF268E /* Zoomable.swift in Sources */, 3841946C2C4E4D2B00396613 /* ControllerView.swift in Sources */, 38B7FE022C7610A600D274FB /* AirPlay.swift in Sources */, 3841946D2C4E4D2B00396613 /* SudachiEmulationView.swift in Sources */, 386F6EEA2C42E0B900C62EBE /* SudachiGame.swift in Sources */, - 38020F422C43754700029E9A /* JITEnabler.m in Sources */, + 4EE462C42CB576F400BF268E /* BottomMenuView.swift in Sources */, + 4EE462C62CB5770700BF268E /* TopBarView.swift in Sources */, + 4EE462C92CB5774900BF268E /* GameGridView.swift in Sources */, 38020F432C43754700029E9A /* EnableJIT.swift in Sources */, 38020F442C43754700029E9A /* DetectServer.swift in Sources */, - 38020F452C43754700029E9A /* fishhook.c in Sources */, 4E4AF12D2C926BBD00BBF2DE /* FolderMonitor.swift in Sources */, - 38020F462C43754700029E9A /* utils.m in Sources */, 38B7FDFF2C760DE400D274FB /* Air.swift in Sources */, + 4EE462B92CB54F2100BF268E /* ScreenShotListView.swift in Sources */, 38020F5A2C43AFFA00029E9A /* CoreSettingsView.swift in Sources */, + 4EE462BC2CB5552900BF268E /* MotionManager.swift in Sources */, + 4EA0AA602CB6845700B51C64 /* JITEnabler.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -892,7 +934,7 @@ "$(PROJECT_DIR)/Pomelo/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/Pomelo/Dependencies/Dynamic\\ Libraries", ); - MARKETING_VERSION = 1.8; + MARKETING_VERSION = 2.0; OTHER_LDFLAGS = "-lSudachi"; PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.Pomelo; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -958,7 +1000,7 @@ "$(PROJECT_DIR)/Pomelo/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/Pomelo/Dependencies/Dynamic\\ Libraries", ); - MARKETING_VERSION = 1.8; + MARKETING_VERSION = 2.0; OTHER_LDFLAGS = "-lSudachi"; PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.Pomelo; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Pomelo/BootOSManager/BootOSView.swift b/Pomelo/BootOSManager/BootOSView.swift index 2b5fa1c..688c480 100644 --- a/Pomelo/BootOSManager/BootOSView.swift +++ b/Pomelo/BootOSManager/BootOSView.swift @@ -9,8 +9,6 @@ import SwiftUI import Sudachi struct BootOSView: View { - @Binding var core: Core - @Binding var currentnavigarion: Int @State var sudachi = Sudachi.shared @AppStorage("cangetfullpath") var canGetFullPath: Bool = false var body: some View { diff --git a/Pomelo/ContentView.swift b/Pomelo/ContentView.swift index 2713d22..1728047 100644 --- a/Pomelo/ContentView.swift +++ b/Pomelo/ContentView.swift @@ -13,7 +13,7 @@ struct ContentView: View { @State var core = Core(games: [], root: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]) var body: some View { //NavView(core: $core) // pain and suffering - HomeView(core: core) + LibraryView(core: core) .onAppear() { Air.play(AnyView( Text("Select Game") @@ -21,6 +21,13 @@ struct ContentView: View { )) + let isJIT = UserDefaults.standard.bool(forKey: "JIT-ENABLED") + + if !isJIT { + askForJIT() + } + + do { try PomeloFileManager.shared.createdirectories() // this took a while to create the proper directories diff --git a/Pomelo/Emulation/ControllerView/ControllerView.swift b/Pomelo/Emulation/ControllerView/ControllerView.swift index 6fc54fe..b2be8fb 100644 --- a/Pomelo/Emulation/ControllerView/ControllerView.swift +++ b/Pomelo/Emulation/ControllerView/ControllerView.swift @@ -9,15 +9,19 @@ import SwiftUI import GameController import Sudachi import SwiftUIJoystick +import CoreMotion struct ControllerView: View { let sudachi = Sudachi.shared @State var isPressed = false + @StateObject private var motionManager = MotionManager() @State var controllerconnected = false @State private var x: CGFloat = 0.0 @State private var y: CGFloat = 0.0 @Environment(\.presentationMode) var presentationMode + @AppStorage("onscreenhandheld") var onscreenjoy: Bool = false + @State var lastTimestamp = Date().timeIntervalSince1970 // Initialize timestamp when motion starts var body: some View { GeometryReader { geometry in @@ -30,6 +34,11 @@ struct ControllerView: View { .onAppear { print("checking for controller:") controllerconnected = false + if !controllerconnected { + motionManager.startGyros() + } else { + motionManager.stopGyros() + } DispatchQueue.main.async { setupControllers() // i dont know what half of this shit does } @@ -38,6 +47,7 @@ struct ControllerView: View { // Add a dictionary to track controller IDs @State var controllerIDs: [GCController: Int] = [:] + private func setupControllers() { NotificationCenter.default.addObserver(forName: .GCControllerDidConnect, object: nil, queue: .main) { notification in @@ -120,7 +130,7 @@ struct ControllerView: View { } extendedGamepad.leftShoulder.pressedChangedHandler = { button, value, pressed in - pressed ? self.touchDown(.triggerL, controllerId: controllerId) : self.touchUpInside(.L, controllerId: controllerId) + pressed ? self.touchDown(.triggerL, controllerId: controllerId) : self.touchUpInside(.triggerL, controllerId: controllerId) } extendedGamepad.leftTrigger.pressedChangedHandler = { button, value, pressed in @@ -132,11 +142,11 @@ struct ControllerView: View { } extendedGamepad.leftThumbstickButton?.pressedChangedHandler = { button, value, pressed in - pressed ? self.touchDown(.L, controllerId: controllerId) : self.touchUpInside(.triggerR, controllerId: controllerId) + pressed ? self.touchDown(.L, controllerId: controllerId) : self.touchUpInside(.L, controllerId: controllerId) } extendedGamepad.rightThumbstickButton?.pressedChangedHandler = { button, value, pressed in - pressed ? self.touchDown(.R, controllerId: controllerId) : self.touchUpInside(.triggerR, controllerId: controllerId) + pressed ? self.touchDown(.R, controllerId: controllerId) : self.touchUpInside(.R, controllerId: controllerId) } extendedGamepad.rightTrigger.pressedChangedHandler = { button, value, pressed in @@ -261,11 +271,6 @@ struct OnScreenController: View { } else { // could be landscape VStack { - HStack { - Spacer() - ButtonView(button: .home) - .padding(.horizontal) - } Spacer() VStack { HStack { @@ -279,16 +284,17 @@ struct OnScreenController: View { } } HStack { - Spacer() + // Spacer() VStack { - Spacer() + // Spacer() ButtonView(button: .plus) // Adding the + button } + Spacer() VStack { - Spacer() + // Spacer() ButtonView(button: .minus) // Adding the - button } - Spacer() + // Spacer() } VStack { ShoulderButtonsViewRight() @@ -300,7 +306,7 @@ struct OnScreenController: View { } } - .padding(.bottom, geometry.size.height / 11) // also extremally broken ( + // .                                                                                                     padding(.bottom, geometry.size.height / 11) // also extremally broken ( } } } diff --git a/Pomelo/Emulation/ControllerView/Gyro/MotionManager.swift b/Pomelo/Emulation/ControllerView/Gyro/MotionManager.swift index 7bb88d6..7cd496e 100644 --- a/Pomelo/Emulation/ControllerView/Gyro/MotionManager.swift +++ b/Pomelo/Emulation/ControllerView/Gyro/MotionManager.swift @@ -1,44 +1,50 @@ +// +// MotionManager.swift +// Pomelo +// +// Created by Stossy11 on 8/10/2024. +// Copyright © 2024 Stossy11. All rights reserved. +// + + import CoreMotion import SwiftUI -class MotionManager: ObservableObject { - private var motionManager = CMMotionManager() - @Published var gyroData: CMGyroData? - @Published var accelerometerData: CMAccelerometerData? - init() { - startGyroUpdates() - startAccelerometerUpdates() - } +class MotionManager : ObservableObject { + + let motion = CMMotionManager() + var timer = Timer() + var GyroVar = 0 + @State var gyroData: CMGyroData = CMGyroData() - func startGyroUpdates() { - if motionManager.isGyroAvailable { - motionManager.gyroUpdateInterval = 1.0 / 60.0 // Update at 60 Hz - motionManager.startGyroUpdates(to: .main) { [weak self] data, error in - if let error = error { - print("Gyro Error: \(error.localizedDescription)") - return + + func startGyros() { + if motion.isGyroAvailable { + self.motion.gyroUpdateInterval = 1.0 / 60.0 + self.motion.startGyroUpdates() + + // Configure a timer to fetch the accelerometer data. + + self.timer = Timer(fire: Date(), interval: (1.0/60.0), + + repeats: true, block: { (timer) in + if let data = self.motion.gyroData { + self.gyroData = data } - self?.gyroData = data - } + // print("outloop") + }) + + RunLoop.current.add(self.timer, forMode: RunLoop.Mode.default) } } - func startAccelerometerUpdates() { - if motionManager.isAccelerometerAvailable { - motionManager.accelerometerUpdateInterval = 1.0 / 60.0 // Update at 60 Hz - motionManager.startAccelerometerUpdates(to: .main) { [weak self] data, error in - if let error = error { - print("Accelerometer Error: \(error.localizedDescription)") - return - } - self?.accelerometerData = data - } - } - } - deinit { - motionManager.stopGyroUpdates() - motionManager.stopAccelerometerUpdates() + func stopGyros() { + print("stop") + if self.timer != nil { + self.timer.invalidate() + self.motion.stopGyroUpdates() + } } } diff --git a/Pomelo/Emulation/ControllerView/Joystick/JoystickView.swift b/Pomelo/Emulation/ControllerView/Joystick/JoystickView.swift index 04bc184..4979238 100644 --- a/Pomelo/Emulation/ControllerView/Joystick/JoystickView.swift +++ b/Pomelo/Emulation/ControllerView/Joystick/JoystickView.swift @@ -41,10 +41,12 @@ public struct Joystick: View { Circle().fill(Color.gray) }, locksInPlace: false) + .onTapGesture { + Haptics.shared.play(.light) + } .onChange(of: self.joystickMonitor.xyPoint) { newValue in let scaledX = Float(newValue.x) let scaledY = Float(-newValue.y) // my dumbass broke this by having -y instead of y :/ (well it appears that with the new joystick code, its supposed to be -y) - joystickMonitor.objectWillChange print("Joystick Position: (\(scaledX), \(scaledY))") if iscool != nil { diff --git a/Pomelo/Emulation/EmulationViews/SudachiEmulationView.swift b/Pomelo/Emulation/EmulationViews/SudachiEmulationView.swift index f253bae..ee4e484 100644 --- a/Pomelo/Emulation/EmulationViews/SudachiEmulationView.swift +++ b/Pomelo/Emulation/EmulationViews/SudachiEmulationView.swift @@ -16,6 +16,7 @@ import SwiftUIIntrospect struct SudachiEmulationView: View { @StateObject private var viewModel: SudachiEmulationViewModel @State var controllerconnected = false + @State var game: PomeloGame? @State var sudachi = Sudachi.shared var device: MTLDevice? = MTLCreateSystemDefaultDevice() @State var CaLayer: CAMetalLayer? @@ -27,13 +28,17 @@ struct SudachiEmulationView: View { @State private var timer: Timer? @Environment(\.scenePhase) var scenePhase @AppStorage("isairplay") private var isairplay: Bool = true + let documentsDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + @Environment(\.presentationMode) var presentationMode init(game: PomeloGame?) { + _game = State(wrappedValue: game) _viewModel = StateObject(wrappedValue: SudachiEmulationViewModel(game: game)) } var body: some View { ZStack { + if !isairplay { MetalView(device: device) { view in DispatchQueue.main.async { @@ -45,6 +50,8 @@ struct SudachiEmulationView: View { } } } + .edgesIgnoringSafeArea(.all) + .persistentSystemOverlays(.hidden) .onRotate { size in if !isairplay { viewModel.handleOrientationChange() @@ -54,6 +61,71 @@ struct SudachiEmulationView: View { ControllerView() + + VStack { + HStack { + Spacer() + Menu { + Button { + if let metalView = mtkview { + print("button pressed") + + let lastDrawableDisplayed = metalView.currentDrawable?.texture + + if let imageRef = lastDrawableDisplayed?.toImage() { + let uiImage: UIImage = UIImage.init(cgImage: imageRef) + + if let pngData = uiImage.pngData() { + // Define the path to save the PNG file + if let game = self.game { + let fileURL = documentsDir.appendingPathComponent("screenshots/\(game.title)-(\(Date())).png") + print(Date()) + do { + // Write the PNG data to the file + try pngData.write(to: fileURL) + print("Image saved to: \(fileURL.path)") + } catch { + print("Error saving PNG: \(error)") + } + } else { + let fileURL = documentsDir.appendingPathComponent("screenshots/Home_Menu-(\(Date())).png") + + do { + // Write the PNG data to the file + try pngData.write(to: fileURL) + print("Image saved to: \(fileURL.path)") + } catch { + print("Error saving PNG: \(error)") + } + } + } else { + print("Failed to convert UIImage to PNG data") + } + } + } + } label: { + Text("Take Screenshot") + .font(.title) + .padding() + } + + Button { + viewModel.customButtonTapped() + + presentationMode.wrappedValue.dismiss() + } label: { + Text("Exit (Unstable)") + } + + } label: { + Image(systemName: "ellipsis.circle.fill") + .resizable() + .frame(width: 45, height: 45) + .foregroundColor(Color.gray) + } + } + Spacer() + } } .overlay( // Loading screen overlay on top of MetalView @@ -99,11 +171,10 @@ struct SudachiEmulationView: View { } } .onDisappear { - if sudachi.FirstFrameShowed() || !isairplay { + if !isairplay { stopPollingFirstFrameShowed() } uiTabBarController?.tabBar.isHidden = false - viewModel.customButtonTapped() } .navigationBarBackButtonHidden(true) .introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { (tabBarController) in diff --git a/Pomelo/Extentions/MTLViewExtentions.swift b/Pomelo/Extentions/MTLViewExtentions.swift index e69de29..13f9716 100644 --- a/Pomelo/Extentions/MTLViewExtentions.swift +++ b/Pomelo/Extentions/MTLViewExtentions.swift @@ -0,0 +1,44 @@ +// +// MTLViewExtentions.swift +// Pomelo +// +// Created by Stossy11 on 8/10/2024. +// Copyright © 2024 Stossy11. All rights reserved. +// + +import SwiftUI +import UIKit +import Metal + +extension MTLTexture { + + func bytes() -> UnsafeMutableRawPointer { + let width = self.width + let height = self.height + let rowBytes = self.width * 4 + let p = malloc(width * height * 4) + + self.getBytes(p!, bytesPerRow: rowBytes, from: MTLRegionMake2D(0, 0, width, height), mipmapLevel: 0) + + return p! + } + + func toImage() -> CGImage? { + let p = bytes() + + let pColorSpace = CGColorSpaceCreateDeviceRGB() + + let rawBitmapInfo = CGImageAlphaInfo.noneSkipFirst.rawValue | CGBitmapInfo.byteOrder32Little.rawValue + let bitmapInfo:CGBitmapInfo = CGBitmapInfo(rawValue: rawBitmapInfo) + + let selftureSize = self.width * self.height * 4 + let rowBytes = self.width * 4 + let releaseMaskImagePixelData: CGDataProviderReleaseDataCallback = { (info: UnsafeMutableRawPointer?, data: UnsafeRawPointer, size: Int) -> () in + return + } + let provider = CGDataProvider(dataInfo: nil, data: p, size: selftureSize, releaseData: releaseMaskImagePixelData) + let cgImageRef = CGImage(width: self.width, height: self.height, bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: rowBytes, space: pColorSpace, bitmapInfo: bitmapInfo, provider: provider!, decode: nil, shouldInterpolate: true, intent: CGColorRenderingIntent.defaultIntent)! + + return cgImageRef + } +} diff --git a/Pomelo/JITClasses/Trollstore/AskForJIT.swift b/Pomelo/JITClasses/Trollstore/AskForJIT.swift new file mode 100644 index 0000000..2c4f36f --- /dev/null +++ b/Pomelo/JITClasses/Trollstore/AskForJIT.swift @@ -0,0 +1,31 @@ +// +// AskForJIT.swift +// Pomelo +// +// Created by Stossy11 on 9/10/2024. +// Copyright © 2024 Stossy11. All rights reserved. +// + +import Foundation +import UIKit + +func askForJIT() { + let bundlePath = Bundle.main.bundleURL.deletingLastPathComponent() + let tsPath = bundlePath.appendingPathComponent("_TrollStore").path + + // Check if TrollStore exists by checking the presence of the directory + if FileManager.default.fileExists(atPath: tsPath) { + // Construct the URL scheme for enabling JIT + let urlScheme = "apple-magnifier://enable-jit?bundle-id=\(Bundle.main.bundleIdentifier!)" + if let launchURL = URL(string: urlScheme) { + if UIApplication.shared.canOpenURL(launchURL) { + // Open the URL to enable JIT + UIApplication.shared.open(launchURL, options: [:], completionHandler: nil) + + return + } + } + } + + return +} diff --git a/Pomelo/JITClasses/Trollstore/JITEnabler.m b/Pomelo/JITClasses/Trollstore/JITEnabler.m index 79e5ee7..254538b 100644 --- a/Pomelo/JITClasses/Trollstore/JITEnabler.m +++ b/Pomelo/JITClasses/Trollstore/JITEnabler.m @@ -1,129 +1,7 @@ -#import -#import #import "utils.h" #import -#define JETSAM_PRIORITY_CRITICAL 19 - -#define MEMORYSTATUS_CMD_GET_PRIORITY_LIST 1 -#define MEMORYSTATUS_CMD_SET_PRIORITY_PROPERTIES 2 -#define MEMORYSTATUS_CMD_GET_JETSAM_SNAPSHOT 3 -#define MEMORYSTATUS_CMD_GET_PRESSURE_STATUS 4 -#define MEMORYSTATUS_CMD_SET_JETSAM_HIGH_WATER_MARK 5 /* Set active memory limit = inactive memory limit, both non-fatal */ -#define MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT 6 /* Set active memory limit = inactive memory limit, both fatal */ -#define MEMORYSTATUS_CMD_SET_MEMLIMIT_PROPERTIES 7 /* Set memory limits plus attributes independently */ -#define MEMORYSTATUS_CMD_GET_MEMLIMIT_PROPERTIES 8 /* Get memory limits plus attributes */ -#define MEMORYSTATUS_CMD_PRIVILEGED_LISTENER_ENABLE 9 /* Set the task's status as a privileged listener w.r.t memory notifications */ -#define MEMORYSTATUS_CMD_PRIVILEGED_LISTENER_DISABLE 10 /* Reset the task's status as a privileged listener w.r.t memory notifications */ -#define MEMORYSTATUS_CMD_AGGRESSIVE_JETSAM_LENIENT_MODE_ENABLE 11 /* Enable the 'lenient' mode for aggressive jetsam. See comments in kern_memorystatus.c near the top. */ -#define MEMORYSTATUS_CMD_AGGRESSIVE_JETSAM_LENIENT_MODE_DISABLE 12 /* Disable the 'lenient' mode for aggressive jetsam. */ -#define MEMORYSTATUS_CMD_GET_MEMLIMIT_EXCESS 13 /* Compute how much a process's phys_footprint exceeds inactive memory limit */ -#define MEMORYSTATUS_CMD_ELEVATED_INACTIVEJETSAMPRIORITY_ENABLE 14 /* Set the inactive jetsam band for a process to JETSAM_PRIORITY_ELEVATED_INACTIVE */ -#define MEMORYSTATUS_CMD_ELEVATED_INACTIVEJETSAMPRIORITY_DISABLE 15 /* Reset the inactive jetsam band for a process to the default band (0)*/ -#define MEMORYSTATUS_CMD_SET_PROCESS_IS_MANAGED 16 /* (Re-)Set state on a process that marks it as (un-)managed by a system entity e.g. assertiond */ -#define MEMORYSTATUS_CMD_GET_PROCESS_IS_MANAGED 17 /* Return the 'managed' status of a process */ -#define MEMORYSTATUS_CMD_SET_PROCESS_IS_FREEZABLE 18 /* Is the process eligible for freezing? Apps and extensions can pass in FALSE to opt out of freezing, i.e., - * if they would prefer being jetsam'ed in the idle band to being frozen in an elevated band. */ -#define MEMORYSTATUS_CMD_GET_PROCESS_IS_FREEZABLE 19 /* Return the freezable state of a process. */ - -typedef struct memorystatus_priority_properties { - int32_t priority; - uint64_t user_data; -} memorystatus_priority_properties_t; - -extern int memorystatus_get_level(user_addr_t level); -extern int memorystatus_control(uint32_t command, int32_t pid, uint32_t flags, void *buffer, size_t buffersize); - -extern int proc_track_dirty(pid_t pid, uint32_t flags); - -extern char** environ; - -int tryEnableJIT(int argc, char **argv) -{ - int result = 0; - if (getppid() != 1) - { - NSLog(@"parent pid is not launchd, calling ptrace(PT_TRACE_ME)"); - // Child process can call to PT_TRACE_ME - // then both parent and child processes get CS_DEBUGGED - result = ptrace(PT_TRACE_ME, 0, 0, 0); - // FIXME: how to kill the child process? - NSString *pidFilePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"pid.txt"]; - - NSError *pidReadError; - NSString *pidString = [NSString stringWithContentsOfFile:pidFilePath encoding:NSUTF8StringEncoding error:&pidReadError]; - - if (pidString == nil) { - NSLog(@"Error reading pid from pid.txt: %@", pidReadError); - return 1; - } - - // Convert the pid string to an integer - pid_t me = [pidString intValue]; - - int rc; memorystatus_priority_properties_t props = {JETSAM_PRIORITY_CRITICAL, 0}; - rc = memorystatus_control(MEMORYSTATUS_CMD_SET_PRIORITY_PROPERTIES, me, 0, &props, sizeof(props)); - if (rc < 0) { perror ("memorystatus_control"); NSLog(@"Error!");} - rc = memorystatus_control(MEMORYSTATUS_CMD_SET_JETSAM_HIGH_WATER_MARK, me, -1, NULL, 0); - if (rc < 0) { perror ("memorystatus_control"); NSLog(@"Error!");} - rc = memorystatus_control(MEMORYSTATUS_CMD_SET_PROCESS_IS_MANAGED, me, 0, NULL, 0); - if (rc < 0) { perror ("memorystatus_control"); NSLog(@"Error!");} - rc = memorystatus_control(MEMORYSTATUS_CMD_SET_PROCESS_IS_FREEZABLE, me, 0, NULL, 0); - if (rc < 0) { perror ("memorystatus_control"); NSLog(@"Error!");} - rc = proc_track_dirty(me, 0); - if (rc != 0) { perror("proc_track_dirty");} - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSError *deleteError; - if ([fileManager removeItemAtPath:pidFilePath error:&deleteError]) { - NSLog(@"pid.txt deleted successfully"); - } else { - NSLog(@"Error deleting pid.txt: %@", deleteError); - } - exit(0); - } - - if (getEntitlementValue(@"com.apple.private.security.no-container") - || getEntitlementValue(@"com.apple.private.security.container-required") - || getEntitlementValue(@"com.apple.private.security.no-sandbox")) - { - NSLog(@"[+] Sandbox is disabled, trying to enable JIT"); - int pid; - int ret = posix_spawnp(&pid, argv[0], NULL, NULL, argv, environ); - if (ret == 0) - { - // posix_spawn is successful, let's check if JIT is enabled - int retries; - for (retries = 0; retries < 10; retries++) - { - usleep(10000); - if (isJITEnabled()) - { - NSLog(@"[+] JIT has heen enabled with PT_TRACE_ME"); - retries = -1; - result = 1; - break; - } - } - if (retries != -1) - { - NSLog(@"[+] Failed to enable JIT: unknown reason"); - result = 0; - } - } - else - { - NSLog(@"[+] Failed to enable JIT: posix_spawn() failed errno %d", errno); - result = 0; - } - } - else - { - result = -1; - } - return result; -} - __attribute__((constructor)) static void entry(int argc, char **argv) { double systemVersion = [[[UIDevice currentDevice] systemVersion] doubleValue]; @@ -133,12 +11,12 @@ __attribute__((constructor)) static void entry(int argc, char **argv) if (isJITEnabled()) { NSLog(@"yippee"); NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setBool:NO forKey:@"JIT-NOT-ENABLED"]; + [defaults setBool:YES forKey:@"JIT-ENABLED"]; [defaults synchronize]; // Ensure the value is saved immediately } else { NSLog(@":("); NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setBool:YES forKey:@"JIT-NOT-ENABLED"]; + [defaults setBool:NO forKey:@"JIT-ENABLED"]; [defaults synchronize]; // Ensure the value is saved immediately } @@ -147,28 +25,6 @@ __attribute__((constructor)) static void entry(int argc, char **argv) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setBool:YES forKey:@"entitlementNotExists"]; [defaults synchronize]; // Ensure the value is saved immediately - - if (getEntitlementValue(@"com.apple.private.security.no-container") - || getEntitlementValue(@"com.apple.private.security.container-required") - || getEntitlementValue(@"com.apple.private.security.no-sandbox")) { - pid_t me = getpid(); - - // Create the file path in the app's Documents directory - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = [paths objectAtIndex:0]; - NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"pid.txt"]; - - // Write the C code snippet to the file - NSString *codeSnippet = [NSString stringWithFormat:@"%d", me]; - NSError *error; - - if (![codeSnippet writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error]) { - NSLog(@"Error writing code snippet to file: %@", error); - exit(1); - } - tryEnableJIT(argc, argv); - } - } if (getEntitlementValue(@"com.apple.developer.kernel.increased-debugging-memory-limit")) { @@ -183,4 +39,3 @@ __attribute__((constructor)) static void entry(int argc, char **argv) } } - diff --git a/Pomelo/JITClasses/Trollstore/fishhook/LICENSE b/Pomelo/JITClasses/Trollstore/fishhook/LICENSE deleted file mode 100644 index c45bb7c..0000000 --- a/Pomelo/JITClasses/Trollstore/fishhook/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2013, Facebook, Inc. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name Facebook nor the names of its contributors may be used to -// endorse or promote products derived from this software without specific -// prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/Pomelo/JITClasses/Trollstore/fishhook/fishhook.c b/Pomelo/JITClasses/Trollstore/fishhook/fishhook.c deleted file mode 100644 index fb41e8e..0000000 --- a/Pomelo/JITClasses/Trollstore/fishhook/fishhook.c +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright (c) 2013, Facebook, Inc. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name Facebook nor the names of its contributors may be used to -// endorse or promote products derived from this software without specific -// prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "fishhook.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __LP64__ -typedef struct mach_header_64 mach_header_t; -typedef struct segment_command_64 segment_command_t; -typedef struct section_64 section_t; -typedef struct nlist_64 nlist_t; -#define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT_64 -#else -typedef struct mach_header mach_header_t; -typedef struct segment_command segment_command_t; -typedef struct section section_t; -typedef struct nlist nlist_t; -#define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT -#endif - -#ifndef SEG_DATA_CONST -#define SEG_DATA_CONST "__DATA_CONST" -#endif - -struct rebindings_entry { - struct rebinding *rebindings; - size_t rebindings_nel; - struct rebindings_entry *next; -}; - -static struct rebindings_entry *_rebindings_head; - -static int prepend_rebindings(struct rebindings_entry **rebindings_head, - struct rebinding rebindings[], - size_t nel) { - struct rebindings_entry *new_entry = (struct rebindings_entry *) malloc(sizeof(struct rebindings_entry)); - if (!new_entry) { - return -1; - } - new_entry->rebindings = (struct rebinding *) malloc(sizeof(struct rebinding) * nel); - if (!new_entry->rebindings) { - free(new_entry); - return -1; - } - memcpy(new_entry->rebindings, rebindings, sizeof(struct rebinding) * nel); - new_entry->rebindings_nel = nel; - new_entry->next = *rebindings_head; - *rebindings_head = new_entry; - return 0; -} - -#if 0 -static int get_protection(void *addr, vm_prot_t *prot, vm_prot_t *max_prot) { - mach_port_t task = mach_task_self(); - vm_size_t size = 0; - vm_address_t address = (vm_address_t)addr; - memory_object_name_t object; -#ifdef __LP64__ - mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64; - vm_region_basic_info_data_64_t info; - kern_return_t info_ret = vm_region_64( - task, &address, &size, VM_REGION_BASIC_INFO_64, (vm_region_info_64_t)&info, &count, &object); -#else - mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT; - vm_region_basic_info_data_t info; - kern_return_t info_ret = vm_region(task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)&info, &count, &object); -#endif - if (info_ret == KERN_SUCCESS) { - if (prot != NULL) - *prot = info.protection; - - if (max_prot != NULL) - *max_prot = info.max_protection; - - return 0; - } - - return -1; -} -#endif - -static void perform_rebinding_with_section(struct rebindings_entry *rebindings, - section_t *section, - intptr_t slide, - nlist_t *symtab, - char *strtab, - uint32_t *indirect_symtab) { - uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1; - void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr); - - for (uint i = 0; i < section->size / sizeof(void *); i++) { - uint32_t symtab_index = indirect_symbol_indices[i]; - if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL || - symtab_index == (INDIRECT_SYMBOL_LOCAL | INDIRECT_SYMBOL_ABS)) { - continue; - } - uint32_t strtab_offset = symtab[symtab_index].n_un.n_strx; - char *symbol_name = strtab + strtab_offset; - bool symbol_name_longer_than_1 = symbol_name[0] && symbol_name[1]; - struct rebindings_entry *cur = rebindings; - while (cur) { - for (uint j = 0; j < cur->rebindings_nel; j++) { - if (symbol_name_longer_than_1 && strcmp(&symbol_name[1], cur->rebindings[j].name) == 0) { - kern_return_t err; - - if (cur->rebindings[j].replaced != NULL && indirect_symbol_bindings[i] != cur->rebindings[j].replacement) - *(cur->rebindings[j].replaced) = indirect_symbol_bindings[i]; - - /** - * 1. Moved the vm protection modifying codes to here to reduce the - * changing scope. - * 2. Adding VM_PROT_WRITE mode unconditionally because vm_region - * API on some iOS/Mac reports mismatch vm protection attributes. - * -- Lianfu Hao Jun 16th, 2021 - **/ - err = vm_protect (mach_task_self (), (uintptr_t)indirect_symbol_bindings, section->size, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY); - if (err == KERN_SUCCESS) { - /** - * Once we failed to change the vm protection, we - * MUST NOT continue the following write actions! - * iOS 15 has corrected the const segments prot. - * -- Lionfore Hao Jun 11th, 2021 - **/ - indirect_symbol_bindings[i] = cur->rebindings[j].replacement; - } - goto symbol_loop; - } - } - cur = cur->next; - } - symbol_loop:; - } -} - -static void rebind_symbols_for_image(struct rebindings_entry *rebindings, - const struct mach_header *header, - intptr_t slide) { - Dl_info info; - if (dladdr(header, &info) == 0) { - return; - } - - segment_command_t *cur_seg_cmd; - segment_command_t *linkedit_segment = NULL; - struct symtab_command* symtab_cmd = NULL; - struct dysymtab_command* dysymtab_cmd = NULL; - - uintptr_t cur = (uintptr_t)header + sizeof(mach_header_t); - for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) { - cur_seg_cmd = (segment_command_t *)cur; - if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) { - if (strcmp(cur_seg_cmd->segname, SEG_LINKEDIT) == 0) { - linkedit_segment = cur_seg_cmd; - } - } else if (cur_seg_cmd->cmd == LC_SYMTAB) { - symtab_cmd = (struct symtab_command*)cur_seg_cmd; - } else if (cur_seg_cmd->cmd == LC_DYSYMTAB) { - dysymtab_cmd = (struct dysymtab_command*)cur_seg_cmd; - } - } - - if (!symtab_cmd || !dysymtab_cmd || !linkedit_segment || - !dysymtab_cmd->nindirectsyms) { - return; - } - - // Find base symbol/string table addresses - uintptr_t linkedit_base = (uintptr_t)slide + linkedit_segment->vmaddr - linkedit_segment->fileoff; - nlist_t *symtab = (nlist_t *)(linkedit_base + symtab_cmd->symoff); - char *strtab = (char *)(linkedit_base + symtab_cmd->stroff); - - // Get indirect symbol table (array of uint32_t indices into symbol table) - uint32_t *indirect_symtab = (uint32_t *)(linkedit_base + dysymtab_cmd->indirectsymoff); - - cur = (uintptr_t)header + sizeof(mach_header_t); - for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) { - cur_seg_cmd = (segment_command_t *)cur; - if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) { - if (strcmp(cur_seg_cmd->segname, SEG_DATA) != 0 && - strcmp(cur_seg_cmd->segname, SEG_DATA_CONST) != 0) { - continue; - } - for (uint j = 0; j < cur_seg_cmd->nsects; j++) { - section_t *sect = - (section_t *)(cur + sizeof(segment_command_t)) + j; - if ((sect->flags & SECTION_TYPE) == S_LAZY_SYMBOL_POINTERS) { - perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab); - } - if ((sect->flags & SECTION_TYPE) == S_NON_LAZY_SYMBOL_POINTERS) { - perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab); - } - } - } - } -} - -static void _rebind_symbols_for_image(const struct mach_header *header, - intptr_t slide) { - rebind_symbols_for_image(_rebindings_head, header, slide); -} - -int rebind_symbols_image(void *header, - intptr_t slide, - struct rebinding rebindings[], - size_t rebindings_nel) { - struct rebindings_entry *rebindings_head = NULL; - int retval = prepend_rebindings(&rebindings_head, rebindings, rebindings_nel); - rebind_symbols_for_image(rebindings_head, (const struct mach_header *) header, slide); - if (rebindings_head) { - free(rebindings_head->rebindings); - } - free(rebindings_head); - return retval; -} - -int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel) { - int retval = prepend_rebindings(&_rebindings_head, rebindings, rebindings_nel); - if (retval < 0) { - return retval; - } - // If this was the first call, register callback for image additions (which is also invoked for - // existing images, otherwise, just run on existing images - if (!_rebindings_head->next) { - _dyld_register_func_for_add_image(_rebind_symbols_for_image); - } else { - uint32_t c = _dyld_image_count(); - for (uint32_t i = 0; i < c; i++) { - _rebind_symbols_for_image(_dyld_get_image_header(i), _dyld_get_image_vmaddr_slide(i)); - } - } - return retval; -} diff --git a/Pomelo/JITClasses/Trollstore/fishhook/fishhook.h b/Pomelo/JITClasses/Trollstore/fishhook/fishhook.h deleted file mode 100644 index 0d8e36a..0000000 --- a/Pomelo/JITClasses/Trollstore/fishhook/fishhook.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2013, Facebook, Inc. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name Facebook nor the names of its contributors may be used to -// endorse or promote products derived from this software without specific -// prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef fishhook_h -#define fishhook_h - -#include -#include - -#if !defined(FISHHOOK_EXPORT) -#define FISHHOOK_VISIBILITY __attribute__((visibility("hidden"))) -#else -#define FISHHOOK_VISIBILITY __attribute__((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -/* - * A structure representing a particular intended rebinding from a symbol - * name to its replacement - */ -struct rebinding { - const char *name; - void *replacement; - void **replaced; -}; - -/* - * For each rebinding in rebindings, rebinds references to external, indirect - * symbols with the specified name to instead point at replacement for each - * image in the calling process as well as for all future images that are loaded - * by the process. If rebind_functions is called more than once, the symbols to - * rebind are added to the existing list of rebindings, and if a given symbol - * is rebound more than once, the later rebinding will take precedence. - */ -FISHHOOK_VISIBILITY -int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel); - -/* - * Rebinds as above, but only in the specified image. The header should point - * to the mach-o header, the slide should be the slide offset. Others as above. - */ -FISHHOOK_VISIBILITY -int rebind_symbols_image(void *header, - intptr_t slide, - struct rebinding rebindings[], - size_t rebindings_nel); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //fishhook_h - diff --git a/Pomelo/JITClasses/Trollstore/utils.m b/Pomelo/JITClasses/Trollstore/utils.m index 0fe19d8..a43a6df 100644 --- a/Pomelo/JITClasses/Trollstore/utils.m +++ b/Pomelo/JITClasses/Trollstore/utils.m @@ -1,5 +1,4 @@ #import "utils.h" -#import "fishhook/fishhook.h" typedef struct __SecTask * SecTaskRef; extern CFTypeRef SecTaskCopyValueForEntitlement( diff --git a/Pomelo/LibraryViews/GameButton/GameButtonView.swift b/Pomelo/LibraryViews/GameButton/GameButtonView.swift index 2f8f806..988f4d2 100644 --- a/Pomelo/LibraryViews/GameButton/GameButtonView.swift +++ b/Pomelo/LibraryViews/GameButton/GameButtonView.swift @@ -83,224 +83,3 @@ struct GameIconView: View { } -struct BottomMenuView: View { - @State var core: Core - var body: some View { - HStack(spacing: 40) { - - Button { - - } label: { - Circle() - .overlay { - Image(systemName: "message") - .font(.system(size: 30)) - .foregroundColor(.red) - } - .frame(width: 50, height: 50) - .foregroundColor(Color.init(uiColor: .lightGray)) - } - - Button { - - } label: { - Circle() - .overlay { - Image(systemName: "photo") - .font(.system(size: 30)) - .foregroundColor(.blue) - } - .frame(width: 50, height: 50) - .foregroundColor(Color.init(uiColor: .lightGray)) - } - - NavigationLink(destination: SettingsView(core: core)) { - Circle() - .overlay { - Image(systemName: "gearshape") - .foregroundColor(Color.init(uiColor: .darkGray)) - .font(.system(size: 30)) - } - .frame(width: 50, height: 50) - .foregroundColor(Color.init(uiColor: .lightGray)) - - } - - Button { - - } label: { - Circle() - .overlay { - Image(systemName: "power") - .foregroundColor(Color.init(uiColor: .darkGray)) - .font(.system(size: 30)) - } - .frame(width: 50, height: 50) - .foregroundColor(Color.init(uiColor: .lightGray)) - } - } - .padding(.bottom, 20) - } -} - -struct TopBarView: View { - @State private var currentDate: Date = Date() - @State private var batteryLevel: Float = UIDevice.current.batteryLevel - @State private var batteryState: UIDevice.BatteryState = UIDevice.current.batteryState - - private var timer: Publishers.Autoconnect { - Timer.publish(every: 60, on: .main, in: .common).autoconnect() // Update every minute - } - - var body: some View { - let hour = Calendar.current.component(.hour, from: currentDate) - let minutes = Calendar.current.component(.minute, from: currentDate) - - HStack { - Image(systemName: "person.crop.circle.fill") - .resizable() - .frame(width: 40, height: 40) - - Spacer() - - Text("\(hour % 12 == 0 ? 12 : hour % 12):\(String(format: "%02d", minutes)) \(hour >= 12 ? "PM" : "AM")") - // .foregroundColor(.black) - .font(.system(size: 22)) - - Spacer() - - HStack { - Image(systemName: "wifi") - Image(systemName: batteryImageName(for: batteryLevel)) - } - } - .padding(.horizontal, 20) - .padding(.vertical, 10) - .onReceive(timer) { _ in - currentDate = Date() - } - .onAppear { - UIDevice.current.isBatteryMonitoringEnabled = true - batteryLevel = UIDevice.current.batteryLevel - batteryState = UIDevice.current.batteryState - - - - // Add observers for battery level and state changes - NotificationCenter.default.addObserver( - forName: UIDevice.batteryLevelDidChangeNotification, - object: nil, - queue: .main) { _ in - self.batteryLevel = UIDevice.current.batteryLevel - } - - NotificationCenter.default.addObserver( - forName: UIDevice.batteryStateDidChangeNotification, - object: nil, - queue: .main) { _ in - self.batteryState = UIDevice.current.batteryState - } - } - .onDisappear { - // Remove observers when the view disappears - NotificationCenter.default.removeObserver(self) - } - } - - private func batteryImageName(for level: Float) -> String { - switch level { - case 0.0: return "battery.0" - case 0.1..<0.25: return "battery.25" - case 0.25..<0.5: return "battery.50" - case 0.5..<0.75: return "battery.75" - case 0.75..<1.0: return "battery.75" - default: return "battery.100" - } - } -} - -struct HomeView: View { - @State private var selectedGame: PomeloGame? = nil - - @State var core: Core - - init(selectedGame: PomeloGame? = nil, core: Core) { - - _core = State(wrappedValue: core) - self.selectedGame = selectedGame - print("Getting Roms...") - do { - _core = State(wrappedValue: try LibraryManager.shared.library()) - print(core.games) - } catch { - print("Failed to fetch library: \(error)") - } - } - - var body: some View { - NavigationStack { - GeometryReader { geometry in - VStack { - TopBarView() - // .padding(.top, geometry.safeAreaInsets.top) // Adjust for safe area - - // Spacer() - - GameCarouselView(core: core, selectedGame: $selectedGame) - - Spacer() - - BottomMenuView(core: core) - } - } - } - .background(Color.gray.opacity(0.1)) - .edgesIgnoringSafeArea(.all) - .onAppear { - refreshcore() - - if let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first { - let romsFolderURL = documentsDirectory.appendingPathComponent("roms") - - let folderMonitor = FolderMonitor(folderURL: romsFolderURL) { - do { - core = Core(games: [], root: documentsDirectory) - core = try LibraryManager.shared.library() - } catch { - print("Error refreshing core: \(error)") - } - } - } - } - } - - func refreshcore() { - print("Getting Roms...") - do { - core = try LibraryManager.shared.library() - print(core.games) - } catch { - print("Failed to fetch library: \(error)") - return - } - } -} - - -struct GameCarouselView: View { - // let games: [PomeloGame] - @State var core: Core - @Binding var selectedGame: PomeloGame? - - var body: some View { - ScrollView(.horizontal, showsIndicators: false) { - HStack(spacing: 20) { - ForEach(core.games) { game in - GameIconView(game: game, selectedGame: $selectedGame) - } - } - } - - } - -} diff --git a/Pomelo/LibraryViews/GameGrid/GameGridView.swift b/Pomelo/LibraryViews/GameGrid/GameGridView.swift index e668308..8e4683e 100644 --- a/Pomelo/LibraryViews/GameGrid/GameGridView.swift +++ b/Pomelo/LibraryViews/GameGrid/GameGridView.swift @@ -1,13 +1,14 @@ // -// GameListView.swift +// GameGridView.swift // Pomelo // // Created by Stossy11 on 9/10/2024. // Copyright © 2024 Stossy11. All rights reserved. // +import SwiftUI -struct GameListView: View { +struct GameGridView: View { @State var core: Core @State private var searchText = "" @State var game: Int = 1 diff --git a/Pomelo/LibraryViews/GameList/GameListView.swift b/Pomelo/LibraryViews/GameList/GameListView.swift index 0edb5ee..2af433a 100644 --- a/Pomelo/LibraryViews/GameList/GameListView.swift +++ b/Pomelo/LibraryViews/GameList/GameListView.swift @@ -13,131 +13,64 @@ import UniformTypeIdentifiers import Sudachi struct GameListView: View { + // let games: [PomeloGame] @State var core: Core - @State private var searchText = "" - @State var game: Int = 1 - @State var startgame: Bool = false - @Binding var isGridView: Bool - @State var showAlert = false - @State var alertMessage: Alert? = nil + @Binding var selectedGame: PomeloGame? var body: some View { - let filteredGames = core.games.filter { game in - guard let PomeloGame = game as? PomeloGame else { return false } - return searchText.isEmpty || PomeloGame.title.localizedCaseInsensitiveContains(searchText) + ScrollView(.horizontal, showsIndicators: false) { + HStack(spacing: 0) { + ForEach(core.games.prefix(12)) { game in + GameIconView(game: game, selectedGame: $selectedGame) + } + + if core.games.count > 12 { + NavigationLink { + GameGridView(core: core) + } label: { + Circle() + .frame(width: 180, height: 180) + .overlay { + Image(systemName: "square.grid.2x2") + .resizable() + .foregroundColor(.white) + .frame(width: 70, height: 70) + } + .foregroundColor(Color.init(uiColor: .darkGray)) + } + + } + } + } + .onAppear { + selectedGame = core.games.first } - ScrollView { - VStack { - VStack(alignment: .leading) { - - if isGridView { - LazyVGrid(columns: [GridItem(.adaptive(minimum: 160))], spacing: 10) { - ForEach(0.. (Bool, Bool) { + var doesprodexist = false + var doestitleexist = false + + + let title = core.root.appendingPathComponent("keys").appendingPathComponent("title.keys") + let prod = core.root.appendingPathComponent("keys").appendingPathComponent("prod.keys") + let fileManager = FileManager.default + let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0] + + if fileManager.fileExists(atPath: prod.path) { + doesprodexist = true + } else { + print("File does not exist") } + + if fileManager.fileExists(atPath: title.path) { + doestitleexist = true + } else { + print("File does not exist") + } + + return (doestitleexist, doesprodexist) } } diff --git a/Pomelo/LibraryViews/LibraryView.swift b/Pomelo/LibraryViews/LibraryView.swift index 2cc21d5..f0ce07d 100644 --- a/Pomelo/LibraryViews/LibraryView.swift +++ b/Pomelo/LibraryViews/LibraryView.swift @@ -11,181 +11,76 @@ import CryptoKit import Sudachi struct LibraryView: View { - @Binding var core: Core - @State var isGridView: Bool = true - @State var doesitexist = (false, false) - @State var importedgame: PomeloGame? = nil - @State var importgame: Bool = false - @State var isimportingfirm: Bool = false - @State var launchGame: Bool = false + @State private var selectedGame: PomeloGame? = nil + + @State var core: Core + + init(selectedGame: PomeloGame? = nil, core: Core) { + + _core = State(wrappedValue: core) + self.selectedGame = selectedGame + print("Getting Roms...") + do { + _core = State(wrappedValue: try LibraryManager.shared.library()) + print(core.games) + } catch { + print("Failed to fetch library: \(error)") + } + } + var body: some View { NavigationStack { - if let importedgame = importedgame { - NavigationLink( - isActive: $launchGame, - destination: { - SudachiEmulationView(game: importedgame).toolbar(.hidden, for: .tabBar) - }, - label: { - EmptyView() // This keeps the link hidden - } - ) - } - - VStack { - if doesitexist.0, doesitexist.1 { - HomeView(core: core) - } else { - let (doesKeyExist, doesProdExist) = doeskeysexist() - ScrollView { - Text("You Are Missing These Files:") - .font(.headline) - .foregroundColor(.red) - HStack { - if !doesProdExist { - Text("Prod.keys") - .font(.subheadline) - .foregroundColor(.red) - } - if !doesKeyExist { - Text("Title.keys") - .font(.subheadline) - .foregroundColor(.red) - } - } - Text("These goes into the Keys folder") - .font(.caption) - .foregroundColor(.red) - .padding(.bottom) - - if !LibraryManager.shared.homebrewroms().isEmpty { - Text("Homebrew Roms:") - .font(.headline) - LazyVGrid(columns: [GridItem(.adaptive(minimum: 160))], spacing: 10) { - ForEach(LibraryManager.shared.homebrewroms()) { game in - NavigationLink(destination: SudachiEmulationView(game: game).toolbar(.hidden, for: .tabBar)) { - // GameButtonView(game: game) - // .frame(maxWidth: .infinity, minHeight: 200) - } - .contextMenu { - NavigationLink(destination: SudachiEmulationView(game: game)) { - Text("Launch") - } - } - } - } - } - } - .refreshable { - doesitexist = doeskeysexist() - } - - - } - - } - .fileImporter(isPresented: $isimportingfirm, allowedContentTypes: [.zip], onCompletion: { result in - switch result { - case .success(let elements): - core.AddFirmware(at: elements) - case .failure(let error): - - print(error.localizedDescription) - } - }) - .fileImporter(isPresented: $importgame, allowedContentTypes: [.item], onCompletion: { result in - switch result { - case .success(let elements): - let iscustom = elements.startAccessingSecurityScopedResource() - let information = Sudachi.shared.information(for: elements) - - let game = PomeloGame(developer: information.developer, fileURL: elements, - imageData: information.iconData, - title: information.title) - - importedgame = game - - - DispatchQueue.main.async { - - if iscustom { - elements.stopAccessingSecurityScopedResource() - } - - launchGame = true - } - case .failure(let error): - - print(error.localizedDescription) - } - }) - .onAppear() { - doesitexist = doeskeysexist() - } - .navigationBarTitle("Library", displayMode: .inline) - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { // why did this take me so long to figure out lmfao - Button(action: { - isGridView.toggle() - }) { - Image(systemName: isGridView ? "rectangle.grid.1x2" : "square.grid.2x2") - .imageScale(.large) - .padding() - } - } - - ToolbarItem(placement: .navigationBarTrailing) { // funsies - Menu { - Button(action: { - importgame = true // this part took a while - - }) { - Text("Launch Game") - } - - Button(action: { - isimportingfirm = true - }) { - Text("Import Firmware") - } - } label: { - Image(systemName: "plus.circle.fill") - .imageScale(.large) - .padding() - } + GeometryReader { geometry in + VStack { + TopBarView() + if UIDevice.current.userInterfaceIdiom == .pad { + Spacer() + } + + GameListView(core: core, selectedGame: $selectedGame) + + Spacer() + + BottomMenuView(core: core) + } + } + } + .background(Color.gray.opacity(0.1)) + .edgesIgnoringSafeArea(.all) + .onAppear { + refreshcore() + + if let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first { + let romsFolderURL = documentsDirectory.appendingPathComponent("roms") + + _ = FolderMonitor(folderURL: romsFolderURL) { + do { + core = Core(games: [], root: documentsDirectory) + core = try LibraryManager.shared.library() + } catch { + print("Error refreshing core: \(error)") + } } } } } - - func doeskeysexist() -> (Bool, Bool) { - var doesprodexist = false - var doestitleexist = false - - - let title = core.root.appendingPathComponent("keys").appendingPathComponent("title.keys") - let prod = core.root.appendingPathComponent("keys").appendingPathComponent("prod.keys") - let fileManager = FileManager.default - let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0] - - if fileManager.fileExists(atPath: prod.path) { - doesprodexist = true - } else { - print("File does not exist") + func refreshcore() { + print("Getting Roms...") + do { + core = try LibraryManager.shared.library() + print(core.games) + } catch { + print("Failed to fetch library: \(error)") + return } - - if fileManager.fileExists(atPath: title.path) { - doestitleexist = true - } else { - print("File does not exist") - } - - return (doestitleexist, doesprodexist) } } + + + func getDeveloperNames() -> String { var maindevelopername = "Stossy11" diff --git a/Pomelo/LibraryViews/Menu/BottomMenuView.swift b/Pomelo/LibraryViews/Menu/BottomMenuView.swift index 003547e..80782a1 100644 --- a/Pomelo/LibraryViews/Menu/BottomMenuView.swift +++ b/Pomelo/LibraryViews/Menu/BottomMenuView.swift @@ -1,3 +1,13 @@ +// +// BottomMenuView.swift +// Pomelo +// +// Created by Stossy11 on 9/10/2024. +// Copyright © 2024 Stossy11. All rights reserved. +// + +import SwiftUI + struct BottomMenuView: View { @State var core: Core var body: some View { diff --git a/Pomelo/LibraryViews/Menu/TopBarView.swift b/Pomelo/LibraryViews/Menu/TopBarView.swift index 533f200..3ff1d95 100644 --- a/Pomelo/LibraryViews/Menu/TopBarView.swift +++ b/Pomelo/LibraryViews/Menu/TopBarView.swift @@ -1,3 +1,14 @@ +// +// TopBarView.swift +// Pomelo +// +// Created by Stossy11 on 9/10/2024. +// Copyright © 2024 Stossy11. All rights reserved. +// + +import SwiftUI +import Combine + struct TopBarView: View { @State private var currentDate: Date = Date() @State private var batteryLevel: Float = UIDevice.current.batteryLevel diff --git a/Pomelo/PomeloApp.swift b/Pomelo/PomeloApp.swift index 01e4658..01c74b2 100644 --- a/Pomelo/PomeloApp.swift +++ b/Pomelo/PomeloApp.swift @@ -17,6 +17,7 @@ struct PomeloApp: App { var body: some Scene { WindowGroup { ContentView() // i dont know if i should change anything + .persistentSystemOverlays(.hidden) } } } diff --git a/Pomelo/ScreenshotManager/ScreenShotListView.swift b/Pomelo/ScreenshotManager/ScreenShotListView.swift index e69de29..897fc6c 100644 --- a/Pomelo/ScreenshotManager/ScreenShotListView.swift +++ b/Pomelo/ScreenshotManager/ScreenShotListView.swift @@ -0,0 +1,177 @@ +// +// ScreenShotListView.swift +// Pomelo +// +// Created by Stossy11 on 8/10/2024. +// Copyright © 2024 Stossy11. All rights reserved. +// + +import SwiftUI + +struct Screenshot: Identifiable { + let id = UUID() + let image: UIImage + let gameID: String + let date: Date +} + +struct ScreenshotGridView: View { + @State var core: Core + @State private var selectedScreenshot: UIImage? + @State private var isFullScreenPresented = false + + var screenshots: [Screenshot] { + loadScreenshots() + } + + var body: some View { + let columns = [ + GridItem(.adaptive(minimum: 100)) // Adjust the minimum size as needed + ] + + ScrollView { + LazyVGrid(columns: columns, spacing: 10) { + ForEach(screenshots) { screenshot in + VStack { + Image(uiImage: screenshot.image) + .resizable() + .scaledToFit() + .frame(minWidth: 100, minHeight: 100) // Minimum size for each image + .clipShape(RoundedRectangle(cornerRadius: 10)) + .shadow(radius: 5) + .onTapGesture { + // Set the selected screenshot and present fullscreen + DispatchQueue.main.async { + selectedScreenshot = screenshot.image + } + isFullScreenPresented.toggle() + } + Text("\(core.games.first(where: { $0.title == screenshot.gameID })?.title ?? "Unknown Game")") + .font(.title2) + Text("\(screenshot.date.formatted())") + .font(.caption) + .foregroundColor(.secondary) + } + } + } + .padding() + } + .fullScreenCover(isPresented: $isFullScreenPresented) { + if let selectedScreenshot = selectedScreenshot { + FullScreenImageView(screenshot: selectedScreenshot) + } else { + Text("Unable to get image.") + } + } + } + + // Function to load images from the screenshots directory + func loadScreenshots() -> [Screenshot] { + let fileManager = FileManager.default + guard let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first else { + return [] + } + + let screenshotsDirectory = documentsDirectory.appendingPathComponent("screenshots") + var screenshots: [Screenshot] = [] + + do { + let fileUrls = try fileManager.contentsOfDirectory(at: screenshotsDirectory, includingPropertiesForKeys: nil) + for url in fileUrls { + if let image = UIImage(contentsOfFile: url.path) { + let fileName = url.lastPathComponent + let components = fileName.components(separatedBy: "-(") + + guard components.count == 2, + let gameID = components.first, + let dateString = components.last?.replacingOccurrences(of: ").png", with: "") else { + continue + } + + print(gameID) + print(core.games) + + // Decode the date string from URL encoding + let decodedDateString = dateString.replacingOccurrences(of: "%20", with: " ") + + // Convert the date string back to Date object + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z" // Adjust the format as needed + + if let date = dateFormatter.date(from: decodedDateString) { + let screenshot = Screenshot(image: image, gameID: gameID, date: date) + screenshots.append(screenshot) + } else { + let screenshot = Screenshot(image: image, gameID: gameID, date: Date()) + screenshots.append(screenshot) + } + } + } + } catch { + print("Error loading images: \(error)") + } + + return screenshots + } +} + +struct FullScreenImageView: View { + var screenshot: UIImage + @State private var currentZoom = 0.0 + @State private var totalZoom = 1.0 + @State private var showShareSheet = false + @Environment(\.presentationMode) var presentationMode + + var body: some View { + ZStack(alignment: .top) { + Image(uiImage: screenshot) + .resizable() + .scaledToFit() + .ignoresSafeArea() + .scaleEffect(currentZoom + totalZoom) + .zoomable() + + // Use HStack to position the buttons correctly + HStack { + // Share button on the top left + Button(action: { + showShareSheet = true + }) { + Image(systemName: "square.and.arrow.up") + .padding() + .foregroundColor(.white) + .background(Color.black.opacity(0.5)) + .cornerRadius(8) + .font(.system(size: 30)) + } + Spacer() + // Dismiss button on the top right + Button(action: { + presentationMode.wrappedValue.dismiss() + }) { + Image(systemName: "x.circle") + .padding() + .foregroundColor(.white) + .background(Color.black.opacity(0.5)) + .cornerRadius(8) + .font(.system(size: 30)) + } + } + .padding() // Add padding to the HStack for spacing + } + .sheet(isPresented: $showShareSheet) { + ShareSheet(activityItems: [screenshot]) + } + } +} + + +struct ShareSheet: UIViewControllerRepresentable { + var activityItems: [Any] + + func makeUIViewController(context: Context) -> UIActivityViewController { + UIActivityViewController(activityItems: activityItems, applicationActivities: nil) + } + + func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {} +} diff --git a/Pomelo/SettingsViews/SettingsView.swift b/Pomelo/SettingsViews/SettingsView.swift index cab5e25..e1319b6 100644 --- a/Pomelo/SettingsViews/SettingsView.swift +++ b/Pomelo/SettingsViews/SettingsView.swift @@ -70,14 +70,11 @@ struct SettingsView: View { if UIDevice.current.systemVersion <= "17.0.1" { Button(action: { - /* if UserDefaults.standard.bool(forKey: "useTrollStore") { - UserDefaults.standard.set(false, forKey: "useTrollStore") + UserDefaults.standard.set(false, forKey: "useTrollStore") } else { - UserDefaults.standard.set(true, forKey: "useTrollStore") + UserDefaults.standard.set(true, forKey: "useTrollStore") } - */ - showprompt = true }) { Rectangle() .fill(Color(uiColor: UIColor.secondarySystemBackground)) // Set the fill color (optional) diff --git a/Sudachi/Sudachi/Wrapper/EmulationWindow/EmulationWindow.mm b/Sudachi/Sudachi/Wrapper/EmulationWindow/EmulationWindow.mm index f42db17..cad81b8 100644 --- a/Sudachi/Sudachi/Wrapper/EmulationWindow/EmulationWindow.mm +++ b/Sudachi/Sudachi/Wrapper/EmulationWindow/EmulationWindow.mm @@ -23,7 +23,7 @@ void EmulationWindow::OnSurfaceChanged(CA::MetalLayer* surface, CGSize size) { m_window_height = size.height; // Ensures that we emulate with the correct aspect ratio. - // UpdateCurrentFramebufferLayout(m_window_width, m_window_height); + UpdateCurrentFramebufferLayout(m_window_width, m_window_height); window_info.render_surface = reinterpret_cast(surface); window_info.render_surface_scale = [[UIScreen mainScreen] nativeScale];