Skip to content

Commit

Permalink
hide status var & mouse scale option, fix scrolling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Oct 15, 2024
1 parent 90e1afd commit e4b7379
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion OpenParsec/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions OpenParsec/ParsecSDKBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class ParsecSDKBridge: ParsecService

clientWidth = Float(width)
clientHeight = Float(height)
mouseInfo.mouseX = Int32(width / 2)
mouseInfo.mouseY = Int32(height / 2)
}

func renderGLFrame(timeout:UInt32 = 16) // timeout in ms, 16 == 60 FPS, 8 == 120 FPS, etc.
Expand Down
2 changes: 1 addition & 1 deletion OpenParsec/ParsecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ struct ParsecView:View
}
.zIndex(2)
}
.statusBar(hidden:true)
.statusBarHidden(SettingsHandler.hideStatusBar)
.alert(isPresented:$showDCAlert)
{
Alert(title:Text(DCAlertText), dismissButton:.default(Text("Close"), action:disconnect))
Expand Down
16 changes: 8 additions & 8 deletions OpenParsec/ParsecViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class ParsecViewController :UIViewController {
lastImg = CParsec.mouseInfo.cursorImg!
}

u?.frame = CGRect(x: Int(CParsec.mouseInfo.mouseX) - CParsec.mouseInfo.cursorHotX / 2,
y: Int(CParsec.mouseInfo.mouseY) - CParsec.mouseInfo.cursorHotY / 2,
width: CParsec.mouseInfo.cursorWidth / 2,
height: CParsec.mouseInfo.cursorHeight / 2)
u?.frame = CGRect(x: Int(CParsec.mouseInfo.mouseX) - Int(Float(CParsec.mouseInfo.cursorHotX) * SettingsHandler.cursorScale),
y: Int(CParsec.mouseInfo.mouseY) - Int(Float(CParsec.mouseInfo.cursorHotY) * SettingsHandler.cursorScale),
width: Int(Float(CParsec.mouseInfo.cursorWidth) * SettingsHandler.cursorScale),
height: Int(Float(CParsec.mouseInfo.cursorHeight) * SettingsHandler.cursorScale))

} else {
u?.image = nil
Expand Down Expand Up @@ -161,7 +161,7 @@ class ParsecViewController :UIViewController {
@objc func keyboardWillShow(_ notification: Notification) {
if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
let keyboardRectangle = keyboardFrame.cgRectValue
keyboardHeight = keyboardRectangle.height
keyboardHeight = keyboardRectangle.height - 50 // minus handle button height
}
}

Expand All @@ -177,11 +177,11 @@ extension ParsecViewController : UIGestureRecognizerDelegate {
{
// print("number = \(gestureRecognizer.numberOfTouches) status = \(gestureRecognizer.state.rawValue)")
if gestureRecognizer.numberOfTouches == 2 {
let translation = gestureRecognizer.translation(in: gestureRecognizer.view)
let velocity = gestureRecognizer.velocity(in: gestureRecognizer.view)

if abs( gestureRecognizer.velocity(in: gestureRecognizer.view).y) > 2 && abs(translation.y) > 10 {
if abs(velocity.y) > 2 {
// Run your function when the user uses two fingers and swipes upwards
CParsec.sendWheelMsg(x: 0, y: Int32(translation.y / 2))
CParsec.sendWheelMsg(x: 0, y: Int32(velocity.y / 20))
return
}
if SettingsHandler.cursorMode == .direct {
Expand Down
12 changes: 8 additions & 4 deletions OpenParsec/SettingsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ struct SettingsHandler
public static var resolution : ParsecResolution = ParsecResolution.resolutions[1]
public static var decoder:DecoderPref = .h264
public static var cursorMode:CursorMode = .touchpad
//public static var cursorScale:Float = 1
public static var cursorScale:Float = 0.5
public static var noOverlay:Bool = false
public static var hideStatusBar:Bool = true

public static func load()
{
Expand All @@ -17,10 +18,12 @@ struct SettingsHandler
{ decoder = DecoderPref(rawValue:UserDefaults.standard.integer(forKey:"decoder"))! }
if UserDefaults.standard.exists(forKey:"cursorMode")
{ cursorMode = CursorMode(rawValue:UserDefaults.standard.integer(forKey:"cursorMode"))! }
//if UserDefaults.standard.exists(forKey:"cursorScale")
// { cursorScale = UserDefaults.standard.float(forKey:"cursorScale") }
if UserDefaults.standard.exists(forKey:"cursorScale")
{ cursorScale = UserDefaults.standard.float(forKey:"cursorScale") }
if UserDefaults.standard.exists(forKey:"noOverlay")
{ noOverlay = UserDefaults.standard.bool(forKey:"noOverlay") }
if UserDefaults.standard.exists(forKey:"hideStatusBar")
{ hideStatusBar = UserDefaults.standard.bool(forKey:"hideStatusBar") }

if UserDefaults.standard.exists(forKey:"resolution") {
for res in ParsecResolution.resolutions {
Expand All @@ -37,9 +40,10 @@ struct SettingsHandler
//UserDefaults.standard.set(renderer.rawValue, forKey:"renderer")
UserDefaults.standard.set(decoder.rawValue, forKey:"decoder")
UserDefaults.standard.set(cursorMode.rawValue, forKey:"cursorMode")
//UserDefaults.standard.set(cursorScale, forKey:"cursorScale")
UserDefaults.standard.set(cursorScale, forKey:"cursorScale")
UserDefaults.standard.set(noOverlay, forKey:"noOverlay")
UserDefaults.standard.set(resolution.desc, forKey:"resolution")
UserDefaults.standard.set(hideStatusBar, forKey: "hideStatusBar")
}
}

Expand Down
24 changes: 16 additions & 8 deletions OpenParsec/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ struct SettingsView:View
@State var decoder:DecoderPref = SettingsHandler.decoder
@State var cursorMode:CursorMode = SettingsHandler.cursorMode
@State var resolution : ParsecResolution = SettingsHandler.resolution
//@State var cursorScale:Float = SettingsHandler.cursorScale
@State var cursorScale:Float = SettingsHandler.cursorScale
@State var noOverlay:Bool = SettingsHandler.noOverlay
@State var hideStatusBar:Bool = SettingsHandler.hideStatusBar

let resolutionChoices : [Choice<ParsecResolution>]

Expand Down Expand Up @@ -81,10 +82,12 @@ struct SettingsView:View
Choice("Direct", CursorMode.direct)
])
}
// CatItem("Cursor Scale")
// {
// Slider(value: $cursorScale, in:0.1...4, step:0.1)
// }
CatItem("Cursor Scale")
{
Slider(value: $cursorScale, in:0.1...4, step:0.1)
.frame(width: 200)
Text(String(format: "%.1f", cursorScale))
}
}
CatTitle("Graphics")
CatList()
Expand Down Expand Up @@ -119,7 +122,12 @@ struct SettingsView:View
Toggle("", isOn:$noOverlay)
.frame(width:80)
}
}
CatItem("Hide Status Bar")
{
Toggle("", isOn:$hideStatusBar)
.frame(width:80)
}
}
Text("More options coming soon.")
.multilineTextAlignment(.center)
.opacity(0.5)
Expand All @@ -143,9 +151,9 @@ struct SettingsView:View
SettingsHandler.decoder = decoder
SettingsHandler.resolution = resolution
SettingsHandler.cursorMode = cursorMode
//SettingsHandler.cursorScale = cursorScale
SettingsHandler.cursorScale = cursorScale
SettingsHandler.noOverlay = noOverlay

SettingsHandler.hideStatusBar = hideStatusBar
SettingsHandler.save()

visible = false
Expand Down

0 comments on commit e4b7379

Please sign in to comment.