============================== Using the USB IR Toy with LIRC ============================== :CreationDate: 2012-10-08 10:49:07 :Id: SW/usb-ir-toy-lirc :tags: - software - configs So I got myself a `programmable remote control in the shape of Eleven's sonic screwdriver `_ (sorry, horrible in-accessible website). Of course I want to control my PC with it! To do that, I needed a IR receiver and `LIRC `_. Since I sometimes like being overly generic, I bought `Dangerous Prototypes `_ `USB Infrared Toy `_, which allows me to send & receive any kind of IR pulse stream. Getting the three pieces (remote, toy, LIRC) to play together was more effort than I'd really liked, so here's what I did, to help everybody else. Flash a newer firmware ====================== Your IR Toy is probably running an old version of the firmware. If you're running Windows, the `instructions provided `_ may work; otherwise, you have to dig deeper. The source code for the ``fw_update`` program that you can get from those pages (or from `the Subversion repository `_) does not even compile (it "forgets" to include half the header files it needs), and when you get it to compile it segfaults. User "JessH" of the Dangerous Prototypes forums `posted a working version `_ (`here's the patch `_ if you want to see it, it should apply to the SVN version). .. note:: Yes, I know I'm pointing at the updater source for the 18F24J50, but the chip on the actual IR Toy says "18F2550". What can I say, it works! Having compiled it, I was able to update the firmware to version 22:: $ echo '$' > /dev/ttyACM0 $ ./fw_update -e -w -v -m all -vid 0x04D8 -pid 0xFD0B \ -ix ~/src/dangerous-prototypes-open-hardware/USB_IR_Toy/package/firmware/USBIRToy.v22.hex Unplug, re-plug, and we're set. Patching LIRC ============= .. note:: ``lircd`` 0.10 has native support for the USB IR Toy, using the ``irtoy`` driver LIRC can use the IR Toy in ``irman`` compatibility mode, but I needed full send capability, to program the sonic screwdriver. I found `a patch to add full support `_, thanks to Peter Kooiman. If you're running Gentoo, you can add `my overlay `_ and install `my patched LIRC `_. Configuring LIRC ================ This may well be written down somewhere, but I had problems finding a useful guide, so I'll just show what I did: 1) get a full Philips RC-5 code list from `the LIRC remotes repository `_ 2) assign, arbitrarily, the first 39 codes to the 13 gestures on 3 memory banks of the screwdriver:: begin remote name sonic # snip begin codes b1_tap_top 0x1000 b1_tap_left 0x1001 #etc etc Programming the remote ====================== I wrote `a simple Perl program to send the IR codes `_. Run it with ``lircd`` running and ``irsend`` in your path. When it say ``Ready to send $something``, press "enter" to send it, ``a`` to go back to the previous code (useful if the screwdriver didn't get it), ``n`` to go the next code without sending anything. I put the screwdriver in programming mode, performed all 39 gestures one after the other, and programmed all of them. LIRC now uses sensible names for the 39 gestures. Using it ======== Finally, I re-compiled `vlc `_ with LIRC support, and wrote `a |lircrc| for vlc `_. With that, I can control ``vlc`` with my sonic screwdriver! .. |lircrc| replace:: ``~/.lircrc``