aboutsummaryrefslogtreecommitdiffstats
path: root/libgamepad_open_device.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-07-12 18:50:28 +0200
committerMattias Andrée <maandree@kth.se>2023-07-12 18:50:28 +0200
commita5adfb3ea93da5f62157bc619f9945ed4675e9e2 (patch)
tree7b784646c66d9293d18ae42e81ff5f372829d7e5 /libgamepad_open_device.c
parentAdd readme (diff)
downloadlibgamepad-a5adfb3ea93da5f62157bc619f9945ed4675e9e2.tar.gz
libgamepad-a5adfb3ea93da5f62157bc619f9945ed4675e9e2.tar.bz2
libgamepad-a5adfb3ea93da5f62157bc619f9945ed4675e9e2.tar.xz
Let name, unique_id, and physical_location be empty if unavailable
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libgamepad_open_device.c')
-rw-r--r--libgamepad_open_device.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libgamepad_open_device.c b/libgamepad_open_device.c
index 27c5600..9fa438e 100644
--- a/libgamepad_open_device.c
+++ b/libgamepad_open_device.c
@@ -166,7 +166,18 @@ libgamepad_open_device(struct libgamepad_device *devicep, int dirfd, const char
#define GET_STRING(EVIOCMACRO, OUTPUT)\
do {\
for (;;) {\
- DEFER_EINTR((r = ioctl(devicep->fd, EVIOCMACRO(bufsize), buf)) < 0, fail_free_buf);\
+ while ((r = ioctl(devicep->fd, EVIOCMACRO(bufsize), buf)) < 0) {\
+ if (errno == EINTR) {\
+ devicep->internals->deferred_error = EINTR;\
+ continue;\
+ } else if (errno == ENOENT) {\
+ if (bufsize)\
+ r = 0;\
+ break;\
+ } else {\
+ goto fail_free_buf;\
+ }\
+ }\
if ((size_t)r < bufsize)\
break;\
new = realloc(buf, bufsize += 32);\