Archive:Configure Gyration USB remote for Ubuntu: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Gsgleason
No edit summary
>Gsgleason
No edit summary
Line 199: Line 199:
/usr/bin/sudo /usr/bin/evrouter --config=/home/xbmc/evrouter_gyration.txt /dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-*
/usr/bin/sudo /usr/bin/evrouter --config=/home/xbmc/evrouter_gyration.txt /dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-*
exec /usr/bin/xbmc --standalone
exec /usr/bin/xbmc --standalone
</source>
==Customizations==
To change or customize the behavior of evrouter with your remote, you will need to figure out what you want a certain key to do.  For instance, I want the My Music key on the remote to take me right to my music.
Using evrouter -d, the configuration for that key looks like this:
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/391 "Xfill this in!"
We need to populate an action where "fill this in" is written.  Since we are replacing the remote button events with keyboard presses, we need to find which key will do that in the [http://trac.xbmc.org/browser/trunk/system/keymaps/keyboard.xml default keyboard keymap].  The key on the default keyboard keymap for music is this:
<launch_media_select>XBMC.ActivateWindow(MyMusic)</launch_media_select>
Unfortunately we don't have that key '''launch_media_select''', whatever that is.  I guess we'll have to find an unused key.
If you read the evrouter man page like you should have by now, you would see that there is a key called "XF86AudioPlay" which sounds good to me.  So, to make the music key on the remote send that, replace "fill this in!" with the action '''XKey/XF86AudioPlay''' -- it should now look like this:
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/391 "XKey/XF86AudioPlay"
Great!  Now when I press that button, it should send that key.  Using the [http://wiki.xbmc.org/index.php?title=Log_file debug log], I can see that when I press that button, it see the button code:
17:30:44 T:3077924736 M:1455194112  DEBUG: SDLKeyboard: scancode: 172, sym: 0, unicode: 0, modifier: 0
17:30:44 T:3077924736 M:1455194112  DEBUG: OnKey: 61619 pressed, action is Pause
I will now make a keyboard mapping in ~/.xbmc/userdata/keymaps/ to associate that button code with the action I want in XBMC:
<source lang="xml">
<keymap>
  <global>
    <keyboard>
      <key id="61606">ParentDir</key>
      <key id='61619'>XBMC.ActivateWindow(MyMusic)</key>
    </keyboard>
  </global>
</keymap>
</source>
</source>

Revision as of 23:35, 9 June 2010

Template:GoToParent

Introduction

There are several buttons on the Gyration Media Center Remote that work with XBMC out of the box, so to speak.

There are also some that do not.

This method uses the evrouter program to map the unused keys (or any key you wish, for that matter) to keyboard keys that XBMC uses.

This was written using Ubuntu 9.10 i386 with XBMC 9.11 installed from the svn ppa.

We are going to use evrouter to look at the two event devices associated with the Gyration remote, which are:

/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd
/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse

Install evrouter

The Ubuntu repositories do not have evrouter, but there is a .deb package available at the author's website, which this guide will use.

Download the package:

wget http://debian.bedroomlan.org/debian/pool/main/e/evrouter/evrouter_0.4_i386.deb

Install the package:

sudo dpkg -i evrouter_0.4_i386.deb

Create configuration file for evrouter

You can use evrouter to dump the output of keys for devices. To do this, run this command:

sudo evrouter -d /dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-*

While the command is running, press the buttons on the remote, and the configuration will be generated. Here is what it should look like:

sudo evrouter -d /dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-*
device  0: /dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd: Gyration Gyration RF Technology Receiver
device  1: /dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse: Gyration Gyration RF Technology Receiver
Display name: localhost:10.0

Window "xterm": # Window title
# Window "xterm": # Resource name
# Window "XTerm": # Class name
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/102 "fill this in!"

The last part in the quotes, "fill this in," needs to be replaced with the desired action. According to the man page of evrouter, the action can be either a keyboard press, a mouse button, or a shell script. Please read the man page for more info.

man evrouter

Below is a file where every single button on the remote was pressed. The working buttons have been commented out, but they are there in case you want to change the default behavior. Evrouter can be configured on a per-window basis using the Window parameter in the configuration file. The example below is affecting all windows, so if you're using this in windowed mode in a desktop environment, you might want to put the window class or resource name in the quotes. I think it should be "xbmc.bin"

Copy this and save it wherever you want. I have it save as ~/evrouter_gyration.txt which will be used later in this guide.

#Window "xbmc.bin": # Window title
Window "": # Window title

#Power/Sleep
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/142 "XKey/End"

#or to bring up shutdown menu
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/142 "XKey/S"

#LiveTV
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/366 "XKey/O"

#left mouse
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/272 "fill this in!"

#right mouse
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/273 "fill this in!"

#green windows button
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/102 "XKey/Escape"

#mypictures
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/212 "fill this in!"

#myTV
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/226 "fill this in!"

#mymusic
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/391 "fill this in!"

#myvideos
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/393 "fill this in!"

#DVD Menu
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/389 "fill this in!"

#stop
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/166 "fill this in!"

#record
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/167 "fill this in!"

#pause
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/119 "fill this in!"

#rewind
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/168 "fill this in!"

#fastfoward
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/208 "fill this in!"

#play
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/207 "fill this in!"

#skipback
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/165 "fill this in!"

#skip forward
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/163 "fill this in!"

#guide
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/362 "XKey/Menu"

#up
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/103 "fill this in!"

#down
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/108 "fill this in!"

#left
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/105 "fill this in!"

#right
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/106 "fill this in!"

#ok
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/28 "fill this in!"

#back 
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/158 "XKey/BackSpace"

#info
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/130 "XKey/I"

#volup
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/115 "fill this in!"

#voldown
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/114 "fill this in!"

#mute
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/113 "fill this in!"

#chan up 
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/402 "XKey/Page_Up"

#chan down
"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/403 "XKey/Page_Down"

#1
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/2 "fill this in!"

#2
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/3 "fill this in!"

#3
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/4 "fill this in!"

#4
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/5 "fill this in!"

#5
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/6 "fill this in!"

#6
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/7 "fill this in!"

#7
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/8 "fill this in!"

#8
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/9 "fill this in!"

#9
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/10 "fill this in!"

#0
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/11 "fill this in!"

#clear
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/1 "fill this in!"

#enter
#"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd" none key/28 "fill this in!"

Set Up Sudo

Since root permissions are required for evrouter to do what it does, we will launch it using sudo. However, since this is going to be a part of a script, we need to make sure that the user that is launching XBMC is allowed to run evrouter without having to put in the user's password. To do this, use the command visudo with super user permissions:

sudo viduso

This will launch your editor to edit the sudoers file. To allow the user xbmc to run evrouter with super user permissions without a password, add this line:

xbmc ALL=NOPASSWD: /usr/bin/evrouter

Configure evrouter to start up with the X server

Evrouter needs to be started after the X server is running. To do this, I put it in the user's ~/.xinitrc file.

This was tested using mingetty to auto log in a user that has a file ~/.bash_login as follows:

if [[ -z $SSH_CONNECTION ]]; then
        while [[ x`pidof X` = "x" ]]; do startx; done
fi

This will run startx as long as the login is not through SSH and X isn't already running, and will restart it if it dies. There may be better ways to do this, but that's not the discussion here.

Here is the user's ~/.xinitrc file:

#!/bin/bash
/usr/bin/sudo /usr/bin/evrouter --config=/home/xbmc/evrouter_gyration.txt /dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-*
exec /usr/bin/xbmc --standalone

Customizations

To change or customize the behavior of evrouter with your remote, you will need to figure out what you want a certain key to do. For instance, I want the My Music key on the remote to take me right to my music.

Using evrouter -d, the configuration for that key looks like this:

"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/391 "Xfill this in!"

We need to populate an action where "fill this in" is written. Since we are replacing the remote button events with keyboard presses, we need to find which key will do that in the default keyboard keymap. The key on the default keyboard keymap for music is this:

<launch_media_select>XBMC.ActivateWindow(MyMusic)</launch_media_select>

Unfortunately we don't have that key launch_media_select, whatever that is. I guess we'll have to find an unused key.

If you read the evrouter man page like you should have by now, you would see that there is a key called "XF86AudioPlay" which sounds good to me. So, to make the music key on the remote send that, replace "fill this in!" with the action XKey/XF86AudioPlay -- it should now look like this:

"Gyration Gyration RF Technology Receiver" "/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse" none key/391 "XKey/XF86AudioPlay"

Great! Now when I press that button, it should send that key. Using the debug log, I can see that when I press that button, it see the button code:

17:30:44 T:3077924736 M:1455194112   DEBUG: SDLKeyboard: scancode: 172, sym: 0, unicode: 0, modifier: 0
17:30:44 T:3077924736 M:1455194112   DEBUG: OnKey: 61619 pressed, action is Pause

I will now make a keyboard mapping in ~/.xbmc/userdata/keymaps/ to associate that button code with the action I want in XBMC:

<keymap>
  <global>
    <keyboard>
      <key id="61606">ParentDir</key>
      <key id='61619'>XBMC.ActivateWindow(MyMusic)</key>
    </keyboard>
  </global>
</keymap>