Mercurial > remote-gamepad-server
diff uinput.c @ 2:f362b20de51e
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 22 Feb 2015 18:03:26 +0100 |
parents | e70ea46d6073 |
children | 73c20831be0a |
line wrap: on
line diff
--- a/uinput.c +++ b/uinput.c @@ -19,7 +19,7 @@ -/* +/* Create a new uinput device Returns: file descriptor (-1 if error) */ @@ -29,21 +29,21 @@ int init_uinput_device(void){ if(uinput_dev == NULL){ fd = open("/dev/uinput", O_RDWR); - + if(fd < 0) fd = open("/dev/misc/uinput", O_RDWR); - + if(fd < 0) fd = open("/dev/input/uinput", O_RDWR); } else fd = open(uinput_dev, O_RDWR); //from xml - + if(fd < 0){ fprintf(stderr, " [%d] Unable to open uinput device ; hint: 'modprobe uinput' ?!\n", curdev); return -1; } - - + + memset(&dev, 0, sizeof(dev)); strncpy(dev.name, DS_NAME, UINPUT_MAX_NAME_SIZE); @@ -55,8 +55,8 @@ int init_uinput_device(void){ dev.absmax[ABS_X] = DS_MAX_X; dev.absmin[ABS_X] = DS_MIN_X; dev.absfuzz[ABS_X] = 4; - dev.absflat[ABS_X] = 2; - + dev.absflat[ABS_X] = 2; + dev.absmax[ABS_Y] = DS_MAX_Y; dev.absmin[ABS_Y] = DS_MIN_Y; dev.absfuzz[ABS_X] = 4; @@ -67,9 +67,9 @@ int init_uinput_device(void){ fprintf(stderr, " [%d] Registering device at uinput failed\n", curdev); return -1; } - + /* Keys [01] (found in <linux/input.h>) */ - if( ioctl(fd, UI_SET_EVBIT, EV_KEY) ) return -1; + if( ioctl(fd, UI_SET_EVBIT, EV_KEY) ) return -1; if( ioctl(fd, UI_SET_KEYBIT, BTN_A) ) return -1; if( ioctl(fd, UI_SET_KEYBIT, BTN_B) ) return -1; if( ioctl(fd, UI_SET_KEYBIT, BTN_X) ) return -1; @@ -78,7 +78,7 @@ int init_uinput_device(void){ if( ioctl(fd, UI_SET_KEYBIT, BTN_TR) ) return -1; if( ioctl(fd, UI_SET_KEYBIT, BTN_START) ) return -1; if( ioctl(fd, UI_SET_KEYBIT, BTN_SELECT)) return -1; - + /* D-Pad [-0xFFFF - 0xFFFF] */ if( ioctl(fd, UI_SET_EVBIT, EV_ABS) ) return -1; if( ioctl(fd, UI_SET_ABSBIT, ABS_X) ) return -1; @@ -87,7 +87,7 @@ int init_uinput_device(void){ /* Register device */ if( ioctl(fd, UI_DEV_CREATE) ) return -1; - + return fd; } @@ -99,11 +99,11 @@ int init_uinput_device(void){ int do_uinput(int fd, unsigned short key, int pressed, unsigned short event_type){ struct input_event event; memset(&event, 0 , sizeof(event)); - + event.type = event_type; event.code = key; event.value = pressed; - + if(write(fd,&event,sizeof(event)) != sizeof(event)){ fprintf(stderr, " [%d] Writing event to uinput driver failed ; Aborting\n", curdev); return false; @@ -118,7 +118,7 @@ int do_uinput(int fd, unsigned short key void flush_uinput(int fd){ struct input_event event; memset(&event, 0 , sizeof(event)); - + event.type = EV_SYN; event.code = SYN_REPORT;