zeth / inputs

Cross-platform Python support for keyboards, mice and gamepads
BSD 3-Clause "New" or "Revised" License
273 stars 88 forks source link

PS3 not detected when on bluetooth #29

Open mrmoss opened 6 years ago

mrmoss commented 6 years ago

I'm on an RPi Zero W, running Raspbian Jessie, and an official PS3 controller.

I'm running the newest version of inputs from this git.

The controller shows up as a joystick under /dev/input/js0. I can run jstest /dev/input/js0 and see all axes and buttons.

Code I'm trying:

#!/usr/bin/env python3
from inputs import devices
print('List Devices')
for device in devices:
        print(device)
print('Done')

Output when using bluetooth:

Devices
Done

It works when plugged in via USB though:

Devices
Sony PLAYSTATION(R)3 Controller
Sony PLAYSTATION(R)3 Controller Motion Sensors
Done
zeth commented 6 years ago

This probably could work with sixad, though I haven't actually managed to get sixad to work on my Linux computer. Is there are particular Operating System that sixad works on?

zeth commented 6 years ago

Ok, RetroPi claims sixad support, maybe I will see if I can get inputs working on that with the PS3 over bluetooth. Then I will see if I can work my way to getting it to work on Raspian.

https://retropie.org.uk/docs/PS3-Controller/

mrmoss commented 6 years ago

I wasn't able to get sixad or qtsixa to work on the newest Raspian version. I've gotten it to work on older Raspian versions and pre Ubuntu 16.04. It looks like those two projects are no longer being updated either.

That being said, sixpair is a single c file that I've gotten to work on every Linux distro I've ever used (Arch, Ubuntu, Raspbian, Fedora, etc...) both old and new.

With just sixpair and the python evdev package, I can access the gamepad without issue. The fd shows up in /dev and jstest shows all axes and buttons working without sixpair/qtsixa.

On Sun, Jul 8, 2018, 14:34 Zeth notifications@github.com wrote:

Ok, RetroPi claims sixad support, maybe I will see if I can get inputs working on that with the PS3 over bluetooth. Then I will see if I can work my way to getting it to work on Raspian.

https://retropie.org.uk/docs/PS3-Controller/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zeth/inputs/issues/29#issuecomment-403306913, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvm01Rc77CiHt16en2Qr7pp5K9cYyjcks5uElDJgaJpZM4U1CR4 .

zeth commented 6 years ago

You are doing better than me. My PS3 controller is a Chinese clone (known as Gasia) and I haven't managed to get it to pair with bluetooth at all.

Apparently if it ever pairs, it should become available in: /dev/hidrawX Then we can connect it to inputs.

When your fd shows up in /dev using bluetooth, what does it come up as?

mrmoss commented 6 years ago

Shows up as: /dev/input/js0 and /dev/input/event0

As I recall, sixpair was patched to work with non-official PS3 controllers...but I could be wrong.

Here are my steps on Ubuntu 18.04:

sudo apt install libusb-dev joystick
cd /tmp/
wget http://www.pabr.org/sixlinux/sixpair.c
gcc -o sixpair sixpair.c -lusb
#And then I read sixpair.c for shells...because I'm paranoid I guess...
sudo mv sixpair /usr/bin
rm -f sixpair.c

From there I:

  1. Plugged the controller in via USB.
  2. Ran: sudo sixpair
  3. Unplugged controller.
  4. Turned controller and Bluetooth on.
  5. Then I had to trust the Bluetooth connection once I saw the controller in the Bluetooth manager.

You can trust the controller via cmd if that's easier:

bluetoothctl
agent on
discoverable on
#Wait to see controller and grab address
trust XXXXXXXXXXXXXXXXXXXXX
connect XXXXXXXXXXXXXXXXXXXXX
discoverable off
zeth commented 6 years ago

Thanks I will try that.