2014-03-04 21:19:30

by Andrea

[permalink] [raw]
Subject: Controlling LEDs and rumble on sixaxis

Hi,

I would like to be able to control from a client app the LEDs and rumble of the sixaxis PS3 controller.

As far as I understand the kernel 3.15 will allow LEDs to be set by bluez when the controller is
connected.
If I wanted to change the LEDs in my app, would this something that needs to be done by bluez? Can I
write to some device and bypass bluez?
Would this be a job for dbus?

I use the sixaxis to control an app on the Pi, and given the lack of feedbacks from the Pi, the LEDs
and rumble could help me on that front.

Does it make sense to do it?

Andrea


2014-03-30 19:17:22

by Andrea

[permalink] [raw]
Subject: Re: Controlling LEDs and rumble on sixaxis

On 04/03/14 22:11, Antonio Ospite wrote:
>
> With older kernels you can already set LEDs and rumble by sending the
> HID output report 01 via hidraw (actually there is a regression
> preventing that via BT in some versions). See the code in the BlueZ
> sixaxis plugin or in the newer linux kernel for the report format.

hi

after a while I managed to try to use the LEDs.
I'm using linux 3.13.6 with this hack (modified for PS3 usb id)

http://www.spinics.net/lists/linux-bluetooth/msg42955.html

as the good one is too complicated to back port to 3.13

http://article.gmane.org/gmane.linux.kernel.input/34896

(is it going to make it in 3.15?)

This is all via Bluetooth, using bluez 5.16

Results:
1) using /dev/hidraw0 LEDs work like a charm
2) I don't think my kernel supports /sys/class/leds as I can't find anything there
3) rumble does not work. I've tried various combination of the bytes 2 to 5
(e.g. 0xfe, 0x00, 0xfe, 0xff) but nothing happens. do I need the full patch?
or the hack is enough?
4) ff: tried fftest and nothing happens: this is the output

Force feedback test program.
HOLD FIRMLY YOUR WHEEL OR JOYSTICK TO PREVENT DAMAGES

Device /dev/input/event0 opened
Axes query:
Effects: Periodic Rumble
Number of simultaneous effects: 16
Upload effects[1]: Invalid argument
Upload effects[2]: Invalid argument
Upload effects[3]: Invalid argument
Enter effect number, -1 to exit
1
Now Playing: Constant Force
Enter effect number, -1 to exit


Any idea what else is missing to make rumble work?


2014-03-05 14:06:42

by Andrea

[permalink] [raw]
Subject: Re: Controlling LEDs and rumble on sixaxis

On 04/03/14 22:11, Antonio Ospite wrote:
>
> With older kernels you can already set LEDs and rumble by sending the
> HID output report 01 via hidraw (actually there is a regression
> preventing that via BT in some versions). See the code in the BlueZ

I think the kernels I use have this regressions as the plugin does not set anything.
(Szymon mentioned something like that)
could you please give me a link to the fix so I can track if and when they are fixed for me.

> sixaxis plugin or in the newer linux kernel for the report format.
>
> With recent/newer kernels you can use the sysfs leds class under
> /sys/class/leds/ to control the LEDs and the force feedback api[1] to
> control the rumble.

sounds simple. is this functionality affected by the above regression?

> dbus is not necessary, but depending on your application you may want to
> use libudev to add the hotplug detection of the controller.
>

I only mentioned dbus as I found I can use it to disconnect the controller (Bluetooth).
Happy to skip it altogether. If there is a better way?

Andrea


2014-03-04 22:11:18

by Antonio Ospite

[permalink] [raw]
Subject: Re: Controlling LEDs and rumble on sixaxis

Hi Andrea,

On Tue, 04 Mar 2014 21:19:30 +0000
Andrea <[email protected]> wrote:

> Hi,
>
> I would like to be able to control from a client app the LEDs and
> rumble of the sixaxis PS3 controller.
>
> As far as I understand the kernel 3.15 will allow LEDs to be set by
> bluez when the controller is connected. If I wanted to change the
> LEDs in my app, would this something that needs to be done by bluez?
> Can I write to some device and bypass bluez?

With older kernels you can already set LEDs and rumble by sending the
HID output report 01 via hidraw (actually there is a regression
preventing that via BT in some versions). See the code in the BlueZ
sixaxis plugin or in the newer linux kernel for the report format.

With recent/newer kernels you can use the sysfs leds class under
/sys/class/leds/ to control the LEDs and the force feedback api[1] to
control the rumble.

No need to "bypass" BlueZ, the BlueZ sixaxis plugin sets the LEDs when
it detects the controller in order to tell the user the controller
number, but after that you are free to change the LEDs as you want.

[1] https://www.kernel.org/doc/Documentation/input/ff.txt

> Would this be a job for dbus?
>

dbus is not necessary, but depending on your application you may want to
use libudev to add the hotplug detection of the controller.

> I use the sixaxis to control an app on the Pi, and given the lack of
> feedbacks from the Pi, the LEDs and rumble could help me on that
> front.
>
> Does it make sense to do it?
>

Why not?

Ciao,
Antonio

--
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?