mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
Merge pull request #542 from HiassofT/lirc-fix
lirc: re-add patch to support additional keys
This commit is contained in:
commit
de6f79d04b
110
packages/sysutils/lirc/patches/lirc-0005-uinput.patch
Normal file
110
packages/sysutils/lirc/patches/lirc-0005-uinput.patch
Normal file
@ -0,0 +1,110 @@
|
||||
diff --git a/daemons/lircd-uinput.cpp b/daemons/lircd-uinput.cpp
|
||||
index 6a619e9..1bee48b 100644
|
||||
--- a/daemons/lircd-uinput.cpp
|
||||
+++ b/daemons/lircd-uinput.cpp
|
||||
@@ -135,6 +135,8 @@ int setup_uinputfd(const char* path)
|
||||
{
|
||||
int fd;
|
||||
int key;
|
||||
+ linux_input_code code;
|
||||
+ int i;
|
||||
struct uinput_user_dev dev;
|
||||
|
||||
fd = open(path, O_RDWR);
|
||||
@@ -150,9 +152,14 @@ int setup_uinputfd(const char* path)
|
||||
|| ioctl(fd, UI_SET_EVBIT, EV_REP) != 0)
|
||||
goto setup_error;
|
||||
|
||||
- for (key = KEY_RESERVED; key <= KEY_UNKNOWN; key++)
|
||||
- if (ioctl(fd, UI_SET_KEYBIT, key) != 0)
|
||||
- goto setup_error;
|
||||
+ for (i = 0; get_input_code_by_index(i, &code) >= 0; i++) {
|
||||
+ key = (int)code;
|
||||
+ if (((key >= KEY_ESC) && (key <= KEY_RFKILL)) ||
|
||||
+ ((key >= KEY_OK ) && (key <= KEY_WPS_BUTTON))) {
|
||||
+ if (ioctl(fd, UI_SET_KEYBIT, key) != 0)
|
||||
+ goto setup_error;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
if (ioctl(fd, UI_DEV_CREATE) != 0)
|
||||
goto setup_error;
|
||||
diff --git a/daemons/lircd.cpp b/daemons/lircd.cpp
|
||||
index 782b6d3..020c57e 100644
|
||||
--- a/daemons/lircd.cpp
|
||||
+++ b/daemons/lircd.cpp
|
||||
@@ -695,6 +695,8 @@ int setup_uinputfd(const char* name)
|
||||
#if defined(__linux__)
|
||||
int fd;
|
||||
int key;
|
||||
+ linux_input_code code;
|
||||
+ int i;
|
||||
struct uinput_user_dev dev;
|
||||
|
||||
fd = open("/dev/input/uinput", O_RDWR);
|
||||
@@ -715,9 +717,14 @@ int setup_uinputfd(const char* name)
|
||||
|| ioctl(fd, UI_SET_EVBIT, EV_REP) != 0)
|
||||
goto setup_error;
|
||||
|
||||
- for (key = KEY_RESERVED; key <= KEY_UNKNOWN; key++)
|
||||
- if (ioctl(fd, UI_SET_KEYBIT, key) != 0)
|
||||
- goto setup_error;
|
||||
+ for (i = 0; get_input_code_by_index(i, &code) >= 0; i++) {
|
||||
+ key = (int)code;
|
||||
+ if (((key >= KEY_ESC) && (key <= KEY_RFKILL)) ||
|
||||
+ ((key >= KEY_OK ) && (key <= KEY_WPS_BUTTON))) {
|
||||
+ if (ioctl(fd, UI_SET_KEYBIT, key) != 0)
|
||||
+ goto setup_error;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
if (ioctl(fd, UI_DEV_CREATE) != 0)
|
||||
goto setup_error;
|
||||
diff --git a/lib/input_map.c b/lib/input_map.c
|
||||
index 7c54301..31341b7 100644
|
||||
--- a/lib/input_map.c
|
||||
+++ b/lib/input_map.c
|
||||
@@ -29,6 +29,19 @@ struct {
|
||||
}
|
||||
};
|
||||
|
||||
+int get_input_code_by_index(int index, linux_input_code * code)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; input_map[i].name != NULL; i++) {
|
||||
+ if (i == index) {
|
||||
+ *code = input_map[i].code;
|
||||
+ return i;
|
||||
+ }
|
||||
+ }
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
int get_input_code(const char* name, linux_input_code* code)
|
||||
{
|
||||
int i;
|
||||
diff --git a/lib/input_map.h b/lib/input_map.h
|
||||
index f5798d0..1efa4f1 100644
|
||||
--- a/lib/input_map.h
|
||||
+++ b/lib/input_map.h
|
||||
@@ -36,6 +36,7 @@ typedef __u16 linux_input_code;
|
||||
typedef unsigned short linux_input_code;
|
||||
#endif
|
||||
|
||||
+int get_input_code_by_index(int index, linux_input_code * code);
|
||||
int get_input_code(const char* name, linux_input_code* code);
|
||||
void fprint_namespace(FILE* f);
|
||||
int is_in_namespace(const char* name);
|
||||
diff --git a/lib/lirc/input_map.h b/lib/lirc/input_map.h
|
||||
index f5798d0..1efa4f1 100644
|
||||
--- a/lib/lirc/input_map.h
|
||||
+++ b/lib/lirc/input_map.h
|
||||
@@ -36,6 +36,7 @@ typedef __u16 linux_input_code;
|
||||
typedef unsigned short linux_input_code;
|
||||
#endif
|
||||
|
||||
+int get_input_code_by_index(int index, linux_input_code * code);
|
||||
int get_input_code(const char* name, linux_input_code* code);
|
||||
void fprint_namespace(FILE* f);
|
||||
int is_in_namespace(const char* name);
|
Loading…
x
Reference in New Issue
Block a user