Skip to content

Commit 21c9751

Browse files
committed
Manual mouse emulation in gui touchscreen (instead of kernel-based function)
1 parent 6b4b224 commit 21c9751

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

virtual_touchscreen.clj

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,38 @@
6161

6262
(defn create-touchscreen-window [events]
6363
(def tracking-id (atom 1))
64+
(def currently-pressed (atom 0))
6465

6566
(defn send-string! [s]
6667
(locking events
6768
(swap! events (fn[_] s))
6869
(.notifyAll events)))
6970

7071
(defn toucher-moved [i x y]
71-
;; Send select-slot, touch-x, touch-y, trigger-mouse-emu and sync messages
72+
;; Send select-slot, touch-x, touch-y, x and y for mouse emulation and sync messages
7273
(send-string! (format
73-
"s %d\nX %d\nY %d\ne 0\nS 0\n"
74-
i, x, y)))
74+
"s %d\nX %d\nY %d\nx %d\ny %d\nS 0\n"
75+
i, x, y, x, y)))
7576

7677
(defn toucher-active [i flag]
77-
;; Send select-slot, tracking-id, touch-major-axis, trigger-mouse-emu and sync messages
78-
(if flag
79-
(do (send-string! (format "s %d\nT %d\n0 10\ne 0\nS 0\n", i, @tracking-id))
80-
(println @tracking-id)
81-
(swap! tracking-id (fn[i] (if (> i 10000) 1 (inc i)))))
82-
(send-string! (format "s %d\nT -1\ne 0\nS 0\n", i))))
78+
;; Send select-slot, tracking-id, touch-major-axis, pressure, trigger-mouse-emu and sync messages
79+
(send-string! (if flag
80+
(do (let [
81+
part1 (format "s %d\nT %d\n0 10\n: 100\ne 0\n", i, @tracking-id)
82+
_ (swap! tracking-id (fn[i] (if (> i 10000) 1 (inc i))))
83+
part2 (if (= @currently-pressed 0)
84+
"d 0\nS 0\n"
85+
"S 0\n")
86+
_ (swap! currently-pressed inc)
87+
] (str part1 part2)))
88+
(do (let [
89+
part1 (format "s %d\nT -1\n0 0\n: 0\ne 0\n", i)
90+
part2 (if (= @currently-pressed 1)
91+
"u 0\nS 0\n"
92+
"S 0\n")
93+
_ (swap! currently-pressed dec)
94+
] (str part1 part2))))))
95+
8396

8497
(let [
8598
panel (create-painted-panel)

0 commit comments

Comments
 (0)