summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-16 14:11:51 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-16 14:37:01 -0400
commitc6d2a0358f221be41450503b45a4f14db14bf690 (patch)
tree80af5b360d9b54238a1247d93215d2a4f2c5a556
parent1a76bc403e647ac40f2218dd3808ce8b3f9a80d9 (diff)
downloadrockbox-c6d2a0358f221be41450503b45a4f14db14bf690.tar.gz
rockbox-c6d2a0358f221be41450503b45a4f14db14bf690.zip
hosted: open input device as read-only.
Change-Id: I4dcd98f45f41fe06a0a75a2a0dd45c753c2cf365
-rw-r--r--firmware/target/hosted/agptek/button-agptek.c5
-rw-r--r--firmware/target/hosted/aigo/button-erosq.c8
-rw-r--r--firmware/target/hosted/fiio/button-fiio.c10
-rw-r--r--firmware/target/hosted/sonynwz/button-nwz.c2
-rw-r--r--firmware/target/hosted/xduoo/button-xduoo.c4
5 files changed, 14 insertions, 15 deletions
diff --git a/firmware/target/hosted/agptek/button-agptek.c b/firmware/target/hosted/agptek/button-agptek.c
index 83953e0dab..2c84a50405 100644
--- a/firmware/target/hosted/agptek/button-agptek.c
+++ b/firmware/target/hosted/agptek/button-agptek.c
@@ -70,14 +70,14 @@ static int button_map(int keycode)
70 70
71void button_init_device(void) 71void button_init_device(void)
72{ 72{
73 const char * const input_devs[] = { 73 const char * const input_devs[NR_POLL_DESC] = {
74 "/dev/input/event0", 74 "/dev/input/event0",
75 "/dev/input/event1" 75 "/dev/input/event1"
76 }; 76 };
77 77
78 for(int i = 0; i < NR_POLL_DESC; i++) 78 for(int i = 0; i < NR_POLL_DESC; i++)
79 { 79 {
80 int fd = open(input_devs[i], O_RDWR | O_CLOEXEC); 80 int fd = open(input_devs[i], O_RDONLY | O_CLOEXEC);
81 81
82 if(fd < 0) 82 if(fd < 0)
83 { 83 {
@@ -146,4 +146,3 @@ void button_close_device(void)
146 close(poll_fds[i].fd); 146 close(poll_fds[i].fd);
147 } 147 }
148} 148}
149
diff --git a/firmware/target/hosted/aigo/button-erosq.c b/firmware/target/hosted/aigo/button-erosq.c
index 2735c48c71..db7f7e24e5 100644
--- a/firmware/target/hosted/aigo/button-erosq.c
+++ b/firmware/target/hosted/aigo/button-erosq.c
@@ -38,7 +38,7 @@
38#include "backlight-target.h" 38#include "backlight-target.h"
39#include "erosqlinux_codec.h" 39#include "erosqlinux_codec.h"
40 40
41#define NR_POLL_DESC 3 41#define NR_POLL_DESC 2
42static struct pollfd poll_fds[NR_POLL_DESC]; 42static struct pollfd poll_fds[NR_POLL_DESC];
43 43
44static int button_map(int keycode) 44static int button_map(int keycode)
@@ -82,18 +82,18 @@ static int button_map(int keycode)
82 82
83void button_init_device(void) 83void button_init_device(void)
84{ 84{
85 const char * const input_devs[] = { 85 const char * const input_devs[NR_POLL_DESC] = {
86 "/dev/input/event0", // Rotary encoder 86 "/dev/input/event0", // Rotary encoder
87 "/dev/input/event1" // Keys 87 "/dev/input/event1" // Keys
88 }; 88 };
89 89
90 for(int i = 0; i < NR_POLL_DESC; i++) 90 for(int i = 0; i < NR_POLL_DESC; i++)
91 { 91 {
92 int fd = open(input_devs[i], O_RDWR | O_CLOEXEC); 92 int fd = open(input_devs[i], O_RDONLY | O_CLOEXEC);
93 93
94 if(fd < 0) 94 if(fd < 0)
95 { 95 {
96 panicf("Cannot open input device: %s\n", input_devs[i]); 96 panicf("Cannot open input device: %s (%d)\n", input_devs[i], errno);
97 } 97 }
98 98
99 poll_fds[i].fd = fd; 99 poll_fds[i].fd = fd;
diff --git a/firmware/target/hosted/fiio/button-fiio.c b/firmware/target/hosted/fiio/button-fiio.c
index 79ed702668..134ec5a426 100644
--- a/firmware/target/hosted/fiio/button-fiio.c
+++ b/firmware/target/hosted/fiio/button-fiio.c
@@ -85,7 +85,7 @@ static int button_map_on(int keycode)
85 case KEY_F8: 85 case KEY_F8:
86 key_power_delay = 0; 86 key_power_delay = 0;
87 return BUTTON_POWER; 87 return BUTTON_POWER;
88 88
89 case KEY_HOME: 89 case KEY_HOME:
90 key_home_delay = DEF_DELAY; 90 key_home_delay = DEF_DELAY;
91 return BUTTON_OPTION; 91 return BUTTON_OPTION;
@@ -147,7 +147,7 @@ static int button_map_off(int keycode)
147 147
148 case KEY_F8: 148 case KEY_F8:
149 return BUTTON_POWER; 149 return BUTTON_POWER;
150 150
151 case KEY_F9: 151 case KEY_F9:
152 return BUTTON_OPTION; 152 return BUTTON_OPTION;
153 153
@@ -168,7 +168,7 @@ static int button_map_off(int keycode)
168static int button_map_timer(void) 168static int button_map_timer(void)
169{ 169{
170 int map = 0; 170 int map = 0;
171 171
172 if (key_enter_delay) 172 if (key_enter_delay)
173 { 173 {
174 if (--key_enter_delay == 0) map |= BUTTON_PLAY; 174 if (--key_enter_delay == 0) map |= BUTTON_PLAY;
@@ -219,14 +219,14 @@ static int button_map_timer(void)
219 219
220void button_init_device(void) 220void button_init_device(void)
221{ 221{
222 const char * const input_devs[] = { 222 const char * const input_devs[NR_POLL_DESC] = {
223 "/dev/input/event0", 223 "/dev/input/event0",
224 "/dev/input/event1", 224 "/dev/input/event1",
225 }; 225 };
226 226
227 for(int i = 0; i < NR_POLL_DESC; i++) 227 for(int i = 0; i < NR_POLL_DESC; i++)
228 { 228 {
229 int fd = open(input_devs[i], O_RDWR | O_CLOEXEC); 229 int fd = open(input_devs[i], O_RDONLY | O_CLOEXEC);
230 230
231 if(fd < 0) 231 if(fd < 0)
232 { 232 {
diff --git a/firmware/target/hosted/sonynwz/button-nwz.c b/firmware/target/hosted/sonynwz/button-nwz.c
index 2fb23e1471..f85a4be496 100644
--- a/firmware/target/hosted/sonynwz/button-nwz.c
+++ b/firmware/target/hosted/sonynwz/button-nwz.c
@@ -156,7 +156,7 @@ static void key_init_state(int fd)
156 156
157static void open_input_device(const char *path) 157static void open_input_device(const char *path)
158{ 158{
159 int fd = open(path, O_RDWR); 159 int fd = open(path, O_RDONLY | O_CLOEXEC);
160 if(fd < 0) 160 if(fd < 0)
161 return; 161 return;
162 /* query name */ 162 /* query name */
diff --git a/firmware/target/hosted/xduoo/button-xduoo.c b/firmware/target/hosted/xduoo/button-xduoo.c
index 3dc1bdc13a..67cb9a6c46 100644
--- a/firmware/target/hosted/xduoo/button-xduoo.c
+++ b/firmware/target/hosted/xduoo/button-xduoo.c
@@ -76,7 +76,7 @@ static int button_map(int keycode)
76 76
77void button_init_device(void) 77void button_init_device(void)
78{ 78{
79 const char * const input_devs[] = { 79 const char * const input_devs[NR_POLL_DESC] = {
80 "/dev/input/event0", 80 "/dev/input/event0",
81 "/dev/input/event1", 81 "/dev/input/event1",
82 "/dev/input/event2" 82 "/dev/input/event2"
@@ -84,7 +84,7 @@ void button_init_device(void)
84 84
85 for(int i = 0; i < NR_POLL_DESC; i++) 85 for(int i = 0; i < NR_POLL_DESC; i++)
86 { 86 {
87 int fd = open(input_devs[i], O_RDWR | O_CLOEXEC); 87 int fd = open(input_devs[i], O_RDONLY | O_CLOEXEC);
88 88
89 if(fd < 0) 89 if(fd < 0)
90 { 90 {