Skip to content

Commit fe16152

Browse files
committed
Add direct drag scroll settings
1 parent 4e042da commit fe16152

11 files changed

Lines changed: 321 additions & 44 deletions

OpenParsec/CParsec.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ protocol ParsecService {
153153
func sendKeyboardMessage(keyCode: UInt32, pressed: Bool)
154154
func sendVirtualKeyboardInput(text: String)
155155
func sendVirtualKeyboardInput(text: String, isOn: Bool)
156+
func sendKeyboardShortcut(modifier: ShortcutModifier, key: String)
156157
func sendGameControllerButtonMessage(controllerId: UInt32, _ button: ParsecGamepadButton, pressed: Bool)
157158
func sendGameControllerAxisMessage(controllerId: UInt32, _ button: ParsecGamepadAxis, _ value: Int16)
158159
func sendGameControllerUnplugMessage(controllerId: UInt32)
@@ -259,6 +260,10 @@ class CParsec {
259260
parsecImpl.sendVirtualKeyboardInput(text: text, isOn: isOn)
260261
}
261262

263+
static func sendKeyboardShortcut(modifier: ShortcutModifier, key: String) {
264+
parsecImpl.sendKeyboardShortcut(modifier: modifier, key: key)
265+
}
266+
262267
static func sendGameControllerButtonMessage(controllerId: UInt32, _ button: ParsecGamepadButton, pressed: Bool) {
263268
parsecImpl.sendGameControllerButtonMessage(controllerId: controllerId, button, pressed: pressed)
264269
}

OpenParsec/ParsecSDKBridge.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ enum CursorMode: Int {
1717
case direct
1818
}
1919

20+
enum DirectDragMode: Int {
21+
case scroll
22+
case drag
23+
}
24+
25+
enum ShortcutModifier: Int {
26+
case control
27+
case command
28+
29+
var keyText: String {
30+
switch self {
31+
case .control:
32+
return "CONTROL"
33+
case .command:
34+
return "LGUI"
35+
}
36+
}
37+
}
38+
2039
enum RightClickPosition: Int {
2140
case firstFinger
2241
case middle
@@ -202,6 +221,7 @@ class ParsecSDKBridge: ParsecService {
202221
DataManager.model.resolutionY = videoConfig.resolutionY
203222
DataManager.model.bitrate = videoConfig.encoderMaxBitrate
204223
DataManager.model.constantFps = videoConfig.fullFPS
224+
DataManager.model.hostMacOS = videoConfig.hostMacOS || videoConfig.hostOS == 2
205225
if !self.didSetResolution {
206226
self.didSetResolution = true
207227
DataManager.model.resolutionX = SettingsHandler.resolution.width
@@ -423,6 +443,21 @@ class ParsecSDKBridge: ParsecService {
423443

424444
}
425445

446+
func sendKeyboardShortcut(modifier: ShortcutModifier, key: String) {
447+
guard let modifierKeyCode = KeyCodeTranslators.parsecKeyCodeTranslator(modifier.keyText),
448+
let keyCode = KeyCodeTranslators.parsecKeyCodeTranslator(key.uppercased()) else {
449+
return
450+
}
451+
452+
sendKeyboardMessage(keyCode: modifierKeyCode.rawValue, pressed: true)
453+
sendKeyboardMessage(keyCode: keyCode.rawValue, pressed: true)
454+
455+
DispatchQueue.global().asyncAfter(deadline: .now() + 0.02) {
456+
self.sendKeyboardMessage(keyCode: keyCode.rawValue, pressed: false)
457+
self.sendKeyboardMessage(keyCode: modifierKeyCode.rawValue, pressed: false)
458+
}
459+
}
460+
426461
func sendKeyboardMessage(event: KeyBoardKeyEvent) {
427462
if event.input == nil {
428463
return

OpenParsec/ParsecUserData.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ struct ParsecUserDataVideo: Codable {
44
var resolutionY: Int = 0
55
var fullFPS: Bool = false
66
var hostOS = 0
7+
var hostMacOS = false
78
var output = "none"
89
var encoderMaxBitrate: Int = 50
910
}

OpenParsec/ParsecView.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,20 @@ struct ParsecView: View {
215215
.frame(maxWidth: .infinity)
216216
.multilineTextAlignment(.center)
217217
}
218+
HStack(spacing: 3) {
219+
Button(action: sendCopyShortcut) {
220+
Label("Copy", systemImage: "doc.on.doc")
221+
.padding(8)
222+
.frame(maxWidth: .infinity)
223+
.multilineTextAlignment(.center)
224+
}
225+
Button(action: sendPasteShortcut) {
226+
Label("Paste", systemImage: "doc.on.clipboard")
227+
.padding(8)
228+
.frame(maxWidth: .infinity)
229+
.multilineTextAlignment(.center)
230+
}
231+
}
218232
Button(action: toggleMute) {
219233
Text(localized("Sound: %@", localized(muted ? "OFF" : "ON")))
220234
.padding(8)
@@ -483,6 +497,14 @@ struct ParsecView: View {
483497
}
484498
}
485499

500+
func sendCopyShortcut() {
501+
CParsec.sendKeyboardShortcut(modifier: DataManager.model.shortcutModifierForHost, key: "C")
502+
}
503+
504+
func sendPasteShortcut() {
505+
CParsec.sendKeyboardShortcut(modifier: DataManager.model.shortcutModifierForHost, key: "V")
506+
}
507+
486508
func toggleZoom() {
487509
DispatchQueue.main.async {
488510
zoomEnabled.toggle()

0 commit comments

Comments
 (0)