• Sean Young's avatar
    media: lirc: implement reading scancode · de142c32
    Sean Young authored
    This implements LIRC_MODE_SCANCODE reading from the lirc device. The
    scancode can be read from the input device too, but with this interface
    you get the rc protocol, keycode, toggle and repeat status in addition
    to just the scancode.
    
    int main()
    {
    	int fd, mode, rc;
    	fd = open("/dev/lirc0", O_RDWR);
    
    	mode = LIRC_MODE_SCANCODE;
    	if (ioctl(fd, LIRC_SET_REC_MODE, &mode)) {
    		// kernel too old or lirc does not support transmit
    	}
    	struct lirc_scancode scancode;
    	while (read(fd, &scancode, sizeof(scancode)) == sizeof(scancode)) {
    		printf("protocol:%d scancode:0x%x toggle:%d repeat:%d\n",
    			scancode.rc_proto, scancode.scancode,
    			!!(scancode.flags & LIRC_SCANCODE_FLAG_TOGGLE),
    			!!(scancode.flags & LIRC_SCANCODE_FLAG_REPEAT));
    	}
    	close(fd);
    }
    Signed-off-by: default avatarSean Young <sean@mess.org>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
    de142c32
ir-lirc-codec.c 13.3 KB