Skip to content

Conversation

@nicolas0p
Copy link
Contributor

Implement support for the Sony DualShock 3 controller.

This implementation was based on the linux driver for this controller and tested manually using both Bluetooth connection and USB cable.

The DS3 reports battery capacity in a odd way. It actually only reports 7 possible values: 0, 1, 25, 50, 75, 100% battery capacity, charging-not-full or charging-full. So I had to choose which value of battery capacity when it reports charging-not-full. I opted for 75% so the user wouldn't think the battery is full when it is not. But this leads to a funny situation:

  • Controller is connected via Bluetooth reporting 100% battery
  • User connects the controller via cable
  • Now we are going to report battery as 75%. It seems like the controller just lost battery capacity.
    Anyway, this is just a minor inconvenience, but it is confusing.

I tried to follow all code conventions, but I may have failed.

Please point out errors and improvements I could make to the code.

All tests were done using a DualShock 3 model CECHZC2U. I can adapt the code to other similar models if needed, however, I don't have other DS3 controllers. I don't think there are major differences, at least according to the linux driver.

Hope we can get this code merged, I think it would help a few users.
It was a fun little project.

It reads from the DS3 controller and figures out the battery capacity
and status. Based on the linux driver for this controller.
Also dedup hidapi.device_list() using device serial_number in
controllers() because in my tests the DualShock 3 controller was showing
up twice.
@jfernandez jfernandez merged commit 526f8a4 into jfernandez:main Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants