feat: auto hover
This commit is contained in:
1 parent
6d36219e88
commit
2c9902ce77
9 files changed
+147
-11
No files matched your search
@@ -22,7 +22,7 @@ import UIKit
|
||||
private var pencilTickEnabled: Bool
|
||||
private var pressureCurveEnabled: Bool = false
|
||||
private var manualHoverFlag: Bool = false
|
||||
private var autoHoverFlag: Bool = false
|
||||
@objc static var autoHoverEnabled: Bool = false
|
||||
private(set) var pencilProEnabled: Bool = false
|
||||
private var isFirstMove: Bool = false
|
||||
private var moveEventIndex: Int64 = 0
|
||||
@@ -59,15 +59,24 @@ import UIKit
|
||||
selectedProfile = profile!
|
||||
}
|
||||
|
||||
if selectedProfile.eraserShortcut != "" {
|
||||
doubleTapShorcuts.append(selectedProfile.eraserShortcut)
|
||||
doubleTapShorcuts.removeAll()
|
||||
if selectedProfile.doubleTapShorcutEnabled {
|
||||
if selectedProfile.eraserShortcut != "" {
|
||||
doubleTapShorcuts.append(selectedProfile.eraserShortcut)
|
||||
}
|
||||
if selectedProfile.brushShortcut != "" {
|
||||
doubleTapShorcuts.append(selectedProfile.brushShortcut)
|
||||
}
|
||||
}
|
||||
if selectedProfile.brushShortcut != "" {
|
||||
doubleTapShorcuts.append(selectedProfile.brushShortcut)
|
||||
|
||||
PencilHandler.squeezeStartShortcut = ""
|
||||
PencilHandler.squeezeEndShortcut = ""
|
||||
if selectedProfile.squeezeShorcutEnabled {
|
||||
PencilHandler.squeezeStartShortcut = selectedProfile.squeezeStartShortcut
|
||||
PencilHandler.squeezeEndShortcut = selectedProfile.squeezeEndShortcut
|
||||
print("squeezeShorcutEnabled \(CACurrentMediaTime())")
|
||||
}
|
||||
|
||||
PencilHandler.squeezeStartShortcut = selectedProfile.squeezeStartShortcut
|
||||
PencilHandler.squeezeEndShortcut = selectedProfile.squeezeEndShortcut
|
||||
pressureCurveEnabled = selectedProfile.pressureCurveEnabled
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
@@ -76,6 +85,7 @@ import UIKit
|
||||
self.pencilTickEnabled = self.pencilTickEnabled && info.valid
|
||||
self.pencilProEnabled = info.valid
|
||||
PencilHandler.pencilPausesNativeTouch = selectedProfile.pencilPausesNativeTouch && info.valid
|
||||
PencilHandler.autoHoverEnabled = selectedProfile.autoPencilHover && info.valid
|
||||
if info.valid {
|
||||
self.setupPencilInteraction(view: self.streamView)
|
||||
}
|
||||
@@ -229,9 +239,21 @@ import UIKit
|
||||
|
||||
let sendableForce = targetForce
|
||||
DispatchQueue.global().asyncAfter(deadline: dispatchMoment + tickMoment + delay) {
|
||||
|
||||
if PencilHandler.autoHoverEnabled, eventType == UInt8(LI_TOUCH_EVENT_DOWN) {
|
||||
LiSendPenEvent(UInt8(LI_TOUCH_EVENT_HOVER_LEAVE), UInt8(LI_TOOL_TYPE_PEN), 0, Float(normalizedLocation.x), Float(normalizedLocation.y), 0, 0, 0, self.getRotation(fromAzimuthAngle: Float(azimuth)), self.getTilt(fromAltitudeAngle: Float(altitude)))
|
||||
}
|
||||
|
||||
LiSendPenEvent(eventType, UInt8(LI_TOOL_TYPE_PEN), 0, Float(normalizedLocation.x), Float(normalizedLocation.y), sendableForce, 0, 0, self.getRotation(fromAzimuthAngle: Float(azimuth)), self.getTilt(fromAltitudeAngle: Float(altitude)))
|
||||
if eventType == UInt8(LI_TOUCH_EVENT_UP) {
|
||||
|
||||
if PencilHandler.autoHoverEnabled, eventType == UInt8(LI_TOUCH_EVENT_UP) {
|
||||
PencilHandler.isDrawing = false
|
||||
LiSendPenEvent(UInt8(LI_TOUCH_EVENT_HOVER), UInt8(LI_TOOL_TYPE_PEN), 0, Float(normalizedLocation.x), Float(normalizedLocation.y), 0, 0, 0, self.getRotation(fromAzimuthAngle: Float(azimuth)), self.getTilt(fromAltitudeAngle: Float(altitude)))
|
||||
DispatchQueue.global().asyncAfter(deadline: .now() + 0.015){
|
||||
if !PencilHandler.isDrawing {
|
||||
LiSendPenEvent(UInt8(LI_TOUCH_EVENT_HOVER_LEAVE), UInt8(LI_TOOL_TYPE_PEN), 0, Float(normalizedLocation.x), Float(normalizedLocation.y), 0, 0, 0, self.getRotation(fromAzimuthAngle: Float(azimuth)), self.getTilt(fromAltitudeAngle: Float(altitude)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +277,7 @@ import UIKit
|
||||
private func setupPencilInteraction(view:UIView?) {
|
||||
let interaction = UIPencilInteraction()
|
||||
guard let view else { return }
|
||||
if pencilInteraction != nil {return}
|
||||
interaction.delegate = self
|
||||
view.addInteraction(interaction)
|
||||
pencilInteraction = interaction
|
||||
@@ -265,6 +288,7 @@ import UIKit
|
||||
if !pencilProEnabled {return}
|
||||
if doubleTapShorcuts.isEmpty {return}
|
||||
let keyStrings = CommandManager.shared.extractAutoReleaseButtonStrings(from: doubleTapShorcuts[shortcutIndex])
|
||||
print("pencilInteractionDidTap \(CACurrentMediaTime())")
|
||||
CommandManager.shared.sendAutoReleaseComboCommand(cmdStrings: keyStrings, delay: 0.1)
|
||||
shortcutIndex = (shortcutIndex + 1) % doubleTapShorcuts.count
|
||||
}
|
||||
@@ -275,6 +299,8 @@ import UIKit
|
||||
didReceiveSqueeze squeeze: UIPencilInteraction.Squeeze
|
||||
) {
|
||||
if !pencilProEnabled {return}
|
||||
if PencilHandler.squeezeStartShortcut == "", PencilHandler.squeezeEndShortcut == "" {return}
|
||||
|
||||
let keepPressedUntilRelease = PencilHandler.squeezeEndShortcut.uppercased() == "NULL"
|
||||
let squeezePressKeyStrings = CommandManager.shared.extractAutoReleaseButtonStrings(from: PencilHandler.squeezeStartShortcut)
|
||||
let squeezeReleaseKeyStrings = CommandManager.shared.extractAutoReleaseButtonStrings(from: PencilHandler.squeezeEndShortcut)
|
||||
|
||||
Reference in new issue
Block a user