|
62 | 62 | (defn create-touchscreen-window [events] |
63 | 63 | (def tracking-id (atom 1)) |
64 | 64 | (def currently-pressed (atom 0)) |
| 65 | + (def master-slot (atom nil)) ;; the slot that it pressed first and used for mouse emulation |
65 | 66 |
|
66 | 67 | (defn send-string! [s] |
67 | 68 | (locking events |
|
70 | 71 |
|
71 | 72 | (defn toucher-moved [i x y] |
72 | 73 | ;; Send select-slot, touch-x, touch-y, x and y for mouse emulation and sync messages |
73 | | - (send-string! (format |
74 | | - "s %d\nX %d\nY %d\nx %d\ny %d\nS 0\n" |
75 | | - i, x, y, x, y))) |
| 74 | + (send-string! |
| 75 | + (if (or (= i @master-slot) (= nil @master-slot)) |
| 76 | + (format "s %d\nX %d\nY %d\nx %d\ny %d\nS 0\n" i, x, y, x, y) |
| 77 | + (format "s %d\nX %d\nY %d\nS 0\n" i, x, y) |
| 78 | + ) |
| 79 | + )) |
76 | 80 |
|
77 | 81 | (defn toucher-active [i flag] |
78 | 82 | ;; Send select-slot, tracking-id, touch-major-axis, pressure, trigger-mouse-emu and sync messages |
|
81 | 85 | part1 (format "s %d\nT %d\n0 10\n: 100\ne 0\n", i, @tracking-id) |
82 | 86 | _ (swap! tracking-id (fn[i] (if (> i 10000) 1 (inc i)))) |
83 | 87 | part2 (if (= @currently-pressed 0) |
84 | | - "d 0\nS 0\n" |
| 88 | + (do |
| 89 | + (swap! master-slot (fn[_] i)) |
| 90 | + "d 0\nS 0\n" |
| 91 | + ) |
85 | 92 | "S 0\n") |
86 | 93 | _ (swap! currently-pressed inc) |
87 | 94 | ] (str part1 part2))) |
88 | 95 | (do (let [ |
89 | 96 | part1 (format "s %d\nT -1\n0 0\n: 0\ne 0\n", i) |
90 | 97 | part2 (if (= @currently-pressed 1) |
91 | | - "u 0\nS 0\n" |
| 98 | + (do |
| 99 | + (swap! master-slot (fn[_] nil)) |
| 100 | + "u 0\nS 0\n" |
| 101 | + ) |
92 | 102 | "S 0\n") |
93 | 103 | _ (swap! currently-pressed dec) |
94 | 104 | ] (str part1 part2)))))) |
|
0 commit comments