ArturSpirin / pyPS4Controller

Light module (less than 30KB) without any dependencies designed to provide hooks for PS4 Controller events
MIT License
124 stars 34 forks source link

Wrong or no potentiometer values #24

Open smarkwardt opened 3 years ago

smarkwardt commented 3 years ago

The PS4-Controller is connected via bluetooth to my raspberry pi and it works fine

I tested the controller with the following command.

root@pi:/tmpt# jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (Wireless Controller) has 8 axes (X, Y, Z, Rx, Ry, Rz, Hat0X, Hat0Y)
and 13 buttons (BtnA, BtnB, BtnX, BtnY, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR).
Testing ... (interrupt to exit)
Axes:  0:     0  1:     0  2:     0  3:     0  4:     0  5:     0  6:     0  7:     0 Buttons:  0:off  1:off  2:of
...
Axes:  0:     0  1:     0  2:-32767  3:     0  4:     0  5:     0  6:     0  7:     0 Buttons:  0:off  1:off  2:of
Axes:  0:     0  1:     0  2:-32767  3:     0  4:     0  5:     0  6:     0  7:     0 Buttons:  0:off  1:off  2:of
Axes:  0:     0  1:     0  2:-32767  3:     0  4:     0  5:     0  6:     0  7:     0 Buttons:  0:off  1:off  2:of
Axes:  0:     0  1:     0  2:-32767  3:     0  4:     0  5:-32767  6:     0  7:     0 Buttons:  0:off  1:off  2:of
Axes:  0:     0  1:     0  2:-32767  3:     0  4:     0  5:-32767  6:     0  7:     0 Buttons:  0:off  1:off  2:of
...
Axes:  0:     0  1:     0  2:-32767  3:     0  4:     0  5:-32767  6:     0  7:     0 Buttons:  0:off  1:off  2:of

With jstest i get for the potentiometer values for L2, R2, L3 & R3 value up to 32k.

But with Python and the pyPS4Controller package received only static values in lower range. The value ist randomly changed with every restart or connect.

I installed the latest version with pip install pyps4controller and pip3 install pyps4controller

root@pi:/tmp# python3 test.py
Waiting for interface: /dev/input/js0 to become available . . .
Successfully bound to: /dev/input/js0.
on_R3_up: 76
on_R3_up: 76
...
on_R3_y_at_rest
on_L3_right: 76
on_L3_right: 76
on_L3_x_at_rest
on_R3_left: 76
on_R3_left: 76
on_R3_left: 76
...
on_R3_left: 76
on_R3_left: 76
on_R3_x_at_rest
on_R2_press: 76
on_R2_press: 76
...

Thats my code.

from pyPS4Controller.controller import Controller

class MyController(Controller):
    def __init__(self, **kwargs):
        Controller.__init__(self, **kwargs)

controller = MyController(interface="/dev/input/js0", connecting_using_ds4drv=False)
controller.listen()
jiatinglu99 commented 3 years ago

I believe you had the same problem as #20 It is a bug and you can fix it according to @thavens 's solution at the bottom of #20

smarkwardt commented 3 years ago

The hotfix works perfect. Thanks!