Homepage Forums RetroPie Project Everything else related to the RetroPie Project Tutorial to get wiimotes with classic controllers to work with RetroPie

Viewing 22 posts - 1 through 22 (of 22 total)
  • Author
    Posts
  • #3145
    rolsch
    Participant

    This tutorial shows how to get one to four wiimotes (the controller of Nintendo Wii) running with RetroPi with or without a classic controller (attached to the wiimote).

    Prerequisites

    1. For the following I assume that RetroPi was installed and is running with other controls (like keyboard, joystick etc.). I followed the excellent tutorial http://supernintendopi.wordpress.com/2013/01/23/an-a-to-z-beginners-guide-to-installing-retropie-on-a-raspberry-pi/ for this (using the “RetroPie Project SD Card Image”).

    2. You have a blue-tooth dongle (sometimes called blue-tooth adapter). For a list of dongles known to work with Raspberry Pi see http://elinux.org/RPi_USB_Bluetooth_adapters#Working_Bluetooth_adapters ).

    Note: Put the dongle in one of the USB ports of the Raspberry Pi directly, don’t put it into a USB hub (I read somewhere that it doesn’t work even with an active USB hub).

    Installation

    Now install the needed parts:

    sudo apt-get install bluetooth 
    sudo apt-get install python-cwiid 
    sudo apt-get install wminput

    Getting the wiimotes to work

    . uinput device needs to work with non-root users. To do so, create a file called /etc/udev/rules.d/wiimote.rules with the following line:
    KERNEL==“uinput“, MODE:=“0666“

    Reboot the Raspberry Pi to make this change active.

    . Check that the blue-tooth dongle works: Command
    /etc/init.d/bluetooth status
    should return that bluetooth is working

    . Scan for the wiimotes. Start
    hcitool scan
    and press 1+2 on your wiimote(s). After a short while, the output should be something like

    Scanning ...
            00:19:1D:87:90:38		Nintendo RVL-CNT-01
    	00:19:1D:88:EF:12		Nintendo RVL-CNT-01

    Take a note of the addresses of your wiimotes (the 00:19:1D:87:90:38 in the output above), we need that later.
    Note: If the scan is not successful try it again. Sometimes you need to try it several times (I read that somewhere, but it always worked for me the first time).

    . Correct usage of wminput
    For every wiimote, we need one wminput command to map the wiimote (and the classic controller) buttons to something emulationstation and the emulators can work with. wminput comes with configuration files (in directory /etc/cwiid/wminput). I created my own configuration file, which works if you use a wiimote with or without a classic controller. Create the file /home/pi/mywminput with the following content:

    Classic.Dpad.X = ABS_X
    Classic.Dpad.Y = ABS_Y
    Classic.LStick.X = ABS_HAT0X
    Classic.LStick.Y = ABS_HAT0Y
    Classic.RStick.X = ABS_HAT1X
    Classic.RStick.Y = ABS_HAT1Y
    Classic.A = BTN_A
    Classic.B = BTN_B
    Classic.X = BTN_X
    Classic.Y = BTN_Y
    Classic.Minus = BTN_SELECT
    Classic.Plus  = BTN_START
    Classic.Home  = BTN_MODE
    Classic.L  = BTN_TL
    Classic.R  = BTN_TR
    Classic.ZL = BTN_TL2
    Classic.ZR = BTN_TR2
    Wiimote.A		= BTN_A
    Wiimote.B		= BTN_B
    Wiimote.Dpad.X		= -ABS_Y
    Wiimote.Dpad.Y		= ABS_X
    Wiimote.Minus	= BTN_SELECT
    Wiimote.Plus	= BTN_START
    Wiimote.Home	= BTN_MODE
    Wiimote.1		= BTN_X
    Wiimote.2		= BTN_Y

    If the Raspberry Pi is started and emulationstation starts, we want to register the wiimotes so they can be used with emulationstation and the emulators.
    I did it the following way:
    mkdir /home/pi/bin
    create file /home/pi/bin/attachwii.sh with the following content:

    #!/bin/bash
    hcitool dev | grep hci >/dev/null
    if test $? -eq 0 ; then
    	wminput -d -c  /home/pi/mywminput 00:19:1D:92:90:38 &
    	wminput -d -c  /home/pi/mywminput 00:19:1D:84:EF:33 &
    else
    	echo "Blue-tooth adapter not present!"
    fi

    Note: You need one wminput line for every wiimote you want to use (i.e. the above is for two wiimotes)
    Note 2: You need to replace the addresses of the wiimotes above by the addresses of your wiimotes (shown by command „hcitool scan“ as shown above).
    make the script executable with
    chmod 775 /home/pi/bin/attachwii.sh
    have the script be started just before emulationstation starts. To do so, edit the file /etc/profile
    The last line should be
    [ -n "${SSH_CONNECTION}" ] || emulationstation
    right before this line, add the line
    /home/pi/bin/attachwii.sh
    and save the file.

    If you now do a reboot, wait until emulationstation has been started. When it did, press 1+2 on all of your wiimotes to register the wiimotes. Now you can „tell“ emulationstation and the emulators to use the wiimotes (and the classic controllers). Here are my configuration files.
    For emulationstation:
    Content of /home/pi/.emulationstation/es_input.cfg for two wiimotes:

    <?xml version="1.0"?>
    <inputList>
    	<inputConfig type="joystick" deviceName="Nintendo Wiimote">
    		<input name="a" type="button" id="0" value="1" />
    		<input name="b" type="button" id="1" value="1" />
    		<input name="down" type="axis" id="1" value="-1" />
    		<input name="left" type="axis" id="0" value="-1" />
    		<input name="menu" type="button" id="2" value="1" />
    		<input name="pagedown" type="button" id="4" value="1" />
    		<input name="pageup" type="button" id="5" value="1" />
    		<input name="right" type="axis" id="0" value="1" />
    		<input name="select" type="button" id="3" value="1" />
    		<input name="up" type="axis" id="1" value="1" />
    	</inputConfig>
    	<inputConfig type="joystick" deviceName="Nintendo Wiimote">
    		<input name="a" type="button" id="0" value="1" />
    		<input name="b" type="button" id="1" value="1" />
    		<input name="down" type="axis" id="1" value="-1" />
    		<input name="left" type="axis" id="0" value="-1" />
    		<input name="menu" type="button" id="2" value="1" />
    		<input name="pagedown" type="button" id="4" value="1" />
    		<input name="pageup" type="button" id="5" value="1" />
    		<input name="right" type="axis" id="0" value="1" />
    		<input name="select" type="button" id="3" value="1" />
    		<input name="up" type="axis" id="1" value="1" />
    	</inputConfig>
    	<inputConfig type="keyboard">
    		<input name="a" type="key" id="13" value="1" />
    		<input name="b" type="key" id="8" value="1" />
    		<input name="down" type="key" id="274" value="1" />
    		<input name="left" type="key" id="276" value="1" />
    		<input name="menu" type="key" id="32" value="1" />
    		<input name="right" type="key" id="275" value="1" />
    		<input name="up" type="key" id="273" value="1" />
    	</inputConfig>
    </inputList>

    For retroarch:
    End of file /home/pi/RetroPi/configs/all/retroarch.cfg (for two wiimotes):

    input_player1_joypad_index = "0"
    input_player1_b_btn = "0"
    input_player1_y_btn = "2"
    input_player1_select_btn = "8"
    input_player1_start_btn = "9"
    input_player1_up_axis = "+1"
    input_player1_down_axis = "-1"
    input_player1_left_axis = "-0"
    input_player1_right_axis = "+0"
    input_player1_a_btn = "1"
    input_player1_x_btn = "3"
    input_player1_l_btn = "4"
    input_player1_r_btn = "5"
    input_player1_l2_btn = "6"
    input_player1_r2_btn = "7"
    input_player1_l3_btn = "10"
    input_player1_r3_btn = "10"
    input_player1_l_x_plus_axis = "+2"
    input_player1_l_x_minus_axis = "-2"
    input_player1_l_y_plus_axis = "-3"
    input_player1_l_y_minus_axis = "+3"
    input_player1_r_x_plus_axis = "+4"
    input_player1_r_x_minus_axis = "-4"
    input_player1_r_y_plus_axis = "-5"
    input_player1_r_y_minus_axis = "+5"
    input_player2_joypad_index = "1"
    input_player2_b_btn = "1"
    input_player2_y_btn = "3"
    input_player2_select_btn = "8"
    input_player2_start_btn = "9"
    input_player2_up_axis = "+1"
    input_player2_down_axis = "-1"
    input_player2_left_axis = "-0"
    input_player2_right_axis = "+0"
    input_player2_a_btn = "0"
    input_player2_x_btn = "2"
    input_player2_l_btn = "4"
    input_player2_r_btn = "5"
    input_player2_l2_btn = "6"
    input_player2_r2_btn = "7"
    input_player2_l3_btn = "10"
    input_player2_r3_btn = "10"
    input_player2_l_x_plus_axis = "+2"
    input_player2_l_x_minus_axis = "-2"
    input_player2_l_y_plus_axis = "-3"
    input_player2_l_y_minus_axis = "+3"
    input_player2_r_x_plus_axis = "+4"
    input_player2_r_x_minus_axis = "-4"
    input_player2_r_y_plus_axis = "-5"
    input_player2_r_y_minus_axis = "+5"

    Make sure that the settings are only one time in retroarch.cfg file (i.e. if you have a line
    input_player1_b_btn = "0"
    in the retroarch.cfg file before adding my lines, remove (or out-comment) the whole section. If you want to use more than two wiimotes, search for the line
    input_player1_joypad_index = 0
    in retroarch.cfg and add the a corresponding line for the other wiimotes. For example you should have the following lines in retroarch.cfg for four wiimotes:

    input_player1_joypad_index = 0
    input_player2_joypad_index = 1
    input_player3_joypad_index = 2
    input_player4_joypad_index = 3

    Finally, add the following two lines at the end of /home/pi/RetroPi/configs/all/retroarch.cfg:

    input_enable_hotkey_btn = "0"
    input_exit_emulator_btn = "1"

    This will exit the emulator when you press A+B simultaneously on the wiimote (or the classic controller).

    Note: the config files above work for wiimotes with or without classic controller.
    Note 2: If you want to use the wiimote (i.e. not only the classic controller) and you are using my config files, you need to hold the wiimote horizontally (with the power button on the right).

    Hope that helps.

    #3146
    petrockblog
    Keymaster

    Thanks a lot for that!

    I have also added this guide to the wiki at https://github.com/retropie/RetroPie-Setup/wiki/Wiimotes-with-classic-controllers.

    #3998
    rogueapache
    Participant

    How would I change the config files to use the nunchuck instead of classic controllers?

    #47384
    paul
    Guest

    Hi, I went through this tutorial and it seems that the location of the config files has changed from $home/RetroPie/configs/ to /opt/retropie/emulators/RetroArch/configs. While the configs for the individual emulators is in /opt/retropie/configs/.

    Thanks for the tutorial!

    #75948
    AMeyer
    Guest

    Hello there,

    thank you for the tutorial.

    I´m on retropie 2.3- I have followed all the steps, but I get an

    unable to open uinput

    at startup.

    Any ideas?

    #76124
    escher
    Participant

    Great tutorial!

    There is any game that we can use the wiimote as a gun that runs in rpi ? Like The house of the dead ?

    #81977
    troyekto
    Participant

    There is a little mistake:

    KERNEL==“uinput“, MODE:=“0666“

    Should be:

    KERNEL=="uinput", MODE:="0666"

    ( ” instead of “ ).

    Anyway, excellent tutorial.

    #84661
    selim
    Participant

    How would you make the remote’s LED’s automatically turn on then too so that you can clearly see when it is connected?

    Edit:
    Better question, do any of the scripts ever store the remote as a variable? Because I couldn’t find that spot if it does.

    #84776
    buggers
    Participant

    I did everything here and when it loads the emulation station screen it says no gamepad detected. Even though I know the bluetooth device paired it.

    controller also doesn’t even work in games either

    any idea?

    #84778
    selim
    Participant

    After connecting the remote, do:
    `jstest /dev/input/js0
    Does that show your button presses?

    #84786
    buggers
    Participant

    [quote=84778]After connecting the remote, do:
    `jstest /dev/input/js0
    Does that show your button presses?[/quote]

    actually comes up as jstest command not found

    #84816
    selim
    Participant

    Hm

    #84832
    jayp76
    Participant

    Nice tutorial.
    Is cwiid a daemon? That would be awesome.
    I would try to connecy my 8-bitdo FC30 Blueetooth controllers with this in wiimote mode. Seems to be the missing piece of my portable retro console.
    I’ll report if it is working with FC30 in wiimote mode.

    #85848
    bobinio
    Participant

    Guys,

    Is this what I need to get a wii u pro controller working?

    I guess the “Mywminput” file needs to have more button map pings in it?

    Any help is appreciated.

    #87994
    squiffybagshaw
    Participant

    Thanks for the Tutorial.
    I’ve run through it and got stuck part way through. Trying to get Wiimotes working with my Raspberry Pi B+ and Retropie.

    make the script executable with
    chmod 775 /home/pi/bin/attachwii.sh

    I get an “Operation not permitted” for the chmod.
    I tried to prefix the command with sudo and that didn’t visibly do anything, but no error.

    And, on reboot, pressing the 1+2 buttons on my wiimote, Emulation Station doesn’t recognise them.
    Everything up to that point seemed to go OK.
    Any thoughts?
    Thanks

    #88623
    brainfrz
    Participant

    Thank you for this helpfull tutorial, i got it working, but i’m breaking my thoughts over the following:

    Whenever i connect my wiimote, my SSH session floods with the following message: Socket connect error (control channel)
    As soon as i disconnect my wiimote, all is fine again. I can’t figure out where to start looking to fix this. i hope there’s someone here that knows how to fix this, or can point me in the right direction.

    Also a minor issue, after using the above retroarch.cfg example, the buttons X and Y, and A and B were swapped. easy to fix though. Edit: on SNES only it seems, so i just added the lines to the console-specific .cfg, so i can set them up per console.

    Also it would be really nice if the LED would light up to show me it’s powered on. And could i use the “home” button to go back to emulationstation?

    #89215
    brainfrz
    Participant

    Just a quick add for reference, i found the attachwii.sh script started too fast on my rpi2. 9 out of 10 times the bluetooth dongle wasn’t initialized before it ran, so it gave me the “Blue-tooth adapter not present!” notification. After starting it manually it worked fine. So i added a simple “sleep 1” in the script so it would wait a second. After that, i haven’t had this problem again.

    #!/bin/bash
    sleep 1
    hcitool dev | grep hci >/dev/null
    if test $? -eq 0 ; then
    	wminput -d -c  /home/pi/mywminput 00:19:1D:92:90:38 &
    	wminput -d -c  /home/pi/mywminput 00:19:1D:84:EF:33 &
    else
    	echo "Blue-tooth adapter not present!"
    fi
    #93705
    kelemvor
    Participant

    So are these still the best instructions to use for the Wiimote?

    When my Attachwi.sh file runs and the last line “fi” runs, I get spammed with “unexpected character”.
    Is that normal?

    I was able to scan the bluetooth and get the MAC for my Wii mote.

    If I load into Emu Station, then I can’t use my keyboard at all if my BT adapter is plugged in. As soon as I unplug it then the keyboard starts working normally. Anyone have any ideas what the problem might be?

    I just want to use the u/d/l/r pad and the 1/2 buttons to play things like Mario until I can get an Xbox controller or something like that.

    Thanks!

    #93873
    lakespiral
    Participant

    Why on earth would you hold it with the power button to the right? Are you left handed? In emulationstation only button accepted was “A” (not 2). I started SMB1 with my keyboard. Start and select buttons weren’t anywhere and 1 & 2 didn’t do nothing. Only A & B. And now my playstation controllers or nes controllers won’t work anymore. So after few hours of work, nothing works anymore.

    Edit: Fucked up saving es_input.cfg. My bad. But the buttons are still wrong…

    #93883
    kelemvor
    Participant

    Nevermind my question. I picked up a wired Xbox compatible controller and had this whole thing setup within a couple minutes. :) Too much messing around to use the Wii controller.

    #93894
    brunchero
    Participant

    If you want your WiiMotes giving a connection status, just add a line to your mywminput file:
    Plugin.led.Led1 = 1

    You probably want different leds active on two controllers, which means you have provide different mywminput files to wminput, e.g. one with Led1 and one with Led2 activated.

    #105777
    dertak
    Participant

    EDIT: I think I cleared all problems. And I’m stupid :)

    PROBLEM 1:
    Wiimote detected only If I login via SSH:
    Really stupid problem because this tutorial mention it:
    https://github.com/RetroPie/RetroPie-Setup/wiki/Wiimotes-with-classic-controllers

    sleep 1 was the solution

    #!/bin/bash
    sleep 1 # Wait until Bluetooth services are fully initialized
    hcitool dev | grep hci >/dev/null
    if test $? -eq 0 ; then
        wminput -d -c  /home/pi/mywminput 00:19:1D:92:90:38 &
        ...
    fi

    PROBLEM 2:
    select and start buttons didn’t work.
    Just delete /home/pi/.emulationstation/es_input.cfg and follow GUI-Incstructions for button mapping. I was lazy and used mapping from this tutorial.

    My mapping (just Classic Pro Controller):

    <?xml version="1.0"?>
    <inputList>
            <inputConfig type="joystick" deviceName="Nintendo Wiimote" deviceGUID="050000$
                    <input name="a" type="button" id="0" value="1" />
                    <input name="b" type="button" id="1" value="1" />
                    <input name="down" type="axis" id="1" value="-1" />
                    <input name="left" type="axis" id="0" value="-1" />
                    <input name="leftanalogdown" type="axis" id="4" value="-1" />
                    <input name="leftanalogleft" type="axis" id="3" value="-1" />
                    <input name="leftanalogright" type="axis" id="3" value="1" />
                    <input name="leftanalogup" type="axis" id="4" value="1" />
                    <input name="leftbottom" type="button" id="6" value="1" />
                    <input name="lefttop" type="button" id="4" value="1" />
                    <input name="right" type="axis" id="0" value="1" />
                    <input name="rightanalogdown" type="axis" id="5" value="-1" />
                    <input name="rightanalogleft" type="axis" id="2" value="-1" />
                    <input name="rightanalogright" type="axis" id="2" value="1" />
                    <input name="rightanalogup" type="axis" id="5" value="1" />
                    <input name="rightbottom" type="button" id="7" value="1" />
                    <input name="righttop" type="button" id="5" value="1" />
                    <input name="select" type="button" id="8" value="1" />
                    <input name="start" type="button" id="9" value="1" />
                    <input name="up" type="axis" id="1" value="1" />
                    <input name="x" type="button" id="2" value="1" />
                    <input name="y" type="button" id="3" value="1" />
            </inputConfig>
    </inputList>

    I have other values for Start and Select.
    <input name=”select” type=”button” id=”8″ value=”1″ />
    <input name=”start” type=”button” id=”9″ value=”1″ />

Viewing 22 posts - 1 through 22 (of 22 total)
  • The forum ‘Everything else related to the RetroPie Project’ is closed to new topics and replies.