Difference between revisions of "Nintendo WiiMote"

From LinuxMCE
Jump to: navigation, search
 
(31 intermediate revisions by 18 users not shown)
Line 1: Line 1:
 
[[Category: Hardware]]
 
[[Category: Hardware]]
 +
{{versioninfo|1004Status=working|1004UpdatedDate=24th April 2013|1004UpdatedBy=[[User:Jamo|Jamo]]}}
 +
{| align="right"
 +
  | __TOC__
 +
  |}
 +
[[Category: Remote Controls]]
 
[[Category: Input]]
 
[[Category: Input]]
{{stub}}
+
[[Category: Infrared]]
 +
[[Category: Tutorials]]
  
[[Image:Wiimote.jpg|right]]
 
  
This device is not (yet?) supported by LinuxMCE, but it is known to work [https://help.ubuntu.com/community/CWiiD] [http://forum.linuxmce.com/index.php?topic=1246.0] [http://forum.linuxmce.org/index.php?topic=2411.msg11435].
+
[[Image:Wiimote.jpg|right|thumb|The Nintendo Wiimote]]
 +
 
 +
I am working on a [[New Wii Remote Driver]], written from scratch using the WiiUse library, integrated into the Bluetooth_Dongle DCE device, and modifying Orbiter PlugIn appropriately. --[[User:Tschak909|Tschak909]] 19:12, 26 September 2010 (CEST)
 +
 
 +
This device is not out of the box supported by LinuxMCE, but it is known to work [https://help.ubuntu.com/community/CWiiD] [http://forum.linuxmce.com/index.php?topic=1246.0] [http://forum.linuxmce.org/index.php?topic=2411.msg11435].
  
 
== Wiimote setup ==
 
== Wiimote setup ==
Line 11: Line 20:
 
I will try to explain what i have done to make the wiimote work with linuxmce.
 
I will try to explain what i have done to make the wiimote work with linuxmce.
  
The wiimote is a cheap gyration device which could work for linuxmce instead of the chief remote from fiire which i find to expensive!!
+
The wiimote is a cheap gyration device which could work for linuxmce instead of the chief remote from fiire which i find too expensive!!
  
 
= Setup =
 
= Setup =
  
Login as root to the media director which has a bluetooth stick with ssh.
+
Login ([[Logging_In]]) as root to the media director which has a bluetooth stick with ssh.
Install the cwiid driver as fllows
+
sudo su -
  apt-get install libcwiid0
+
Install the cwiid driver as follows
apt-get install wminput
+
* For LinuxMCE 0710:
 +
  apt-get install libcwiid0 wminput
  
create the daemon
+
* For LinuxMCE 0810, 1004:
  vi /usr/sbin/wminputd
+
  apt-get install libcwiid1 wminput
  
 +
Make sure the uinput kernel module is loaded at boot-time:
 +
echo "uinput" >> /etc/modules
 +
Load it manually in the mean time:
 +
modprobe uinput
 +
 +
create the daemon
 +
cat >/usr/sbin/wminputd <<"EOF"
 
  #!/bin/bash
 
  #!/bin/bash
 
  #read the config file
 
  #read the config file
Line 28: Line 45:
 
  export DISPLAY=:0
 
  export DISPLAY=:0
 
   
 
   
  while true ; do
+
  while true
         #check if the OrbiterGL is already running!
+
do
        LMCE=`pidof OrbiterGL`
+
         #check if the Orbiter/OrbiterGL is already running!
         if [ ! -z $LMCE ] ; then
+
         if [ "$(pidof OrbiterGL)$(pidof Orbiter)" ]
                while true ; do
+
        then
 +
 
                 #check if the wiimote is already connected
 
                 #check if the wiimote is already connected
                 SCAN=`hcitool con|grep $WIIMOTE_BDADDR`
+
                 if [ -z "$(hcitool con|grep $WIIMOTE_BDADDR)" ]
                        if [ -z $SCAN ] ; then
+
                then
                                PID=`pidof wminput`
+
                        PID=$(pidof wminput)
 +
                        if [ "$PID" ]
 +
                        then
 
                                 kill -9 $PID
 
                                 kill -9 $PID
                                 xset m 3 1/2
+
                        fi
 +
                        #check if WiiMote is in range (prevents spawning devices every 10 secs)
 +
                        if [ "$(hcitool scan|grep $WIIMOTE_BDADDR)" ]
 +
                        then
 +
                                 #mouse acceleration, adjust to your liking
 +
                                #see also: "man xset" and/or "xset -h"
 +
#                              xset m 1/2 3
 
                                 wminput -c ir_ptr $WIIMOTE_BDADDR &
 
                                 wminput -c ir_ptr $WIIMOTE_BDADDR &
                                sleep 5
 
                        else
 
                                sleep 5
 
 
                         fi
 
                         fi
                 done
+
                 fi
        fi
+
 +
        fi
 +
 +
        sleep 5
 +
 
  done
 
  done
 +
 +
EOF
  
 
Make it executable
 
Make it executable
 
  chmod 755 /usr/sbin/wminputd
 
  chmod 755 /usr/sbin/wminputd
  
*Create the config file
+
*Create the config file ([http://en.wikipedia.org/wiki/Vi vi commands])
 
  vi /etc/wminputd.conf
 
  vi /etc/wminputd.conf
  
 
  #this is the config file for the wminputd
 
  #this is the config file for the wminputd
  #enter the wiimote mac address, you can find it with ~#hcitool scan  and then press the red button
+
  #enter the wiimote mac address, you can find it with
 +
#hcitool scan  and then press the red button
 
  #besides the battery's off the wiimote
 
  #besides the battery's off the wiimote
 
  #Then place the show'n mac address as follows
 
  #Then place the show'n mac address as follows
Line 69: Line 99:
 
  #buttons
 
  #buttons
 
   
 
   
  Wiimote.A               = BTN_LEFT
+
  Wiimote.A       = BTN_LEFT
  Wiimote.B               = BTN_RIGHT
+
  Wiimote.B       = BTN_RIGHT
  Wiimote.Up             = KEY_UP
+
  Wiimote.Up     = KEY_UP
 
  Wiimote.Down    = KEY_DOWN
 
  Wiimote.Down    = KEY_DOWN
 
  Wiimote.Left    = KEY_LEFT
 
  Wiimote.Left    = KEY_LEFT
Line 78: Line 108:
 
  Wiimote.Plus    = KEY_F8
 
  Wiimote.Plus    = KEY_F8
 
  Wiimote.Home    = KEY_F3
 
  Wiimote.Home    = KEY_F3
  Wiimote.1               = KEY_F1
+
  Wiimote.1       = KEY_F1
  Wiimote.2               = KEY_F6
+
  Wiimote.2       = KEY_F6
  
  
Line 124: Line 154:
 
  esac
 
  esac
 
  exit 0
 
  exit 0
 +
 +
Make it executable
 +
chmod 755 /etc/init.d/wminputd
  
 
run the script and push the red button beside the battery and your wiimote is ready to go
 
run the script and push the red button beside the battery and your wiimote is ready to go
  
 
+
enable the script so that it will start at boot time
enable the script so it wil start at boot time
+
 
  update-rc.d wminputd defaults
 
  update-rc.d wminputd defaults
now start the script and take look if it works
+
now start the script and see if it works
 
  /etc/init.d/wminputd start
 
  /etc/init.d/wminputd start
  
Line 137: Line 169:
 
*Q: When i reload the router then the wiimote will be slow
 
*Q: When i reload the router then the wiimote will be slow
 
*A: Just push the red button besides the wiimote so it will connect again
 
*A: Just push the red button besides the wiimote so it will connect again
 +
 +
*Q: Using a sensor bar (ir_ptr), and the cursor is limited to the bottom left corner of the screen
 +
*A: Make the following changes to the /etc/X11/xorg.conf file on the Media Director and then restarting the Media Director:
 +
 +
Add this section:
 +
 +
    Section "InputDevice"
 +
        Identifier      "Wiimote"
 +
        Driver          "evdev"
 +
        Option          "Name"          "Nintendo Wiimote"
 +
    EndSection
 +
 +
Add this line to the ServerLayout section:
 +
 +
    InputDevice    "Wiimote" "AlwaysCore"
 +
 +
This was taken from the ubuntu forums: https://help.ubuntu.com/community/CWiiD
 +
*Q: Using a sensor bar (ir_ptr), can't scroll through lists
 +
*A: Add the following lines from acc_ptr to ir_ptr:
 +
    Plugin.acc.X = REL_X
 +
    Plugin.acc.Y = REL_Y
 +
 +
= Added 3-30-2008 =
 +
I tried this and it works beautifully!
 +
 +
A couple of other notes...
 +
 +
Its a pain to get to the little red button by the battery. Instead, you can press and hold the '1' and '2' buttons at the same time for the same effect.
 +
The power button will not start the system, but once the system is started (with either the Red button or the button 1+2 being held down together), holding the power button for a couple of seconds will turn the wiimote off and break the connection.
 +
 +
 +
== Troubles Experienced ==
 +
*I have a Targus bluetooth doggle.  The system recognizes the adapter, but it would not allow the Wiimote to connect.  What I need to do to get it to work is get to a command prompt and execute '''hciconfig hci0 down; hciconfig hci0 up; hciconfig hci0 piscan'''.  Then I am able to press the 1 & 2 buttons then it works. An additional change that I need to make was in /usr/sbin/wminputd.  Had the change the line ''wminput -c ir_ptr $WIIMOTE_BDADDR &'' to ''wminput $WIIMOTE_BDADDR &''.  Otherwise I could not move the cursor, but the buttons works.  Then I also mapped the buttons to how I wanted them.  If I come up with a fix/workaround for executing the hciconfig commands I will update this.  Thanks!
 +
*On my system, each call to wminput would cause a frame drop which meant that watching a video with no wiimote connected would have dropped frames every ~8sec.  The following wminputd avoids the problem, though it won't stop with /etc/init.d/wminputd stop.  As I want it to run indefinitely, that point is moot.
 +
#!/bin/bash                           
 +
#read the config file                 
 +
. /etc/wminputd.conf                   
 +
export DISPLAY=:0                     
 +
while [ -z "$(pidof OrbiterGL)$(pidof Orbiter)" ]
 +
do
 +
        sleep 5
 +
done
 +
wminput -r -w -c ir_ptr

Latest revision as of 22:28, 24 April 2013

Version Status Date Updated Updated By
710 Unknown N/A N/A
810 Unknown N/A N/A
1004 working 24th April 2013 Jamo
1204 Unknown N/A N/A
1404 Unknown N/A N/A
Usage Information
The Nintendo Wiimote

I am working on a New Wii Remote Driver, written from scratch using the WiiUse library, integrated into the Bluetooth_Dongle DCE device, and modifying Orbiter PlugIn appropriately. --Tschak909 19:12, 26 September 2010 (CEST)

This device is not out of the box supported by LinuxMCE, but it is known to work [1] [2] [3].

Wiimote setup

I will try to explain what i have done to make the wiimote work with linuxmce.

The wiimote is a cheap gyration device which could work for linuxmce instead of the chief remote from fiire which i find too expensive!!

Setup

Login (Logging_In) as root to the media director which has a bluetooth stick with ssh.

sudo su -

Install the cwiid driver as follows

  • For LinuxMCE 0710:
apt-get install libcwiid0 wminput
  • For LinuxMCE 0810, 1004:
apt-get install libcwiid1 wminput

Make sure the uinput kernel module is loaded at boot-time:

echo "uinput" >> /etc/modules

Load it manually in the mean time:

modprobe uinput

create the daemon

cat >/usr/sbin/wminputd <<"EOF"
#!/bin/bash
#read the config file
. /etc/wminputd.conf
export DISPLAY=:0

while true
do
        #check if the Orbiter/OrbiterGL is already running!
        if [ "$(pidof OrbiterGL)$(pidof Orbiter)" ]
        then

                #check if the wiimote is already connected
                if [ -z "$(hcitool con|grep $WIIMOTE_BDADDR)" ]
                then
                        PID=$(pidof wminput)
                        if [ "$PID" ]
                        then
                                kill -9 $PID
                        fi
                        #check if WiiMote is in range (prevents spawning devices every 10 secs)
                        if [ "$(hcitool scan|grep $WIIMOTE_BDADDR)" ]
                        then
                                #mouse acceleration, adjust to your liking
                                #see also: "man xset" and/or "xset -h"
#                               xset m 1/2 3
                                wminput -c ir_ptr $WIIMOTE_BDADDR &
                        fi
                fi

       fi

       sleep 5

done

EOF

Make it executable

chmod 755 /usr/sbin/wminputd
vi /etc/wminputd.conf
#this is the config file for the wminputd
#enter the wiimote mac address, you can find it with
#hcitool scan  and then press the red button
#besides the battery's off the wiimote
#Then place the show'n mac address as follows
WIIMOTE_BDADDR="00:AA:00:BB:AA:FF"

you can find your address with hcitool scan

  • Edit the file /etc/cwiid/wminput/buttons
vi /etc/cwiid/wminput/buttons

And make it suitable to your needs below is mine

#buttons

Wiimote.A       = BTN_LEFT
Wiimote.B       = BTN_RIGHT
Wiimote.Up      = KEY_UP
Wiimote.Down    = KEY_DOWN
Wiimote.Left    = KEY_LEFT
Wiimote.Right   = KEY_RIGHT
Wiimote.Minus   = KEY_F7
Wiimote.Plus    = KEY_F8
Wiimote.Home    = KEY_F3
Wiimote.1       = KEY_F1
Wiimote.2       = KEY_F6


  • create the init file
vi /etc/init.d/wminputd
#!/bin/sh
# Start/stop the wminputd daemon.
#
### BEGIN INIT INFO
# Provides:          wminputd
# Required-Start:    $syslog $time
# Required-Stop:     $syslog $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mousemodule
# Description:       wminputd
#
#
#
### END INIT INFO


test -f /usr/sbin/wminputd || exit 0
. /lib/lsb/init-functions

case "$1" in
start)  log_daemon_msg "Starting wii-remote mousemodule" "wminputd"
        start-stop-daemon -b --start --quiet --pidfile /var/run/wminputd.pid --name wminputd --startas /usr/sbin/wminputd -- $LSBNAMES
        log_end_msg $?
        ;;
stop)   log_daemon_msg "Stopping wii-mote mousemodule" "wminputd"
        start-stop-daemon --stop --quiet --pidfile /var/run/wminputd.pid --name wminputd
        log_end_msg $?
        ;;
restart) log_daemon_msg "Restarting wii-mote mousemdule" "wminputd"
        start-stop-daemon --stop --retry 5 --quiet --pidfile /var/run/wminputd.pid --name wminputd
        start-stop-daemon -b --start --quiet --pidfile /var/run/wminputd.pid --name wminputd --startas /usr/sbin/wminputd -- $LSBNAMES
        log_end_msg $?
        ;;
*)      log_action_msg "Usage: /etc/init.d/wminputd {start|stop|restart}"
        exit 2
        ;;
esac
exit 0

Make it executable

chmod 755 /etc/init.d/wminputd

run the script and push the red button beside the battery and your wiimote is ready to go

enable the script so that it will start at boot time

update-rc.d wminputd defaults

now start the script and see if it works

/etc/init.d/wminputd start

Troubleshooting

  • Q: When i reload the router then the wiimote will be slow
  • A: Just push the red button besides the wiimote so it will connect again
  • Q: Using a sensor bar (ir_ptr), and the cursor is limited to the bottom left corner of the screen
  • A: Make the following changes to the /etc/X11/xorg.conf file on the Media Director and then restarting the Media Director:

Add this section:

   Section "InputDevice"
       Identifier      "Wiimote"
       Driver          "evdev"
       Option          "Name"          "Nintendo Wiimote"
   EndSection

Add this line to the ServerLayout section:

   InputDevice     "Wiimote" "AlwaysCore"

This was taken from the ubuntu forums: https://help.ubuntu.com/community/CWiiD

  • Q: Using a sensor bar (ir_ptr), can't scroll through lists
  • A: Add the following lines from acc_ptr to ir_ptr:
   Plugin.acc.X = REL_X
   Plugin.acc.Y = REL_Y

Added 3-30-2008

I tried this and it works beautifully!

A couple of other notes...

Its a pain to get to the little red button by the battery. Instead, you can press and hold the '1' and '2' buttons at the same time for the same effect. The power button will not start the system, but once the system is started (with either the Red button or the button 1+2 being held down together), holding the power button for a couple of seconds will turn the wiimote off and break the connection.


Troubles Experienced

  • I have a Targus bluetooth doggle. The system recognizes the adapter, but it would not allow the Wiimote to connect. What I need to do to get it to work is get to a command prompt and execute hciconfig hci0 down; hciconfig hci0 up; hciconfig hci0 piscan. Then I am able to press the 1 & 2 buttons then it works. An additional change that I need to make was in /usr/sbin/wminputd. Had the change the line wminput -c ir_ptr $WIIMOTE_BDADDR & to wminput $WIIMOTE_BDADDR &. Otherwise I could not move the cursor, but the buttons works. Then I also mapped the buttons to how I wanted them. If I come up with a fix/workaround for executing the hciconfig commands I will update this. Thanks!
  • On my system, each call to wminput would cause a frame drop which meant that watching a video with no wiimote connected would have dropped frames every ~8sec. The following wminputd avoids the problem, though it won't stop with /etc/init.d/wminputd stop. As I want it to run indefinitely, that point is moot.
#!/bin/bash                             
#read the config file                   
. /etc/wminputd.conf                    
export DISPLAY=:0                       
while [ -z "$(pidof OrbiterGL)$(pidof Orbiter)" ]
do
        sleep 5
done
wminput -r -w -c ir_ptr