Skip to content

Commit

Permalink
iOS: Let RApplication handle touch events when TouchMouse not enabled (
Browse files Browse the repository at this point in the history
  • Loading branch information
warmenhoven authored Sep 27, 2024
1 parent 443348f commit d7839bb
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions pkg/apple/MouseEmulation/EmulatorTouchMouse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,7 @@ import UIKit
}

public func touchesBegan(touches: Set<UITouch>, event: UIEvent?) {
guard enabled, let touch = touches.first else {
if #available(iOS 13.4, *), let _ = touches.first {
let isLeftClick=(event?.buttonMask == UIEvent.ButtonMask.button(1))
delegate?.handleMouseClick(isLeftClick: isLeftClick, isPressed: true)
}
return
}
guard enabled, let touch = touches.first else { return }
if primaryTouch == nil {
primaryTouch = TouchInfo(touch: touch, origin: touch.location(in: view), holdState: .wait)
if touch.tapCount == 2 {
Expand All @@ -132,15 +126,7 @@ import UIKit
}

public func touchesEnded(touches: Set<UITouch>, event: UIEvent?) {
guard enabled else {
if #available(iOS 13.4, *) {
let isLeftClick=(event?.buttonMask == UIEvent.ButtonMask.button(1))
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
self?.delegate?.handleMouseClick(isLeftClick: isLeftClick, isPressed: false)
}
}
return
}
guard enabled else { return }
for touch in touches {
if touch == primaryTouch?.touch {
if touch.tapCount > 0 {
Expand Down Expand Up @@ -177,13 +163,7 @@ import UIKit
}

public func touchesCancelled(touches: Set<UITouch>, event: UIEvent?) {
guard enabled else {
if #available(iOS 13.4, *) {
let isLeftClick=(event?.buttonMask == UIEvent.ButtonMask.button(1))
delegate?.handleMouseClick(isLeftClick: isLeftClick, isPressed: false)
}
return
}
guard enabled else { return }
for touch in touches {
if touch == primaryTouch?.touch {
endHold()
Expand Down

0 comments on commit d7839bb

Please sign in to comment.