changeset 8:dec5fe6cd0d0

Open the uinput device in write-only, and display every error.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 18 Aug 2015 02:09:15 +0100
parents 6aa40a25de22
children 5e15d64a2d24
files uinput.c
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/uinput.c
+++ b/uinput.c
@@ -28,15 +28,19 @@ int init_uinput_device(void){
     int fd = -1;
 
     if(uinput_dev == NULL){
-        fd = open("/dev/uinput", O_RDWR);
+        fd = open("/dev/uinput", O_WRONLY);
 
-        if(fd < 0)
-            fd = open("/dev/misc/uinput", O_RDWR);
+        if(fd < 0){
+            perror("open");
+            fd = open("/dev/misc/uinput", O_WRONLY);
+        }
 
-        if(fd < 0)
-            fd = open("/dev/input/uinput", O_RDWR);
+        if(fd < 0){
+            perror("open");
+            fd = open("/dev/input/uinput", O_WRONLY);
+        }
     }
-    else fd = open(uinput_dev, O_RDWR); //from xml
+    else fd = open(uinput_dev, O_WRONLY); //from xml
 
     if(fd < 0){
         perror("open");