I wasn’t supposed to be doing this today, but:
Multitouch support on Linux seems much simpler with a different library than SMT that I was unsuccessfully tryin last year. “Simple Touch” actually “just works” via evdev library. The only thing that was needed was to supply the right event device from /dev/input and also make it readable and writable for normal user.
Find out which event device is your touch screen:
1 2 3 4 5 6 7 8 9 10 11 |
$ xinput ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ USB Keyboard id=9 [slave pointer (2)] ⎜ ↳ Kensington Kensington Slimblade Trackball id=10 [slave pointer (2)] ⎜ ↳ Advanced Silicon S.A CoolTouch(TM) System id=11 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Power Button id=7 [slave keyboard (3)] ↳ USB Keyboard id=8 [slave keyboard (3)] |
Above you see that id of the touch-screen is 11. Which means we have to allow access to /dev/input/event11.
1 |
$ sudo chmod 777 /dev/input/event11 |
Alternatively (and perhaps much more reliably) one should check the contents of /dev/input/by-id/
1 2 3 4 5 6 7 8 |
$ ls -al /dev/input/by-id/ random@zarquon:~$ ll /dev/input/by-id/ usb-04d9_USB_Keyboard-event-kbd -> ../event2 usb-04d9_USB_Keyboard-if02-event-mouse -> ../event3 usb-04d9_USB_Keyboard-if02-mouse -> ../mouse0 usb-Advanced_Silicon_S.A_CoolTouch_TM__System-event-if00 -> ../event5 usb-Kensington_Kensington_Slimblade_Trackball-event-mouse -> ../event4 usb-Kensington_Kensington_Slimblade_Trackball-mouse -> ../mouse1 |
You can see that the touch-screen reports to be device “../event5”.
Simple Touch library is available from the Tools menu in Processing, but also here:
https://github.com/gohai/processing-simpletouch/
In Processing there is couple of examples for Simple Touch library, but the essence for a successful start is
1) list devices
1 2 3 |
println("Available input devices:"); String[] devs = SimpleTouch.list(); printArray(devs); |
will output something like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Available input devices: [0] "event0" [1] "event1" [2] "event10" [3] "event11" [4] "event12" [5] "event13" [6] "event14" [7] "event15" [8] "event16" [9] "event2" [10] "event3" [11] "event4" [12] "event5" [13] "event6" [14] "event7" [15] "event8" [16] "event9" |
Touch-screen (event11) has [3] index, so to open this device you finally use
1 2 |
touchscreen = new SimpleTouch(this, devs[3]); println("Opened device: " + touchscreen.name()); |
It seems also to be possible to do just this:
1 |
touchscreen = new SimpleTouch(this, "event11"); |
and the following also works:
1 |
touchscreen = new SimpleTouch(this, "by-id/usb-Advanced_Silicon_S.A_CoolTouch_TM__System-event-if00"); |
This opens the door for writing multitouch interfaces in Processing, which however means a lot more work. For now it seems a good way to go with writing control GUI in SuperCollider, but eventually, the Processing possibility seems like very interesting and inviting.
So a final complete working example for my machine is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gohai.simpletouch.*; SimpleTouch touchscreen; void setup() { fullScreen(); colorMode(HSB, 360, 100, 100); noStroke(); println("Available input devices:"); String[] devs = SimpleTouch.list(); printArray(devs); if (devs.length == 0) { println("No input devices available"); exit(); } touchscreen = new SimpleTouch(this, "by-id/usb-Advanced_Silicon_S.A_CoolTouch_TM__System-event-if00"); println("Opened device: " + touchscreen.name()); } void draw() { background(0); SimpleTouchEvt touches[] = touchscreen.touches(); for (SimpleTouchEvt touch : touches) { // the id value is used to track each touch // we use it to assign a unique color fill((touch.id * 100) % 360, 100, 100); // x and y are values from 0.0 to 1.0 ellipse(width * touch.x, height * touch.y, 100, 100); } } |