Skip to content

Commit

Permalink
[linuxinput] Handle all kinds of buttons (#10730)
Browse files Browse the repository at this point in the history
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: t-8ch/binding-linuxinput#5

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
  • Loading branch information
t-8ch authored May 23, 2021
1 parent 66a5402 commit e2fa4ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void enable(EvdevLibrary.Type type, int code) {

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)) {
Expand All @@ -215,6 +215,11 @@ public int getCode() {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public InputEvent(Runtime runtime) {

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);
Expand Down

0 comments on commit e2fa4ba

Please sign in to comment.