Difference between revisions of "Wii remote"

From MythTV Official Wiki
Jump to: navigation, search
(Added uinput module loading)
Line 29: Line 29:
 
Find ''MY_WIIMOTE_ADDR'' and set the address of your Wii remote which you got from the previous scan.
 
Find ''MY_WIIMOTE_ADDR'' and set the address of your Wii remote which you got from the previous scan.
 
   'MY_WIIMOTE_ADDR': "99:88:77:66:55:44",
 
   'MY_WIIMOTE_ADDR': "99:88:77:66:55:44",
Find ''commandMap'' and configure the buttons to suite your needs<br>
+
Find ''commandMap'' and configure the buttons to suite your needs
 +
 
 +
{{Box File|~mythtv/wmd/wmd/Config.py|
 
<pre>
 
<pre>
 
'commandMap': {
 
'commandMap': {
Line 45: Line 47:
 
},
 
},
 
</pre>
 
</pre>
 +
}}
  
 
=== Test driver ===
 
=== Test driver ===
 
To test the driver run ''~mythtv/wmd/WMD.py''. Press button ''1'' and ''2'' on your remote and wait for the driver to connect.
 
To test the driver run ''~mythtv/wmd/WMD.py''. Press button ''1'' and ''2'' on your remote and wait for the driver to connect.
 +
{{Box File|~mythtv/wmd/WMD.py|
 
<pre>
 
<pre>
 
# ~mythtv/wmd/WMD.py
 
# ~mythtv/wmd/WMD.py
Line 71: Line 75:
 
[112, 0, 22, 126, 124, 129, 28, 151, 150, 154, 18, 0, 0, 0, 0, 0, 0, 0, 0]
 
[112, 0, 22, 126, 124, 129, 28, 151, 150, 154, 18, 0, 0, 0, 0, 0, 0, 0, 0]
 
</pre>
 
</pre>
 
+
}}
 
Now press any buttons on your remote and you should see the corresponding events
 
Now press any buttons on your remote and you should see the corresponding events
 
<pre>
 
<pre>
Line 98: Line 102:
 
To use the Wii remote in mythtv we just need to start the main python script ''~mythtv/wmd/WMD.py''.
 
To use the Wii remote in mythtv we just need to start the main python script ''~mythtv/wmd/WMD.py''.
 
Create a file ''~mythtv/wmd/mythtv_wiimote.sh'' with the following content
 
Create a file ''~mythtv/wmd/mythtv_wiimote.sh'' with the following content
 +
{{Box File|~mythtv/wmd/mythtv_wiimote.sh|
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
Line 105: Line 110:
 
done
 
done
 
</pre>
 
</pre>
 +
}}
 
and add it to your X startup file ''~/.xinitrc''
 
and add it to your X startup file ''~/.xinitrc''
 +
{{Box File|~/.xinitrc|
 
<pre>
 
<pre>
 
# Using the wiimote to control mythtv
 
# Using the wiimote to control mythtv
Line 117: Line 124:
 
mythwelcome
 
mythwelcome
 
</pre>
 
</pre>
 
+
}}
 
To use your remote just press button ''1'' and ''2'' and it should connect to your mythtv box.
 
To use your remote just press button ''1'' and ''2'' and it should connect to your mythtv box.
  
Line 126: Line 133:
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 +
[[Category:Python Script]]

Revision as of 03:54, 22 March 2007

This article describes how to install and configure a software to use the nintendo Wii remote to control MythTV.

As of 12/29/2006 buttons are working, pointing/shaking is not!

Installing a bluetooth adapter

  • Connect a linux supported bluetooth adapter (e.g. D-Link DBT-120)
  • Install linux bluetooth support BlueZ
 # apt-get install bluez-utils
  • First check, if the bluetooth adapter is installed correctly. Entering the following command should give you a list of all adapters.
 # hcitool dev
 Devices:
     hci0    01:23:45:67:89:AB
  • Next scan for bluetooth devices. To activate the discover mode of the Wii remote, press buttons 1 and 2 simultaneously, then enter the following command, which should give you a list of all bluetooth devices in range.
 # hcitool scan
 Scanning ...
         99:88:77:66:55:44       Nintendo RVL-CNT-01

The Wii remote is named (as you can see) Nintendo RVL-CNT-01.

Install linux driver for Wii remote

Install Python, Python-XLib and PyBlueZ

 # apt-get install python-xlib python-bluez

Now install the Wii remote driver by downloading and unpacking the newest package from this site, or use the subversion repository to get the bleeding edge version. The following chapters assume you installed the driver in ~mythtv/wmd

Modify configuration file

Edit the configuration file ~mythtv/wmd/wmd/Config.py Find MY_WIIMOTE_ADDR and set the address of your Wii remote which you got from the previous scan.

 'MY_WIIMOTE_ADDR': "99:88:77:66:55:44",

Find commandMap and configure the buttons to suite your needs

Template:Box File

Test driver

To test the driver run ~mythtv/wmd/WMD.py. Press button 1 and 2 on your remote and wait for the driver to connect. Template:Box File Now press any buttons on your remote and you should see the corresponding events

...
CONNECTED
Event type WM_CLOCK_BEAT is being ignored
[112, 0, 22, 126, 124, 129, 28, 151, 150, 154, 18, 0, 0, 0, 0, 0, 0, 0, 0]
Send Key DOWN: 50
Buttons down: ['1']
mSend Key UP: 50
Buttons up: ['1']
Send Key DOWN: 23
Buttons down: ['2']
iSend Key UP: 23
Buttons up: ['2']
Send Key DOWN: 15
Buttons down: ['+']
        Send Key UP: 15
Buttons up: ['+']

If you see an error message complaining about a missing uinput-device you have to load the uinput kernel module first.

 # modprobe uinput

Setup for MythTV use

To use the Wii remote in mythtv we just need to start the main python script ~mythtv/wmd/WMD.py. Create a file ~mythtv/wmd/mythtv_wiimote.sh with the following content Template:Box File and add it to your X startup file ~/.xinitrc Template:Box File To use your remote just press button 1 and 2 and it should connect to your mythtv box.

Make sure that the uinput module is loaded on system startup and your mythtv user has read access to the created device /dev/input/uinput. I added the following lines to /etc/rc.local

 modprobe uinput
 chmod a+r /dev/input/uinput