File: multi-controller.sh

package info (click to toggle)
xboxdrv 0.8.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,364 kB
  • sloc: cpp: 19,638; xml: 3,202; ansic: 507; python: 492; sh: 105; makefile: 34; ruby: 19
file content (39 lines) | stat: -rw-r--r-- 1,225 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

# Bash script for using two (or more) wireless controllers 
# ########################################################
#
# Running xboxdrv regularly only supports a single controller, using
# two or more controllers is however possible by launching multiple
# instances of xbdroxv. When launching two instances the build-in
# command execution of xboxdrv no longer can be used, so keeping track
# and killing the xboxdrv processes has to be done manually.

# tell bash to exit the script when something goes wrong
set -e 

# launch xboxdrv for the first wireless controller
xboxdrv \
  --wid 0 \
  --deadzone 6000 --trigger-as-button -s --dpad-as-button \
  --ui-buttonmap back=KEY_ESC,start=KEY_ENTER,dd=KEY_DOWN,du=KEY_UP,dr=KEY_RIGHT,dl=KEY_LEFT &
XBOXPID1=$!

# launch xboxdrv for the second wireless controller
xboxdrv \
  --wid 1 \
  --deadzone 6000 --trigger-as-button -s --dpad-as-button \
  --ui-buttonmap back=KEY_ESC,start=KEY_ENTER,dd=KEY_DOWN,du=KEY_UP,dr=KEY_RIGHT,dl=KEY_LEFT &
XBOXPID2=$!

# launch your game
/usr/games/you_game

# after the game has exited, kill the started xboxdrv processes and
# wait for them to shut down
kill $XBOXPID1
kill $XBOXPID2
wait $XBOXPID1
wait $XBOXPID2

# EOF #