View Single Post
Copernicus's Avatar
Posts: 1,986 | Thanked: 7,698 times | Joined on Dec 2010 @ Dayton, Ohio
#234
Originally Posted by tecs View Post
I have no knowledge of Pierogi's inner workings
Oh, well, let me give you a little intro! Don't worry, it isn't too painful. Here's a bit of the current sony.cpp file:

Code:
// The "Sony TV Keyset 1" constructor!

SonyTV1::SonyTV1(
  QObject *guiObject,
  unsigned int index)
  : PIRKeysetMetaData(
      "TV Keyset 1",
      Sony_Make,
      index)
{
  addControlledDevice(Sony_Make, "KV-M1420D", TV_Device);
  addControlledDevice(Sony_Make, "KV-20FV10", TV_Device);
  addControlledDevice(Sony_Make, "KV-2184MT", TV_Device);
  // and so forth....

  threadableProtocol = new SIRCProtocol(guiObject, index);

  addSIRC12Key("1", One_Key, 0x01, 0x0);
  addSIRC12Key("2", Two_Key, 0x01, 0x1);
  addSIRC12Key("3", Three_Key, 0x01, 0x2);
  addSIRC12Key("4", Four_Key, 0x01, 0x3);
  addSIRC12Key("5", Five_Key, 0x01, 0x4);
  addSIRC12Key("6", Six_Key, 0x01, 0x5);
  addSIRC12Key("7", Seven_Key, 0x01, 0x6);
  addSIRC12Key("8", Eight_Key, 0x01, 0x7);
  addSIRC12Key("9", Nine_Key, 0x01, 0x8);
  addSIRC12Key("0", Zero_Key, 0x01, 0x9);
  addSIRC12Key("enter", Enter_Key, 0x01, 0x0B);
  // And so forth...
So yes, I'm just dropping the data directly into the constructor for each keyset object. Each object has a set of associated devices, a "threadableProtocol" object that is used to actually interact with the IR hardware, and finally a set of key assignments, each containing three pieces of data: the human-readable string (taken from the LIRC file), a mapping to a Pierogi button, and the actual code to be sent out in infrared. In this case, the Sony 12-bit code is composed of two pieces of data, a 5-bit address and a 7-bit command. (There are also 15-bit and 20-bit Sony codes.)

If you wanted to code this up yourself from an LIRC file, there are two problems -- one, LIRC doesn't know anything about Pierogi buttons, so you'd have to do that mapping yourself (not so hard), and two, LIRC doesn't know anything about Sony codes, so you'd have to convert their pulse counts into Sony format yourself (which might be harder for folks to do, if they're not handy with thinking in hexadecimal.) Originally, I was using the LIRC pulse counts directly, but it is just far easier (and more efficient) to calculate the pulses using the manufacturer's protocol instead.

But yeah, I do agree that there needs to be a better way to do this, other than just writing it all down directly in the code.

Unfortunately it does not. Neither it does with any of the other Sony TV keysets. I will give it another try tomorrow just to be sure.
Well, drat. I'm not sure what to say about that... One thing I should ask: does your TV support "pairing"? I haven't added pairing support for Sony yet, so if you don't have the TV set up on the default pairing setting, this keyset won't work...
 

The Following User Says Thank You to Copernicus For This Useful Post: