Multi touch API for Linux on Java
libjam-mt is a library for linux written in C and Java. It allows for multitouch input in Java for linux systems that use X11. It automatically attaches to the currently focused window and listens for touch events only. It currently is in Beta and is being developed.
It uses libmtdev to emulate kernel input events on the focused windows, which those events via JNI are sent to the TouchHandler Java class which does processing and further forwards it the referenced listeners. The events called are as follows; onTouch(double x, double y, int id)
is called when the users creates a touch, onUpdate(double x, double y, int id
is called when the touch of the id
is still active and has moved, and finally onRelease(double x, double y, int id)
which is called when the user releases their finger from the screen, of touch id specified in int id
.
you will need to run chmod +x script
on all of the provided scripts in order to run them.
Installation is fairly complicated but can be done fairly easily. The following explain each step in a fair amount of detail.
You may skip this step if you know you have your drivers installed, if you do not visit this website for detailed steps on how to configure your kernel.
In order to use multitouch you must load the module each time at boot. To do this simply add hid-multitouch
in your /etc/modules/
files. If you do not have this file or prefer an alternate method, add sudo modprobe hid-multitouch
to your /etc/rc.local
file.
The next step is to tell the module what device to use. This can be done by adding echo W X Y Z > /sys/module/hid_multitouch/drivers/hid\:hid-multitouch/new_id
to the /etc/rc.local
file after loading in the module where W, X, Y, Z stand for:
I have a chalk-panel so the Z stood for:
If you do not have one of those panels refer to this website for details on how to obtain your id.
libjam-mt
requires a few libraries to function properly so you will need to install them. Run:
sudo apt-get install git libmtdev-dev libutouch-frame-dev libutouch-evemu-dev libc-dev libxmu-dev
The package names may vary on your system.
This is easy. cd
into a directory you like and run git clone https://github.com/shahbaz-man/libjam-mt.git
. This should produce a folder call libjam-mt
. Next cd
into this directory.
5) Run sudo ./frc
. This should autobuild the native libraries, compile the Java code and run the application. If you did everything right the program should output the X, Y and ID of touches. If you've made it this far then congrats! You can start using the library.
NOTE: If if doesn't work there maybe several reasons:
- You need to set the
-Djava.library.path
to the library location - You will need to change the jdk include paths. In the script assemble, replace -I/opt/jdk/include with /path/to/jdk/include and -I/opt/jdk/include/linux to -I/path/to/jdk/include/linux
- You may need a reboot.
- You must run as
root
because the C lib needs access to/dev/input/eventX
- You may need to change the
/dev/input/eventX
number. You can change this in ./run. In the linejava -D...
the last parameter should be replaced with your event device number
Just email me at shahbaz.man3@gmail.com and I will get back to you as soon as I can.