Repository navigation
Controller Configuration
This section is mostly useful if you want to use your controller for Kodi as well as moonlight. It's written for X360 controllers using xboxdrv.
There are mainly two ways on how to do this:
- create a file named
xbox_kodi.iniwith the following content:
[xboxdrv]
extra-devices = false
extra-events = false
deadzone = 6000
device-name = "Microsoft Xbox 360 Controller"
[ui-buttonmap]
A = KEY_ENTER
B = KEY_BACKSPACE
X = KEY_X
Y = KEY_ESC
du = KEY_UP
dd = KEY_DOWN
dl = KEY_LEFT
dr = KEY_RIGHT
start = KEY_SPACE
back = KEY_L
white = KEY_C
black = KEY_I
TR = BTN_RIGHT # Left stick buttons
TL = BTN_LEFT # Right stick buttons
RT = KEY_EQUAL # Right trigger
LT = KEY_MINUS # Left trigger
[ui-axismap]
x1=REL_X:10
y1=REL_Y:10
LT^resp:127:255=ABS_Z
RT^resp:127:255=ABS_RZ
# EOF #
(this is taken from Toast's post at OSMC forums)
This is most useful if you're using totally different configurations, as you can't re-assign specific stuff (e.g. deadzone) on the fly using xboxdrv's daemon mode.
- create a file named
xbox_kodi.sh(or whatever you prefer), including all of your xboxdrv launch arguments, e.g.xboxdrv --wid 0 --led 2 --deadzone 4000 --config /home/osmc/xbox_kodi.ini - edit your
/etc/rc.localfile and add/home/osmc/xbox_kodi.sh &(before theexit 0line). This will cause xboxdrv to start when your Pi starts - create a second file named
xbox_moonlight.shwith whatever arguments you usually use for moonlight, e.g.xboxdrv --trigger-as-button --wid 0 --led 2 --deadzone 4000 --dpad-rotation 90 --axismap -DPAD_X=DPAD_X --silent - create another file named
luna_pre.shand fill it with:
#!/bin/sh
sudo pkill xboxdrv
sudo /home/osmc/xbox_moonlight.sh &
- and yet another file:
luna_post.shcontaining the following:
#!/bin/sh
sudo pkill xboxdrv
sudo /home/osmc/xbox_kodi.sh &
- make all files executable:
chmod +x xbox_kodi.sh xbox_moonlight.sh luna_pre.sh luna_post.sh - inside Luna's settings in the "Init Scripts" tab, select the respective paths (luna_pre.sh as Pre Script, luna_post.sh as Post Script)
- either reboot your Pi or shut down any running instance of xboxdrv using
sudo pkill xboxdrvand launch it again usingsudo /etc/rc.local
Starting xboxdrv in daemon mode allows controller hotplugging, which is what I'm using a lot as I'm often playing alone but sometimes with 2+ people and don't want to change my setup all the time.
- create
xbox.shand add your xboxdrv launch arguments, referencing thexbox_kodi.inicreated above (after --config) and your other configuration (which is to be used for moonlight, after --next-config) for every controller slot you want to provide, e.g.:
xboxdrv --daemon \
--led 2 --deadzone 4000 --config /home/osmc/xbox_kodi.ini --next-config --dpad-rotation 90 --axismap -DPAD_X=DPAD_X --trigger-as-button \
--next-controller \
--led 3 --deadzone 4000 --config /home/osmc/xbox_kodi.ini --next-config --dpad-rotation 90 --axismap -DPAD_X=DPAD_X --trigger-as-button
- edit
/etc/rc.localand add/home/osmc/xbox.sh &(before theexit 0line) - create the file
luna_pre.shand fill it with:
#!/bin/sh
dbus-send --system --type=method_call --dest=org.seul.Xboxdrv /org/seul/Xboxdrv/ControllerSlots/0 org.seul.Xboxdrv.Controller.SetConfig int32:1
dbus-send --system --type=method_call --dest=org.seul.Xboxdrv /org/seul/Xboxdrv/ControllerSlots/1 org.seul.Xboxdrv.Controller.SetConfig int32:1
(repeat this for every controller you configured, in this example we're using two, so two calls are added)
- create another file named
luna_post.shand add:
#!/bin/sh
dbus-send --system --type=method_call --dest=org.seul.Xboxdrv /org/seul/Xboxdrv/ControllerSlots/0 org.seul.Xboxdrv.Controller.SetConfig int32:0
dbus-send --system --type=method_call --dest=org.seul.Xboxdrv /org/seul/Xboxdrv/ControllerSlots/1 org.seul.Xboxdrv.Controller.SetConfig int32:0
(this reverts the config back to the first config slot)
- make all scripts executable:
chmod +x xbox.sh luna_pre.sh luna_post.sh - create / edit (as root):
sudo nano /etc/dbus-1/system.d/org.seul.Xboxdrv.confand fill it with:
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus
Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<allow own="org.seul.Xboxdrv"/>
<allow send_type="method_call" log="true"/>
</policy>
</busconfig>
(this needs to be done as DBus access to the system bus - which xboxdrv uses by default if run as root - is limited, so we need rules to allow access for the driver itself and any method calls we want to send to it using this bus.)
- inside Luna's settings in the "Init Scripts" tab, select the respective paths (luna_pre.sh as Pre Script, luna_post.sh as Post Script)
- either reboot your Pi or shut down any running instance of xboxdrv using
sudo pkill xboxdrvand launch it again usingsudo /etc/rc.local