power: Linux /sys/class testing should skip "device" scopes.
(the PS4 game controllers report their batteries through this interface, which
is cool, but not helpful for powering the rest of the system. :) )
1.1 --- a/src/power/linux/SDL_syspower.c Sun Jul 02 22:46:49 2017 +0200
1.2 +++ b/src/power/linux/SDL_syspower.c Mon Jul 03 16:38:37 2017 -0400
1.3 @@ -460,6 +460,16 @@
1.4 continue; /* we don't care about UPS and such. */
1.5 }
1.6
1.7 + /* if the scope is "device," it might be something like a PS4
1.8 + controller reporting its own battery, and not something that powers
1.9 + the system. Most system batteries don't list a scope at all; we
1.10 + assume it's a system battery if not specified. */
1.11 + if (read_power_file(base, name, "scope", str, sizeof (str))) {
1.12 + if (SDL_strcmp(str, "device\n") != 0) {
1.13 + continue; /* skip external devices with their own batteries. */
1.14 + }
1.15 + }
1.16 +
1.17 /* some drivers don't offer this, so if it's not explicitly reported assume it's present. */
1.18 if (read_power_file(base, name, "present", str, sizeof (str)) && (SDL_strcmp(str, "0\n") == 0)) {
1.19 st = SDL_POWERSTATE_NO_BATTERY;