Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not showing correct battery status #339

Open
devnore opened this issue Apr 4, 2024 · 2 comments
Open

Not showing correct battery status #339

devnore opened this issue Apr 4, 2024 · 2 comments

Comments

@devnore
Copy link

devnore commented Apr 4, 2024

Description

Hi Denis!

First of all, it is awesome to see the formatting (yaml/json/env) added

But I ran into an issue with the output that I guess is specific to either my specific model or Steelseries in general as the functionality was discussed in #271 and seemed to be working with Corsair Void.

The issue:
My battery status is always showing BATTERY_AVAILABLE regardless of if it is charging/discharging/off the only value that changes (when turned off is the battery level which reports 0 (and that should be fine)

On, Connected/Charging

name: "HeadsetControl"
version: "3.0.0-1-g0005a0a"
api_version: "1.0"
hidapi_version: "0.11.2"
device_count: 1
devices:
  - status: "success"
    device: "SteelSeries Arctis (7/Pro)"
    vendor: "SteelSeries "
    product: "SteelSeries Arctis 7"
    id_vendor: "0x1038"
    id_product: "0x12ad"
    capabilities:
      - CAP_SIDETONE
      - CAP_BATTERY_STATUS
      - CAP_LIGHTS
      - CAP_INACTIVE_TIME
      - CAP_CHATMIX_STATUS
    capabilities_str:
      - sidetone
      - battery
      - lights
      - inactive time
      - chatmix
    battery:
      status: "BATTERY_AVAILABLE"
      level: 70
    chatmix: 53

Off, Connected/Charging

version: "3.0.0-1-g0005a0a"
api_version: "1.0"
hidapi_version: "0.11.2"
device_count: 1
devices:
  - status: "success"
    device: "SteelSeries Arctis (7/Pro)"
    vendor: "SteelSeries "
    product: "SteelSeries Arctis 7"
    id_vendor: "0x1038"
    id_product: "0x12ad"
    capabilities:
      - CAP_SIDETONE
      - CAP_BATTERY_STATUS
      - CAP_LIGHTS
      - CAP_INACTIVE_TIME
      - CAP_CHATMIX_STATUS
    capabilities_str:
      - sidetone
      - battery
      - lights
      - inactive time
      - chatmix
    battery:
      status: "BATTERY_AVAILABLE"
      level: 0
    chatmix: 64

Off, Disconnected

---
name: "HeadsetControl"
version: "3.0.0-1-g0005a0a"
api_version: "1.0"
hidapi_version: "0.11.2"
device_count: 1
devices:
  - status: "success"
    device: "SteelSeries Arctis (7/Pro)"
    vendor: "SteelSeries "
    product: "SteelSeries Arctis 7"
    id_vendor: "0x1038"
    id_product: "0x12ad"
    capabilities:
      - CAP_SIDETONE
      - CAP_BATTERY_STATUS
      - CAP_LIGHTS
      - CAP_INACTIVE_TIME
      - CAP_CHATMIX_STATUS
    capabilities_str:
      - sidetone
      - battery
      - lights
      - inactive time
      - chatmix
    battery:
      status: "BATTERY_AVAILABLE"
      level: 0
    chatmix: 64

Headset Name

SteelSeries Arctis 7

On which OS does the problem happen?

Linux

Device information

Detailed Device Information
$>headsetcontrol --dev -- --list --device 0x1038:0x12ad
Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xc Usageid: 0x1

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff43 Usageid: 0x202

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0x1

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0xa

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0x22

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0xa

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0x22

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0xa

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0x22

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0xa

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0x22

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0xa

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0xc

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0x1 Usageid: 0x3a

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0xff00 Usageid: 0xc

Device Found
 VendorID: 0x1038
ProductID: 0x12ad
 path: /dev/hidraw10
 serial_number: 
 Manufacturer: SteelSeries 
 Product:      SteelSeries Arctis 7
 Interface:    5
 Usage-Page: 0x1 Usageid: 0x3a
@Sapd
Copy link
Owner

Sapd commented Apr 5, 2024

The Steelseries implementation does not define that, thats why it always show BATTERY_AVAILABLE, see here:

static BatteryInfo arctis_7_request_battery(hid_device* device_handle)
{
int r = 0;
BatteryInfo info = { .status = BATTERY_UNAVAILABLE, .level = -1 };
// request battery status
unsigned char data_request[2] = { 0x06, 0x18 };
r = hid_write(device_handle, data_request, 2);
if (r < 0) {
info.status = BATTERY_HIDERROR;
return info;
}
// read battery status
unsigned char data_read[8];
r = hid_read_timeout(device_handle, data_read, 8, hsc_device_timeout);
if (r < 0) {
info.status = BATTERY_HIDERROR;
return info;
}
if (r == 0) {
info.status = BATTERY_TIMEOUT;
return info;
}
int bat = data_read[2];
info.status = BATTERY_AVAILABLE;
if (bat > 100)
info.level = 100;
else
info.level = bat;
return info;
}

Basically, BATTERY_AVAILABLE must be seen as general status, it just means that the Battery info could be read from the device. (and in this case it reads as 0). Probably there is another flag to check if it is charging, but you would have to take a look with WireShark. Or alternatively and easier, you can try this:

headsetcontrol --dev -- --device 0x1038:0x12ad --send 0x06,0x18 --receive

then see if one of the bytes change during charging. You could then simply supplement the value in the code and open up a PR.

@devnore
Copy link
Author

devnore commented Apr 9, 2024

I currently don't have my GitHub creds set up on my work-laptop (so unable to push). But here is my quick and dirty solution

diff --git a/src/devices/steelseries_arctis_7.c b/src/devices/steelseries_arctis_7.c
index bd52730..a86ce04 100644
--- a/src/devices/steelseries_arctis_7.c
+++ b/src/devices/steelseries_arctis_7.c
@@ -112,13 +112,16 @@ static BatteryInfo arctis_7_request_battery(hid_device* device_handle)
 
     int bat = data_read[2];
 
-    info.status = BATTERY_AVAILABLE;
+    // 0% battery == BATTERY_UNAVAILABLE
+    if (bat == 0)
+        return info;
 
     if (bat > 100)
         info.level = 100;
     else
         info.level = bat;
 
+    info.status = BATTERY_AVAILABLE;
     return info;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants