Mercurial > remote-gamepad-server
comparison uinput.c @ 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 |
comparison
equal
deleted
inserted
replaced
| 7:6aa40a25de22 | 8:dec5fe6cd0d0 |
|---|---|
| 26 int init_uinput_device(void){ | 26 int init_uinput_device(void){ |
| 27 struct uinput_user_dev dev; | 27 struct uinput_user_dev dev; |
| 28 int fd = -1; | 28 int fd = -1; |
| 29 | 29 |
| 30 if(uinput_dev == NULL){ | 30 if(uinput_dev == NULL){ |
| 31 fd = open("/dev/uinput", O_RDWR); | 31 fd = open("/dev/uinput", O_WRONLY); |
| 32 | 32 |
| 33 if(fd < 0) | 33 if(fd < 0){ |
| 34 fd = open("/dev/misc/uinput", O_RDWR); | 34 perror("open"); |
| 35 fd = open("/dev/misc/uinput", O_WRONLY); | |
| 36 } | |
| 35 | 37 |
| 36 if(fd < 0) | 38 if(fd < 0){ |
| 37 fd = open("/dev/input/uinput", O_RDWR); | 39 perror("open"); |
| 40 fd = open("/dev/input/uinput", O_WRONLY); | |
| 41 } | |
| 38 } | 42 } |
| 39 else fd = open(uinput_dev, O_RDWR); //from xml | 43 else fd = open(uinput_dev, O_WRONLY); //from xml |
| 40 | 44 |
| 41 if(fd < 0){ | 45 if(fd < 0){ |
| 42 perror("open"); | 46 perror("open"); |
| 43 fprintf(stderr, " [%d] Unable to open uinput device ; hint: 'modprobe uinput' ?!\n", curdev); | 47 fprintf(stderr, " [%d] Unable to open uinput device ; hint: 'modprobe uinput' ?!\n", curdev); |
| 44 return -1; | 48 return -1; |
