Summary
I am trying to build a JAVA application (not android) that will interact with multiple barcode scanners and my plan was to use the EventInput
in order to identify which keyboard (or barcode scanner) is sending the data. This would allow having different barcodes working at the same time to scan the elements in different operations.
e.g: 1 barcode operates for the inventory, 1 is operating for the sales, etc...
While I could theoretically add a prefix on the barcode scanner to identify it (e.g: barcode 0001 becomes xx-001), I would like to keep my code more generic and reusable, such that whoever uses it doesn't have to use more costly scanners which allow for the prefix function.
Expected result
The expected result would be to be able to recognize the MAC code, the ID, the hash or any other unique id of the keyboard on keypress.
Attempts
I've tried exploring the keypress event, but the closest I got was:
public int uniqueIdTyped(KeyEvent e) {
return e.getSource().hashCode();
}
Which DOES return an id... but trying it with different devices (Kinesis keyboard
, a random regular keyboard
, leelbox portable keyboard
, on-screen keyboard
), I always get the same hashcode.