[mythtv-users] Infra-red Remote as keyboard

Paul Andreassen paulx at andreassen.com.au
Fri Dec 2 09:23:55 EST 2005


On Wed, 30 Nov 2005 12:37 am, David Watkins wrote:
> > David Watkins mentioned that you can use LIRC to change the keys of the
> > remote.  I think he was referring to a ATI remote which uses the
> > ati_remote.ko kernel module.  LIRC has its own kernel module for that
> > remote. I'm not sure you can use LIRC with a usbhid device that thinks it
> > is a keyboard.
>
> No, I'm using a nova-t card.  The ir receiver plugs into the capture
> card and is handled by one of the cx88 modules ( I forget which
> exactly ), but it does end up thinking it's a keyboard.
>
> In case it helps you, this is the way my nova-t works.
>
> On loading the dvb module, a new device gets created for the remote
>
> /dev/input/event0     (if I don't have any other input devices)
> /dev/input/event1     (if I have a keyboard connected)
> etc
>
> and keypresses from both the standard keyboard and the remote control
> are sent to the keyboard buffer. (eg pressing the '1' on the remote
> control produces a '1 on the screen if I'm in a terminal window at the
> input prompt).
>
> So at this point the remote could be working with mythtv, all without
> touching lirc.  However,  it wasn't working for me for two reason.
>
> 1)   Very few of the remote keys worked at all.  eg. the remote
> keypresses were not mapped to valid keycodes (as defined in input.h),
> and pressing them just produced an error in dmesg.  Of those that did
> work, they weren't necessarily mapped to the key that mythtv expected.
>
> 2)   The key repeat rate was much too fast.  ie it was almost
> impossible to send a single keypress, which made scrolling up and down
> difficult to control and pressing enter a bit of a lottery as I dived
> down through menu levels.
>
> I solved (1) by editing cx88_input.c and recompiling the cx88 modules
> (a BIG learning experience for me).
>
> and I solved (2) by running lircd and connecting it to the correct
> input/event device. This allows for more flexible key mapping and
> control of the repeat rate.
>
> So, if loading your usb module produces a /dev device, such that
>
> $cat /dev/<device>
>
> produces stuff on the screen when you press buttons on your remote
> then maybe the same approach is usefull for you.
>
>
> One gotcha is that if I don't have a keyboard then the ir device is on
> /dev/input/event0, so I configure lircd to be automatically started,
> attached to this device.
>
> Adding a keyboard bumps the device numbers up, with the result that
> neither the keyboard nor the remote work.  Someone on this list kindly
> sent me a script that detects which device the nova-t remote is on,
> and starts lircd accordingly.
>
> (Search gossamer/threads/mythtv/users for 'nova-t repeat lirc')
>
> Sorry for the rambling thread - hope this helps.

Sorry for the delay in replying.

I'm trying to understand how this all works.

When you use LIRC for your remote, do you still get the key press going in the 
keyboard buffer?

My event devices are non existent, even with a PS/2 keyboard attached.

dbox:0:/dev/input# ls -al
total 0
crw-rw----  1 root root 13, 64 2005-02-26 16:43 event0
crw-rw----  1 root root 13, 65 2005-02-26 16:43 event1
crw-rw----  1 root root 13, 66 2005-02-26 16:43 event2
crw-rw----  1 root root 13, 67 2005-02-26 16:43 event3
crw-rw----  1 root root 13,  0 2005-02-26 16:43 js0
crw-rw----  1 root root 13,  1 2005-02-26 16:43 js1
crw-rw----  1 root root 13,  2 2005-02-26 16:43 js2
crw-rw----  1 root root 13,  3 2005-02-26 16:43 js3
crw-rw----  1 root root 13, 63 2005-02-26 16:43 mice
crw-rw----  1 root root 13, 32 2005-02-26 16:43 mouse0
crw-rw----  1 root root 13, 33 2005-02-26 16:43 mouse1
crw-rw----  1 root root 13, 34 2005-02-26 16:43 mouse2
crw-rw----  1 root root 13, 35 2005-02-26 16:43 mouse3
dbox:0:/dev/input# cat event0
cat: event0: No such device
dbox:1:/dev/input# cat event1
cat: event1: No such device
dbox:1:/dev/input# cat event2
cat: event2: No such device
dbox:1:/dev/input# cat event3
cat: event3: No such device
dbox:0:/dev/input# cat mouse0
								(Ctrl-C)
dbox:130:/dev/input# cat mouse1
								(Ctrl-C)
dbox:130:/dev/input# cat mouse2
cat: mouse3: No such device
dbox:1:/dev/input# cat mouse3
cat: mouse2: No such device
dbox:1:/dev/input#

By looking in linux/drivers/usb/input/hid-input.c, the code to handle what it 
thinks is a usb keyboard is pretty simple:

                case HID_UP_KEYBOARD:

                        set_bit(EV_REP, input->evbit);

                        if ((usage->hid & HID_USAGE) < 256) {
                                if (!hid_keyboard[usage->hid & HID_USAGE]) 
goto ignore;
                                map_key_clear(hid_keyboard[usage->hid & 
HID_USAGE]);
                        } else
                                map_key(KEY_UNKNOWN);

                        break;
It gets a code from USB HID and maps it to Linux Input.

Thanks,
Paul
-- 


More information about the mythtv-users mailing list