Skip to content

Ready made input devices

ArtMG edited this page Apr 5, 2021 · 6 revisions

This article gives examples of how to use common console Game Controller hardware device like a Wiimote or PS3 controller on PC hardware or Embedded devices

PS3 Controller

USB Connected

Recent versions of Linux should work just fine with the controller directly attached over USB, but it depends on the software recognising the input controls.

NB:

  • earlier Linux versions needed the xboxdrv driver package installing
  • some people recommend using the QTSixA utils if the game does not recognise controls
    • see SixAxis below

Bluetooth

This is using a Sony DualShock 3 Controller for the PlayStation (model number CECHZC2E which was sold as an authentic device).

NB: Two important steps with pairing your controller over Bluetooth

  1. Remove all power to your PS3 console
    1. or do this far enough away
    2. so it can't interfere with the pairing and connection process
  2. Connect the PS3 controller in using a USB cable
    1. it needs to be directly connected to recognise and authenticate the specific controller

Bluetooth adapter

See the ELinux list of USB Bluetooth Adapters for guidance on compatible hardware.

If you want to be sure what hardware your adapter is, run lsusb before and after inserting the dongle, to check which line appears.

Bluetooth stack

Some distros, like the Ubuntu family, already have the Bluetooth stack installed.

Test
# Do I have the Bluetooth stack installed?
bluetoothctl -v

If you get a version number, not an error, then skip the install below

Example to diagnose more about your system

# This page uses Raspbian Wheezy on a Raspberry Pi 2
sudo apt-get install -y lsb-release

lsb_release -d
# Description:	Debian GNU/Linux 7.8 (wheezy)

cat /proc/cpuinfo|grep Revision
# Revision	: a21041       indicates Raspberry Pi 2
# help - http://elinux.org/RPi_HardwareHistory
Install
# Install the drivers you need to use bluetooth (including the GUI tools)
sudo apt-get update
sudo apt-get install -y bluetooth bluez-utils blueman
# credit - https://www.thinkpenguin.com/gnu-linux/bluetooth-usb-adapter-setup-raspbian-raspberry-pi

# check it's working
hciconfig -a | grep UP
# 	UP RUNNING PSCAN 

# check the bluetooth group is present
cat /etc/group |grep blu
# and permit the pi user to change settings
sudo usermod -aG bluetooth pi
groups pi

Using pygame

This is rather a heavyweight solution, with loads of libraries being installed.

# credit [https://www.piborg.org/rpi-ps3-help]

sudo apt-get -y install libusb-dev joystick python3-pygame
cd ~
wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb

Once installed, the article [https://www.piborg.org/rpi-ps3-help] guides you through:

  • Connecting the Controller over USB to the Pi
  • using sixpair to make our Pi bluetooth the master of this controller
  • using bluetoothctl to:
    • set the Bluetooth discoverable
    • identify the MAC address of the controller
    • try to connect
    • trust (pair with) the controller
    • test the inputs to see which controls you're pressing

SixAxis

Ubuntu instructions:

# credit https://askubuntu.com/a/823220
sudo apt-get update&&sudo apt-get install git dialog build-essential pyqt4-dev-tools libusb-dev libjack-dev libbluetooth-dev python-dbus -y&&git clone https://github.com/falkTX/qtsixa.git&&cd qtsixa&&make&&sudo make install

Raspberry Pi instructions:

At the time of writing QtSixA was still not available in the list of Packages in the Raspbian archive (and using Debian / Ubuntu PPAs is hit and miss) so it's gonna have to be a compile from source...

other

see also:

  • [https://github.com/artmg/MuGammaPi/wiki/CamJam-Robotics-Kit]
    • example of using pygame to control a Raspberry Pi robot with PS3 over bluetooth
  • instructions on PS3 Bluetooth
    • to Install and Pair a PS3 controller in RetroPie

Wiimote

Kodi

For using console remote hardware see also:

Logitech steering set

Force-feedback steering wheel with pedals and optional gear stick/shift

e.g. G25 or G29

FYI G2x is for Playstations and PC, Gxx0 for Xbox and PC

For game compatibility see https://www.logitechg.com/en-gb/products/driving/driving-force-racing-wheel.html

VID / PID = 046D / C294

testing on Windows PC

  • Power on wheel and plug in USB
  • in Device Manager you should see a 'HID-compliant game controller' appear
  • See the Wheel Tester app in the Microsoft Store
  • If that does not recognise your device consider Docklight below

Docklight Scripting

This is a limited Evaluation software that allows you to monitor HID input

  • Download Docklight Scripting
  • Expand All and Setup/Install
  • Run Docklight Scripting
  • Tools / Project Settings
  • On the field Send / Recieve on Comm Channel enter:
    • USBHID:vvvv:pppp
    • where vvvv is the VID and pppp is the PID from Device Manager
  • Now click Scripting / Run (the Play button)
  • You should see inputs as you manipulate the device
  • for more see https://docklight.de/dl_faq047/