Skip to content

Commit

Permalink
fix: start mouse timing when mouse-position command is executed
Browse files Browse the repository at this point in the history
Previously it started on mouse down
  • Loading branch information
socsieng committed Jan 5, 2021
1 parent 615e64b commit 1437aac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/SendKeysLib/MouseEventProcessor.swift
Expand Up @@ -94,6 +94,10 @@ struct MouseEvent: CustomStringConvertible {
class MouseEventProcessor {
var events: [RawMouseEvent] = []
var lastDate: Date = Date()

func start() {
lastDate = Date()
}

func consumeEvent(type: CGEventType, event: CGEvent) -> MouseEvent? {
let button = getMouseButton(type: type, event: event)
Expand Down
2 changes: 2 additions & 0 deletions Sources/SendKeysLib/MousePosition.swift
Expand Up @@ -61,6 +61,8 @@ class MousePosition: ParsableCommand {

func watchMouseInput() {
fputs("Waiting for mouse input... ctrl + c to stop.\n", stderr)

MousePosition.eventProcessor.start()

var eventMask = (1 << CGEventType.leftMouseDown.rawValue)
| (1 << CGEventType.leftMouseUp.rawValue)
Expand Down

0 comments on commit 1437aac

Please sign in to comment.