diff options
author | Sean Young <sean@mess.org> | 2017-02-25 06:51:32 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-14 10:35:20 -0500 |
commit | de142c32410649e64d44928505ffad2176a96a9e (patch) | |
tree | fe6334fd19c3279bfb40eb273cc05a2d7cd36e91 /drivers/media/rc/ir-mce_kbd-decoder.c | |
parent | a6ddd4fecbb02d8ec5a865621bd2b746d585a01c (diff) | |
download | op-kernel-dev-de142c32410649e64d44928505ffad2176a96a9e.zip op-kernel-dev-de142c32410649e64d44928505ffad2176a96a9e.tar.gz |
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>
Diffstat (limited to 'drivers/media/rc/ir-mce_kbd-decoder.c')
-rw-r--r-- | drivers/media/rc/ir-mce_kbd-decoder.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index 2c9ee0c..8cf4cf3 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c @@ -215,6 +215,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev) struct mce_kbd_dec *data = &dev->raw->mce_kbd; u32 scancode; unsigned long delay; + struct lirc_scancode lsc = {}; if (!is_timing_event(ev)) { if (ev.reset) @@ -326,18 +327,22 @@ again: mod_timer(&data->rx_timeout, jiffies + delay); /* Pass data to keyboard buffer parser */ ir_mce_kbd_process_keyboard_data(data->idev, scancode); + lsc.rc_proto = RC_PROTO_MCIR2_KBD; break; case MCIR2_MOUSE_NBITS: scancode = data->body & 0x1fffff; IR_dprintk(1, "mouse data 0x%06x\n", scancode); /* Pass data to mouse buffer parser */ ir_mce_kbd_process_mouse_data(data->idev, scancode); + lsc.rc_proto = RC_PROTO_MCIR2_MSE; break; default: IR_dprintk(1, "not keyboard or mouse data\n"); goto out; } + lsc.scancode = scancode; + ir_lirc_scancode_event(dev, &lsc); data->state = STATE_INACTIVE; input_event(data->idev, EV_MSC, MSC_SCAN, scancode); input_sync(data->idev); |