|
61 | 61 |
|
62 | 62 | (defn create-touchscreen-window [events] |
63 | 63 | (def tracking-id (atom 1)) |
| 64 | + (def currently-pressed (atom 0)) |
64 | 65 |
|
65 | 66 | (defn send-string! [s] |
66 | 67 | (locking events |
67 | 68 | (swap! events (fn[_] s)) |
68 | 69 | (.notifyAll events))) |
69 | 70 |
|
70 | 71 | (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 |
72 | 73 | (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))) |
75 | 76 |
|
76 | 77 | (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 | + |
83 | 96 |
|
84 | 97 | (let [ |
85 | 98 | panel (create-painted-panel) |
|
0 commit comments