]> asedeno.scripts.mit.edu Git - linux.git/commit
media: lirc: implement reading scancode
authorSean Young <sean@mess.org>
Sat, 25 Feb 2017 11:51:32 +0000 (06:51 -0500)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Thu, 14 Dec 2017 15:35:20 +0000 (10:35 -0500)
commitde142c32410649e64d44928505ffad2176a96a9e
treefe6334fd19c3279bfb40eb273cc05a2d7cd36e91
parenta6ddd4fecbb02d8ec5a865621bd2b746d585a01c
media: lirc: implement reading scancode

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: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/rc/ir-lirc-codec.c
drivers/media/rc/ir-mce_kbd-decoder.c
drivers/media/rc/lirc_dev.c
drivers/media/rc/rc-core-priv.h
drivers/media/rc/rc-main.c
include/media/rc-core.h