Difference between revisions of "Wii remote"

From MythTV Official Wiki
Jump to: navigation, search
(Created)
 
m (moved Controlling MythTV using a Wii remote to Wii remote: Standardize the name to go in the Remote Controls category)
 
(22 intermediate revisions by 8 users not shown)
Line 1: Line 1:
'''ATTENTION:''' ''This article is a work in progress and not completed.''
+
{{Outdated2|The site linked to for the Wiimote drivers no longer exists.}}
  
----
+
This article describes how to install and configure a software to use the nintendo Wii remote to control MythTV.
  
The controllers of the nintendo gaming console [http://www.wii.com Wii] are called WiiMote.
+
There are two methods - the original method, and the new kid on the block, MythPyWii. MythPyWii is easier to set up, and has more functions (and is cooler!), but is likely to have more bugs, though it seems stable currently. Here are the [http://www.benjiegillam.com/mythpywii-installation/ MythPyWii installation instructions], and [http://www.youtube.com/watch?v=Fx8uoTlZXF0 a video of MythPyWii in action].
This article describes how to install and configure a software to use a WiiMote to control MythTV.
 
  
'''As of 12/29/2006 buttons are working, pointing/shaking is not!'''
+
== Original Method (very manual) ==
  
 
+
=== Installing a bluetooth adapter ===
==Preparation==
 
 
* Connect a linux supported bluetooth adapter (e.g. D-Link DBT-120)
 
* Connect a linux supported bluetooth adapter (e.g. D-Link DBT-120)
 
* Install linux bluetooth support [http://www.bluez.org/ BlueZ]
 
* Install linux bluetooth support [http://www.bluez.org/ BlueZ]
* Install Python, Python-XLib and [http://org.csail.mit.edu/pybluez/ PyBlueZ]
+
   # apt-get install bluez-utils
* Hint for Ubuntu-Users: Type
 
   # apt-get install bluez-utils python-xlib python-bluez
 
 
 
===Check for working bluetooth installation===
 
 
* First check, if the bluetooth adapter is installed correctly. Entering the following command should give you a list of all adapters.
 
* First check, if the bluetooth adapter is installed correctly. Entering the following command should give you a list of all adapters.
 
   # hcitool dev
 
   # hcitool dev
Line 22: Line 16:
 
       hci0    01:23:45:67:89:AB
 
       hci0    01:23:45:67:89:AB
  
* Next scan for bluetooth devices. To activate the discover mode of the WiiMote, press buttons ''1'' and ''2'' simultaneously, then enter the following command which should give you a list of all bluetooth devices in range.
+
* 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
 
   # hcitool scan
 
   Scanning ...
 
   Scanning ...
 
           99:88:77:66:55:44      Nintendo RVL-CNT-01
 
           99:88:77:66:55:44      Nintendo RVL-CNT-01
The WiiMote is named (as you can see) ''Nintendo RVL-CNT-01''.
+
The Wii remote is named (as you can see) ''Nintendo RVL-CNT-01''.
 +
 
 +
=== Install linux driver for Wii remote ===
 +
Install [http://www.python.org Python], [http://python-xlib.sourceforge.net/ Python-XLib] and [http://org.csail.mit.edu/pybluez/ PyBlueZ]
 +
  # apt-get install python-xlib python-bluez
  
==Install WiiMote Software==
+
Now install the [http://www.forthewiin.org/ Wii remote driver] by downloading and unpacking the newest package from [http://www.forthewiin.org/ this site], or use the subversion repository to get the bleeding edge version. The latest code from subversion has mouse support.
Now install the [http://www.forthewiin.org/ WiiMote software] by downloading and unpacking the newest package from [http://www.forthewiin.org/ this site], or use the subversion repository to get the bleeding edge version.
+
The following chapters assume you installed the driver in ''~mythtv/wmd''
  
Edit the configuration file ''wmd/Config.py''
+
==== Modify configuration file ====
Find ''MY_WIIMOTE_ADDR'' and set the address of your WiiMote which you got from the previous scan.
+
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",
 
   '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
 +
 
 +
{{Python|~mythtv/wmd/wmd/Config.py|
 
<pre>
 
<pre>
 
'commandMap': {
 
'commandMap': {
Line 50: Line 51:
 
},
 
},
 
</pre>
 
</pre>
 +
}}
  
To test the WiiMote software run ''WMD.py''. Press button ''1'' and ''2'' on your WiiMote and wait for the software to connect.
+
==== 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.
 +
{{Python|~mythtv/wmd/WMD.py|
 
<pre>
 
<pre>
# ./WMD.py
+
# ~mythtv/wmd/WMD.py
 
Registering key KEY_ENTER for button A with code 1c
 
Registering key KEY_ENTER for button A with code 1c
 
Registering key KEY_ESC for button B with code 1
 
Registering key KEY_ESC for button B with code 1
Line 75: Line 79:
 
[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 WiiMote and you should see the corresponding events
+
Now press any buttons on your remote and you should see the corresponding events
 
<pre>
 
<pre>
 
...
 
...
Line 99: Line 103:
 
   # modprobe uinput
 
   # modprobe uinput
  
==Preparing for MythTV use==
+
=== Setup for MythTV use ===
To use the WiiMote for mythtv we just need to start the main python script ''WMD.py''.
+
You will want to enable the mouse pointer in Mythtv.  In the settings menu, select "Appearance".  On the second page enable a checkbox to enable the mouse pointer.
Create a file ''/usr/local/bin/mythtv_wiimote.sh'' with the following content
+
 
 +
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
 +
{{Code box|~mythtv/wmd/mythtv_wiimote.sh|
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
while (1) {
+
while [ 1 ]; do
   /usr/local/bin/mythtv_wiimote.sh
+
   $HOME/wmd/WMD.py ;
 
   sleep 5
 
   sleep 5
}
+
done
 
</pre>
 
</pre>
 +
}}
 
and add it to your X startup file ''~/.xinitrc''
 
and add it to your X startup file ''~/.xinitrc''
 +
{{Code box|~/.xinitrc|
 
<pre>
 
<pre>
 
# Using the wiimote to control mythtv
 
# Using the wiimote to control mythtv
/usr/local/bin/mythtv_wiimote.sh &
+
$HOME/wmd/mythtv_wiimote.sh &
  
 
xset -dpms s off
 
xset -dpms s off
Line 121: Line 130:
 
mythwelcome
 
mythwelcome
 
</pre>
 
</pre>
 +
}}
 +
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
 +
 +
== Alternatively, install MythPyWii ==
 +
 +
=== Features ===
 +
Current features include:
 +
 +
* Fastfoward/rewind/timestretch by varying amounts via twisting of the wiimote
 +
* Play/pause/back/up/down/left/right/menu/information/delete/save position via button pushes.
 +
 +
=== Brief Intro Video ===
 +
 +
http://www.youtube.com/watch?v=Fx8uoTlZXF0
 +
 +
=== Install Video ===
 +
 +
http://www.youtube.com/watch?v=fqacVgG394I
  
To use your WiiMote just press button ''1'' and ''2'' and it should connect to your mythtv box.
+
=== Installation ===
 +
[http://www.benjiegillam.com/mythpywii-installation/ MythPyWii installation instructions]
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 +
[[Category:Remote Control Scripts]]
 +
[[Category:Remote Controls]]

Latest revision as of 15:34, 22 October 2010

Time.png Outdated: The site linked to for the Wiimote drivers no longer exists.

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

There are two methods - the original method, and the new kid on the block, MythPyWii. MythPyWii is easier to set up, and has more functions (and is cooler!), but is likely to have more bugs, though it seems stable currently. Here are the MythPyWii installation instructions, and a video of MythPyWii in action.

Original Method (very manual)

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 latest code from subversion has mouse support. 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


PythonIcon.png ~mythtv/wmd/wmd/Config.py

'commandMap': {
  'A': ['key', 'KEY_ENTER' ],
  'B': ['key', 'KEY_ESC' ],
  'H': ['quit', 1],                 # Home key: quits WMD
  '+': ['key', 'KEY_TAB' ],
  '-': ['key', [ 'KEY_LEFTSHIFT', 'KEY_TAB' ] ],
  '1': ['key', 'KEY_M' ],
  '2': ['key', 'KEY_I' ],
  'U': ['key', 'KEY_UP' ],
  'D': ['key', 'KEY_DOWN' ],
  'L': ['key', 'KEY_LEFT' ],
  'R': ['key', 'KEY_RIGHT' ]
},

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.

PythonIcon.png ~mythtv/wmd/WMD.py

# ~mythtv/wmd/WMD.py
Registering key KEY_ENTER for button A with code 1c
Registering key KEY_ESC for button B with code 1
Registering key KEY_DOWN for button D with code 6c
Registering key KEY_TAB for button + with code f
Registering key ['KEY_LEFTSHIFT', 'KEY_TAB'] for button - with code 2a
Registering key ['KEY_LEFTSHIFT', 'KEY_TAB'] for button - with code f
Registering key KEY_LEFT for button L with code 69
Registering key KEY_M for button 1 with code 32
Registering key KEY_I for button 2 with code 17
Registering key KEY_UP for button U with code 67
Registering key KEY_RIGHT for button R with code 6a
[[1074025828, 3], [1074025831, 0], [1074025831, 1], [1074025828, 2], [1074025830, 0], [1074025830, 1], [1074025828, 1], [1074025828, 0], [1074025829, 28], [1074025829, 1], [1074025829, 108], [1074025829, 15], [1074025829, 42], [1074025829, 15], [1074025829, 105], [1074025829, 50], [1074025829, 23], [1074025829, 103], [1074025829, 106]]
Could not import pygame. Set DISABLE_PYGAME=1
CONNECTING
Looking for Wiimote services at address 99:88:77:66:55:44
Victory! We have found that Wiimote!
We are now connected to Wiimote at address 99:88:77:66:55:44
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]

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

You will want to enable the mouse pointer in Mythtv. In the settings menu, select "Appearance". On the second page enable a checkbox to enable the mouse pointer.

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

Script.png ~mythtv/wmd/mythtv_wiimote.sh

#!/bin/sh
while [ 1 ]; do
  $HOME/wmd/WMD.py ;
  sleep 5
done

and add it to your X startup file ~/.xinitrc

Script.png ~/.xinitrc

# Using the wiimote to control mythtv
$HOME/wmd/mythtv_wiimote.sh &

xset -dpms s off
xsetroot -solid black
xsetroot -bg black
xsetroot -cursor $HOME/etc/X11_EmptyCursor $HOME/etc/X11_EmptyCursor
/usr/bin/evilwm &
mythwelcome

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

Alternatively, install MythPyWii

Features

Current features include:

  • Fastfoward/rewind/timestretch by varying amounts via twisting of the wiimote
  • Play/pause/back/up/down/left/right/menu/information/delete/save position via button pushes.

Brief Intro Video

http://www.youtube.com/watch?v=Fx8uoTlZXF0

Install Video

http://www.youtube.com/watch?v=fqacVgG394I

Installation

MythPyWii installation instructions