Author Topic: Development: Supporting Gyration Media Center Remotes  (Read 10444 times)

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Development: Supporting Gyration Media Center Remotes
« on: April 14, 2009, 06:31:39 pm »
This thread will detail the development and status of the Gyration 3101 Media Center Remotes.

Thank you all for your contributions thus far, so I am at this point waiting on the hardware to get here. I believe Jimmiejames has sent the hardware, as he asked me for my address here, which if anyone needs this to send hardware, or any correspondence, feel free to ask me in private message.

Onward and Upward.

-Thom

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #1 on: April 15, 2009, 12:11:33 am »
I have recieved payments from almost all of you, I believe. Will work with colinjones to verify.

I have ordered the Beagle USB protocol analyser for work, it will be arriving in a few days.

-Thom

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #2 on: April 18, 2009, 05:58:14 am »
Remote has arrived, thank you. Awaiting shipment of USB protocol analyser.

MCR Remote seems to have exact same USB ID as Gyration Go mouse. Same dongles it appears.

-Thom

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #3 on: April 18, 2009, 07:06:09 am »
I have started notes on integration here in the wiki:

http://wiki.linuxmce.org/index.php/GYR3101_Integration_Notes

Which includes a color coded chart of what part of the HID subsystem will decode each currently available decodable button, there are a couple at the bottom which don't emit any sort of HID code. Forensic analysis when I get the analyser will shed more light on this.

-Thom

jimmejames

  • Guru
  • ****
  • Posts: 183
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #4 on: April 18, 2009, 07:13:49 am »
For anyone curious, I purchased the remote Thom is configuring for at the now defunct Circuit City approximately 2 years ago.  It was a 30 something dollar remote at the time....   there is nothing special about it- your standard off the shelf model.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #5 on: April 21, 2009, 10:00:50 pm »
I have recieved the forensics analysis equipment, and will use it to analyse packets for the remaining buttons, as well as analyse the connect and bind request for any information we can use.

-Thom

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #6 on: April 22, 2009, 05:04:42 am »
Analysis with forensic equipment verifies my initial findings.

Everything shown on color coded chart is decoded.

And in actuality even the rocker switches are decoded, as well under 0810, which was a nice surprise.

Now, this essentially means AT THIS point:

* No Follow Me, that was handled by Fiire's firmware
* the left and right buttons are not mapped to media and lights. I am trying to see what will need to happen to intercept these to get expected behaviour.

To see what I need to do for this first pass, take a look at the template for the Gyration Go mouse.

-Thom

krys

  • Addicted
  • *
  • Posts: 583
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #7 on: April 24, 2009, 05:09:44 pm »
Good News! and good to see your making progress.
-Krys

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #8 on: April 26, 2009, 10:28:38 am »
Some more investigative work done.

Architecturally, the remote is actually three devices in one, a mouse, and two keyboard devices.

For reasons not really important, Gyration split the remote into a keyboard and mouse, both of which have event devices which emit HID packets.

The good news is, that ALL of these packets are completely decoded by the kernel in 0810. However, this is made less easy by the fact that I have to decode button presses from two different devices, and act upon them.

It's made even more interesting by the fact that X does not decode the resulting event Key messages. Why? is anyone's quess. So this means that the input device must be accessed directly, and the resulting Key messages need to be decoded.

So for this remote, we need two threads created which listen to the input device file, read from it, and queue up a key event inside orbiter for further processing.

This brings us to the second bit of this whole thing, now that we know we have to decode these event messages, can't we just make and ship a DCE device that sends DCE commands to the right places?

Not exactly, and that would be reinventing part of the wheel...

Because there isn't a direct correlation between all keys and DCE commands, or PK_Button symbols, there is no way to just make a DCE device that sends Simulate Keypress messages to the orbiter.

Why?

Well, the answer is a bit more complicated.

LinuxMCE deals with anything that has buttons that you use as a remote to an on-screen device, as an Infra Red remote. This is done so that the RemoteMapping table can be used to determine what commands to send depending on the screen that is currently visible.

There are rows for each screen type, and in each, a set of new line delimited lines, containing:

keysym1;keysym2|message to send

i.e.

tv;live_tv;LiveTV;|0 -106 1 43 29 1

you can refer to this mapping by tv, live_tv, or LiveTV, and when evoked, will send a message from device 0 to -106 (the media plugin), message type 1 which is command, 43 which is MH Start Media, 29 which is the command parameter for media type, and 1 which means media type 1, which is TV.

Basically, this is the same format as the last set of parameters as MessageSend.

why is this important?

When Orbiter starts, it looks for all children of the Orbiter that are of category Remote Controls. It will then grab two very important pieces of device data, Configuration, and Mapping.

Mapping, is basically just a simple way to re-map scan codes (which are normally X scan codes, but can contain synthetic scan codes injected into the event system too. we'll use this to deal with buttons that X doesn't deal with.), the Gyration Go Mouse template uses this to map the three grey buttons to key codes for F6, F7, and F8, and can be used for SIMPLE remapping of completely decodable buttons to other keys. I use this to map the green windows button to menu. Each entry is:

event type, event keycode=new event type, new event keycode

event types:
2 = key pressed
3 = key repeat

Configuration, is the more interesting one, and can be used to emit commands to the system based on key codes that are recognized.

It is organized as so, one per line:

RemoteMapping_Entry,x scancode,UDH,Y

the last parameter is optional.

The first bit is of course, the remote mapping entry to match, remember earlier?, the second bit is the scan code to match, the third bit corresponds to Up, Down, or Held-down states, and Y is an optional parameter, that if present, means that this mapping ONLY makes sense for screens that have yielded all input, such as when a DVD menu is displayed, or when MythTV is visible. These correspond to screen types that are labeled as "osd" in the description.

These two device data will be used to map our remote buttons, but this still begs the question, if X doesn't decode our buttons, how will they reach this point?

This is where our injecting synthetic events comes into play.

There is a method in Orbiter that injects events into Orbiter's event queue. One of those events registers key presses, along with up, down, hold states.

What we do, is take the HID codes emitted, and add 10000 to them, so we can distinguish them from the other scan codes.. so HID packet 401 becomes 10401.

We can then reference the button like so in Configuration:

Music,10401,U,Y

and we now have a mapping for the music button to go to the music screen.

I hope this is shedding a light for others as to the internals of supporting other types of remote controls.

-Thom

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2421
    • View Profile
    • ago control
Re: Development: Supporting Gyration Media Center Remotes
« Reply #9 on: April 28, 2009, 05:37:22 pm »
way to go tschak!! Thanks for the braindump!!
rock your home - http://www.agocontrol.com home automation

krys

  • Addicted
  • *
  • Posts: 583
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #10 on: May 06, 2009, 07:17:04 pm »
Any new progress?
-Krys

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5501
  • DOES work for LinuxMCE.
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #11 on: May 06, 2009, 07:30:19 pm »
I had to take some time to investigate the HAL problem a bit further..when I get a chance, i'll hammer out the first pass of the new HID code in orbiter to handle spawning HID input threads and injecting synthetic event numbers onto them.

-Thom

LegoGT

  • Regular Poster
  • **
  • Posts: 29
    • View Profile
    • Medium Rare Brain
Re: Development: Supporting Gyration Media Center Remotes
« Reply #12 on: May 09, 2009, 05:09:07 pm »
Are donations still being accepted for this work? I am really interested in this and would like to support it in any way possible.
A brain dump of my neverending projects: http://MediumRareBrain.com

dlewis

  • Guru
  • ****
  • Posts: 401
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #13 on: May 09, 2009, 05:13:00 pm »
Are donations still being accepted for this work? I am really interested in this and would like to support it in any way possible.

Yes, donations are still being accepted. Please contact colinjones or tschak909 for details.

totonano

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Development: Supporting Gyration Media Center Remotes
« Reply #14 on: May 26, 2009, 09:17:19 pm »
Any new progress?