Bug 491053

Summary: Battery status not shown for Nintendo switch Pro controller
Product: [Plasma] plasmashell Reporter: gudvinr+kde
Component: Bluetooth widgetAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: kde, nate
Priority: NOR    
Version First Reported In: 6.1.3   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=505394
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description gudvinr+kde 2024-07-31 09:37:56 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY

When I use Xbox controller via xpadneo, I also have battery status in bluetooth devices list.

With Pro controller, I see battery status in battery menu but battery status in bluetooth devices list is missing.

STEPS TO REPRODUCE
1. Pair and connect switch pro controller
2. Open bluetooth device list

OBSERVED RESULT

No battery status

EXPECTED RESULT

Battery level indication
SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.3
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2
Kernel Version: 6.10.2-arch1-1 (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION

Here's dump from upower:

Device: /org/freedesktop/UPower/devices/battery_nintendo_switch_controller_battery_0005o057Eo2009x000F
  native-path:          nintendo_switch_controller_battery_0005:057E:2009.000F
  model:                Pro Controller
  serial:               <same address as in bluetooth device list>
  power supply:         no
  updated:              Wed Jul 31 12:31:50 2024 (5 seconds ago)
  has history:          yes
  has statistics:       yes
  gaming-input
    rechargeable:        yes
    warning-level:       none
    battery-level:       high
    percentage:          70% (should be ignored)
    icon-name:          'battery-good-symbolic'
  History (charge):
    1722418220  70.000  discharging
Comment 1 ratijas 2024-08-01 22:04:46 UTC
Well, the upstream upower project has something to say about this:

https://gitlab.freedesktop.org/upower/upower/-/blob/669a1c2a27a7a590524d7c45ad427ce9ba9afa8c/libupower-glib/up-device.c?page=2#L1185-1191

> The percentage charge of the device. Note that if the battery level property
> is something other than %UP_DEVICE_LEVEL_NONE, then this percentage is an
> approximation, and should not be used a number to display to the user.

then is proceeds to have conditions like:

	if (battery_level != UP_DEVICE_LEVEL_NONE)
		g_string_append_printf (string, "    battery-level:       %s\n", up_device_level_to_string (battery_level));

(else don't print anything)

and

		if (battery_level == UP_DEVICE_LEVEL_NONE)
			g_string_append_printf (string, "    percentage:          %g%%\n", up_exported_device_get_percentage (priv->proxy_device));
		else
			g_string_append_printf (string, "    percentage:          %g%% (should be ignored)\n", up_exported_device_get_percentage (priv->proxy_device));

so we might be not totally wrong on the KDE side. But surely we'd better display at least *something*.

I don't have Nintendo Switch Pro Controller with me to test, but I trust your logs, so I'm marking this bug report as CONFIRMED.
Comment 2 gudvinr+kde 2024-08-02 16:23:08 UTC
(In reply to ratijas from comment #1)
> Well, the upstream upower project has something to say about this:
> so we might be not totally wrong on the KDE side. But surely we'd better
> display at least *something*.

Tbh, I don't think anyone needs exact battery percentage when they look at bluetooth device list.
It is bluetooth device list, for battery values there is power and battery widget.

IMO, battery icon with full/not so full/low/need to charge asap indication should be good enough even for devices that do provide exact values (like xbox controller or wireless headphones). Detailed percentage can be shown in dropdown in that case.

Also I am not 100% sure but power and battery widget doesn't have indication that device provides "approximate values".
Comment 3 ratijas 2024-08-02 20:57:38 UTC
Since Bluetooth devices are part of the real world, and as we know the real world is all messed up beyond recognition, things may get weird with some devices.

For example, I happened to have a Sony WH-1000XM4 headset, and it reports its battery percentage kinda fine but only in increments of 10%. I never knew before that there is such a flag UP_DEVICE_LEVEL_NONE in Bluetooth, so now I went to check it in the headphones. And nope, it's not there, even though they only report their approximate value:

Device: /org/freedesktop/UPower/devices/headset_dev_[[REDACTED]]
  native-path:          /org/bluez/hci0/dev_[[REDACTED]]
  model:                WH-1000XM4
  serial:               [[REDACTED]]
  power supply:         no
  updated:              Fri 02 Aug 2024 10:51:31 PM CEST (21 seconds ago)
  has history:          yes
  has statistics:       no
  headset
    warning-level:       none
    percentage:          50%
    icon-name:          'battery-missing-symbolic'
  History (charge):
    1722631891  0.000   unknown
  History (rate):
    1722631891  0.000   unknown