forked from folium-app/Cytrus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cytrus.swift
140 lines (106 loc) · 3.87 KB
/
Cytrus.swift
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//
// Cytrus.swift
// Cytrus
//
// Created by Jarrod Norwell on 12/7/2024.
//
import Foundation
import MetalKit
import UIKit
public struct Cytrus : @unchecked Sendable {
public static var shared = Cytrus()
fileprivate let cytrusObjC = CytrusObjC.shared()
public func informationForGame(at url: URL) -> CytrusGameInformation {
cytrusObjC.informationForGame(at: url)
}
public func allocateVulkanLibrary() {
cytrusObjC.allocateVulkanLibrary()
}
public func deallocateVulkanLibrary() {
cytrusObjC.deallocateVulkanLibrary()
}
public func allocateMetalLayer(for layer: CAMetalLayer, with size: CGSize, isSecondary: Bool = false) {
cytrusObjC.allocateMetalLayer(layer, with: size, isSecondary: isSecondary)
}
public func deallocateMetalLayers() {
cytrusObjC.deallocateMetalLayers()
}
public func insertCartridgeAndBoot(with url: URL) {
cytrusObjC.insertCartridgeAndBoot(url)
}
public func importGame(at url: URL) -> ImportResultStatus {
cytrusObjC.importGame(at: url)
}
public func touchBegan(at point: CGPoint) {
cytrusObjC.touchBegan(at: point)
}
public func touchEnded() {
cytrusObjC.touchEnded()
}
public func touchMoved(at point: CGPoint) {
cytrusObjC.touchMoved(at: point)
}
public func virtualControllerButtonDown(_ button: VirtualControllerButtonType) {
cytrusObjC.virtualControllerButtonDown(button)
}
public func virtualControllerButtonUp(_ button: VirtualControllerButtonType) {
cytrusObjC.virtualControllerButtonUp(button)
}
public func thumbstickMoved(_ thumbstick: VirtualControllerAnalogType, _ x: Float, _ y: Float) {
cytrusObjC.thumbstickMoved(thumbstick, x: CGFloat(x), y: CGFloat(y))
}
public func isPaused() -> Bool {
cytrusObjC.isPaused()
}
public func pausePlay(_ pausePlay: Bool) {
cytrusObjC.pausePlay(pausePlay)
}
public func stop() {
cytrusObjC.stop()
}
public func running() -> Bool {
cytrusObjC.running()
}
public func stopped() -> Bool {
cytrusObjC.stopped()
}
public func orientationChange(with orientation: UIInterfaceOrientation, using mtkView: MTKView) {
cytrusObjC.orientationChanged(orientation, metalView: mtkView)
}
public func installed() -> [URL] {
cytrusObjC.installedGamePaths() as? [URL] ?? []
}
public func system() -> [URL] {
cytrusObjC.systemGamePaths() as? [URL] ?? []
}
public func updateSettings() {
cytrusObjC.updateSettings()
}
public var stepsPerHour: UInt16 = 42 {
didSet {
cytrusObjC.setStepsPerHour(stepsPerHour)
}
}
public struct Multiplayer : @unchecked Sendable {
public static let shared = Multiplayer()
let multiplayerObjC = MultiplayerManager.shared()
public var rooms: [NetworkRoom] {
multiplayerObjC.rooms()
}
public var state: StateChange {
multiplayerObjC.state()
}
public func connect(to room: NetworkRoom, with username: String, and password: String? = nil,
error errorHandler: @escaping (ErrorChange) -> Void, state stateHandler: @escaping (StateChange) -> Void) {
multiplayerObjC.connect(room, withUsername: username, andPassword: password,
withErrorChange: errorHandler, withStateChange: stateHandler)
}
public func disconnect() {
multiplayerObjC.disconnect()
}
public func updateWebAPIURL() {
multiplayerObjC.updateWebAPIURL()
}
}
public let multiplayer = Multiplayer.shared
}