]> git.basschouten.com Git - openhab-addons.git/commitdiff
[linuxinput] Handle all kinds of buttons (#10730)
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 23 May 2021 19:03:14 +0000 (21:03 +0200)
committerGitHub <noreply@github.com>
Sun, 23 May 2021 19:03:14 +0000 (21:03 +0200)
Previously only the basic keyboard buttons where handled.
Now all buttons known to Linux, or rather libevdev are reported.

Reported-in: https://community.openhab.org/t/linuxinput-binding-and-mouse-capture/122612
Reported-in: https://github.com/t-8ch/binding-linuxinput/issues/5

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
bundles/org.openhab.binding.linuxinput/src/main/java/org/openhab/binding/linuxinput/internal/evdev4j/EvdevDevice.java
bundles/org.openhab.binding.linuxinput/src/main/java/org/openhab/binding/linuxinput/internal/evdev4j/jnr/EvdevLibrary.java

index f2ca21cf968e9da964928b589f3765b153d54af3..978aee31a9354a319f0dfb441f8afc57275bf616 100644 (file)
@@ -189,7 +189,7 @@ public class EvdevDevice implements Closeable {
 
     public Collection<Key> enumerateKeys() {
         int minKey = 0;
-        int maxKey = 255 - 1;
+        int maxKey = lib.event_type_get_max(EvdevLibrary.Type.KEY.intValue());
         List<Key> result = new ArrayList<>();
         for (int i = minKey; i <= maxKey; i++) {
             if (has(EvdevLibrary.Type.KEY, i)) {
@@ -215,6 +215,11 @@ public class EvdevDevice implements Closeable {
         public String getName() {
             return lib.event_code_get_name(EvdevLibrary.Type.KEY.intValue(), code);
         }
+
+        @Override
+        public String toString() {
+            return String.valueOf(code);
+        }
     }
 
     public static class InputEvent {
index 2a26425e37c413d2aa143b20e00e485e12a1c882..7eca6b89bf1a0c6b734ff15530cf63afc0bd67bf 100644 (file)
@@ -98,6 +98,8 @@ public interface EvdevLibrary {
 
     int enable_event_type(@In Handle handle, int type);
 
+    int event_type_get_max(int type);
+
     int disable_event_type(@In Handle handle, int type);
 
     boolean has_event_code(@In Handle handle, int type, int code);