Wii classic controllers
#1
Good afternoon,

I am running Leia 18.5 on RPi3 with Librelec.  I have Retroplayer running and a few test ROMs.  But I have a question about the game controllers.

I have a Wii with a set of Wii remotes and classic controllers that I was hoping to re-purpose as Kodi emulator game controllers.  For those that do not know, the classic controllers are the ones that plug into the Wii remote and resemble the old SNES controllers.  I have been able to set up the Wii remote to control Kodi just fine.  The problem is that when I go to configure the game controllers, the only button on the classic controller that seems to register with Kodi is the directional pad.  Neither the joysticks or any other buttons on the classic controller seem to do anything.

I have been doing a bunch of searching of the Kodi wiki and this forum, but I can't seem to find anything that can help me.  From what I understand, it seems that the Wii classic controllers are not supported by Retroplayer "out of the box", but there are allusions to the fact that you can get other controllers to work with it.  I just really don't know what's involved or where to start - is there a reference online that I should check out?

I'm not a Linux guy per se but I have a lot of coding experience in other languages.  I'm comfortable with SSH and command-line syntax, I just really need someone to point me in the right direction.  I realize I could just go out and buy a bunch of controllers that are compatible with Retroplayer, but the point was to try to use something that I already have lying around the house.  If there's a relatively easy way to get what I have to work, I'm willing to try.

Thanks so much in advance.  And thanks to all of you who volunteer your time and advice supporting Kodi.
Reply
#2
(2020-01-31, 21:52)MovieGuy2 Wrote: Good afternoon,

I am running Leia 18.5 on RPi3 with Librelec.  I have Retroplayer running and a few test ROMs.  But I have a question about the game controllers.

I have a Wii with a set of Wii remotes and classic controllers that I was hoping to re-purpose as Kodi emulator game controllers.  For those that do not know, the classic controllers are the ones that plug into the Wii remote and resemble the old SNES controllers.  I have been able to set up the Wii remote to control Kodi just fine.  The problem is that when I go to configure the game controllers, the only button on the classic controller that seems to register with Kodi is the directional pad.  Neither the joysticks or any other buttons on the classic controller seem to do anything.

I have been doing a bunch of searching of the Kodi wiki and this forum, but I can't seem to find anything that can help me.  From what I understand, it seems that the Wii classic controllers are not supported by Retroplayer "out of the box", but there are allusions to the fact that you can get other controllers to work with it.  I just really don't know what's involved or where to start - is there a reference online that I should check out?

I'm not a Linux guy per se but I have a lot of coding experience in other languages.  I'm comfortable with SSH and command-line syntax, I just really need someone to point me in the right direction.  I realize I could just go out and buy a bunch of controllers that are compatible with Retroplayer, but the point was to try to use something that I already have lying around the house.  If there's a relatively easy way to get what I have to work, I'm willing to try.

Thanks so much in advance.  And thanks to all of you who volunteer your time and advice supporting Kodi.

i am no expert, please disregard this if it doesn't help.

i had  a similar issue with some cheap wifi controllers
where basically a, b, x, y buttons were not recognised
in my case i had to ssh into libreelec and edit  .kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linu
x/Gasia_Co._Ltd_PS_R__Gamepad_12b_7a.xml
Note: "Gasia_Co..." is how the system recognises my gamepad, so yours might be different
i ended up adding the entries for these buttons directly into the joystick xml


for reference this is how the controller part of the file looks now (a,b,x,y were missing) :
make a backup before editing ;-)
Code:
       <controller id="game.controller.default">
            <feature name="a" button="2" />
            <feature name="b" button="1" />
            <feature name="x" button="3" />
            <feature name="y" button="0" />
            <feature name="back" button="8" />
            <feature name="down" axis="+1" />
            <feature name="left" axis="-0" />
            <feature name="leftbumper" button="4" />
            <feature name="leftstick">
                <up axis="-5" />
                <down axis="+5" />
                <right axis="+4" />
                <left axis="-4" />
            </feature>
            <feature name="leftthumb" button="10" />
            <feature name="lefttrigger" button="6" />
            <feature name="right" axis="+0" />
            <feature name="rightbumper" button="5" />
            <feature name="rightthumb" button="11" />
            <feature name="righttrigger" button="7" />
            <feature name="start" button="9" />
            <feature name="up" axis="-1" />
        </controller>

 




hope this helps
M
Reply
#3
Hi MovieGuy2,

I'm the dev behind the current joystick system. I've uploaded several guides to the wiki: https://kodi.wiki/view/Game_controllers . If your controller is missing a button map (e.g. it would appear at .kodi/userdata/addon_data/peripheral.joystick/resources/buttonmaps/xml/linux, create one and share it here (see https://kodi.wiki/view/HOW-TO:Share_button_maps ). If you're quick, I'll include the button map in the 18.6 release so that Wii Classic controllers work out-of-the-box.
Reply
#4
Sad 
I am also trying to get a Wii Remote Classic Controller to work. I'm experiencing the same effects the OP mentioned. I've been trying to put together a mapping XML file for the controller but haven't had any luck.

I'm starting to think there may be a lower level issue because even though the Wii Remote buttons seem to be working (A confirms, B goes back, 1 is pgUp and 2 is pgDown, + and - control volume), the Classic Controller is only responding to the d-pad buttons.

So, I started trying to identify how does this look to the OS:
Quote:LibreELEC:~ # cat /proc/bus/input/devices
I: Bus=0005 Vendor=057e Product=0306 Version=8600
N: Name="Nintendo Wii Remote Accelerometer"
P: Phys=
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:42/0005:057E:0306.0001/input/input1
U: Uniq=
H: Handlers=event0
B: PROP=0
B: EV=9
B: ABS=38

I: Bus=0005 Vendor=057e Product=0306 Version=8600
N: Name="Nintendo Wii Remote IR"
P: Phys=
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:42/0005:057E:0306.0001/input/input2
U: Uniq=
H: Handlers=event1
B: PROP=0
B: EV=9
B: ABS=ff0000

I: Bus=0005 Vendor=057e Product=0306 Version=8600
N: Name="Nintendo Wii Remote"
P: Phys=
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:42/0005:057E:0306.0001/input/input0
U: Uniq=
H: Handlers=kbd js0 event2
B: PROP=0
B: EV=200003
B: KEY=10800000 0 0 10030000 6 0 0 0 0 1680 0 0 0
B: FF=1 7030000 0 0

I: Bus=0005 Vendor=057e Product=0306 Version=8600
N: Name="Nintendo Wii Remote Classic Controller"
P: Phys=
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:42/0005:057E:0306.0001/input/input3
U: Uniq=
H: Handlers=kbd js1 event3
B: PROP=0
B: EV=b
B: KEY=10800000 0 0 13db0000 0 0 0 0 0 1680 0 0 0
B: ABS=fc0000

I: Bus=0005 Vendor=057e Product=0306 Version=8600
N: Name="Nintendo Wii Remote Motion Plus"
P: Phys=
S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:42/0005:057E:0306.0001/input/input4
U: Uniq=
H: Handlers=event4
B: PROP=0
B: EV=9
B: ABS=38

LibreELEC:~ # evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Nintendo Wii Remote Accelerometer
/dev/input/event1:      Nintendo Wii Remote IR
/dev/input/event2:      Nintendo Wii Remote
/dev/input/event3:      Nintendo Wii Remote Classic Controller
/dev/input/event4:      Nintendo Wii Remote Motion Plus
Select the device event number [0-4]: 3
Input driver version is 1.0.1
Input device ID: bus 0x5 vendor 0x57e product 0x306 version 0x8600
Input device name: "Nintendo Wii Remote Classic Controller"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 103 (KEY_UP)
    Event code 105 (KEY_LEFT)
    Event code 106 (KEY_RIGHT)
    Event code 108 (KEY_DOWN)
    Event code 304 (BTN_SOUTH)
    Event code 305 (BTN_EAST)
    Event code 307 (BTN_NORTH)
    Event code 308 (BTN_WEST)
    Event code 310 (BTN_TL)
    Event code 311 (BTN_TR)
    Event code 312 (BTN_TL2)
    Event code 313 (BTN_TR2)
    Event code 316 (BTN_MODE)
    Event code 407 (KEY_NEXT)
    Event code 412 (KEY_PREVIOUS)
  Event type 3 (EV_ABS)
    Event code 18 (ABS_HAT1X)
      Value      0
      Min      -30
      Max       30
      Fuzz       1
      Flat       1
    Event code 19 (ABS_HAT1Y)
      Value     -3
      Min      -30
      Max       30
      Fuzz       1
      Flat       1
    Event code 20 (ABS_HAT2X)
      Value      0
      Min      -30
      Max       30
      Fuzz       1
      Flat       1
    Event code 21 (ABS_HAT2Y)
      Value      0
      Min      -30
      Max       30
      Fuzz       1
      Flat       1
    Event code 22 (ABS_HAT3X)
      Value      2
      Min      -30
      Max       30
      Fuzz       1
      Flat       1
    Event code 23 (ABS_HAT3Y)
      Value      0
      Min      -30
      Max       30
      Fuzz       1
      Flat       1
Properties:
Testing ... (interrupt to exit)

LibreELEC:~ # evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Nintendo Wii Remote Accelerometer
/dev/input/event1:      Nintendo Wii Remote IR
/dev/input/event2:      Nintendo Wii Remote
/dev/input/event3:      Nintendo Wii Remote Classic Controller
/dev/input/event4:      Nintendo Wii Remote Motion Plus
Select the device event number [0-4]: 2
Input driver version is 1.0.1
Input device ID: bus 0x5 vendor 0x57e product 0x306 version 0x8600
Input device name: "Nintendo Wii Remote"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 103 (KEY_UP)
    Event code 105 (KEY_LEFT)
    Event code 106 (KEY_RIGHT)
    Event code 108 (KEY_DOWN)
    Event code 257 (BTN_1)
    Event code 258 (BTN_2)
    Event code 304 (BTN_SOUTH)
    Event code 305 (BTN_EAST)
    Event code 316 (BTN_MODE)
    Event code 407 (KEY_NEXT)
    Event code 412 (KEY_PREVIOUS)
  Event type 21 (EV_FF)
    Event code 80 (FF_RUMBLE)
    Event code 81 (FF_PERIODIC)
    Event code 88 (FF_SQUARE)
    Event code 89 (FF_TRIANGLE)
    Event code 90 (FF_SINE)
    Event code 96 (FF_GAIN)
Properties:
Testing ... (interrupt to exit)

According to this, Wii Remote should have 11 buttons and no axes, and Classic Controller 15 buttons and 6 axes. Both devices have the same vendorId 057e and productId 0306. evtest receives and prints out properly all of the controller's buttons and axis with their expected values.

I'm assuming writing this buttonmapping XML file that the button index it expects is relative to the order provided by evtest (button 0 is KEY_UP, button 1 is KEY_LEFT and so on). I've been looking at the sources of the peripheral.joystick addon and had that feeling from those DriverPrimitive calls. I've tried multiple variations of this file adding the pid and vid attributes, the buttoncount and axiscount attributes (in the device tag and also in the filename as expected according to the sources). Also tried using udev as provider (under xml/udev in that case).
Quote:<?xml version="1.0" ?>
<buttonmap>
    <device name="Nintendo Wii Remote Classic Controller" provider="linux">
        <controller id="game.controller.default">
            <feature name="up" button="0"/>
            <feature name="left" button="1"/>
            <feature name="right" button="2"/>
            <feature name="down" button="3"/>
        
            <feature name="a" button="4" />
            <feature name="b" button="5" />
            <feature name="x" button="6" />
            <feature name="y" button="7" />
            
            <feature name="lefttrigger" button="8" />
            <feature name="righttrigger" button="9" />
            
            <feature name="leftbumper" button="10" />
            <feature name="rightbumper" button="11" />
            
            <feature name="start" button="13" />
            <feature name="select" button="14" />

            <feature name="leftstick">
                <left axis="-0" />
                <right axis="+0" />
                <up axis="+1" />
                <down axis="-1" />
            </feature>
            <feature name="righttstick">
                <left axis="-2" />
                <right axis="+2" />
                <up axis="+3" />
                <down axis="-3" />
            </feature>
        </controller>
    </device>
</buttonmap>

Here is the kodi log penareyode.kodi (paste).

This log has the device attached then there's a change to udev and back to linux drivers in the addon.
One curious thing I've noticed is with udev it seems to properly detect button numbers:
Quote:INFO: AddOnLog: Joystick Support: Disabling joystick interface "linux"
INFO: AddOnLog: Joystick Support: Enabling joystick interface "udev"
INFO: AddOnLog: Joystick Support: Initialized joystick 2: "Nintendo Wii Remote", axes: 0, hats: 0, buttons: 11
INFO: AddOnLog: Joystick Support: Initialized joystick 3: "Nintendo Wii Remote Classic Controller", axes: 6, hats: 0, buttons: 15

OTOH, with linux it seems to be losing 4 buttons:
Quote:INFO: AddOnLog: Joystick Support: Enabling joystick interface "linux"
INFO: AddOnLog: Joystick Support: Disabling joystick interface "udev"
INFO: AddOnLog: Joystick Support: Initialized joystick 4: "Nintendo Wii Remote Classic Controller", axes: 6, hats: 0, buttons: 11
INFO: AddOnLog: Joystick Support: Initialized joystick 5: "Nintendo Wii Remote", axes: 0, hats: 0, buttons: 7

The libinput: event3  - debounce state: .... log lines happen whenever I press a button on the Controller (only d-pad seems to be recognised), which is the most annoying part. I can't figure out what to do with this, and it's what's making me think it may be a lower level issue.

I don't know what else to try, any hints - pretty please - @garbear?

Thanks and sorry if this is too long or garbled, first time poster here!
Reply
#5
Sorry again for double posting, didn't find a way to edit the previous post.

Also might be relevant pointing out these log lines that seem to only happen with linux
Quote:DEBUG: Failed to load button map for "Nintendo Wii Remote Classic Controller"
DEBUG: Failed to load button map for "Nintendo Wii Remote"
I really don't know why that might be happening, didn't even find that error message in the sources.
Reply
#6
I've finally got this to work. Taking a closer look at the log, it showed the controller was being actually recognized as a keyboard:

Code:
    DEBUG: libinput: event2: device is ignored
    DEBUG: CLibInputHandler::DeviceAdded - keyboard type device added: Nintendo Wii Remote Classic Controller (event3)
    DEBUG: CLibInputKeyboard::GetRepeat - could not get key repeat for event3 (Function not implemented)
    DEBUG: CLibInputKeyboard::GetRepeat - delay: 400ms repeat: 80ms for Nintendo Wii Remote Classic Controller (event3)
     INFO: AddOnLog: Joystick Support: Initialized joystick 0: "Nintendo Wii Remote", axes: 0, hats: 0, buttons: 11
     INFO: AddOnLog: Joystick Support: Initialized joystick 1: "Nintendo Wii Remote Classic Controller", axes: 6, hats: 0, buttons: 15

Then, once the controller was connected, d-pad buttons were effectively treated as keyboard input:

Code:
    DEBUG: Keyboard: scancode: 0x69, sym: 0x0114, unicode: 0x0000, modifier: 0x0
    DEBUG: HandleKey: left (0xf082) pressed, action is Left

And all other buttons were just outputting those DEBUG: libinput: event3  - debounce state: DEBOUNCE_STATE_ lines.

I'm not familiar at all with udev and this sort of stuff (always happy to learn though) and a bit of research - https://github.com/xbmc/xbmc/issues/15588 for instance - suggested installing a udev rule that would disable ID_INPUT_KEY on the controller. Tried that to no effect, but a closer look at the Wii Remote udev info revealed it had

Code:
    E: eventlircd_enable=true
    E: eventlircd_evmap=wiimote.evmap
    E: LIBINPUT_IGNORE_DEVICE=1

The eventlircd_enable=true explained why d-pad presses on the Wii Remote were actually not showing as keyboard events but LIRC ones:
Code:

    DEBUG: LIRC: - NEW 6c 0 KEY_DOWN devinput (KEY_DOWN)
    DEBUG: HandleKey: 167 (0xa7, obc88) pressed, action is Down

But the line that got my attention was LIBINPUT_IGNORE_DEVICE=1. And voila:

Code:
    LibreELEC:~ # systemctl stop kodi
    LibreELEC:~ # libinput debug-events
    -event3   DEVICE_ADDED     Nintendo Wii Remote Classic Controller seat0 default group1  cap:k
     event3   KEYBOARD_KEY      +8.94s      KEY_LEFT (105) pressed
     event3   KEYBOARD_KEY      +9.04s      KEY_LEFT (105) released
     event3   KEYBOARD_KEY     +10.00s      KEY_RIGHT (106) pressed
     event3   KEYBOARD_KEY     +10.08s      KEY_RIGHT (106) released
    libinput error: libinput bug: Event for missing capability CAP_POINTER on device "Nintendo Wii Remote Classic Controller"
    libinput error: libinput bug: Event for missing capability CAP_POINTER on device "Nintendo Wii Remote Classic Controller"

D-Pad buttons were properly tracing but the other buttons were bugging out! So, after using this udev rule:

Code:
    SUBSYSTEM=="input", ENV{DEVNAME}=="/dev/input/event*", MODE="0666", ENV{ID_INPUT_KEY}="", ENV{LIBINPUT_IGNORE_DEVICE}="1"
    SUBSYSTEM=="input", ENV{DEVNAME}=="/dev/input/js*", MODE="0666", ENV{ID_INPUT_KEY}="", ENV{LIBINPUT_IGNORE_DEVICE}="1"

It shows in the logs the event* and js* devices are ignored, and the controller in inmediately recognized by joystick.peripheral on a button press.

I'm still looking for a way to refine this udev rule so it will apply only to the controller. Trying with ATTRS{name}=="Nintendo Wii Classic Controller" didn't work. This is the Classic Controller's udev info for the record:

Code:
    LibreELEC:~ # udevadm info /dev/input/event3
    P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:42/0005:057E:0306.0001/input/input3/event3
    N: input/event3
    L: 0
    E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:42/0005:057E:0306.0001/input/input3/event3
    E: DEVNAME=/dev/input/event3
    E: MAJOR=13
    E: MINOR=67
    E: SUBSYSTEM=input
    E: USEC_INITIALIZED=147219569
    E: ID_INPUT=1
    E: ID_INPUT_JOYSTICK=1
    E: ID_BUS=usb
    E: ID_INPUT_JOYSTICK_INTEGRATION=external
    E: ID_VENDOR=0a12
    E: ID_VENDOR_ENC=0a12
    E: ID_VENDOR_ID=0a12
    E: ID_MODEL=0001
    E: ID_MODEL_ENC=0001
    E: ID_MODEL_ID=0001
    E: ID_REVISION=1958
    E: ID_SERIAL=0a12_0001
    E: ID_TYPE=generic
    E: ID_USB_INTERFACES=:e00101:
    E: ID_USB_INTERFACE_NUM=00
    E: ID_USB_DRIVER=btusb
    E: LIBINPUT_IGNORE_DEVICE=1
    E: TAGS=:power-switch:

Must also say I only got it to work properly with the udev driver. This controller has apparently really weird key codes for the d-pad (which are actually for keyboards) which would explain the 4 lost buttons I mentioned in the previous post. Linux driver actually worked for the buttons but the d-pad wasn't understandably being recognised.

Sorry if this is way too verbose or outright spammy, just wanted to share and also hoping someone more knowledgeable will be able to clarify why did libinput have to be ignored for this device.
Reply
#7
Can anyone tell me the current status for Wii classic controllers?  I've just started trying to play games and set up our Wiii classic controllers.  Thanks for any replies.
Reply
#8
(2020-05-17, 18:03)ctviggen Wrote: Can anyone tell me the current status for Wii classic controllers?

I don't really know if there has been any progress - or if we should expect any at all regarding this - from
Code:
peripheral.joystick
. In my last post I explained how I got it working on LibreElec. I had to install a custom
Code:
udev
rule to set
Code:
LIBINPUT_IGNORE_DEVICE
to
Code:
1
. Unsetting
Code:
ID_INPUT_KEY
may also help.

This rule
Code:
SUBSYSTEM=="input", ENV{DEVNAME}=="/dev/input/event*", MODE="0666", ENV{ID_INPUT_KEY}="", ENV{LIBINPUT_IGNORE_DEVICE}="1"
    SUBSYSTEM=="input", ENV{DEVNAME}=="/dev/input/js*", MODE="0666", ENV{ID_INPUT_KEY}="", ENV{LIBINPUT_IGNORE_DEVICE}="1"

Worked for me on LE although if you have other controllers it may be too broad and mess up with them. The device selection part of the rule obviously needs tweaking.

Also, I had to use the
Code:
udev
driver instead of the
Code:
linux
one. Apparently the Wii Classic Controller turns out to be very peculiar about the event codes for some of its buttons.
Reply
#9
Sorry about the formatting mess up there ^ Can't edit post sorry.
Reply
#10
Thanks for the info. 

Well, I realized that my new HT computer I set up did not have Bluetooth...which I thought all modern motherboards would have.  No wonder my Wii controller would not sync with Kodi. ;-) So, I can't test this out until I get a bluetooth dongle, which is taking a while to ship.
Reply
#11
My main constraint is time, but I'm going to try to do some testing once the Multiplayer GSoC projects comes into swing this summer.
Reply

Logout Mark Read Team Forum Stats Members Help
Wii classic controllers0