Skip to content

Windows Go application for showing the battery level of a PS5 DualSense controller

License

Notifications You must be signed in to change notification settings

neolit123/go-dualsense-battery

Repository files navigation

go-dualsense-battery

Description

A small Windows taskbar application, written in Go, for showing the battery level of a PlayStation 5 DualSense controller connected over Bluetooth or USB.

Supports a single controller, the first one in the device list. Last tested with controller firmware A-0520 on Windows 11 Pro 64bit 10.0.26100.2605.

Screenshot0

Screenshot1

How it works

  • Every few seconds the applications opens a DualSense controller Windows device and reads its status and battery level.
  • It shows different icons depending if it's charging or not, and if there is a charging error.
  • It consumes a couple of MB of RAM and a tiny amount of CPU cycles.
  • You can right click and:
    • Exit at any time.
    • attach a debug console for more detailed output.
    • click the application name to open the GitHub project page.

Installing

  • Download a 64bit binary release (go-dualsense-battery.exe) somewhere on disk from the Releases page.
  • Press Win+R and type shell:startup. This will open the Startup folder in Explorer.
  • Create a shortcut of the executable in this folder to start it with Windows.

You can also make the icon always visible by:

  • Right click the Taskbar.
  • Select "Taskbar settings".
  • Expand "Other system tray icons".
  • Select "On" for "go-dualsense-battery".

Known issues

This Go bug manifests on rare occasions, which can result in an application exit: golang/go#13672

Other notes

The battery power level is stored in 4 bits of memory in the input report from the controller. That is a value between 0x00 and 0x0F, or 16 levels in total. However, the actual value is in the range between 0x00 and 0x0A, or 11 levels in total. That nicely makes it so that for every reported level, there is a 10% multiplier. This application is designed following this principle and it seems consistent, despite the fact that the input report value can be a bit imprecise - e.g. sometimes status 'Complete' is reported for level 90%.

For some reason other apps and libraries divide the obtained 4 bits by 8, which seems less correct.

Dependencies

Building

  • Install a MinGW toolchain. For example w64devkit.
  • Install a Go toolchain.
  • Install go-winres. For generating a resource file and adding an application icon.
  • Run build.cmd. What it does is:
    • Sets CGO_ENABLED=1.
    • Gets the application version from a git tag.
    • Generates resources with go-winres.
    • Builds a Windows GUI application.
  • To covert the icons from PNG to ICO, you'd need go-png2ico or a similar tool. Check /artwork to see how its done.

License

Apache 2.0. See the LICENSE file.

Icons and art

Authored by me (neolit123) using Clip Studio Paint 1.x. The art license is the same as the project LICENSE.

Acknowledgements

Examined the source code of the following projects while figuring out how to approach the reading of device status:

About

Windows Go application for showing the battery level of a PS5 DualSense controller

Resources

License

Stars

Watchers

Forks

Packages

No packages published