Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access a hardware button in Java

I have an industrial touchscreen tablet device running windows7 (this one). It has an integrated RFID/Barcode scanner and camera. Both can be started via a hardware button. I would like to recognize, whenever one of these buttons is pressed. I wrote a small test app with a GlobalKeyEventListener, but no event is fired, when one of these buttons is pressed. All normal keyboard events are fired. Does anyone know, if and how these type of button events can be accessed in Java? What else should I try, before telling the customer, that it isn't possible. Thanks.

like image 546
haferblues Avatar asked Mar 26 '13 11:03

haferblues


1 Answers

There is going to be some programming interface for listening for these buttons, and it is unlikely to have a connection to a Java Virtual Machine built in. I would look into writing a program/service/whatever that listened for those button pushes that I could compile into a Windows DLL, and then I would call the DLL from the Java program. Windows DLLs can listen for things, and Java classes can register themselves as listeners for events from the DLLs. It isn't likely to be trivial, the hardest part for me would be the DLL program itself (no java there, C or C# or something Microsoft likes), followed by the Java Native Interface or API or whatever to call the DLL.

If you get that far, I do recommend a product which name I do not remember; it allows you to call DLLs without using any JNI 'glue' code at all, i.e., used to be you had to write C code with a very specific set of rules to call from Java, and this other product nicely eliminates that entirely.

Good luck.

like image 132
arcy Avatar answered Sep 29 '22 07:09

arcy