Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: LIRC Support...  (Read 1117 times)

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
LIRC Support...
« on: January 20, 2007, 09:09:04 PM »

Well, since I started a wiimote thread for supporting that, I felt I should start a thread for the other item in work right now. First of all, no garuntees on this. Secondly, just so you know: LIRC/WinIRC == Linux Infrared Remote Control. What it is? A TCP API for communicating with IR remotes (such as VCR remotes, or homemade ones) through a port on the computer. An interesting thing to use as a control I must say :D

Anyway, OIS (when built with support enabled - default is false) will use boost::asio to look at an IP address for a LIRC server. From there, it will recieve button reports it can translate into a joystick class (joystick, because it is basically a joystick with only buttons).

Since, I didn't (on purpose) really provide a way for users to iteract with factory creators inside OIS... The LIRCFactoryCreator class will read two environment variables - OIS_LIRC_IP & OIS_LIRC_PORT - or it will use default values. I have not committed anything yet... but so far, I have gotten to the point where the class connects to the server.

There are a few commands I can use to query state:
VERSION -- This lists lirc deamon version info
LIST <optional remote name> -- lists all remotes, or information about a specified remote.

After that, it will just be lircd sending button presses to the listener. Now, I don't have a remote to really test with, but I can get most of it done without. I may eventually build a little reciever as a test project for myself, and then try any number of remotes around the house. Anyway, just a little note to anyone intersted in such a thing :)
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
LIRC Support...
« Reply #1 on: January 22, 2007, 03:13:00 PM »

Made a bit more progress. The code isn't as flexible as I would like it, but it will do for the mean time. One issue that will likely cause problems is if someone is pushing buttons on the remote during enumeration (at the start of OIS)... if the button messages come before I expect them, I don't handle that and likely will cause 0 buttons as being supported.

Anyway, besides that. The basic flow is down: all connected LIRC remotes are enumerated, each connected remote reports # of buttons. Then, I plan to have a single thread in the factory (similiar to the wiimote thread) that will only exist as long as there is a remote joystick device created (with no devices, the only open socket is closed). The one thread will read in non-blocking mode and continually pass messages to created remotes which will put the message in a ringbuffer holding the button event. Then, when the app calls capture, it reads all events from the ring buffer at once. This should work pretty well. In the case of the WiiMote, even moving the remote alot + buttons presses result in very little ringbuffer usage (unless your app is very very slow to call capture to empty the queue - in which case further messages will be lost until that happens).
Logged