├── OpenParsec ├── Assets.xcassets │ ├── Contents.json │ ├── AppIcon.appiconset │ │ ├── icon-20.png │ │ ├── icon-29.png │ │ ├── icon-40.png │ │ ├── icon-76.png │ │ ├── icon-1024.png │ │ ├── icon-20@2x.png │ │ ├── icon-20@3x.png │ │ ├── icon-29@2x.png │ │ ├── icon-29@3x.png │ │ ├── icon-40@2x.png │ │ ├── icon-40@3x.png │ │ ├── icon-60@2x.png │ │ ├── icon-60@3x.png │ │ ├── icon-76@2x.png │ │ ├── icon-83.5@2x.png │ │ └── Contents.json │ ├── LogoShadow.imageset │ │ ├── logo_shadow.png │ │ └── Contents.json │ ├── IconTransparent.imageset │ │ ├── icon_transparent.png │ │ └── Contents.json │ ├── SymbolExit.symbolset │ │ └── Contents.json │ ├── Shading.colorset │ │ └── Contents.json │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── BackgroundTab.colorset │ │ └── Contents.json │ ├── Foreground.colorset │ │ └── Contents.json │ ├── BackgroundButton.colorset │ │ └── Contents.json │ ├── BackgroundCard.colorset │ │ └── Contents.json │ ├── BackgroundField.colorset │ │ └── Contents.json │ ├── BackgroundGray.colorset │ │ └── Contents.json │ ├── BackgroundPrompt.colorset │ │ └── Contents.json │ └── ForegroundInactive.colorset │ │ └── Contents.json ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── OpenParsec-Bridging-Header.h ├── Shared.swift ├── audio.h ├── ParsecMetalView.swift ├── UIViewControllerWrapper.swift ├── ActivityIndicator.swift ├── ParsecGLKViewController.swift ├── URLImage.swift ├── ParsecGLKRenderer.swift ├── AppDelegate.swift ├── ParsecMTLRender.swift ├── NetworkHandler.swift ├── SettingsView.swift ├── KeyboardViewController.swift ├── ContentView.swift ├── Info.plist ├── SceneDelegate.swift ├── TouchHandlingView.swift ├── Base.lproj │ └── LaunchScreen.storyboard ├── LoginView.swift ├── GameController.swift ├── ParsecView.swift ├── audio.c ├── CParsec.swift └── MainView.swift ├── .gitmodules ├── OpenParsec.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── xcshareddata │ └── xcschemes │ │ └── OpenParsec.xcscheme └── project.pbxproj ├── .gitignore ├── README.md ├── .github └── workflows │ └── build.yml └── LICENSE /OpenParsec/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /OpenParsec/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-20.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-29.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-1024.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /OpenParsec/OpenParsec-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "audio.h" 6 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/LogoShadow.imageset/logo_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/LogoShadow.imageset/logo_shadow.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Frameworks/ParsecSDK.framework"] 2 | path = Frameworks/ParsecSDK.framework 3 | url = https://github.com/dicksonhk/parsec-sdk 4 | branch = sdk/ios 5 | shallow = true 6 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/IconTransparent.imageset/icon_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaoxuhuanxiang/OpenParsec/HEAD/OpenParsec/Assets.xcassets/IconTransparent.imageset/icon_transparent.png -------------------------------------------------------------------------------- /OpenParsec.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/LogoShadow.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "logo_shadow.png", 5 | "idiom" : "universal" 6 | } 7 | ], 8 | "info" : { 9 | "author" : "xcode", 10 | "version" : 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/IconTransparent.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "icon_transparent.png", 5 | "idiom" : "universal" 6 | } 7 | ], 8 | "info" : { 9 | "author" : "xcode", 10 | "version" : 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/SymbolExit.symbolset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | }, 6 | "symbols" : [ 7 | { 8 | "filename" : "rectangle.portrait.and.arrow.right.svg", 9 | "idiom" : "universal" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /OpenParsec/Shared.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Shared.swift 3 | // OpenParsec 4 | // 5 | // Created by Seçkin KÜKRER on 25.02.2023. 6 | // 7 | 8 | import Foundation 9 | 10 | struct GLBData 11 | { 12 | let SessionKeyChainKey = "OPStoredAuthData" 13 | } 14 | 15 | class GLBDataModel 16 | { 17 | static let shared = GLBData() 18 | } 19 | -------------------------------------------------------------------------------- /OpenParsec.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /OpenParsec/audio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct audio; 7 | 8 | void audio_init(struct audio **ctx_out); 9 | void audio_destroy(struct audio **ctx_out); 10 | void audio_clear(struct audio **ctx_out); 11 | void audio_cb(const int16_t *pcm, uint32_t frames, void *opaque); 12 | void audio_mute(bool muted, const void *opaque); 13 | 14 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/Shading.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "0.500", 8 | "blue" : "0.000", 9 | "green" : "0.000", 10 | "red" : "0.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "1.000", 9 | "green" : "0.250", 10 | "red" : "0.625" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/BackgroundTab.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.129", 9 | "green" : "0.122", 10 | "red" : "0.122" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/Foreground.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "1.000", 9 | "green" : "1.000", 10 | "red" : "1.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/BackgroundButton.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "0.300", 8 | "blue" : "0.525", 9 | "green" : "0.500", 10 | "red" : "0.500" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/BackgroundCard.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.205", 9 | "green" : "0.200", 10 | "red" : "0.200" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/BackgroundField.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "0.500", 8 | "blue" : "0.215", 9 | "green" : "0.200", 10 | "red" : "0.200" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/BackgroundGray.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.110", 9 | "green" : "0.100", 10 | "red" : "0.100" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/BackgroundPrompt.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.255", 9 | "green" : "0.250", 10 | "red" : "0.250" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/ForegroundInactive.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "0.750", 8 | "blue" : "1.000", 9 | "green" : "1.000", 10 | "red" : "1.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OpenParsec/ParsecMetalView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import MetalKit 3 | import UIKit 4 | 5 | struct MetalView: UIViewRepresentable 6 | { 7 | let view = MTKView() 8 | let renderer = MTLRender() 9 | func makeUIView(context:UIViewRepresentableContext) -> MTKView 10 | { 11 | renderer.initWithView(view) 12 | return view 13 | } 14 | 15 | func updateUIView(_ uiView:MTKView, context:UIViewRepresentableContext) 16 | { 17 | } 18 | 19 | typealias UIViewType = MTKView 20 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | .AppleDouble 4 | .LSOverride 5 | 6 | # Icon must end with two \r 7 | Icon 8 | 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | .com.apple.timemachine.donotpresent 21 | 22 | # Directories potentially created on remote AFP share 23 | .AppleDB 24 | .AppleDesktop 25 | Network Trash Folder 26 | Temporary Items 27 | .apdisk 28 | 29 | ## User settings 30 | xcuserdata/ 31 | -------------------------------------------------------------------------------- /OpenParsec/UIViewControllerWrapper.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import UIKit 3 | 4 | struct UIViewControllerWrapper:UIViewControllerRepresentable 5 | { 6 | typealias UIViewControllerType = Wrapped 7 | 8 | let wrappedController:Wrapped 9 | 10 | init(_ wrappedController:Wrapped) 11 | { 12 | self.wrappedController = wrappedController 13 | } 14 | 15 | func makeUIViewController(context:Context) -> Wrapped 16 | { 17 | return wrappedController 18 | } 19 | 20 | func updateUIViewController(_ uiViewController:Wrapped, context:Context) 21 | { 22 | // No-op 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #

![icon_transparent.png](OpenParsec/Assets.xcassets/IconTransparent.imageset/icon_transparent.png) ![OpenParsec](OpenParsec/Assets.xcassets/LogoShadow.imageset/logo_shadow.png)

2 | 3 | OpenParsec is a simple, open-source Parsec client for iOS/iPadOS written in Swift using the SwiftUI framework and the Parsec SDK. 4 | 5 | This project is still a major WIP, so apologies for the currently lackluster documentation. I'm also very new to both Swift and SwiftUI so I'm sure there are many places for improvement. 6 | 7 | Before building, make sure you have the Parsec SDK framework symlinked or copied to the `Frameworks` folder. Builds were tested on Xcode Version 12.5. 8 | -------------------------------------------------------------------------------- /OpenParsec/ActivityIndicator.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import SwiftUI 3 | 4 | struct ActivityIndicator: UIViewRepresentable 5 | { 6 | @Binding var isAnimating:Bool 7 | let style:UIActivityIndicatorView.Style 8 | var tint:UIColor 9 | 10 | func makeUIView(context:UIViewRepresentableContext) -> UIActivityIndicatorView 11 | { 12 | let uiView:UIActivityIndicatorView = UIActivityIndicatorView(style:style) 13 | uiView.color = tint; 14 | return uiView 15 | } 16 | 17 | func updateUIView(_ uiView:UIActivityIndicatorView, context:UIViewRepresentableContext) 18 | { 19 | isAnimating ? uiView.startAnimating() : uiView.stopAnimating() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OpenParsec/ParsecGLKViewController.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import GLKit 3 | 4 | struct ParsecGLKViewController:UIViewControllerRepresentable 5 | { 6 | let glkView = GLKView() 7 | let glkViewController = GLKViewController() 8 | 9 | func makeCoordinator() -> ParsecGLKRenderer 10 | { 11 | ParsecGLKRenderer(glkView, glkViewController) 12 | } 13 | 14 | func makeUIViewController(context:UIViewControllerRepresentableContext) -> GLKViewController 15 | { 16 | glkView.context = EAGLContext(api:.openGLES3)! 17 | glkViewController.view = glkView 18 | glkViewController.preferredFramesPerSecond = 60 19 | return glkViewController 20 | } 21 | 22 | func updateUIViewController(_ uiViewController:GLKViewController, context:UIViewControllerRepresentableContext) { } 23 | } 24 | -------------------------------------------------------------------------------- /OpenParsec/URLImage.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct URLImage:View 4 | { 5 | let url:URL? 6 | let output:(Image) -> RemoteImage 7 | let placeholder:() -> Placeholder 8 | 9 | @State private var _remoteData:UIImage? = nil 10 | 11 | var body:some View 12 | { 13 | if let img = _remoteData 14 | { 15 | output(Image(uiImage:img)) 16 | } 17 | else 18 | { 19 | placeholder() 20 | .onAppear 21 | { 22 | var request = URLRequest(url:url!) 23 | request.httpMethod = "GET" 24 | request.setValue("image/jpeg", forHTTPHeaderField:"Content-Type") 25 | 26 | let task = URLSession.shared.dataTask(with:request) 27 | { (data, response, error) in 28 | DispatchQueue.main.async 29 | { 30 | if let data = data, let uiImage = UIImage(data:data) 31 | { 32 | _remoteData = uiImage 33 | } 34 | } 35 | } 36 | task.resume() 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /OpenParsec/ParsecGLKRenderer.swift: -------------------------------------------------------------------------------- 1 | import GLKit 2 | import ParsecSDK 3 | 4 | class ParsecGLKRenderer:NSObject, GLKViewDelegate, GLKViewControllerDelegate 5 | { 6 | var glkView:GLKView 7 | var glkViewController:GLKViewController 8 | var lastWidth:CGFloat 9 | //var FramesNotFlush:UInt32 10 | init(_ view:GLKView, _ viewController:GLKViewController) 11 | { 12 | glkView = view 13 | glkViewController = viewController 14 | lastWidth = 1.0 15 | //FramesNotFlush = 0 16 | super.init() 17 | 18 | glkView.delegate = self 19 | glkViewController.delegate = self 20 | } 21 | 22 | deinit 23 | { 24 | glkView.delegate = nil 25 | glkViewController.delegate = nil 26 | } 27 | 28 | func glkView(_ view:GLKView, drawIn rect:CGRect) 29 | { 30 | CParsec.pollAudio() 31 | let deltaWidth: CGFloat = view.frame.size.width - lastWidth 32 | if deltaWidth > 0.1 || deltaWidth < -0.1 33 | { 34 | CParsec.setFrame(view.frame.size.width, view.frame.size.height, view.contentScaleFactor) 35 | lastWidth = view.frame.size.width 36 | } 37 | //CParsec.renderFrame(.opengl, cq: nil, texturePtr: nil) 38 | //glFlush() 39 | 40 | } 41 | 42 | func glkViewControllerUpdate(_ controller:GLKViewController) { } 43 | } 44 | -------------------------------------------------------------------------------- /OpenParsec/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @main 4 | class AppDelegate:UIResponder, UIApplicationDelegate 5 | { 6 | func application(_ application:UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey: Any]?) -> Bool 7 | { 8 | // Override point for customization after application launch. 9 | UIApplication.shared.isIdleTimerDisabled = true 10 | return true 11 | } 12 | 13 | func application(_ application:UIApplication, configurationForConnecting connectingSceneSession:UISceneSession, options:UIScene.ConnectionOptions) -> UISceneConfiguration 14 | { 15 | // Called when a new scene session is being created. 16 | // Use this method to select a configuration to create the new scene with. 17 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 18 | } 19 | 20 | func application(_ application:UIApplication, didDiscardSceneSessions sceneSessions:Set) 21 | { 22 | // Called when the user discards a scene session. 23 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 24 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 25 | } 26 | 27 | func applicationWillTerminate(_ application: UIApplication) 28 | { 29 | CParsec.destroy() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /OpenParsec/ParsecMTLRender.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import MetalKit 3 | 4 | class MTLRender: NSObject, MTKViewDelegate 5 | { 6 | private let device = MTLCreateSystemDefaultDevice() 7 | private var commandQueue: MTLCommandQueue? 8 | private var texture: MTLTexture? 9 | private var texturePtr: UnsafeMutableRawPointer? 10 | 11 | override init(){} 12 | 13 | func initWithView(_ view: MTKView) 14 | { 15 | view.delegate = self 16 | view.device = device 17 | self.commandQueue = device?.makeCommandQueue() 18 | print("zxx commandQueue:", commandQueue) 19 | let textureDescriptor = MTLTextureDescriptor() 20 | textureDescriptor.pixelFormat = .rgba8Unorm 21 | self.texture = device?.makeTexture(descriptor: textureDescriptor) 22 | print("zxx texture:", texture) 23 | self.texturePtr = withUnsafeMutablePointer(to: &texture, { UnsafeMutableRawPointer($0) }) 24 | print("zxx:", texturePtr) 25 | } 26 | 27 | func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) 28 | { 29 | CParsec.setFrame(size.width, size.height, view.contentScaleFactor) 30 | } 31 | 32 | func draw(in view: MTKView) 33 | { 34 | guard let commandBuffer = commandQueue?.makeCommandBuffer() else { return } 35 | guard let renderPassDescriptor = view.currentRenderPassDescriptor else { return } 36 | guard let renderCommandEncoder = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor) else {return} 37 | renderCommandEncoder.endEncoding() 38 | CParsec.renderFrame(.metal, cq: &commandQueue!, texturePtr:&texturePtr) 39 | 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /OpenParsec/NetworkHandler.swift: -------------------------------------------------------------------------------- 1 | class NetworkHandler 2 | { 3 | public static var clinfo:ClientInfo? = nil 4 | } 5 | 6 | struct ErrorInfo:Decodable 7 | { 8 | var error:String 9 | // var codes:Array 10 | } 11 | 12 | struct ClientInfo:Decodable 13 | { 14 | var instance_id:String 15 | var user_id:Int 16 | var session_id:String 17 | var host_peer_id:String 18 | } 19 | 20 | struct UserInfo:Decodable 21 | { 22 | var id:Int 23 | var name:String 24 | var warp:Bool 25 | // var external_id:String 26 | // var external_provider:String 27 | var team_id:String 28 | } 29 | 30 | struct HostInfo:Decodable 31 | { 32 | var user:UserInfo 33 | var peer_id:String 34 | var game_id:String 35 | var description:String 36 | var max_players:Int 37 | var mode:String 38 | var name:String 39 | var event_name:String 40 | var players:Int 41 | // var public:Bool 42 | var guest_access:Bool 43 | var online:Bool 44 | // var self:Bool 45 | var build:String 46 | } 47 | 48 | struct HostInfoList:Decodable 49 | { 50 | var data:Array? 51 | var has_more:Bool 52 | } 53 | 54 | struct SelfInfoData:Decodable 55 | { 56 | var id:Int 57 | var name:String 58 | var email:String 59 | var warp:Bool 60 | var staff:Bool 61 | var team_id:String 62 | var is_confirmed:Bool 63 | var team_is_active:Bool 64 | var is_saml:Bool 65 | var is_gateway_enabled:Bool 66 | var is_relay_enabled:Bool 67 | var has_tfa:Bool 68 | // var app_config:Any 69 | var cohort_channel:String 70 | } 71 | 72 | struct SelfInfo:Decodable 73 | { 74 | var data:SelfInfoData 75 | } 76 | 77 | struct FriendInfo:Decodable 78 | { 79 | var user_id:Int 80 | var user_name:String 81 | } 82 | 83 | struct FriendInfoList:Decodable 84 | { 85 | var data:Array? 86 | var has_more:Bool 87 | } 88 | -------------------------------------------------------------------------------- /OpenParsec/SettingsView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct SettingsView:View 4 | { 5 | @Binding var visible:Bool 6 | 7 | var body:some View 8 | { 9 | ZStack() 10 | { 11 | if (visible) 12 | { 13 | // Background 14 | Rectangle() 15 | .fill(Color.init(red:0, green:0, blue:0, opacity:0.67)) 16 | .edgesIgnoringSafeArea(.all) 17 | } 18 | } 19 | .animation(.linear(duration:0.24)) 20 | 21 | ZStack() 22 | { 23 | if (visible) 24 | { 25 | // Main controls 26 | VStack() 27 | { 28 | // Navigation controls 29 | ZStack() 30 | { 31 | Rectangle() 32 | .fill(Color("BackgroundTab")) 33 | .frame(height:52) 34 | .shadow(color:Color("Shading"), radius:4, y:6) 35 | ZStack() 36 | { 37 | HStack() 38 | { 39 | Button(action:{ visible = false }, label:{ Image(systemName:"xmark").scaleEffect(x:-1) }) 40 | .padding() 41 | Spacer() 42 | } 43 | Text("Settings") 44 | .multilineTextAlignment(.center) 45 | .foregroundColor(Color("Foreground")) 46 | .font(.system(size:20, weight:.medium)) 47 | Spacer() 48 | } 49 | .foregroundColor(Color("AccentColor")) 50 | } 51 | .zIndex(1) 52 | 53 | ScrollView() 54 | { 55 | Text("This menu is a work in progress.\nCheck back later.") 56 | .multilineTextAlignment(.center) 57 | .foregroundColor(Color("Foreground")) 58 | .opacity(0.5) 59 | .padding() 60 | } 61 | } 62 | .background(Rectangle().fill(Color("BackgroundGray"))) 63 | .cornerRadius(8) 64 | .padding() 65 | } 66 | } 67 | .scaleEffect(visible ? 1 : 0, anchor:.zero) 68 | .animation(.easeInOut(duration:0.24)) 69 | } 70 | } 71 | 72 | struct SettingsView_Previews:PreviewProvider 73 | { 74 | @State static var value:Bool = true 75 | 76 | static var previews:some View 77 | { 78 | SettingsView(visible:$value) 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /OpenParsec/KeyboardViewController.swift: -------------------------------------------------------------------------------- 1 | import ParsecSDK 2 | import UIKit 3 | 4 | class KeyboardViewController:UIViewController 5 | { 6 | override func viewDidLoad() 7 | { 8 | super.viewDidLoad() 9 | print("KeyboardViewController did load!") 10 | } 11 | 12 | @objc func handleKeyCommand(sender:UIKeyCommand) 13 | { 14 | print("KeyboardViewController keyboard info: \(sender)") 15 | 16 | CParsec.sendKeyboardMessage(sender:sender) 17 | } 18 | 19 | @objc func handleModifierKeyCommand(sender:UIKeyCommand) 20 | { 21 | print("KeyboardViewController keyboard modifier info \(sender.modifierFlags.rawValue)") 22 | } 23 | 24 | override var keyCommands:[UIKeyCommand]? 25 | { 26 | // Create an array to hold the key commands 27 | var commands = [UIKeyCommand]() 28 | 29 | // Add a key command for each printable ASCII character 30 | for scalar in (Unicode.Scalar(32)...Unicode.Scalar(255)).makeIterator() 31 | { 32 | let input = String(scalar) 33 | let keyCommand = UIKeyCommand(action:#selector(handleKeyCommand(sender:)), input:input, modifierFlags:[], propertyList:input) 34 | print("Key added to the Commands: \(input)") 35 | commands.append(keyCommand) 36 | } 37 | 38 | // ESC Key 39 | let escKeyCommand = UIKeyCommand(action:#selector(handleKeyCommand(sender:)), input:UIKeyCommand.inputEscape, modifierFlags:[], propertyList:nil) 40 | 41 | // TAB Key 42 | let tabKeyCommand = UIKeyCommand(action:#selector(handleKeyCommand(sender:)), input:"\t", modifierFlags:[], propertyList:nil) 43 | 44 | // Shift Keys 45 | let shiftKeyCommand = UIKeyCommand(action:#selector(handleKeyCommand(sender:)), input:"", modifierFlags:.shift, propertyList:nil) 46 | 47 | // CTRL Key 48 | let ctrlKeyCommand = UIKeyCommand(action:#selector(handleKeyCommand(sender:)), input:"", modifierFlags:.control, propertyList:nil) 49 | 50 | // CMD Key 51 | let commandKey = UIKeyCommand(action:#selector(handleKeyCommand(sender:)), input:"", modifierFlags:.command, propertyList:nil) 52 | 53 | // Return the array of key commands 54 | return commands + 55 | [ 56 | escKeyCommand, 57 | tabKeyCommand, 58 | shiftKeyCommand, 59 | ctrlKeyCommand, 60 | commandKey 61 | ] 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /OpenParsec/ContentView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | enum ViewType 4 | { 5 | case login 6 | case main 7 | case parsec 8 | } 9 | 10 | struct ContentView:View 11 | { 12 | @State var curView:ViewType = .login 13 | 14 | let defaultTransition = AnyTransition.move(edge:.trailing) 15 | 16 | var body:some View 17 | { 18 | ZStack() 19 | { 20 | switch curView 21 | { 22 | case .login: 23 | LoginView(self) 24 | case .main: 25 | MainView(self) 26 | .transition(defaultTransition) 27 | case .parsec: 28 | ParsecView(self) 29 | } 30 | } 31 | .onAppear(perform:initApp) 32 | .background(Rectangle().fill(Color.black).edgesIgnoringSafeArea(.all)) 33 | } 34 | 35 | func initApp() 36 | { 37 | CParsec.initialize() 38 | 39 | // Check to see if we have old session data 40 | if let data = loadFromKeychain(key: GLBDataModel.shared.SessionKeyChainKey) 41 | { 42 | let decoder = JSONDecoder() 43 | 44 | print("Retrieved data from keychain: \(data).\nTrying to restore session.") 45 | NetworkHandler.clinfo = try? decoder.decode(ClientInfo.self, from:data) 46 | if NetworkHandler.clinfo != nil 47 | { 48 | curView = .main 49 | print("Session restored and moved to the main page.") 50 | } 51 | else 52 | { 53 | print("Unable to restore session, falling back to login page.") 54 | } 55 | } 56 | 57 | print("Initialized") 58 | } 59 | 60 | func loadFromKeychain(key: String) -> Data? 61 | { 62 | let query: [String: Any] = [kSecClass as String: kSecClassGenericPassword, kSecAttrAccount as String: key, kSecReturnData as String: kCFBooleanTrue!, kSecMatchLimit as String: kSecMatchLimitOne] 63 | var item: CFTypeRef? 64 | let status = SecItemCopyMatching(query as CFDictionary, &item) 65 | guard status == errSecSuccess else 66 | { 67 | if status != errSecItemNotFound 68 | { 69 | print("Error loading from keychain: \(status)") 70 | } 71 | return nil 72 | } 73 | guard let data = item as? Data else 74 | { 75 | return nil 76 | } 77 | return data 78 | } 79 | 80 | public func setView(_ t:ViewType) 81 | { 82 | withAnimation(.easeInOut) { curView = t } 83 | } 84 | } 85 | 86 | struct ContentView_Previews:PreviewProvider 87 | { 88 | static var previews:some View 89 | { 90 | ContentView() 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /OpenParsec/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UIApplicationSupportsIndirectInputEvents 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UIRequiresFullScreen 49 | 50 | UIStatusBarHidden 51 | 52 | UIStatusBarStyle 53 | UIStatusBarStyleLightContent 54 | UISupportedInterfaceOrientations 55 | 56 | UIInterfaceOrientationPortrait 57 | UIInterfaceOrientationLandscapeLeft 58 | UIInterfaceOrientationLandscapeRight 59 | 60 | UISupportedInterfaceOrientations~ipad 61 | 62 | UIInterfaceOrientationPortrait 63 | UIInterfaceOrientationPortraitUpsideDown 64 | UIInterfaceOrientationLandscapeLeft 65 | UIInterfaceOrientationLandscapeRight 66 | 67 | UIViewControllerBasedStatusBarAppearance 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /OpenParsec/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import SwiftUI 3 | 4 | class SceneDelegate:UIResponder, UIWindowSceneDelegate 5 | { 6 | var window:UIWindow? 7 | 8 | func scene(_ scene:UIScene, willConnectTo session:UISceneSession, options connectionOptions:UIScene.ConnectionOptions) 9 | { 10 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 11 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 12 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 13 | 14 | // Create the SwiftUI view that provides the window contents. 15 | let contentView = ContentView() 16 | 17 | // Use a UIHostingController as window root view controller. 18 | if let windowScene = scene as? UIWindowScene 19 | { 20 | let window = UIWindow(windowScene: windowScene) 21 | window.rootViewController = UIHostingController(rootView: contentView) 22 | self.window = window 23 | window.makeKeyAndVisible() 24 | } 25 | } 26 | 27 | func sceneDidDisconnect(_ scene:UIScene) 28 | { 29 | // Called as the scene is being released by the system. 30 | // This occurs shortly after the scene enters the background, or when its session is discarded. 31 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 32 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 33 | } 34 | 35 | func sceneDidBecomeActive(_ scene:UIScene) 36 | { 37 | // Called when the scene has moved from an inactive state to an active state. 38 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 39 | } 40 | 41 | func sceneWillResignActive(_ scene:UIScene) 42 | { 43 | // Called when the scene will move from an active state to an inactive state. 44 | // This may occur due to temporary interruptions (ex. an incoming phone call). 45 | } 46 | 47 | func sceneWillEnterForeground(_ scene:UIScene) 48 | { 49 | // Called as the scene transitions from the background to the foreground. 50 | // Use this method to undo the changes made on entering the background. 51 | } 52 | 53 | func sceneDidEnterBackground(_ scene:UIScene) 54 | { 55 | // Called as the scene transitions from the foreground to the background. 56 | // Use this method to save data, release shared resources, and store enough scene-specific state information 57 | // to restore the scene back to its current state. 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /OpenParsec/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "icon-20@2x.png", 5 | "idiom" : "iphone", 6 | "scale" : "2x", 7 | "size" : "20x20" 8 | }, 9 | { 10 | "filename" : "icon-20@3x.png", 11 | "idiom" : "iphone", 12 | "scale" : "3x", 13 | "size" : "20x20" 14 | }, 15 | { 16 | "filename" : "icon-29@2x.png", 17 | "idiom" : "iphone", 18 | "scale" : "2x", 19 | "size" : "29x29" 20 | }, 21 | { 22 | "filename" : "icon-29@3x.png", 23 | "idiom" : "iphone", 24 | "scale" : "3x", 25 | "size" : "29x29" 26 | }, 27 | { 28 | "filename" : "icon-40@2x.png", 29 | "idiom" : "iphone", 30 | "scale" : "2x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "filename" : "icon-40@3x.png", 35 | "idiom" : "iphone", 36 | "scale" : "3x", 37 | "size" : "40x40" 38 | }, 39 | { 40 | "filename" : "icon-60@2x.png", 41 | "idiom" : "iphone", 42 | "scale" : "2x", 43 | "size" : "60x60" 44 | }, 45 | { 46 | "filename" : "icon-60@3x.png", 47 | "idiom" : "iphone", 48 | "scale" : "3x", 49 | "size" : "60x60" 50 | }, 51 | { 52 | "filename" : "icon-20.png", 53 | "idiom" : "ipad", 54 | "scale" : "1x", 55 | "size" : "20x20" 56 | }, 57 | { 58 | "filename" : "icon-20@2x.png", 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "20x20" 62 | }, 63 | { 64 | "filename" : "icon-29.png", 65 | "idiom" : "ipad", 66 | "scale" : "1x", 67 | "size" : "29x29" 68 | }, 69 | { 70 | "filename" : "icon-29@2x.png", 71 | "idiom" : "ipad", 72 | "scale" : "2x", 73 | "size" : "29x29" 74 | }, 75 | { 76 | "filename" : "icon-40.png", 77 | "idiom" : "ipad", 78 | "scale" : "1x", 79 | "size" : "40x40" 80 | }, 81 | { 82 | "filename" : "icon-40@2x.png", 83 | "idiom" : "ipad", 84 | "scale" : "2x", 85 | "size" : "40x40" 86 | }, 87 | { 88 | "filename" : "icon-76.png", 89 | "idiom" : "ipad", 90 | "scale" : "1x", 91 | "size" : "76x76" 92 | }, 93 | { 94 | "filename" : "icon-76@2x.png", 95 | "idiom" : "ipad", 96 | "scale" : "2x", 97 | "size" : "76x76" 98 | }, 99 | { 100 | "filename" : "icon-83.5@2x.png", 101 | "idiom" : "ipad", 102 | "scale" : "2x", 103 | "size" : "83.5x83.5" 104 | }, 105 | { 106 | "filename" : "icon-1024.png", 107 | "idiom" : "ios-marketing", 108 | "scale" : "1x", 109 | "size" : "1024x1024" 110 | } 111 | ], 112 | "info" : { 113 | "author" : "xcode", 114 | "version" : 1 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /OpenParsec.xcodeproj/xcshareddata/xcschemes/OpenParsec.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /OpenParsec/TouchHandlingView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import ParsecSDK 3 | 4 | extension Unicode.Scalar:Strideable 5 | { 6 | public func distance(to other:Unicode.Scalar) -> Int 7 | { 8 | return Int(other.value - self.value) 9 | } 10 | 11 | public func advanced(by n:Int) -> Unicode.Scalar 12 | { 13 | return Unicode.Scalar(self.value + UInt32(n))! 14 | } 15 | } 16 | 17 | struct TouchHandlingView:UIViewRepresentable 18 | { 19 | let handleTouch:(ParsecMouseButton, CGPoint, UIGestureRecognizer.State) -> Void 20 | let handleTap:(ParsecMouseButton, CGPoint) -> Void 21 | 22 | func makeCoordinator() -> Coordinator 23 | { 24 | Coordinator(self) 25 | } 26 | 27 | func makeUIView(context:Context) -> UIView 28 | { 29 | let view = UIView() 30 | view.isMultipleTouchEnabled = true 31 | view.isUserInteractionEnabled = true 32 | view.becomeFirstResponder() 33 | 34 | let panGestureRecognizer = UIPanGestureRecognizer(target:context.coordinator, action:#selector(Coordinator.handlePanGesture(_:))) 35 | panGestureRecognizer.delegate = context.coordinator 36 | view.addGestureRecognizer(panGestureRecognizer) 37 | 38 | // Add tap gesture recognizer for single-finger touch 39 | let singleFingerTapGestureRecognizer = UITapGestureRecognizer(target:context.coordinator, action:#selector(Coordinator.handleSingleFingerTap(_:))) 40 | singleFingerTapGestureRecognizer.numberOfTouchesRequired = 1 41 | view.addGestureRecognizer(singleFingerTapGestureRecognizer) 42 | 43 | // Add tap gesture recognizer for two-finger touch 44 | let twoFingerTapGestureRecognizer = UITapGestureRecognizer(target:context.coordinator, action:#selector(Coordinator.handleTwoFingerTap(_:))) 45 | twoFingerTapGestureRecognizer.numberOfTouchesRequired = 2 46 | view.addGestureRecognizer(twoFingerTapGestureRecognizer) 47 | 48 | return view 49 | } 50 | 51 | func updateUIView(_ uiView:UIView, context:Context) 52 | { 53 | uiView.becomeFirstResponder() 54 | } 55 | 56 | class Coordinator:NSObject, UIGestureRecognizerDelegate 57 | { 58 | var parent:TouchHandlingView 59 | 60 | init(_ parent:TouchHandlingView) 61 | { 62 | self.parent = parent 63 | super.init() 64 | } 65 | 66 | @objc func handlePanGesture(_ gestureRecognizer:UIPanGestureRecognizer) 67 | { 68 | let location = gestureRecognizer.location(in:gestureRecognizer.view) 69 | parent.handleTouch(ParsecMouseButton(rawValue:1), location, gestureRecognizer.state) 70 | } 71 | 72 | @objc func handleSingleFingerTap(_ gestureRecognizer:UITapGestureRecognizer) 73 | { 74 | let location = gestureRecognizer.location(in:gestureRecognizer.view) 75 | parent.handleTap(ParsecMouseButton(rawValue:1), location) 76 | } 77 | 78 | @objc func handleTwoFingerTap(_ gestureRecognizer:UITapGestureRecognizer) 79 | { 80 | let location = gestureRecognizer.location(in: gestureRecognizer.view) 81 | parent.handleTap(ParsecMouseButton(rawValue:3), location) 82 | } 83 | } 84 | } 85 | 86 | struct TouchHandlingView_Previews:PreviewProvider 87 | { 88 | static var previews:some View 89 | { 90 | TouchHandlingView(handleTouch: 91 | { _, _, _ in 92 | print("Touch event received in preview") 93 | }, handleTap: 94 | { _, _ in 95 | print("Tap event received in preview") 96 | }) 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /OpenParsec/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Xcode - Build 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | inputs: 8 | release__nightly: 9 | description: Create a nightly release 10 | type: boolean 11 | required: false 12 | 13 | jobs: 14 | build: 15 | name: Build using xcodebuild command 16 | runs-on: macos-latest 17 | env: 18 | scheme: OpenParsec 19 | archive_path: archive 20 | outputs: 21 | scheme: ${{ steps.scheme.outputs.scheme }} 22 | archive_path: ${{ env.archive_path }} 23 | 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v3 27 | with: 28 | submodules: recursive 29 | - name: Set Scheme 30 | id: scheme 31 | run: | 32 | if [ $scheme = default ] 33 | then 34 | scheme_list=$(xcodebuild -list -json | tr -d "\n") 35 | scheme=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]") 36 | echo Using default scheme: $scheme 37 | else 38 | echo Using configured scheme: $scheme 39 | fi 40 | echo "scheme=$scheme" >> $GITHUB_OUTPUT 41 | - name: Set filetype_parameter 42 | id: filetype_parameter 43 | run: | 44 | filetype_parameter=`ls -A | grep -i \\.xcworkspace\$ && echo workspace || echo project` 45 | echo "filetype_parameter=$filetype_parameter" >> $GITHUB_OUTPUT 46 | - name: Set file_to_build 47 | id: file_to_build 48 | run: | 49 | file_to_build=`ls -A | grep -i \\.xcworkspace\$ || ls -A | grep -i \\.xcodeproj\$` 50 | file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` 51 | echo "file_to_build=$file_to_build" >> $GITHUB_OUTPUT 52 | - name: Build 53 | env: 54 | scheme: ${{ steps.scheme.outputs.scheme }} 55 | filetype_parameter: ${{ steps.filetype_parameter.outputs.filetype_parameter }} 56 | file_to_build: ${{ steps.file_to_build.outputs.file_to_build }} 57 | run: xcodebuild clean build -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -sdk iphoneos -arch arm64 -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty && exit ${PIPESTATUS[0]} 58 | - name: Analyze 59 | env: 60 | scheme: ${{ steps.scheme.outputs.scheme }} 61 | filetype_parameter: ${{ steps.filetype_parameter.outputs.filetype_parameter }} 62 | file_to_build: ${{ steps.file_to_build.outputs.file_to_build }} 63 | run: xcodebuild analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -sdk iphoneos -arch arm64 -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty && exit ${PIPESTATUS[0]} 64 | - name: Archive 65 | env: 66 | scheme: ${{ steps.scheme.outputs.scheme }} 67 | filetype_parameter: ${{ steps.filetype_parameter.outputs.filetype_parameter }} 68 | file_to_build: ${{ steps.file_to_build.outputs.file_to_build }} 69 | run: xcodebuild archive -archivePath "$archive_path" -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -sdk iphoneos -arch arm64 -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | xcpretty && exit ${PIPESTATUS[0]} 70 | - name: Tar Build Artifact 71 | run: tar -cvf "$archive_path.xcarchive.tar" "$archive_path.xcarchive" 72 | - name: Upload a Build Artifact 73 | uses: actions/upload-artifact@v3 74 | with: 75 | name: ${{ env.archive_path }}.xcarchive.tar 76 | path: ${{ env.archive_path }}.xcarchive.tar 77 | 78 | package: 79 | name: Create fake-signed ipa 80 | runs-on: ubuntu-latest 81 | needs: [build] 82 | env: 83 | scheme: ${{ needs.build.outputs.scheme }} 84 | archive_path: ${{ needs.build.outputs.archive_path }} 85 | outputs: 86 | artifact: ${{ env.scheme }}.ipa 87 | 88 | steps: 89 | - name: Download a Build Artifact 90 | uses: actions/download-artifact@v3 91 | with: 92 | name: ${{ env.archive_path }}.xcarchive.tar 93 | - name: Extract Build Artifact 94 | run: tar -xf "$archive_path.xcarchive.tar" 95 | - name: Install ldid 96 | run: | 97 | if [ `uname -s` = "Linux" ]; then 98 | curl -sSL -o /usr/local/bin/ldid "${{ github.server_url }}/ProcursusTeam/ldid/releases/latest/download/ldid_linux_`uname -m`" 99 | chmod +x /usr/local/bin/ldid 100 | elif [ `uname -s` = "Darwin" ]; then 101 | brew install ldid 102 | else 103 | exit 1 104 | fi 105 | - name: Fakesign 106 | run: | 107 | find "$archive_path.xcarchive/Products/Applications/$scheme.app" -type d -path '*/Frameworks/*.framework' -exec ldid -S \{\} \; 108 | ldid -S "$archive_path.xcarchive/Products/Applications/$scheme.app" 109 | - name: Create IPA 110 | run: | 111 | mv "$archive_path.xcarchive/Products/Applications" Payload 112 | zip -r "$scheme.ipa" "Payload" -x "._*" -x ".DS_Store" -x "__MACOSX" 113 | - name: Upload a Build Artifact 114 | uses: actions/upload-artifact@v3 115 | with: 116 | name: ${{ env.scheme }}.ipa 117 | path: ${{ env.scheme }}.ipa 118 | 119 | release__nightly: 120 | name: Nightly Release 121 | permissions: 122 | contents: write 123 | if: inputs.release__nightly || github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) 124 | runs-on: ubuntu-latest 125 | needs: [package] 126 | concurrency: 127 | group: release__nightly 128 | cancel-in-progress: true 129 | 130 | steps: 131 | - name: Download a Build Artifact 132 | uses: actions/download-artifact@v3 133 | with: 134 | name: ${{ needs.package.outputs.artifact }} 135 | - name: Nightly Release 136 | uses: andelf/nightly-release@v1 137 | env: 138 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 139 | with: 140 | body: | 141 | This is a nightly release [created automatically with GitHub Actions workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}). 142 | files: | 143 | ${{ needs.package.outputs.artifact }} 144 | -------------------------------------------------------------------------------- /OpenParsec/LoginView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import os 3 | 4 | struct LoginView:View 5 | { 6 | var controller:ContentView? 7 | 8 | @State var inputEmail:String = "" 9 | @State var inputPassword:String = "" 10 | @State var inputTFA:String = "" 11 | @State var isTFAOn:Bool = false 12 | @State private var presentTFAAlert = false 13 | @State var isLoading:Bool = false 14 | @State var showAlert:Bool = false 15 | @State var alertText:String = "" 16 | 17 | init(_ controller:ContentView?) 18 | { 19 | self.controller = controller 20 | } 21 | 22 | var body:some View 23 | { 24 | ZStack() 25 | { 26 | // Background 27 | Rectangle() 28 | .fill(Color("BackgroundGray")) 29 | .edgesIgnoringSafeArea(.all) 30 | 31 | // Login controls 32 | VStack(spacing:8) 33 | { 34 | HStack(spacing:2) 35 | { 36 | Image("IconTransparent") 37 | .resizable() 38 | .aspectRatio(contentMode: .fit) 39 | Image("LogoShadow") 40 | .resizable() 41 | .aspectRatio(contentMode: .fit) 42 | .padding([.top, .bottom, .trailing]) 43 | } 44 | .frame(height:80) 45 | TextField("Email", text:$inputEmail) 46 | .padding() 47 | .background(Rectangle().fill(Color("BackgroundField"))) 48 | .cornerRadius(8) 49 | .disableAutocorrection(true) 50 | .autocapitalization(/*@START_MENU_TOKEN@*/.none/*@END_MENU_TOKEN@*/) 51 | .keyboardType(.emailAddress) 52 | .textContentType(.emailAddress) 53 | SecureField("Password", text:$inputPassword) 54 | .padding() 55 | .background(Rectangle().fill(Color("BackgroundField"))) 56 | .cornerRadius(8) 57 | .disableAutocorrection(true) 58 | .autocapitalization(/*@START_MENU_TOKEN@*/.none/*@END_MENU_TOKEN@*/) 59 | .textContentType(.password) 60 | Button(action:{authenticate()}) 61 | { 62 | ZStack() 63 | { 64 | Rectangle() 65 | .fill(Color("AccentColor")) 66 | .cornerRadius(8) 67 | Text("Login") 68 | .foregroundColor(.white) 69 | } 70 | .frame(height:54) 71 | } 72 | } 73 | 74 | .padding() 75 | .frame(maxWidth:400) 76 | .disabled(isLoading) // Disable when loading 77 | 78 | // Loading elements 79 | if isLoading || presentTFAAlert 80 | { 81 | ZStack() 82 | { 83 | Rectangle() // Darken background 84 | .fill(Color.black) 85 | .opacity(0.5) 86 | .edgesIgnoringSafeArea(.all) 87 | VStack() 88 | { 89 | if isLoading 90 | { 91 | ActivityIndicator(isAnimating:$isLoading, style:.large, tint:.white) 92 | .padding() 93 | Text("Loading...") 94 | .multilineTextAlignment(.center) 95 | } 96 | else if presentTFAAlert 97 | { 98 | Text("Please enter your 2FA code from your authenticator app") 99 | .multilineTextAlignment(.center) 100 | SecureField("2FA Code", text:$inputTFA) 101 | .padding() 102 | .background(Rectangle().fill(Color("BackgroundField"))) 103 | .foregroundColor(Color("Foreground")) 104 | .cornerRadius(8) 105 | .disableAutocorrection(true) 106 | .autocapitalization(/*@START_MENU_TOKEN@*/.none/*@END_MENU_TOKEN@*/) 107 | .textContentType(.oneTimeCode) 108 | HStack() 109 | { 110 | Button(action:{presentTFAAlert = false}) 111 | { 112 | ZStack() 113 | { 114 | Rectangle() 115 | .fill(Color("BackgroundButton")) 116 | .cornerRadius(8) 117 | Text("Cancel") 118 | .foregroundColor(Color("Foreground")) 119 | } 120 | .frame(height:54) 121 | } 122 | Button(action:{authenticate(inputTFA)}) 123 | { 124 | ZStack() 125 | { 126 | Rectangle() 127 | .fill(Color("AccentColor")) 128 | .cornerRadius(8) 129 | Text("Enter") 130 | .foregroundColor(.white) 131 | } 132 | .frame(height:54) 133 | } 134 | } 135 | } 136 | } 137 | .padding() 138 | .background(Rectangle().fill(Color("BackgroundPrompt"))) 139 | .cornerRadius(8) 140 | .padding() 141 | } 142 | } 143 | } 144 | .foregroundColor(Color("Foreground")) 145 | .alert(isPresented:$showAlert) 146 | { 147 | Alert(title:Text(alertText)) 148 | } 149 | } 150 | 151 | func saveToKeychain(data: Data, key: String) 152 | { 153 | let query: [String: Any] = [kSecClass as String: kSecClassGenericPassword, kSecAttrAccount as String: key, kSecValueData as String: data] 154 | let status = SecItemAdd(query as CFDictionary, nil) 155 | guard status == errSecSuccess else 156 | { 157 | print("Error saving to Keychain: \(status)") 158 | return 159 | } 160 | print("Data saved to Keychain.") 161 | } 162 | 163 | func authenticate(_ tfa:String? = "") 164 | { 165 | #if DEBUG 166 | if inputEmail == "test@example.com" // skip authentication (DEBUG ONLY) 167 | { 168 | if let c = controller 169 | { 170 | c.setView(.main) 171 | } 172 | return 173 | } 174 | #endif 175 | 176 | withAnimation { isLoading = true } 177 | 178 | let apiURL = URL(string:"https://kessel-api.parsec.app/v1/auth")! 179 | 180 | var request = URLRequest(url:apiURL) 181 | request.httpMethod = "POST"; 182 | request.setValue("application/json", forHTTPHeaderField:"Content-Type") 183 | request.httpBody = try? JSONSerialization.data(withJSONObject: 184 | [ 185 | "email":inputEmail, 186 | "password":inputPassword, 187 | "tfa": tfa 188 | ], options:[]) 189 | 190 | let task = URLSession.shared.dataTask(with:request) 191 | { (data, response, error) in 192 | isLoading = false 193 | if let data = data 194 | { 195 | let statusCode:Int = (response as! HTTPURLResponse).statusCode 196 | let decoder = JSONDecoder() 197 | 198 | print("Login Information:") 199 | print(statusCode) 200 | print(String(data:data, encoding:.utf8)!) 201 | 202 | if statusCode == 201 // 201 Created 203 | { 204 | // store it and recover it from the next app opening, so people won't swear 205 | NetworkHandler.clinfo = try? decoder.decode(ClientInfo.self, from:data) 206 | 207 | saveToKeychain(data: data, key: GLBDataModel.shared.SessionKeyChainKey) 208 | 209 | if let c = controller 210 | { 211 | print("*** Login succeeded! ***") 212 | c.setView(.main) 213 | } 214 | } 215 | else if statusCode >= 400 // 4XX client errors 216 | { 217 | let info:ErrorInfo = try! decoder.decode(ErrorInfo.self, from:data) 218 | 219 | do 220 | { 221 | let json = try JSONSerialization.jsonObject(with: data, options: []) 222 | if let dict = json as? [String: Any], let isTFARequired = dict["tfa_required"] as? Bool { 223 | print("Code output:") 224 | print(dict) 225 | if isTFARequired 226 | { 227 | presentTFAAlert = true 228 | } 229 | else 230 | { 231 | alertText = "Error: \(info)" 232 | showAlert = true 233 | } 234 | } 235 | } 236 | catch 237 | { 238 | print("Error on trying JSON Serialization on error data!") 239 | } 240 | } 241 | } 242 | } 243 | task.resume() 244 | } 245 | } 246 | 247 | struct LoginView_Previews:PreviewProvider 248 | { 249 | static var previews:some View 250 | { 251 | LoginView(nil) 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /OpenParsec/GameController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import GameController 3 | import ParsecSDK 4 | 5 | class GamepadViewController: UIViewController { 6 | 7 | private let maximumControllerCount: Int = 1 8 | private(set) var controllers = Set() 9 | //private var panRecognizer: UIPanGestureRecognizer! 10 | weak var delegate: InputManagerDelegate? 11 | 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | 15 | NotificationCenter.default.addObserver(self, 16 | selector: #selector(self.didConnectController), 17 | name: NSNotification.Name.GCControllerDidConnect, 18 | object: nil) 19 | NotificationCenter.default.addObserver(self, 20 | selector: #selector(self.didDisconnectController), 21 | name: NSNotification.Name.GCControllerDidDisconnect, 22 | object: nil) 23 | 24 | GCController.startWirelessControllerDiscovery {} 25 | self.registerControllerHandler() 26 | } 27 | 28 | func registerControllerHandler() 29 | { 30 | for controller in GCController.controllers() { 31 | controllers.insert(controller) 32 | if controllers.count > 1 { break } 33 | 34 | delegate?.inputManager(self, didConnect: controller) 35 | 36 | controller.extendedGamepad?.dpad.left.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_DPAD_LEFT, pressed) } 37 | controller.extendedGamepad?.dpad.right.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_DPAD_RIGHT, pressed) } 38 | controller.extendedGamepad?.dpad.up.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_DPAD_UP, pressed) } 39 | controller.extendedGamepad?.dpad.down.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_DPAD_DOWN, pressed) } 40 | 41 | // buttonA is labeled "X" (blue) on PS4 controller 42 | controller.extendedGamepad?.buttonA.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_A, pressed) } 43 | // buttonB is labeled "circle" (red) on PS4 controller 44 | controller.extendedGamepad?.buttonB.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_B, pressed) } 45 | // buttonX is labeled "square" (pink) on PS4 controller 46 | controller.extendedGamepad?.buttonX.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_X, pressed) } 47 | // buttonY is labeled "triangle" (green) on PS4 controller 48 | controller.extendedGamepad?.buttonY.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_Y, pressed) } 49 | 50 | // buttonOptions is labeled "SHARE" on PS4 controller 51 | controller.extendedGamepad?.buttonOptions?.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_BACK, pressed) } 52 | // buttonMenu is labeled "OPTIONS" on PS4 controller 53 | controller.extendedGamepad?.buttonMenu.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_START, pressed) } 54 | 55 | controller.extendedGamepad?.leftShoulder.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_LSHOULDER, pressed) } 56 | controller.extendedGamepad?.rightShoulder.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_RSHOULDER, pressed) } 57 | 58 | //controller.extendedGamepad?.leftTrigger.PressedChangedHandler = { (button, value, pressed) in self.triggerButtonChangedHandler(GAMEPAD_AXIS_TRIGGERL, pressed) } 59 | controller.extendedGamepad?.leftTrigger.valueChangedHandler = { (button, value, pressed) in self.triggerChangedHandler(GAMEPAD_AXIS_TRIGGERL, value, pressed) } 60 | //controller.extendedGamepad?.rightTrigger.pressedChangedHandler = { (button, value, pressed) in self.triggerButtonChangedHandler(GAMEPAD_AXIS_TRIGGERR, pressed) } 61 | controller.extendedGamepad?.rightTrigger.valueChangedHandler = { (button, value, pressed) in self.triggerChangedHandler(GAMEPAD_AXIS_TRIGGERR, value, pressed) } 62 | 63 | controller.extendedGamepad?.leftThumbstick.valueChangedHandler = { (button, xvalue, yvalue) in self.thumbLstickChangedHandler(xvalue, yvalue) } 64 | controller.extendedGamepad?.rightThumbstick.valueChangedHandler = { (button, xvalue, yvalue) in self.thumbRstickChangedHandler(xvalue, yvalue) } 65 | 66 | controller.extendedGamepad?.leftThumbstickButton?.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_LSTICK, pressed) } 67 | controller.extendedGamepad?.rightThumbstickButton?.pressedChangedHandler = { (button, value, pressed) in self.buttonChangedHandler(GAMEPAD_BUTTON_RSTICK, pressed) } 68 | } 69 | } 70 | 71 | @objc func didConnectController(_ notification: Notification) { 72 | 73 | //guard controllers.count < maximumControllerCount else { return } 74 | //let controller = notification.object as! GCController 75 | self.registerControllerHandler() 76 | } 77 | 78 | @objc func didDisconnectController(_ notification: Notification) { 79 | 80 | let controller = notification.object as! GCController 81 | controllers.remove(controller) 82 | 83 | delegate?.inputManager(self, didDisconnect: controller) 84 | CParsec.sendGameControllerUnplugMessage(controllerId:1) 85 | } 86 | 87 | func ButtonFloatToParsecInt(_ value: Float) -> Int16 88 | { 89 | let newval: Float = (65535.0*value-1.0)/2.0 90 | return Int16(newval) 91 | } 92 | 93 | func buttonChangedHandler(_ button: ParsecGamepadButton, _ pressed: Bool) { 94 | CParsec.sendGameControllerButtonMessage(controllerId:1, button, pressed:pressed) 95 | } 96 | 97 | //func triggerButtonChangedHandler(_ button: ParsecGamepadAxis, _ pressed: Bool) { 98 | //CParsec.sendGameControllerTriggerButtonMessage(controllerId:1, button, pressed) 99 | //} 100 | 101 | func triggerChangedHandler(_ button:ParsecGamepadAxis, _ value: Float, _ pressed: Bool) { 102 | CParsec.sendGameControllerAxisMessage(controllerId:1, button, ButtonFloatToParsecInt(value)) 103 | } 104 | 105 | 106 | func thumbLstickChangedHandler(_ xvalue: Float, _ yvalue: Float) { 107 | CParsec.sendGameControllerAxisMessage(controllerId:1, GAMEPAD_AXIS_LX, ButtonFloatToParsecInt(xvalue)) 108 | CParsec.sendGameControllerAxisMessage(controllerId:1, GAMEPAD_AXIS_LY, ButtonFloatToParsecInt(-yvalue)) 109 | 110 | } 111 | 112 | func thumbRstickChangedHandler(_ xvalue: Float, _ yvalue: Float) { 113 | CParsec.sendGameControllerAxisMessage(controllerId:1, GAMEPAD_AXIS_RX, ButtonFloatToParsecInt(xvalue)) 114 | CParsec.sendGameControllerAxisMessage(controllerId:1, GAMEPAD_AXIS_RY, ButtonFloatToParsecInt(-yvalue)) 115 | } 116 | 117 | } 118 | 119 | protocol InputManagerDelegate: AnyObject { 120 | func inputManager(_ manager: GamepadViewController, didConnect controller: GCController) 121 | func inputManager(_ manager: GamepadViewController, didDisconnect controller: GCController) 122 | } 123 | -------------------------------------------------------------------------------- /OpenParsec/ParsecView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import ParsecSDK 3 | 4 | struct ParsecView:View 5 | { 6 | var controller:ContentView? 7 | 8 | @State var pollTimer:Timer? 9 | //@State var audioPollTimer:Timer? 10 | 11 | @State var showDCAlert:Bool = false 12 | @State var DCAlertText:String = "Disconnected (reason unknown)" 13 | @State var MetricInfo1:String = "None" 14 | 15 | @State var hideOverlay:Bool = false 16 | @State var showMenu:Bool = false 17 | 18 | @State var muted:Bool = false 19 | @State var preferH265:Bool = true 20 | 21 | init(_ controller:ContentView?) 22 | { 23 | self.controller = controller 24 | } 25 | 26 | var body:some View 27 | { 28 | ZStack() 29 | { 30 | // Stream view controller 31 | //ParsecGLKViewController() 32 | MetalView() 33 | .zIndex(0) 34 | .edgesIgnoringSafeArea(.all) 35 | //.onAppear(perform:startAudioPollTimer) 36 | //.onDisappear(perform:stopAudioPollTimer) 37 | 38 | 39 | // Input handlers 40 | TouchHandlingView(handleTouch:onTouch, handleTap:onTap) 41 | .zIndex(2) 42 | UIViewControllerWrapper(KeyboardViewController()) 43 | .zIndex(-1) 44 | UIViewControllerWrapper(GamepadViewController()) 45 | .zIndex(-2) 46 | 47 | // Overlay elements 48 | if showMenu 49 | { 50 | VStack() 51 | { 52 | Text("\(MetricInfo1)") 53 | .frame(minWidth:200, maxWidth:.infinity, maxHeight:20) 54 | .multilineTextAlignment(.leading) 55 | .font(.system(size: 10)) 56 | .lineSpacing(20) 57 | .lineLimit(nil) 58 | } 59 | .background(Rectangle().fill(Color("BackgroundPrompt").opacity(0.75))) 60 | .foregroundColor(Color("Foreground")) 61 | .frame(maxHeight: .infinity, alignment: .top) 62 | .zIndex(1) 63 | .edgesIgnoringSafeArea(.all) 64 | } 65 | 66 | VStack() 67 | { 68 | if !hideOverlay 69 | { 70 | HStack() 71 | { 72 | Button(action:{ showMenu.toggle() }) 73 | { 74 | Image("IconTransparent") 75 | .resizable() 76 | .aspectRatio(contentMode: .fit) 77 | .frame(width:48, height:48) 78 | .background(Rectangle().fill(Color("BackgroundPrompt").opacity(showMenu ? 0.75 : 1))) 79 | .cornerRadius(8) 80 | .opacity(showMenu ? 1 : 0.25) 81 | } 82 | .padding() 83 | .edgesIgnoringSafeArea(.all) 84 | Spacer() 85 | } 86 | } 87 | if showMenu 88 | { 89 | HStack() 90 | { 91 | VStack(spacing:4) 92 | { 93 | Button(action:disableOverlay) 94 | { 95 | Text("Hide Overlay") 96 | .padding(12) 97 | .frame(maxWidth:.infinity) 98 | .multilineTextAlignment(.center) 99 | } 100 | Button(action:toggleMute) 101 | { 102 | Text("Sound: \(muted ? "OFF" : "ON")") 103 | .padding(12) 104 | .frame(maxWidth:.infinity) 105 | .multilineTextAlignment(.center) 106 | } 107 | Button(action:toggleH265) 108 | { 109 | Text("Decoder: \(preferH265 ? "prefer H265" : "H264")") 110 | .padding(12) 111 | .frame(maxWidth:.infinity) 112 | .multilineTextAlignment(.center) 113 | } 114 | Rectangle() 115 | .fill(Color("Foreground")) 116 | .opacity(0.25) 117 | .frame(height:1) 118 | Button(action:disconnect) 119 | { 120 | Text("Disconnect") 121 | .foregroundColor(.red) 122 | .padding(12) 123 | .frame(maxWidth:.infinity) 124 | .multilineTextAlignment(.center) 125 | } 126 | } 127 | .background(Rectangle().fill(Color("BackgroundPrompt").opacity(0.75))) 128 | .foregroundColor(Color("Foreground")) 129 | .frame(maxWidth:175) 130 | .cornerRadius(8) 131 | .padding(.horizontal) 132 | //.edgesIgnoringSafeArea(.all) 133 | Spacer() 134 | } 135 | } 136 | Spacer() 137 | } 138 | .zIndex(2) 139 | } 140 | .statusBar(hidden:true) 141 | .alert(isPresented:$showDCAlert) 142 | { 143 | Alert(title:Text(DCAlertText), dismissButton:.default(Text("Close"), action:disconnect)) 144 | } 145 | .onAppear(perform:startPollTimer) 146 | .onDisappear(perform:stopPollTimer) 147 | .edgesIgnoringSafeArea(.all) 148 | } 149 | 150 | func FromBuf(ptr: UnsafeMutablePointer, length len: Int) -> String { 151 | // convert the bytes using the UTF8 encoding 152 | //let theString = NSString(bytes: ptr, length: len, encoding: NSUTF8StringEncoding) 153 | let theString = NSString(bytes: ptr, length: len, encoding: String.Encoding.ascii.rawValue) 154 | return theString as! String 155 | } 156 | 157 | func startPollTimer() 158 | { 159 | if pollTimer != nil { return } 160 | 161 | pollTimer = Timer.scheduledTimer(withTimeInterval:1, repeats:true) 162 | { timer in 163 | 164 | if showMenu == false 165 | { 166 | //var pcs = ParsecClientStatus() 167 | let status = CParsec.getStatus() 168 | if status != PARSEC_OK 169 | { 170 | DCAlertText = "Disconnected (code \(status.rawValue))" 171 | showDCAlert = true 172 | timer.invalidate() 173 | } 174 | } 175 | else 176 | { 177 | var pcs = ParsecClientStatus() 178 | let status = CParsec.getStatusEx(pcs:&pcs) 179 | if status != PARSEC_OK 180 | { 181 | DCAlertText = "Disconnected (code \(status.rawValue))" 182 | showDCAlert = true 183 | timer.invalidate() 184 | } 185 | 186 | let str = FromBuf(ptr: &pcs.decoder.0.name.0, length: 16) 187 | MetricInfo1 = "Decode \(String(format:"%.2f", pcs.`self`.metrics.0.decodeLatency))ms Encode \(String(format:"%.2f", pcs.`self`.metrics.0.encodeLatency))ms Network \(String(format:"%.2f", pcs.`self`.metrics.0.networkLatency))ms Bitrate \(String(format:"%.2f", pcs.`self`.metrics.0.bitrate))Mbps \(pcs.decoder.0.h265 ? "H265" : "H264") \(pcs.decoder.0.width)x\(pcs.decoder.0.height) \(pcs.decoder.0.color444 ? "4:4:4" : "4:2:0") \(str)" 188 | } 189 | } 190 | 191 | CParsec.setMuted(muted) 192 | } 193 | 194 | func stopPollTimer() 195 | { 196 | pollTimer!.invalidate() 197 | } 198 | 199 | /*func startAudioPollTimer() 200 | { 201 | if audioPollTimer != nil { return } 202 | 203 | audioPollTimer = Timer.scheduledTimer(withTimeInterval:0.01666667, repeats:true) 204 | { timer in 205 | 206 | CParsec.pollAudio() 207 | } 208 | } 209 | 210 | func stopAudioPollTimer() 211 | { 212 | audioPollTimer!.invalidate() 213 | }*/ 214 | 215 | func disableOverlay() 216 | { 217 | hideOverlay = true 218 | showMenu = false 219 | } 220 | 221 | func toggleMute() 222 | { 223 | muted.toggle() 224 | CParsec.setMuted(muted) 225 | } 226 | 227 | func toggleH265() 228 | { 229 | preferH265.toggle() 230 | CParsec.setH265(preferH265) 231 | } 232 | 233 | func disconnect() 234 | { 235 | CParsec.disconnect() 236 | 237 | if let c = controller 238 | { 239 | c.setView(.main) 240 | } 241 | } 242 | 243 | func onTouch(typeOfTap:ParsecMouseButton, location:CGPoint, state:UIGestureRecognizer.State) 244 | { 245 | // Log the touch location 246 | print("Touch location: \(location)") 247 | print("Touch type: \(typeOfTap)") 248 | print("Touch state: \(state)") 249 | 250 | // print("Touch finger count:" \(pointerId)) 251 | // Convert the touch location to the host's coordinate system 252 | let screenWidth = UIScreen.main.bounds.width 253 | let screenHeight = UIScreen.main.bounds.height 254 | let x = Int32(location.x * CGFloat(CParsec.hostWidth) / screenWidth) 255 | let y = Int32(location.y * CGFloat(CParsec.hostHeight) / screenHeight) 256 | 257 | // Log the screen and host dimensions and calculated coordinates 258 | print("Screen dimensions: \(screenWidth) x \(screenHeight)") 259 | print("Host dimensions: \(CParsec.hostWidth) x \(CParsec.hostHeight)") 260 | print("Calculated coordinates: (\(x), \(y))") 261 | 262 | // Send the mouse input to the host 263 | switch state 264 | { 265 | case .began: 266 | CParsec.sendMouseMessage(typeOfTap, x, y, true) 267 | case .changed: 268 | CParsec.sendMousePosition(x, y) 269 | case .ended, .cancelled: 270 | CParsec.sendMouseMessage(typeOfTap, x, y, false) 271 | default: 272 | break 273 | } 274 | } 275 | 276 | func onTap(typeOfTap:ParsecMouseButton, location:CGPoint) 277 | { 278 | // Log the touch location 279 | print("Touch location: \(location)") 280 | print("Touch type: \(typeOfTap)") 281 | 282 | // print("Touch finger count:" \(pointerId)) 283 | // Convert the touch location to the host's coordinate system 284 | let screenWidth = UIScreen.main.bounds.width 285 | let screenHeight = UIScreen.main.bounds.height 286 | let x = Int32(location.x * CGFloat(CParsec.hostWidth) / screenWidth) 287 | let y = Int32(location.y * CGFloat(CParsec.hostHeight) / screenHeight) 288 | 289 | // Log the screen and host dimensions and calculated coordinates 290 | print("Screen dimensions: \(screenWidth) x \(screenHeight)") 291 | print("Host dimensions: \(CParsec.hostWidth) x \(CParsec.hostHeight)") 292 | print("Calculated coordinates: (\(x), \(y))") 293 | 294 | // Send the mouse input to the host 295 | CParsec.sendMouseMessage(typeOfTap, x, y, true) 296 | CParsec.sendMouseMessage(typeOfTap, x, y, false) 297 | } 298 | 299 | func handleKeyCommand(sender:UIKeyCommand) 300 | { 301 | CParsec.sendKeyboardMessage(sender:sender) 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /OpenParsec/audio.c: -------------------------------------------------------------------------------- 1 | #include "audio.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | #define NUM_AUDIO_BUF 16 8 | #define BUFFER_SIZE 4096 9 | #define SILENT_SIZE 4096 10 | #define FAKE_SIZE 0 11 | #define ALLOW_DELAY 8 12 | #define LOWEST_NUM_BUFFER 3 13 | bool isMuted = false; 14 | bool isStart = false; 15 | int lastbuf = 0; 16 | 17 | unsigned int silence_inqueue = 0; 18 | unsigned int silence_outqueue = 0; 19 | 20 | AudioQueueBufferRef silence_buf; 21 | typedef struct RecycleChain { 22 | AudioQueueBufferRef *curt; 23 | struct RecycleChain *next; 24 | }RecycleChain; 25 | 26 | typedef struct RecycleChainMgr { 27 | RecycleChain *rc; 28 | RecycleChain *first; 29 | RecycleChain *last_to_queue; 30 | //AudioQueueBufferRef *last_use; 31 | }RecycleChainMgr; 32 | 33 | struct audio { 34 | AudioQueueRef q; 35 | AudioQueueBufferRef audio_buf[NUM_AUDIO_BUF]; 36 | char *mem[NUM_AUDIO_BUF * 2]; 37 | int loc[NUM_AUDIO_BUF]; 38 | RecycleChainMgr rcm; 39 | int32_t fail_num; 40 | int32_t in_use; 41 | }; 42 | 43 | static void audio_queue_callback(void *opaque, AudioQueueRef queue, AudioQueueBufferRef buffer) 44 | { 45 | struct audio *ctx = (struct audio *) opaque; 46 | int deltaBuf = 0; 47 | //int silence_use_count = (int)(silence_buf->mUserData); 48 | 49 | if (ctx == NULL) 50 | return; 51 | 52 | if (ctx->in_use > 0) 53 | { 54 | ctx->in_use -= buffer->mAudioDataByteSize; 55 | } 56 | 57 | if(buffer != silence_buf) 58 | { 59 | buffer->mAudioDataByteSize = FAKE_SIZE; 60 | lastbuf = *((int *)(buffer->mUserData)); 61 | } 62 | else 63 | { 64 | //silence_use_count = 0; 65 | //silence_buf->mUserData = (void *)(0); 66 | ++silence_outqueue; 67 | } 68 | 69 | if (isMuted) return; 70 | 71 | deltaBuf = *((int *)((*ctx->rcm.first->curt)->mUserData)); 72 | deltaBuf = deltaBuf - lastbuf - 1; 73 | if (deltaBuf < 0) deltaBuf += NUM_AUDIO_BUF; 74 | 75 | while(ctx->rcm.last_to_queue->next != ctx->rcm.first) 76 | { 77 | AudioQueueEnqueueBuffer(ctx->q, (*(ctx->rcm.last_to_queue->next->curt)), 0, NULL); 78 | ctx->rcm.last_to_queue = ctx->rcm.last_to_queue->next; 79 | } 80 | 81 | if (deltaBuf + silence_inqueue < LOWEST_NUM_BUFFER + silence_outqueue) 82 | { 83 | int numAddBuffer = ((silence_inqueue >= silence_outqueue) ? (LOWEST_NUM_BUFFER - deltaBuf - (int)(silence_inqueue-silence_outqueue)) : (LOWEST_NUM_BUFFER - deltaBuf - (int)((unsigned int)(0xFFFFFFFF)-silence_outqueue + silence_inqueue + 1))); 84 | if (numAddBuffer > LOWEST_NUM_BUFFER) 85 | { 86 | numAddBuffer = LOWEST_NUM_BUFFER - deltaBuf; 87 | } 88 | else 89 | { 90 | silence_inqueue = silence_outqueue = 0; 91 | } 92 | for (int i=0; iq, silence_buf, 0, NULL); 95 | } 96 | if (numAddBuffer > 0) silence_inqueue += numAddBuffer; 97 | } 98 | 99 | //RecycleChain *tmp = ctx->rcm.last_to_queue->next; 100 | //if ( /*(*tmp->curt)->mAudioDataByteSize != FAKE_SIZE &&*/ tmp != ctx->rcm.first) 101 | //if (deltaBuf > ALLOW_DELAY) 102 | //{ 103 | // //while(ctx->rcm.last_to_queue->next != ctx->rcm.first) 104 | // for (int i = 0; i < deltaBuf - ALLOW_DELAY + 1; ++i) 105 | // { 106 | // AudioQueueEnqueueBuffer(ctx->q, (*(ctx->rcm.last_to_queue->next->curt)), 0, NULL); 107 | // ctx->rcm.last_to_queue = ctx->rcm.last_to_queue->next; 108 | // } 109 | //} 110 | //else 111 | //{ 112 | // int silence_use_count = (int)(silence_buf->mUserData); 113 | // if ( deltaBuf > 0 ) 114 | // { 115 | // AudioQueueEnqueueBuffer(ctx->q, (*(ctx->rcm.last_to_queue->next->curt)), 0, NULL); 116 | // ctx->rcm.last_to_queue = ctx->rcm.last_to_queue->next; 117 | // } 118 | // else if (silence_use_count == 0) 119 | // { 120 | // AudioQueueEnqueueBuffer(ctx->q, silence_buf, 0, NULL); 121 | // //int tmp = (int)(silence_buf->mUserData); 122 | // //++tmp; 123 | // silence_buf->mUserData = (void *)(1); 124 | // } 125 | //} 126 | //else //if ((*ctx->rcm.last_use)->mAudioDataByteSize == FAKE_SIZE) 127 | //{ 128 | // AudioQueueEnqueueBuffer(ctx->q, silence_buf, 0, NULL); 129 | // AudioQueueEnqueueBuffer(ctx->q, silence_buf, 0, NULL); 130 | // AudioQueueEnqueueBuffer(ctx->q, silence_buf, 0, NULL); 131 | // /*AudioQueueStop(ctx->q, true); 132 | // isStart = false; 133 | // ctx->in_use = 0;*/ 134 | //} 135 | 136 | /*if(ctx->rcm.last_to_queue->curt == &buffer && ctx->rcm.last_to_queue->next == ctx->rcm.first) // && (*ctx->rcm.first->curt)->mAudioDataByteSize == FAKE_SIZE) 137 | { 138 | AudioQueueStop(ctx->q, true); 139 | isStart = false; 140 | ctx->in_use = 0; 141 | }*/ 142 | 143 | 144 | //ctx->rcm.last->curt = &buffer; 145 | 146 | 147 | 148 | /*if (ctx->in_use == 0) 149 | AudioQueueStop(ctx->q, true);*/ 150 | } 151 | 152 | void audio_init(struct audio **ctx_out) 153 | { 154 | struct audio *ctx = *ctx_out = calloc(1, sizeof(struct audio)); 155 | RecycleChain *rcTraverse = NULL; 156 | AudioStreamBasicDescription format; 157 | format.mSampleRate = 48000; 158 | format.mFormatID = kAudioFormatLinearPCM; 159 | format.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; 160 | format.mFramesPerPacket = 1; 161 | format.mChannelsPerFrame = 2; 162 | format.mBitsPerChannel = 16; 163 | format.mBytesPerPacket = 4; 164 | format.mBytesPerFrame = 4; 165 | 166 | // Create and audio playback queue 167 | AudioQueueNewOutput(&format, audio_queue_callback, (void *) ctx, nil, nil, 0, &ctx->q); 168 | 169 | //ctx->rcm.first = ctx->audio_buf[0]; 170 | //ctx->rcm.first = ctx->audio_buf[NUM_AUDIO_BUF-1]; 171 | ctx->rcm.rc = (RecycleChain *)(&ctx->mem[0]); 172 | ctx->rcm.first = ctx->rcm.rc; 173 | rcTraverse = ctx->rcm.rc; 174 | // Create buffers for the queue 175 | for (int32_t x = 0; x < NUM_AUDIO_BUF; x++) { 176 | AudioQueueAllocateBuffer(ctx->q, BUFFER_SIZE, &ctx->audio_buf[x]); 177 | ctx->audio_buf[x]->mAudioDataByteSize = FAKE_SIZE; 178 | ctx->loc[x] = x; 179 | ctx->audio_buf[x]->mUserData = (void *)(&ctx->loc[x]); 180 | rcTraverse->curt = &ctx->audio_buf[x]; 181 | if( x != NUM_AUDIO_BUF - 1) 182 | { 183 | rcTraverse->next = (RecycleChain *)(&ctx->mem[2*(x+1)]); 184 | rcTraverse = rcTraverse->next; 185 | } 186 | else 187 | { 188 | //ctx->rcm.first = rcTraverse; 189 | rcTraverse->next = ctx->rcm.rc; 190 | } 191 | } 192 | isStart = false; 193 | ctx->fail_num = 0; 194 | ctx->in_use = 0; 195 | 196 | silence_inqueue = silence_outqueue = 0; 197 | char silence[SILENT_SIZE] = {0}; 198 | AudioQueueAllocateBuffer(ctx->q, SILENT_SIZE, &silence_buf); 199 | memcpy(silence_buf->mAudioData, &silence[0], SILENT_SIZE); 200 | silence_buf->mAudioDataByteSize = SILENT_SIZE; 201 | silence_buf->mUserData = NULL; 202 | } 203 | 204 | void audio_destroy(struct audio **ctx_out) 205 | { 206 | if (!ctx_out || !*ctx_out) 207 | return; 208 | 209 | struct audio *ctx = *ctx_out; 210 | //AudioQueueStop(ctx->q, true); 211 | 212 | for (int32_t x = 0; x < NUM_AUDIO_BUF; x++) { 213 | if (ctx->audio_buf[x]) 214 | AudioQueueFreeBuffer(ctx->q, ctx->audio_buf[x]); 215 | } 216 | 217 | if (ctx->q) 218 | AudioQueueDispose(ctx->q, true); 219 | 220 | free(ctx); 221 | *ctx_out = NULL; 222 | isStart = false; 223 | AudioQueueFreeBuffer(ctx->q, silence_buf); 224 | silence_inqueue = silence_outqueue = 0; 225 | } 226 | 227 | void audio_clear(struct audio **ctx_out) 228 | { 229 | if (!ctx_out || !*ctx_out) 230 | return; 231 | 232 | //RecycleChain *rcTraverse = NULL; 233 | struct audio *ctx = *ctx_out; 234 | if (ctx->q) 235 | AudioQueueStop(ctx->q, true); 236 | 237 | //rcTraverse = ctx->rcm.rc; 238 | for (int32_t x = 0; x < NUM_AUDIO_BUF; x++) { 239 | ctx->audio_buf[x]->mAudioDataByteSize = FAKE_SIZE; 240 | /*rcTraverse->curt = &ctx->audio_buf[x]; 241 | if( x != NUM_AUDIO_BUF - 1) 242 | { 243 | rcTraverse->next = (RecycleChain *)(&ctx->mem[2*(x+1)]); 244 | rcTraverse = rcTraverse->next; 245 | } 246 | else 247 | { 248 | ctx->rcm.first = rcTraverse; 249 | rcTraverse->next = NULL; 250 | }*/ 251 | } 252 | isStart = false; 253 | ctx->in_use = 0; 254 | ctx->fail_num = 0; 255 | silence_inqueue = silence_outqueue = 0; 256 | } 257 | 258 | void audio_cb(const int16_t *pcm, uint32_t frames, void *opaque) 259 | { 260 | if ( frames == 0 || opaque == NULL || isMuted ) 261 | return; 262 | 263 | struct audio *ctx = (struct audio *) opaque; 264 | AudioQueueBufferRef *find_idle = NULL; 265 | 266 | find_idle = ctx->rcm.first->curt; 267 | if ((*find_idle)->mAudioDataByteSize != FAKE_SIZE) 268 | { 269 | ++ctx->fail_num; 270 | if(ctx->fail_num > 10) audio_clear(&ctx); 271 | return; 272 | } 273 | 274 | memcpy((*find_idle)->mAudioData, pcm, frames * 4); 275 | (*find_idle)->mAudioDataByteSize = frames * 4; 276 | 277 | if(!isStart) 278 | { 279 | ctx->rcm.last_to_queue = ctx->rcm.first; 280 | AudioQueueEnqueueBuffer(ctx->q, (*find_idle), 0, NULL); 281 | } 282 | 283 | ctx->fail_num = 0; 284 | ctx->rcm.first = ctx->rcm.first->next; 285 | //ctx->rcm.last_use = find_idle; 286 | 287 | ctx->in_use += frames; 288 | //if (!isStart && (ctx->in_use > 1600)) 289 | if (ctx->in_use > 1000) 290 | { 291 | AudioQueueStart(ctx->q, NULL); 292 | isStart = true; 293 | } 294 | } 295 | 296 | void audio_mute(bool muted, const void *opaque) 297 | { 298 | if (isMuted == muted) return; 299 | isMuted = muted; 300 | isStart = false; 301 | if (opaque == NULL) return; 302 | 303 | struct audio *ctx = (struct audio *) opaque; 304 | if(ctx->q == NULL) return; 305 | if(isMuted) 306 | { 307 | AudioQueuePause(ctx->q); 308 | audio_clear(&ctx); 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /OpenParsec/CParsec.swift: -------------------------------------------------------------------------------- 1 | import ParsecSDK 2 | import UIKit 3 | import MetalKit 4 | 5 | enum RendererType 6 | { 7 | case opengl 8 | case metal 9 | } 10 | 11 | class CParsec 12 | { 13 | private static var _initted:Bool = false 14 | 15 | private static var _parsec:OpaquePointer! 16 | private static var _audio:OpaquePointer! 17 | private static let _audioPtr:UnsafeRawPointer = UnsafeRawPointer(_audio) 18 | 19 | public static var hostWidth:Float = 0 20 | public static var hostHeight:Float = 0 21 | 22 | static let PARSEC_VER:UInt32 = UInt32((PARSEC_VER_MAJOR << 16) | PARSEC_VER_MINOR) 23 | 24 | static func initialize() 25 | { 26 | if _initted { return } 27 | 28 | print("Parsec SDK Version: " + String(CParsec.PARSEC_VER)) 29 | 30 | ParsecSetLogCallback( 31 | { (level, msg, opaque) in 32 | print("[\(level == LOG_DEBUG ? "D" : "I")] \(String(cString:msg!))") 33 | }, nil) 34 | 35 | audio_init(&_audio) 36 | 37 | ParsecInit(PARSEC_VER, nil, nil, &_parsec) 38 | 39 | _initted = true 40 | } 41 | 42 | static func destroy() 43 | { 44 | if !_initted { return } 45 | 46 | ParsecDestroy(_parsec) 47 | audio_destroy(&_audio) 48 | } 49 | 50 | static func connect(_ peerID:String) -> ParsecStatus 51 | { 52 | var parsecClientCfg = ParsecClientConfig() 53 | parsecClientCfg.video.0.decoderIndex = 1 54 | parsecClientCfg.video.0.resolutionX = 0 55 | parsecClientCfg.video.0.resolutionY = 0 56 | parsecClientCfg.video.0.decoderCompatibility = false 57 | parsecClientCfg.video.0.decoderH265 = true 58 | 59 | parsecClientCfg.video.1.decoderIndex = 1 60 | parsecClientCfg.video.1.resolutionX = 0 61 | parsecClientCfg.video.1.resolutionY = 0 62 | parsecClientCfg.video.1.decoderCompatibility = false 63 | parsecClientCfg.video.1.decoderH265 = true 64 | 65 | parsecClientCfg.mediaContainer = 0 66 | parsecClientCfg.protocol = 1 67 | //parsecClientCfg.secret = "" 68 | parsecClientCfg.pngCursor = false 69 | return ParsecClientConnect(_parsec, &parsecClientCfg, NetworkHandler.clinfo?.session_id, peerID) 70 | } 71 | 72 | static func disconnect() 73 | { 74 | audio_clear(&_audio) 75 | ParsecClientDisconnect(_parsec) 76 | } 77 | 78 | static func getStatus() -> ParsecStatus 79 | { 80 | return ParsecClientGetStatus(_parsec, nil) 81 | } 82 | 83 | static func getStatusEx(pcs: inout ParsecClientStatus) -> ParsecStatus 84 | { 85 | return ParsecClientGetStatus(_parsec, &pcs) 86 | } 87 | 88 | static func setFrame(_ width:CGFloat, _ height:CGFloat, _ scale:CGFloat) 89 | { 90 | ParsecClientSetDimensions(_parsec, UInt8(DEFAULT_STREAM), UInt32(width), UInt32(height), Float(scale)) 91 | 92 | hostWidth = Float(width) 93 | hostHeight = Float(height) 94 | } 95 | 96 | static func renderFrame(_ type:RendererType, cq: inout MTLCommandQueue, texturePtr: inout UnsafeMutableRawPointer?, timeout:UInt32 = 16) // timeout in ms, 16 == 60 FPS, 8 == 120 FPS 97 | { 98 | switch type 99 | { 100 | case .opengl: 101 | ParsecClientGLRenderFrame(_parsec, UInt8(DEFAULT_STREAM), nil, nil, timeout) 102 | case .metal: 103 | ParsecClientMetalRenderFrame(_parsec, UInt8(DEFAULT_STREAM), &cq, &texturePtr, nil, nil, timeout) 104 | } 105 | } 106 | 107 | static func pollAudio(timeout:UInt32 = 16) // timeout in ms, 16 == 60 FPS, 8 == 120 FPS 108 | { 109 | ParsecClientPollAudio(_parsec, audio_cb, timeout, _audioPtr) 110 | } 111 | 112 | static func setMuted(_ muted:Bool) 113 | { 114 | audio_mute(muted, _audioPtr) 115 | } 116 | 117 | static func setH265(_ preferH265:Bool) 118 | { 119 | var parsecClientCfg = ParsecClientConfig() 120 | parsecClientCfg.video.0.decoderIndex = 1 121 | parsecClientCfg.video.0.resolutionX = 0 122 | parsecClientCfg.video.0.resolutionY = 0 123 | parsecClientCfg.video.0.decoderCompatibility = false 124 | parsecClientCfg.video.0.decoderH265 = preferH265 125 | 126 | parsecClientCfg.video.1.decoderIndex = 1 127 | parsecClientCfg.video.1.resolutionX = 0 128 | parsecClientCfg.video.1.resolutionY = 0 129 | parsecClientCfg.video.1.decoderCompatibility = false 130 | parsecClientCfg.video.1.decoderH265 = preferH265 131 | 132 | parsecClientCfg.mediaContainer = 0 133 | parsecClientCfg.protocol = 1 134 | //parsecClientCfg.secret = "" 135 | parsecClientCfg.pngCursor = false 136 | ParsecClientSetConfig(_parsec, &parsecClientCfg); 137 | } 138 | 139 | static func sendMouseMessage(_ button:ParsecMouseButton, _ x:Int32, _ y:Int32, _ pressed:Bool) 140 | { 141 | // Send the mouse position 142 | sendMousePosition(x, y) 143 | 144 | // Send the mouse button state 145 | var buttonMessage = ParsecMessage() 146 | buttonMessage.type = MESSAGE_MOUSE_BUTTON 147 | buttonMessage.mouseButton.button = button 148 | buttonMessage.mouseButton.pressed = pressed 149 | ParsecClientSendMessage(_parsec, &buttonMessage) 150 | } 151 | 152 | static func sendMousePosition(_ x:Int32, _ y:Int32) 153 | { 154 | var motionMessage = ParsecMessage() 155 | motionMessage.type = MESSAGE_MOUSE_MOTION 156 | motionMessage.mouseMotion.x = x 157 | motionMessage.mouseMotion.y = y 158 | ParsecClientSendMessage(_parsec, &motionMessage) 159 | } 160 | 161 | static func sendKeyboardMessage(sender:UIKeyCommand) 162 | { 163 | var key = sender.input ?? "" 164 | 165 | switch sender.modifierFlags.rawValue 166 | { 167 | case 131072: 168 | key = "SHIFT" 169 | break 170 | case 262144: 171 | key = "CONTROL" 172 | break 173 | 174 | default: 175 | break 176 | } 177 | 178 | print("Keyboard Message: \(key)") 179 | print("KeyboardViewController keyboard modifier info \(sender.modifierFlags.rawValue)") 180 | 181 | var keyboardMessagePress = ParsecMessage() 182 | keyboardMessagePress.type = MESSAGE_KEYBOARD 183 | keyboardMessagePress.keyboard.code = parsecKeyCodeTranslator(key) 184 | keyboardMessagePress.keyboard.pressed = true 185 | ParsecClientSendMessage(_parsec, &keyboardMessagePress) 186 | 187 | var keyboardMessageRelease = ParsecMessage() 188 | keyboardMessageRelease.type = MESSAGE_KEYBOARD 189 | keyboardMessageRelease.keyboard.code = parsecKeyCodeTranslator(key) 190 | keyboardMessageRelease.keyboard.pressed = false 191 | ParsecClientSendMessage(_parsec, &keyboardMessageRelease) 192 | } 193 | 194 | static func parsecKeyCodeTranslator(_ str:String) -> ParsecKeycode 195 | { 196 | switch str 197 | { 198 | case "A": return ParsecKeycode(4) 199 | case "B": return ParsecKeycode(5) 200 | case "C": return ParsecKeycode(6) 201 | case "D": return ParsecKeycode(7) 202 | case "E": return ParsecKeycode(8) 203 | case "F": return ParsecKeycode(9) 204 | case "G": return ParsecKeycode(10) 205 | case "H": return ParsecKeycode(11) 206 | case "I": return ParsecKeycode(12) 207 | case "J": return ParsecKeycode(13) 208 | case "K": return ParsecKeycode(14) 209 | case "L": return ParsecKeycode(15) 210 | case "M": return ParsecKeycode(16) 211 | case "N": return ParsecKeycode(17) 212 | case "O": return ParsecKeycode(18) 213 | case "P": return ParsecKeycode(19) 214 | case "Q": return ParsecKeycode(20) 215 | case "R": return ParsecKeycode(21) 216 | case "S": return ParsecKeycode(22) 217 | case "T": return ParsecKeycode(23) 218 | case "U": return ParsecKeycode(24) 219 | case "V": return ParsecKeycode(25) 220 | case "W": return ParsecKeycode(26) 221 | case "X": return ParsecKeycode(27) 222 | case "Y": return ParsecKeycode(28) 223 | case "Z": return ParsecKeycode(29) 224 | case "1": return ParsecKeycode(30) 225 | case "2": return ParsecKeycode(31) 226 | case "3": return ParsecKeycode(32) 227 | case "4": return ParsecKeycode(33) 228 | case "5": return ParsecKeycode(34) 229 | case "6": return ParsecKeycode(35) 230 | case "7": return ParsecKeycode(36) 231 | case "8": return ParsecKeycode(37) 232 | case "9": return ParsecKeycode(38) 233 | case "0": return ParsecKeycode(39) 234 | case "ENTER": return ParsecKeycode(40) 235 | case "UIKeyInputEscape": return ParsecKeycode(41) // ESCAPE with re-factored 236 | case "BACKSPACE": return ParsecKeycode(42) 237 | case "TAB": return ParsecKeycode(43) 238 | case "SPACE": return ParsecKeycode(44) 239 | case "MINUS": return ParsecKeycode(45) 240 | case "EQUALS": return ParsecKeycode(46) 241 | case "LBRACKET": return ParsecKeycode(47) 242 | case "RBRACKET": return ParsecKeycode(48) 243 | case "BACKSLASH": return ParsecKeycode(49) 244 | case "SEMICOLON": return ParsecKeycode(51) 245 | case "APOSTROPHE": return ParsecKeycode(52) 246 | case "BACKTICK": return ParsecKeycode(53) 247 | case "COMMA": return ParsecKeycode(54) 248 | case "PERIOD": return ParsecKeycode(55) 249 | case "SLASH": return ParsecKeycode(56) 250 | case "CAPSLOCK": return ParsecKeycode(57) 251 | case "F1": return ParsecKeycode(58) 252 | case "F2": return ParsecKeycode(59) 253 | case "F3": return ParsecKeycode(60) 254 | case "F4": return ParsecKeycode(61) 255 | case "F5": return ParsecKeycode(62) 256 | case "F6": return ParsecKeycode(63) 257 | case "F7": return ParsecKeycode(64) 258 | case "F8": return ParsecKeycode(65) 259 | case "F9": return ParsecKeycode(66) 260 | case "F10": return ParsecKeycode(67) 261 | case "F11": return ParsecKeycode(68) 262 | case "F12": return ParsecKeycode(69) 263 | case "PRINTSCREEN": return ParsecKeycode(70) 264 | case "SCROLLLOCK": return ParsecKeycode(71) 265 | case "PAUSE": return ParsecKeycode(72) 266 | case "INSERT": return ParsecKeycode(73) 267 | case "HOME": return ParsecKeycode(74) 268 | case "PAGEUP": return ParsecKeycode(75) 269 | case "DELETE": return ParsecKeycode(76) 270 | case "END": return ParsecKeycode(77) 271 | case "PAGEDOWN": return ParsecKeycode(78) 272 | case "RIGHT": return ParsecKeycode(79) 273 | case "LEFT": return ParsecKeycode(80) 274 | case "DOWN": return ParsecKeycode(81) 275 | case "UP": return ParsecKeycode(82) 276 | case "NUMLOCK": return ParsecKeycode(83) 277 | case "KP_DIVIDE": return ParsecKeycode(84) 278 | case "KP_MULTIPLY": return ParsecKeycode(85) 279 | case "KP_MINUS": return ParsecKeycode(86) 280 | case "KP_PLUS": return ParsecKeycode(87) 281 | case "KP_ENTER": return ParsecKeycode(88) 282 | case "KP_1": return ParsecKeycode(89) 283 | case "KP_2": return ParsecKeycode(90) 284 | case "KP_3": return ParsecKeycode(91) 285 | case "KP_4": return ParsecKeycode(92) 286 | case "KP_5": return ParsecKeycode(93) 287 | case "KP_6": return ParsecKeycode(94) 288 | case "KP_7": return ParsecKeycode(95) 289 | case "KP_8": return ParsecKeycode(96) 290 | case "KP_9": return ParsecKeycode(97) 291 | case "KP_0": return ParsecKeycode(98) 292 | case "KP_PERIOD": return ParsecKeycode(99) 293 | case "APPLICATION": return ParsecKeycode(101) 294 | case "F13": return ParsecKeycode(104) 295 | case "F14": return ParsecKeycode(105) 296 | case "F15": return ParsecKeycode(106) 297 | case "F16": return ParsecKeycode(107) 298 | case "F17": return ParsecKeycode(108) 299 | case "F18": return ParsecKeycode(109) 300 | case "F19": return ParsecKeycode(110) 301 | case "MENU": return ParsecKeycode(118) 302 | case "MUTE": return ParsecKeycode(127) 303 | case "VOLUMEUP": return ParsecKeycode(128) 304 | case "VOLUMEDOWN": return ParsecKeycode(129) 305 | case "CONTROL": return ParsecKeycode(224) 306 | case "SHIFT": return ParsecKeycode(225) 307 | case "LALT": return ParsecKeycode(226) 308 | case "LGUI": return ParsecKeycode(227) 309 | case "RCTRL": return ParsecKeycode(228) 310 | case "RSHIFT": return ParsecKeycode(229) 311 | case "RALT": return ParsecKeycode(230) 312 | case "RGUI": return ParsecKeycode(231) 313 | case "AUDIONEXT": return ParsecKeycode(258) 314 | case "AUDIOPREV": return ParsecKeycode(259) 315 | case "AUDIOSTOP": return ParsecKeycode(260) 316 | case "AUDIOPLAY": return ParsecKeycode(261) 317 | case "AUDIOMUTE": return ParsecKeycode(262) 318 | case "MEDIASELECT": return ParsecKeycode(263) 319 | 320 | default: return ParsecKeycode(UInt32(0)) 321 | } 322 | } 323 | 324 | static func sendGameControllerButtonMessage(controllerId:UInt32, _ button:ParsecGamepadButton, pressed:Bool) 325 | { 326 | var pmsg = ParsecMessage() 327 | pmsg.type = MESSAGE_GAMEPAD_BUTTON 328 | pmsg.gamepadButton.id = controllerId 329 | pmsg.gamepadButton.button = button 330 | pmsg.gamepadButton.pressed = pressed 331 | ParsecClientSendMessage(_parsec, &pmsg) 332 | } 333 | 334 | /*static func sendGameControllerTriggerButtonMessage(controllerId:UInt32, _ button:ParsecGamepadAxis, pressed:Bool) 335 | { 336 | var pmsg = ParsecMessage() 337 | pmsg.type = MESSAGE_GAMEPAD_AXIS 338 | pmsg.gamepadAxis.id = controllerId 339 | pmsg.gamepadAxis.button = button 340 | pmsg.gamepadAxis.pressed = pressed 341 | ParsecClientSendMessage(_parsec, &pmsg) 342 | }*/ 343 | 344 | static func sendGameControllerAxisMessage(controllerId:UInt32, _ button:ParsecGamepadAxis, _ value: Int16) 345 | { 346 | var pmsg = ParsecMessage() 347 | pmsg.type = MESSAGE_GAMEPAD_AXIS 348 | pmsg.gamepadAxis.id = controllerId 349 | pmsg.gamepadAxis.axis = button 350 | pmsg.gamepadAxis.value = value 351 | ParsecClientSendMessage(_parsec, &pmsg) 352 | } 353 | 354 | static func sendGameControllerUnplugMessage(controllerId:UInt32) 355 | { 356 | var pmsg = ParsecMessage() 357 | pmsg.type = MESSAGE_GAMEPAD_UNPLUG; 358 | pmsg.gamepadUnplug.id = controllerId; 359 | ParsecClientSendMessage(_parsec, &pmsg) 360 | } 361 | } 362 | -------------------------------------------------------------------------------- /OpenParsec/MainView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import ParsecSDK 3 | 4 | struct MainView:View 5 | { 6 | var controller:ContentView? 7 | 8 | @State private var page:Page = .hosts 9 | 10 | // Host page vars 11 | @State var hostCountStr:String = "0 hosts" 12 | @State var refreshTime:String = "Last refreshed at 1/1/1970 12:00 AM" 13 | 14 | @State var hosts:Array = [] 15 | 16 | // Friend page vars 17 | @State var friendCountStr:String = "0 friends" 18 | 19 | @State var userInfo:IdentifiableUserInfo? = nil 20 | @State var friends:Array = [] 21 | 22 | // Global vars 23 | @State var showBaseAlert:Bool = false 24 | @State var baseAlertText:String = "" 25 | 26 | @State var showLogoutAlert:Bool = false 27 | 28 | @State var isConnecting:Bool = false 29 | @State var connectingToName:String = "" 30 | @State var pollTimer:Timer? 31 | 32 | @State var isRefreshing:Bool = false 33 | 34 | @State var inSettings:Bool = false 35 | 36 | var busy:Bool 37 | { 38 | isConnecting || isRefreshing || inSettings 39 | } 40 | 41 | init(_ controller:ContentView?) 42 | { 43 | self.controller = controller 44 | } 45 | 46 | var body:some View 47 | { 48 | ZStack() 49 | { 50 | // Background 51 | Rectangle() 52 | .fill(Color("BackgroundTab")) 53 | .edgesIgnoringSafeArea(.all) 54 | Rectangle() 55 | .fill(Color("BackgroundGray")) 56 | .padding(.vertical, 52) 57 | 58 | // Main controls 59 | VStack() 60 | { 61 | // Navigation controls 62 | HStack() 63 | { 64 | Button(action:{ showLogoutAlert = true }, label:{ Image("SymbolExit").scaleEffect(x:-1) }) 65 | .padding() 66 | .alert(isPresented:$showLogoutAlert) 67 | { 68 | Alert(title:Text("Are you sure you want to logout?"), primaryButton:.destructive(Text("Logout"), action:logout), secondaryButton:.cancel(Text("Cancel"))) 69 | } 70 | Spacer() 71 | HStack() 72 | { 73 | if page == .hosts 74 | { 75 | // Probably not the best solution for equal spacing, but I don't know how to do math properly in SwiftUI. Please send me an issue if you have a better solution. 76 | Image(systemName:"arrow.clockwise") 77 | .padding(4) 78 | .opacity(0) 79 | 80 | Text(hostCountStr) 81 | .multilineTextAlignment(.center) 82 | .foregroundColor(Color("Foreground")) 83 | .font(.system(size:20, weight:.medium)) 84 | Button(action:refreshHosts, label:{ Image(systemName:"arrow.clockwise") }) 85 | .padding(4) 86 | } 87 | else if page == .friends 88 | { 89 | Text(friendCountStr) 90 | .multilineTextAlignment(.center) 91 | .foregroundColor(Color("Foreground")) 92 | .font(.system(size:20, weight:.medium)) 93 | } 94 | } 95 | Spacer() 96 | Button(action:{ inSettings = true }, label:{ Image(systemName:"gear") }) 97 | .padding() 98 | } 99 | .foregroundColor(Color("AccentColor")) 100 | .background(Color("BackgroundTab") 101 | .frame(height:52) 102 | .shadow(color:Color("Shading"), radius:4, y:6) 103 | .mask(Rectangle().frame(height:80).offset(y:50)) 104 | ) 105 | .zIndex(1) 106 | 107 | ZStack() 108 | { 109 | // Hosts page 110 | ScrollView(.vertical) 111 | { 112 | VStack() 113 | { 114 | Text(refreshTime) 115 | .multilineTextAlignment(.center) 116 | .opacity(0.5) 117 | ForEach(hosts) 118 | { i in 119 | ZStack() 120 | { 121 | VStack() 122 | { 123 | URLImage(url:URL(string:"https://parsecusercontent.com/cors-resize-image/w=64,h=64,fit=crop,background=white,q=90,f=jpeg/avatars/\(String(i.user.id))/avatar"), 124 | output: 125 | { 126 | $0 127 | .resizable() 128 | .aspectRatio(contentMode:.fit) 129 | .frame(width:64, height:64) 130 | .cornerRadius(8) 131 | }, 132 | placeholder: 133 | { 134 | Image("IconTransparent") 135 | .resizable() 136 | .aspectRatio(contentMode:.fit) 137 | .frame(width:64, height:64) 138 | .background(Rectangle().fill(Color("BackgroundPrompt"))) 139 | .cornerRadius(8) 140 | }) 141 | Text(i.hostname) 142 | .font(.system(size:20, weight:.medium)) 143 | .multilineTextAlignment(.center) 144 | Text("\(i.user.name)#\(String(i.user.id))") 145 | .font(.system(size:16, weight:.medium)) 146 | .multilineTextAlignment(.center) 147 | .opacity(0.5) 148 | Button(action:{ connectTo(i) }) 149 | { 150 | ZStack() 151 | { 152 | Rectangle() 153 | .fill(Color("AccentColor")) 154 | .cornerRadius(8) 155 | Text("Connect") 156 | .foregroundColor(.white) 157 | .padding(8) 158 | } 159 | .frame(maxWidth:100) 160 | } 161 | } 162 | 163 | if i.connections > 0 164 | { 165 | VStack() 166 | { 167 | HStack() 168 | { 169 | Image(systemName:"person.fill") 170 | Text(String(i.connections)) 171 | .font(.system(size:16, weight:.medium)) 172 | Spacer() 173 | } 174 | Spacer() 175 | } 176 | } 177 | } 178 | .padding() 179 | .frame(maxWidth:400) 180 | .background(Rectangle().fill(Color("BackgroundCard"))) 181 | .cornerRadius(8) 182 | } 183 | } 184 | .padding() 185 | } 186 | .zIndex(page == .hosts ? 0 : -1) 187 | .disabled(page != .hosts) 188 | .opacity(page == .hosts ? 1 : 0) 189 | 190 | // Friends page 191 | ScrollView(.vertical) 192 | { 193 | VStack() 194 | { 195 | if let user = userInfo 196 | { 197 | Text("You") 198 | .multilineTextAlignment(.center) 199 | .opacity(0.5) 200 | HStack() 201 | { 202 | URLImage(url:URL(string:"https://parsecusercontent.com/cors-resize-image/w=48,h=48,fit=crop,background=white,q=90,f=jpeg/avatars/\(String(user.id))/avatar"), 203 | output: 204 | { 205 | $0 206 | .resizable() 207 | .aspectRatio(contentMode:.fit) 208 | .frame(width:48, height:48) 209 | .cornerRadius(6) 210 | }, 211 | placeholder: 212 | { 213 | Image("IconTransparent") 214 | .resizable() 215 | .aspectRatio(contentMode:.fit) 216 | .frame(width:48, height:48) 217 | .background(Rectangle().fill(Color("BackgroundPrompt"))) 218 | .cornerRadius(6) 219 | }) 220 | Text("\(user.username)#\(String(user.id))") 221 | .font(.system(size:16, weight:.medium)) 222 | .multilineTextAlignment(.center) 223 | Spacer() 224 | } 225 | .padding(8) 226 | .background(Color("BackgroundCard")) 227 | .cornerRadius(12) 228 | } 229 | if friends.count > 0 230 | { 231 | Text("Friends") 232 | .multilineTextAlignment(.center) 233 | .opacity(0.5) 234 | ForEach(friends) 235 | { i in 236 | HStack() 237 | { 238 | URLImage(url:URL(string:"https://parsecusercontent.com/cors-resize-image/w=48,h=48,fit=crop,background=white,q=90,f=jpeg/avatars/\(String(i.id))/avatar"), 239 | output: 240 | { 241 | $0 242 | .resizable() 243 | .aspectRatio(contentMode:.fit) 244 | .frame(width:48, height:48) 245 | .cornerRadius(6) 246 | }, 247 | placeholder: 248 | { 249 | Image("IconTransparent") 250 | .resizable() 251 | .aspectRatio(contentMode:.fit) 252 | .frame(width:48, height:48) 253 | .background(Rectangle().fill(Color("BackgroundPrompt"))) 254 | .cornerRadius(6) 255 | }) 256 | Text("\(i.username)#\(String(i.id))") 257 | .font(.system(size:16, weight:.medium)) 258 | .multilineTextAlignment(.center) 259 | Spacer() 260 | // Button(action:{ }, label:{ Image(systemName:"ellipsis.circle.fill") }) 261 | // .font(.system(size:20)) 262 | // .foregroundColor(Color("AccentColor")) 263 | // .padding(8) 264 | } 265 | .padding(8) 266 | .background(Color("BackgroundCard")) 267 | .cornerRadius(12) 268 | } 269 | } 270 | } 271 | .padding() 272 | } 273 | .zIndex(page == .friends ? 0 : -1) 274 | .disabled(page != .friends) 275 | .opacity(page == .friends ? 1 : 0) 276 | } 277 | .padding(.top, -8) 278 | .frame(maxWidth:.infinity) 279 | .alert(isPresented:$showBaseAlert) 280 | { 281 | Alert(title:Text(baseAlertText)) 282 | } 283 | 284 | // Page controls 285 | HStack() 286 | { 287 | Spacer() 288 | Button(action:{ page = .hosts }, label: 289 | { 290 | VStack() 291 | { 292 | Image(systemName:"desktopcomputer") 293 | Text("Hosts") 294 | } 295 | }) 296 | .foregroundColor(Color(page == .hosts ? "AccentColor" : "ForegroundInactive")) 297 | .disabled(page == .hosts) 298 | Spacer() 299 | Button(action:{ page = .friends }, label: 300 | { 301 | VStack() 302 | { 303 | Image(systemName:"person.2.fill") 304 | Text("Friends") 305 | } 306 | }) 307 | .foregroundColor(Color(page == .friends ? "AccentColor" : "ForegroundInactive")) 308 | .disabled(page == .friends) 309 | Spacer() 310 | } 311 | .padding([.leading, .bottom, .trailing], 4) 312 | .background(Color("BackgroundTab") 313 | .padding(.top, -8) 314 | .shadow(color:Color("Shading"), radius:4, y:-2) 315 | .mask(Rectangle().frame(height:80).offset(y:-50)) 316 | ) 317 | .zIndex(1) 318 | } 319 | .onAppear(perform:initView) 320 | .disabled(busy) // disable view if busy 321 | 322 | // Settings screen 323 | SettingsView(visible:$inSettings) 324 | 325 | // Loading elements 326 | if isConnecting 327 | { 328 | ZStack() 329 | { 330 | Rectangle() // Darken background 331 | .fill(Color.black) 332 | .opacity(0.5) 333 | .edgesIgnoringSafeArea(.all) 334 | VStack() 335 | { 336 | ActivityIndicator(isAnimating:$isConnecting, style:.large, tint:.white) 337 | .padding() 338 | Text("Requesting connection to \(connectingToName)...") 339 | .multilineTextAlignment(.center) 340 | Button(action:cancelConnection) 341 | { 342 | ZStack() 343 | { 344 | Rectangle() 345 | .fill(Color("BackgroundButton")) 346 | .cornerRadius(8) 347 | Text("Cancel") 348 | .foregroundColor(.red) 349 | } 350 | } 351 | .frame(maxWidth:100, maxHeight:48) 352 | } 353 | .padding() 354 | .background(Rectangle().fill(Color("BackgroundPrompt"))) 355 | .cornerRadius(8) 356 | .padding() 357 | } 358 | } 359 | if isRefreshing 360 | { 361 | ZStack() 362 | { 363 | Rectangle() // Darken background 364 | .fill(Color.black) 365 | .opacity(0.5) 366 | .edgesIgnoringSafeArea(.all) 367 | VStack() 368 | { 369 | ActivityIndicator(isAnimating:$isRefreshing, style:.large, tint:.white) 370 | .padding() 371 | Text("Refreshing hosts...") 372 | .multilineTextAlignment(.center) 373 | } 374 | .padding() 375 | .background(Rectangle().fill(Color("BackgroundPrompt"))) 376 | .cornerRadius(8) 377 | .padding() 378 | } 379 | } 380 | } 381 | .foregroundColor(Color("Foreground")) 382 | } 383 | 384 | func initView() 385 | { 386 | refreshHosts() 387 | refreshSelf() 388 | refreshFriends() 389 | } 390 | 391 | func refreshHosts() 392 | { 393 | withAnimation 394 | { 395 | isRefreshing = true 396 | 397 | let clinfo = NetworkHandler.clinfo 398 | if clinfo == nil 399 | { 400 | isRefreshing = false; 401 | baseAlertText = "Error gathering hosts: Invalid session" 402 | showBaseAlert = true 403 | return 404 | } 405 | 406 | let apiURL = URL(string:"https://kessel-api.parsec.app/v2/hosts?mode=desktop&public=false")! 407 | 408 | var request = URLRequest(url:apiURL) 409 | request.httpMethod = "GET" 410 | request.setValue("application/json", forHTTPHeaderField:"Content-Type") 411 | request.setValue("Bearer \(clinfo!.session_id)", forHTTPHeaderField:"Authorization") 412 | 413 | let task = URLSession.shared.dataTask(with:request) 414 | { (data, response, error) in 415 | if let data = data 416 | { 417 | let statusCode:Int = (response as! HTTPURLResponse).statusCode 418 | let decoder = JSONDecoder() 419 | 420 | print("/v2/hosts: \(statusCode)") 421 | print(String(data:data, encoding:.utf8)!) 422 | 423 | if statusCode == 200 // 200 OK 424 | { 425 | let info:HostInfoList = try! decoder.decode(HostInfoList.self, from:data) 426 | hosts.removeAll() 427 | if let datas = info.data 428 | { 429 | datas.forEach 430 | { h in 431 | hosts.append(IdentifiableHostInfo(id:h.peer_id, hostname:h.name, user:h.user, connections:h.players)) 432 | } 433 | } 434 | 435 | var grammar:String = "hosts" 436 | if hosts.count == 1 437 | { 438 | grammar = "host" 439 | } 440 | 441 | hostCountStr = "\(hosts.count) \(grammar)" 442 | 443 | let formatter = DateFormatter() 444 | formatter.dateFormat = "M/d/yyyy h:mm a" 445 | refreshTime = "Last refreshed at \(formatter.string(from:Date()))" 446 | } 447 | else if statusCode == 403 // 403 Forbidden 448 | { 449 | let info:ErrorInfo = try! decoder.decode(ErrorInfo.self, from:data) 450 | 451 | baseAlertText = "Error gathering hosts: \(info.error)" 452 | showBaseAlert = true 453 | } 454 | } 455 | 456 | isRefreshing = false 457 | } 458 | task.resume() 459 | } 460 | } 461 | 462 | func refreshSelf() 463 | { 464 | withAnimation 465 | { 466 | let clinfo = NetworkHandler.clinfo 467 | if clinfo == nil 468 | { 469 | return 470 | } 471 | 472 | let apiURL = URL(string:"https://kessel-api.parsec.app/me")! 473 | 474 | var request = URLRequest(url:apiURL) 475 | request.httpMethod = "GET" 476 | request.setValue("application/json", forHTTPHeaderField:"Content-Type") 477 | request.setValue("Bearer \(clinfo!.session_id)", forHTTPHeaderField:"Authorization") 478 | 479 | let task = URLSession.shared.dataTask(with:request) 480 | { (data, response, error) in 481 | if let data = data 482 | { 483 | let statusCode:Int = (response as! HTTPURLResponse).statusCode 484 | let decoder = JSONDecoder() 485 | 486 | print("/me: \(statusCode)") 487 | print(String(data:data, encoding:.utf8)!) 488 | 489 | if statusCode == 200 // 200 OK 490 | { 491 | let data:SelfInfoData = try! decoder.decode(SelfInfo.self, from:data).data 492 | userInfo = IdentifiableUserInfo(id:data.id, username:data.name) 493 | } 494 | else 495 | { 496 | let info:ErrorInfo = try! decoder.decode(ErrorInfo.self, from:data) 497 | 498 | baseAlertText = "Error gathering user info: \(info.error)" 499 | showBaseAlert = true 500 | } 501 | } 502 | } 503 | task.resume() 504 | } 505 | } 506 | 507 | func refreshFriends() 508 | { 509 | withAnimation 510 | { 511 | let clinfo = NetworkHandler.clinfo 512 | if clinfo == nil 513 | { 514 | return 515 | } 516 | 517 | let apiURL = URL(string:"https://kessel-api.parsec.app/friendships")! 518 | 519 | var request = URLRequest(url:apiURL) 520 | request.httpMethod = "GET" 521 | request.setValue("application/json", forHTTPHeaderField:"Content-Type") 522 | request.setValue("Bearer \(clinfo!.session_id)", forHTTPHeaderField:"Authorization") 523 | 524 | let task = URLSession.shared.dataTask(with:request) 525 | { (data, response, error) in 526 | if let data = data 527 | { 528 | let statusCode:Int = (response as! HTTPURLResponse).statusCode 529 | let decoder = JSONDecoder() 530 | 531 | print("/friendships: \(statusCode)") 532 | print(String(data:data, encoding:.utf8)!) 533 | 534 | if statusCode == 200 // 200 OK 535 | { 536 | let info:FriendInfoList = try! decoder.decode(FriendInfoList.self, from:data) 537 | friends.removeAll() 538 | if let datas = info.data 539 | { 540 | datas.forEach 541 | { f in 542 | friends.append(IdentifiableUserInfo(id:f.user_id, username:f.user_name)) 543 | } 544 | } 545 | 546 | var grammar:String = "friends" 547 | if friends.count == 1 548 | { 549 | grammar = "friend" 550 | } 551 | 552 | friendCountStr = "\(friends.count) \(grammar)" 553 | } 554 | else 555 | { 556 | let info:ErrorInfo = try! decoder.decode(ErrorInfo.self, from:data) 557 | 558 | baseAlertText = "Error gathering friends: \(info.error)" 559 | showBaseAlert = true 560 | } 561 | } 562 | 563 | isRefreshing = false 564 | } 565 | task.resume() 566 | } 567 | } 568 | 569 | func connectTo(_ who:IdentifiableHostInfo) 570 | { 571 | connectingToName = who.hostname 572 | withAnimation { isConnecting = true } 573 | 574 | var status = CParsec.connect(who.id) 575 | 576 | // Polling status 577 | pollTimer = Timer.scheduledTimer(withTimeInterval:1, repeats:true) 578 | { timer in 579 | status = CParsec.getStatus() 580 | 581 | if status == PARSEC_CONNECTING { return } // wait 582 | 583 | withAnimation { isConnecting = false } 584 | 585 | if status == PARSEC_OK 586 | { 587 | if let c = controller 588 | { 589 | c.setView(.parsec) 590 | } 591 | } 592 | else 593 | { 594 | baseAlertText = "Error connecting to host (code \(status.rawValue))" 595 | showBaseAlert = true 596 | } 597 | 598 | timer.invalidate() 599 | } 600 | } 601 | 602 | func cancelConnection() 603 | { 604 | withAnimation { isConnecting = false } 605 | 606 | CParsec.disconnect() 607 | 608 | pollTimer!.invalidate() 609 | } 610 | 611 | func logout() 612 | { 613 | removeFromKeychain(key:GLBDataModel.shared.SessionKeyChainKey) 614 | NetworkHandler.clinfo = nil 615 | if let c = controller 616 | { 617 | c.setView(.login) 618 | } 619 | } 620 | 621 | func removeFromKeychain(key:String) 622 | { 623 | let query: [String: Any] = [kSecClass as String: kSecClassGenericPassword, kSecAttrAccount as String: key] 624 | let status = SecItemDelete(query as CFDictionary) 625 | if status == errSecSuccess 626 | { 627 | print("Successfully removed data from keychain.") 628 | } 629 | } 630 | } 631 | 632 | struct MainView_Previews:PreviewProvider 633 | { 634 | static var previews:some View 635 | { 636 | MainView(nil) 637 | } 638 | } 639 | 640 | struct IdentifiableHostInfo:Identifiable 641 | { 642 | var id:String // Peer ID 643 | var hostname:String // Computer's Display Name 644 | var user:UserInfo // User Data 645 | var connections:Int // User's Connected To This Host 646 | } 647 | 648 | struct IdentifiableUserInfo:Identifiable 649 | { 650 | var id:Int // User ID 651 | var username:String // User Display Name 652 | } 653 | 654 | private enum Page 655 | { 656 | case hosts 657 | case friends 658 | } 659 | -------------------------------------------------------------------------------- /OpenParsec.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 271D14F9292E90EB00D7F1D6 /* ParsecView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 271D14F8292E90EB00D7F1D6 /* ParsecView.swift */; }; 11 | 271D14FC292EAA3600D7F1D6 /* ParsecGLKRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 271D14FA292EAA3600D7F1D6 /* ParsecGLKRenderer.swift */; }; 12 | 271D14FD292EAA3600D7F1D6 /* ParsecGLKViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 271D14FB292EAA3600D7F1D6 /* ParsecGLKViewController.swift */; }; 13 | 274A69CF29EA07FA00F595A5 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274A69CE29EA07FA00F595A5 /* SettingsView.swift */; }; 14 | 27899AC7292FE2A9001ACA33 /* audio.c in Sources */ = {isa = PBXBuildFile; fileRef = 27899AC5292FE2A9001ACA33 /* audio.c */; }; 15 | 27A923E029E8E53000F54BDA /* TouchHandlingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27A923DF29E8E53000F54BDA /* TouchHandlingView.swift */; }; 16 | 27A923E229E8FEE900F54BDA /* UIViewControllerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27A923E129E8FEE900F54BDA /* UIViewControllerWrapper.swift */; }; 17 | 27A923E429E9035D00F54BDA /* KeyboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27A923E329E9035D00F54BDA /* KeyboardViewController.swift */; }; 18 | 27AC751829EA339B00E8CAF7 /* URLImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27AC751729EA339B00E8CAF7 /* URLImage.swift */; }; 19 | 27B8D564292DC7A000A324AD /* CParsec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27B8D563292DC7A000A324AD /* CParsec.swift */; }; 20 | 27B8D571292DCA5B00A324AD /* ParsecSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27B8D56F292DCA5800A324AD /* ParsecSDK.framework */; settings = {ATTRIBUTES = (Required, ); }; }; 21 | 27B8D572292DCA5B00A324AD /* ParsecSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 27B8D56F292DCA5800A324AD /* ParsecSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 22 | 27E61A92292965FC00FF6563 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E61A91292965FC00FF6563 /* AppDelegate.swift */; }; 23 | 27E61A94292965FC00FF6563 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E61A93292965FC00FF6563 /* SceneDelegate.swift */; }; 24 | 27E61A96292965FC00FF6563 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E61A95292965FC00FF6563 /* ContentView.swift */; }; 25 | 27E61A98292965FD00FF6563 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27E61A97292965FD00FF6563 /* Assets.xcassets */; }; 26 | 27E61A9B292965FD00FF6563 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27E61A9A292965FD00FF6563 /* Preview Assets.xcassets */; }; 27 | 27E61A9E292965FD00FF6563 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27E61A9C292965FD00FF6563 /* LaunchScreen.storyboard */; }; 28 | 27E61AA62929817700FF6563 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E61AA52929817700FF6563 /* LoginView.swift */; }; 29 | 27E61AA8292994B500FF6563 /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E61AA7292994B500FF6563 /* ActivityIndicator.swift */; }; 30 | 27E61AAA2929B92200FF6563 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E61AA92929B92200FF6563 /* MainView.swift */; }; 31 | 27ED36FF292D4F9800B1BE3D /* NetworkHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27ED36FE292D4F9800B1BE3D /* NetworkHandler.swift */; }; 32 | 84480EBE2ADC4FDA007DE5F1 /* GameController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84480EBD2ADC4FDA007DE5F1 /* GameController.swift */; }; 33 | 84480EC02AEE0ECE007DE5F1 /* ParsecMTLRender.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84480EBF2AEE0ECD007DE5F1 /* ParsecMTLRender.swift */; }; 34 | 84480EC22AEE0EDB007DE5F1 /* ParsecMetalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84480EC12AEE0EDB007DE5F1 /* ParsecMetalView.swift */; }; 35 | FC16A7AD29A97BDA00BB70A7 /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC16A7AC29A97BDA00BB70A7 /* Shared.swift */; }; 36 | /* End PBXBuildFile section */ 37 | 38 | /* Begin PBXCopyFilesBuildPhase section */ 39 | 27B8D569292DC81500A324AD /* Embed Frameworks */ = { 40 | isa = PBXCopyFilesBuildPhase; 41 | buildActionMask = 2147483647; 42 | dstPath = ""; 43 | dstSubfolderSpec = 10; 44 | files = ( 45 | 27B8D572292DCA5B00A324AD /* ParsecSDK.framework in Embed Frameworks */, 46 | ); 47 | name = "Embed Frameworks"; 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXCopyFilesBuildPhase section */ 51 | 52 | /* Begin PBXFileReference section */ 53 | 271D14F8292E90EB00D7F1D6 /* ParsecView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParsecView.swift; sourceTree = ""; }; 54 | 271D14FA292EAA3600D7F1D6 /* ParsecGLKRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParsecGLKRenderer.swift; sourceTree = ""; }; 55 | 271D14FB292EAA3600D7F1D6 /* ParsecGLKViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParsecGLKViewController.swift; sourceTree = ""; }; 56 | 274A69CE29EA07FA00F595A5 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; 57 | 27899AC4292FE2A8001ACA33 /* OpenParsec-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenParsec-Bridging-Header.h"; sourceTree = ""; }; 58 | 27899AC5292FE2A9001ACA33 /* audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = audio.c; sourceTree = ""; }; 59 | 27899AC6292FE2A9001ACA33 /* audio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio.h; sourceTree = ""; }; 60 | 27A923DF29E8E53000F54BDA /* TouchHandlingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchHandlingView.swift; sourceTree = ""; }; 61 | 27A923E129E8FEE900F54BDA /* UIViewControllerWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerWrapper.swift; sourceTree = ""; }; 62 | 27A923E329E9035D00F54BDA /* KeyboardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardViewController.swift; sourceTree = ""; }; 63 | 27AC751729EA339B00E8CAF7 /* URLImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLImage.swift; sourceTree = ""; }; 64 | 27B8D563292DC7A000A324AD /* CParsec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CParsec.swift; sourceTree = ""; }; 65 | 27B8D56F292DCA5800A324AD /* ParsecSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ParsecSDK.framework; sourceTree = ""; }; 66 | 27E61A8E292965FC00FF6563 /* OpenParsec.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenParsec.app; sourceTree = BUILT_PRODUCTS_DIR; }; 67 | 27E61A91292965FC00FF6563 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 68 | 27E61A93292965FC00FF6563 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 69 | 27E61A95292965FC00FF6563 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 70 | 27E61A97292965FD00FF6563 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 71 | 27E61A9A292965FD00FF6563 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 72 | 27E61A9D292965FD00FF6563 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 73 | 27E61A9F292965FD00FF6563 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 74 | 27E61AA52929817700FF6563 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = ""; }; 75 | 27E61AA7292994B500FF6563 /* ActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityIndicator.swift; sourceTree = ""; }; 76 | 27E61AA92929B92200FF6563 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; 77 | 27ED36FE292D4F9800B1BE3D /* NetworkHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkHandler.swift; sourceTree = ""; }; 78 | 84480EBD2ADC4FDA007DE5F1 /* GameController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameController.swift; sourceTree = ""; }; 79 | 84480EBF2AEE0ECD007DE5F1 /* ParsecMTLRender.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParsecMTLRender.swift; sourceTree = ""; }; 80 | 84480EC12AEE0EDB007DE5F1 /* ParsecMetalView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParsecMetalView.swift; sourceTree = ""; }; 81 | FC16A7AC29A97BDA00BB70A7 /* Shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shared.swift; sourceTree = ""; }; 82 | /* End PBXFileReference section */ 83 | 84 | /* Begin PBXFrameworksBuildPhase section */ 85 | 27E61A8B292965FC00FF6563 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | 27B8D571292DCA5B00A324AD /* ParsecSDK.framework in Frameworks */, 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | /* End PBXFrameworksBuildPhase section */ 94 | 95 | /* Begin PBXGroup section */ 96 | 27B8D56A292DC98B00A324AD /* Frameworks */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 27B8D56F292DCA5800A324AD /* ParsecSDK.framework */, 100 | ); 101 | path = Frameworks; 102 | sourceTree = ""; 103 | }; 104 | 27E61A85292965FC00FF6563 = { 105 | isa = PBXGroup; 106 | children = ( 107 | 27B8D56A292DC98B00A324AD /* Frameworks */, 108 | 27E61A90292965FC00FF6563 /* OpenParsec */, 109 | 27E61A8F292965FC00FF6563 /* Products */, 110 | ); 111 | sourceTree = ""; 112 | }; 113 | 27E61A8F292965FC00FF6563 /* Products */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 27E61A8E292965FC00FF6563 /* OpenParsec.app */, 117 | ); 118 | name = Products; 119 | sourceTree = ""; 120 | }; 121 | 27E61A90292965FC00FF6563 /* OpenParsec */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 84480EC12AEE0EDB007DE5F1 /* ParsecMetalView.swift */, 125 | 84480EBF2AEE0ECD007DE5F1 /* ParsecMTLRender.swift */, 126 | 84480EBD2ADC4FDA007DE5F1 /* GameController.swift */, 127 | 27899AC5292FE2A9001ACA33 /* audio.c */, 128 | 27899AC6292FE2A9001ACA33 /* audio.h */, 129 | 271D14FA292EAA3600D7F1D6 /* ParsecGLKRenderer.swift */, 130 | 271D14FB292EAA3600D7F1D6 /* ParsecGLKViewController.swift */, 131 | 27E61A91292965FC00FF6563 /* AppDelegate.swift */, 132 | 27E61A93292965FC00FF6563 /* SceneDelegate.swift */, 133 | 27E61A95292965FC00FF6563 /* ContentView.swift */, 134 | 27E61A97292965FD00FF6563 /* Assets.xcassets */, 135 | 27E61A9C292965FD00FF6563 /* LaunchScreen.storyboard */, 136 | 27E61A9F292965FD00FF6563 /* Info.plist */, 137 | 27E61A99292965FD00FF6563 /* Preview Content */, 138 | 27E61AA52929817700FF6563 /* LoginView.swift */, 139 | 27E61AA7292994B500FF6563 /* ActivityIndicator.swift */, 140 | 27E61AA92929B92200FF6563 /* MainView.swift */, 141 | 27ED36FE292D4F9800B1BE3D /* NetworkHandler.swift */, 142 | 27B8D563292DC7A000A324AD /* CParsec.swift */, 143 | 271D14F8292E90EB00D7F1D6 /* ParsecView.swift */, 144 | 27899AC4292FE2A8001ACA33 /* OpenParsec-Bridging-Header.h */, 145 | FC16A7AC29A97BDA00BB70A7 /* Shared.swift */, 146 | 27A923DF29E8E53000F54BDA /* TouchHandlingView.swift */, 147 | 27A923E129E8FEE900F54BDA /* UIViewControllerWrapper.swift */, 148 | 27A923E329E9035D00F54BDA /* KeyboardViewController.swift */, 149 | 274A69CE29EA07FA00F595A5 /* SettingsView.swift */, 150 | 27AC751729EA339B00E8CAF7 /* URLImage.swift */, 151 | ); 152 | path = OpenParsec; 153 | sourceTree = ""; 154 | }; 155 | 27E61A99292965FD00FF6563 /* Preview Content */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | 27E61A9A292965FD00FF6563 /* Preview Assets.xcassets */, 159 | ); 160 | path = "Preview Content"; 161 | sourceTree = ""; 162 | }; 163 | /* End PBXGroup section */ 164 | 165 | /* Begin PBXNativeTarget section */ 166 | 27E61A8D292965FC00FF6563 /* OpenParsec */ = { 167 | isa = PBXNativeTarget; 168 | buildConfigurationList = 27E61AA2292965FD00FF6563 /* Build configuration list for PBXNativeTarget "OpenParsec" */; 169 | buildPhases = ( 170 | 27E61A8A292965FC00FF6563 /* Sources */, 171 | 27E61A8B292965FC00FF6563 /* Frameworks */, 172 | 27E61A8C292965FC00FF6563 /* Resources */, 173 | 27B8D569292DC81500A324AD /* Embed Frameworks */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | ); 179 | name = OpenParsec; 180 | productName = OpenParsec; 181 | productReference = 27E61A8E292965FC00FF6563 /* OpenParsec.app */; 182 | productType = "com.apple.product-type.application"; 183 | }; 184 | /* End PBXNativeTarget section */ 185 | 186 | /* Begin PBXProject section */ 187 | 27E61A86292965FC00FF6563 /* Project object */ = { 188 | isa = PBXProject; 189 | attributes = { 190 | LastSwiftUpdateCheck = 1250; 191 | LastUpgradeCheck = 1250; 192 | TargetAttributes = { 193 | 27E61A8D292965FC00FF6563 = { 194 | CreatedOnToolsVersion = 12.5; 195 | LastSwiftMigration = 1250; 196 | }; 197 | }; 198 | }; 199 | buildConfigurationList = 27E61A89292965FC00FF6563 /* Build configuration list for PBXProject "OpenParsec" */; 200 | compatibilityVersion = "Xcode 9.3"; 201 | developmentRegion = en; 202 | hasScannedForEncodings = 0; 203 | knownRegions = ( 204 | en, 205 | Base, 206 | ); 207 | mainGroup = 27E61A85292965FC00FF6563; 208 | productRefGroup = 27E61A8F292965FC00FF6563 /* Products */; 209 | projectDirPath = ""; 210 | projectRoot = ""; 211 | targets = ( 212 | 27E61A8D292965FC00FF6563 /* OpenParsec */, 213 | ); 214 | }; 215 | /* End PBXProject section */ 216 | 217 | /* Begin PBXResourcesBuildPhase section */ 218 | 27E61A8C292965FC00FF6563 /* Resources */ = { 219 | isa = PBXResourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | 27E61A9E292965FD00FF6563 /* LaunchScreen.storyboard in Resources */, 223 | 27E61A9B292965FD00FF6563 /* Preview Assets.xcassets in Resources */, 224 | 27E61A98292965FD00FF6563 /* Assets.xcassets in Resources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | /* End PBXResourcesBuildPhase section */ 229 | 230 | /* Begin PBXSourcesBuildPhase section */ 231 | 27E61A8A292965FC00FF6563 /* Sources */ = { 232 | isa = PBXSourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | FC16A7AD29A97BDA00BB70A7 /* Shared.swift in Sources */, 236 | 84480EBE2ADC4FDA007DE5F1 /* GameController.swift in Sources */, 237 | 27AC751829EA339B00E8CAF7 /* URLImage.swift in Sources */, 238 | 27A923E029E8E53000F54BDA /* TouchHandlingView.swift in Sources */, 239 | 27E61A92292965FC00FF6563 /* AppDelegate.swift in Sources */, 240 | 27E61AAA2929B92200FF6563 /* MainView.swift in Sources */, 241 | 271D14FD292EAA3600D7F1D6 /* ParsecGLKViewController.swift in Sources */, 242 | 84480EC02AEE0ECE007DE5F1 /* ParsecMTLRender.swift in Sources */, 243 | 84480EC22AEE0EDB007DE5F1 /* ParsecMetalView.swift in Sources */, 244 | 274A69CF29EA07FA00F595A5 /* SettingsView.swift in Sources */, 245 | 27E61AA8292994B500FF6563 /* ActivityIndicator.swift in Sources */, 246 | 271D14FC292EAA3600D7F1D6 /* ParsecGLKRenderer.swift in Sources */, 247 | 27A923E429E9035D00F54BDA /* KeyboardViewController.swift in Sources */, 248 | 27E61A94292965FC00FF6563 /* SceneDelegate.swift in Sources */, 249 | 27899AC7292FE2A9001ACA33 /* audio.c in Sources */, 250 | 27E61AA62929817700FF6563 /* LoginView.swift in Sources */, 251 | 27B8D564292DC7A000A324AD /* CParsec.swift in Sources */, 252 | 27A923E229E8FEE900F54BDA /* UIViewControllerWrapper.swift in Sources */, 253 | 27E61A96292965FC00FF6563 /* ContentView.swift in Sources */, 254 | 27ED36FF292D4F9800B1BE3D /* NetworkHandler.swift in Sources */, 255 | 271D14F9292E90EB00D7F1D6 /* ParsecView.swift in Sources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | /* End PBXSourcesBuildPhase section */ 260 | 261 | /* Begin PBXVariantGroup section */ 262 | 27E61A9C292965FD00FF6563 /* LaunchScreen.storyboard */ = { 263 | isa = PBXVariantGroup; 264 | children = ( 265 | 27E61A9D292965FD00FF6563 /* Base */, 266 | ); 267 | name = LaunchScreen.storyboard; 268 | sourceTree = ""; 269 | }; 270 | /* End PBXVariantGroup section */ 271 | 272 | /* Begin XCBuildConfiguration section */ 273 | 27E61AA0292965FD00FF6563 /* Debug */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ALWAYS_SEARCH_USER_PATHS = NO; 277 | CLANG_ANALYZER_NONNULL = YES; 278 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 279 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 280 | CLANG_CXX_LIBRARY = "libc++"; 281 | CLANG_ENABLE_MODULES = YES; 282 | CLANG_ENABLE_OBJC_ARC = YES; 283 | CLANG_ENABLE_OBJC_WEAK = YES; 284 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 285 | CLANG_WARN_BOOL_CONVERSION = YES; 286 | CLANG_WARN_COMMA = YES; 287 | CLANG_WARN_CONSTANT_CONVERSION = YES; 288 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 289 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 290 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 291 | CLANG_WARN_EMPTY_BODY = YES; 292 | CLANG_WARN_ENUM_CONVERSION = YES; 293 | CLANG_WARN_INFINITE_RECURSION = YES; 294 | CLANG_WARN_INT_CONVERSION = YES; 295 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 296 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 297 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 299 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 300 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 301 | CLANG_WARN_STRICT_PROTOTYPES = YES; 302 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 303 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 304 | CLANG_WARN_UNREACHABLE_CODE = YES; 305 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 306 | COPY_PHASE_STRIP = NO; 307 | DEBUG_INFORMATION_FORMAT = dwarf; 308 | ENABLE_STRICT_OBJC_MSGSEND = YES; 309 | ENABLE_TESTABILITY = YES; 310 | GCC_C_LANGUAGE_STANDARD = gnu11; 311 | GCC_DYNAMIC_NO_PIC = NO; 312 | GCC_NO_COMMON_BLOCKS = YES; 313 | GCC_OPTIMIZATION_LEVEL = 0; 314 | GCC_PREPROCESSOR_DEFINITIONS = ( 315 | "DEBUG=1", 316 | "$(inherited)", 317 | ); 318 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 319 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 320 | GCC_WARN_UNDECLARED_SELECTOR = YES; 321 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 322 | GCC_WARN_UNUSED_FUNCTION = YES; 323 | GCC_WARN_UNUSED_VARIABLE = YES; 324 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 325 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 326 | MTL_FAST_MATH = YES; 327 | ONLY_ACTIVE_ARCH = YES; 328 | SDKROOT = iphoneos; 329 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 330 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 331 | }; 332 | name = Debug; 333 | }; 334 | 27E61AA1292965FD00FF6563 /* Release */ = { 335 | isa = XCBuildConfiguration; 336 | buildSettings = { 337 | ALWAYS_SEARCH_USER_PATHS = NO; 338 | CLANG_ANALYZER_NONNULL = YES; 339 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 340 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 341 | CLANG_CXX_LIBRARY = "libc++"; 342 | CLANG_ENABLE_MODULES = YES; 343 | CLANG_ENABLE_OBJC_ARC = YES; 344 | CLANG_ENABLE_OBJC_WEAK = YES; 345 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 346 | CLANG_WARN_BOOL_CONVERSION = YES; 347 | CLANG_WARN_COMMA = YES; 348 | CLANG_WARN_CONSTANT_CONVERSION = YES; 349 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 350 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 351 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 352 | CLANG_WARN_EMPTY_BODY = YES; 353 | CLANG_WARN_ENUM_CONVERSION = YES; 354 | CLANG_WARN_INFINITE_RECURSION = YES; 355 | CLANG_WARN_INT_CONVERSION = YES; 356 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 357 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 358 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 361 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 362 | CLANG_WARN_STRICT_PROTOTYPES = YES; 363 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 364 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 365 | CLANG_WARN_UNREACHABLE_CODE = YES; 366 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 367 | COPY_PHASE_STRIP = NO; 368 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 369 | ENABLE_NS_ASSERTIONS = NO; 370 | ENABLE_STRICT_OBJC_MSGSEND = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu11; 372 | GCC_NO_COMMON_BLOCKS = YES; 373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 375 | GCC_WARN_UNDECLARED_SELECTOR = YES; 376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 377 | GCC_WARN_UNUSED_FUNCTION = YES; 378 | GCC_WARN_UNUSED_VARIABLE = YES; 379 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 380 | MTL_ENABLE_DEBUG_INFO = NO; 381 | MTL_FAST_MATH = YES; 382 | SDKROOT = iphoneos; 383 | SWIFT_COMPILATION_MODE = wholemodule; 384 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 385 | VALIDATE_PRODUCT = YES; 386 | }; 387 | name = Release; 388 | }; 389 | 27E61AA3292965FD00FF6563 /* Debug */ = { 390 | isa = XCBuildConfiguration; 391 | buildSettings = { 392 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 393 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 394 | CLANG_ENABLE_MODULES = YES; 395 | CODE_SIGN_STYLE = Automatic; 396 | DEVELOPMENT_ASSET_PATHS = "\"OpenParsec/Preview Content\""; 397 | DEVELOPMENT_TEAM = ""; 398 | ENABLE_PREVIEWS = YES; 399 | INFOPLIST_FILE = OpenParsec/Info.plist; 400 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 401 | LD_RUNPATH_SEARCH_PATHS = ( 402 | "$(inherited)", 403 | "@executable_path/Frameworks", 404 | ); 405 | PRODUCT_BUNDLE_IDENTIFIER = io.github.AngelDTF.OpenParsec; 406 | PRODUCT_NAME = "$(TARGET_NAME)"; 407 | SWIFT_OBJC_BRIDGING_HEADER = "OpenParsec/OpenParsec-Bridging-Header.h"; 408 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 409 | SWIFT_VERSION = 5.0; 410 | SYSTEM_FRAMEWORK_SEARCH_PATHS = $PROJECT_DIR/Frameworks; 411 | TARGETED_DEVICE_FAMILY = "1,2"; 412 | VALIDATE_WORKSPACE = YES; 413 | }; 414 | name = Debug; 415 | }; 416 | 27E61AA4292965FD00FF6563 /* Release */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 420 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 421 | CLANG_ENABLE_MODULES = YES; 422 | CODE_SIGN_STYLE = Automatic; 423 | DEVELOPMENT_ASSET_PATHS = "\"OpenParsec/Preview Content\""; 424 | DEVELOPMENT_TEAM = ""; 425 | ENABLE_PREVIEWS = YES; 426 | INFOPLIST_FILE = OpenParsec/Info.plist; 427 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 428 | LD_RUNPATH_SEARCH_PATHS = ( 429 | "$(inherited)", 430 | "@executable_path/Frameworks", 431 | ); 432 | PRODUCT_BUNDLE_IDENTIFIER = io.github.AngelDTF.OpenParsec; 433 | PRODUCT_NAME = "$(TARGET_NAME)"; 434 | SWIFT_OBJC_BRIDGING_HEADER = "OpenParsec/OpenParsec-Bridging-Header.h"; 435 | SWIFT_VERSION = 5.0; 436 | SYSTEM_FRAMEWORK_SEARCH_PATHS = $PROJECT_DIR/Frameworks; 437 | TARGETED_DEVICE_FAMILY = "1,2"; 438 | VALIDATE_WORKSPACE = YES; 439 | }; 440 | name = Release; 441 | }; 442 | /* End XCBuildConfiguration section */ 443 | 444 | /* Begin XCConfigurationList section */ 445 | 27E61A89292965FC00FF6563 /* Build configuration list for PBXProject "OpenParsec" */ = { 446 | isa = XCConfigurationList; 447 | buildConfigurations = ( 448 | 27E61AA0292965FD00FF6563 /* Debug */, 449 | 27E61AA1292965FD00FF6563 /* Release */, 450 | ); 451 | defaultConfigurationIsVisible = 0; 452 | defaultConfigurationName = Release; 453 | }; 454 | 27E61AA2292965FD00FF6563 /* Build configuration list for PBXNativeTarget "OpenParsec" */ = { 455 | isa = XCConfigurationList; 456 | buildConfigurations = ( 457 | 27E61AA3292965FD00FF6563 /* Debug */, 458 | 27E61AA4292965FD00FF6563 /* Release */, 459 | ); 460 | defaultConfigurationIsVisible = 0; 461 | defaultConfigurationName = Release; 462 | }; 463 | /* End XCConfigurationList section */ 464 | }; 465 | rootObject = 27E61A86292965FC00FF6563 /* Project object */; 466 | } 467 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------