flozz / rivalcfg

CLI tool and Python library to configure SteelSeries gaming mice
https://flozz.github.io/rivalcfg/
Do What The F*ck You Want To Public License
761 stars 62 forks source link

Request: Support for Steelseries Prime Wireless #172

Closed haemka closed 1 year ago

haemka commented 2 years ago

Function wise very similar to the normal Prime mouse, which was added through PR #169, but wireless.

Webpage: https://steelseries.com/gaming-mice/prime-wireless

Wireless mode (1038:1840)

(Wired mode is below)

kern.log:

[34024.766598] usb 3-1.3: new full-speed USB device number 14 using xhci_hcd
[34024.857143] usb 3-1.3: New USB device found, idVendor=1038, idProduct=1840, bcdDevice= 1.05
[34024.857152] usb 3-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[34024.857156] usb 3-1.3: Product: SteelSeries Prime Wireless
[34024.857159] usb 3-1.3: Manufacturer: SteelSeries
[34025.034163] input: SteelSeries SteelSeries Prime Wireless as /devices/pci0000:00/0000:00:07.1/0000:0e:00.3/usb3/3-1/3-1.3/3-1.3:1.0/0003:1038:1840.0023/input/input34
[34025.034395] hid-generic 0003:1038:1840.0023: input,hidraw1: USB HID v1.11 Mouse [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input0
[34025.035335] input: SteelSeries SteelSeries Prime Wireless as /devices/pci0000:00/0000:00:07.1/0000:0e:00.3/usb3/3-1/3-1.3/3-1.3:1.1/0003:1038:1840.0024/input/input35
[34025.087004] hid-generic 0003:1038:1840.0024: input,hidraw8: USB HID v1.11 Keyboard [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input1
[34025.088514] input: SteelSeries SteelSeries Prime Wireless as /devices/pci0000:00/0000:00:07.1/0000:0e:00.3/usb3/3-1/3-1.3/3-1.3:1.2/0003:1038:1840.0025/input/input36
[34025.139956] hid-generic 0003:1038:1840.0025: input,hidraw9: USB HID v1.11 Device [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input2
[34025.141177] hid-generic 0003:1038:1840.0026: hiddev1,hidraw10: USB HID v1.11 Device [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input3
[34025.142282] hid-generic 0003:1038:1840.0027: hiddev4,hidraw11: USB HID v1.11 Device [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input4

lsusb:

$ lsusb -d 1038:1840 --verbose

Bus 003 Device 014: ID 1038:1840 SteelSeries ApS SteelSeries Prime Wireless
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x1038 SteelSeries ApS
  idProduct          0x1840 
  bcdDevice            1.05
  iManufacturer           1 SteelSeries
  iProduct                2 SteelSeries Prime Wireless
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0086
    bNumInterfaces          5
    bConfigurationValue     1
    iConfiguration          3 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      98
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      43
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      25
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      37
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        4
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      21
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1

Wired mode (1038:1842)

kern.log:

[34492.026877] usb 3-1.3: new full-speed USB device number 17 using xhci_hcd
[34492.117281] usb 3-1.3: New USB device found, idVendor=1038, idProduct=1842, bcdDevice= 1.10
[34492.117290] usb 3-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[34492.117294] usb 3-1.3: Product: SteelSeries Prime Wireless
[34492.117298] usb 3-1.3: Manufacturer: SteelSeries
[34492.328719] usb 3-1.3: can't set config #1, error -32
[34492.489637] usb 3-1.3: USB disconnect, device number 17
[34493.458886] usb 3-1.3: new full-speed USB device number 18 using xhci_hcd
[34493.549164] usb 3-1.3: New USB device found, idVendor=1038, idProduct=1842, bcdDevice= 1.10
[34493.549172] usb 3-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[34493.549176] usb 3-1.3: Product: SteelSeries Prime Wireless
[34493.549179] usb 3-1.3: Manufacturer: SteelSeries
[34493.738268] input: SteelSeries SteelSeries Prime Wireless as /devices/pci0000:00/0000:00:07.1/0000:0e:00.3/usb3/3-1/3-1.3/3-1.3:1.0/0003:1038:1842.002D/input/input40
[34493.738507] hid-generic 0003:1038:1842.002D: input,hidraw1: USB HID v1.11 Mouse [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input0
[34493.739434] input: SteelSeries SteelSeries Prime Wireless as /devices/pci0000:00/0000:00:07.1/0000:0e:00.3/usb3/3-1/3-1.3/3-1.3:1.1/0003:1038:1842.002E/input/input41
[34493.791189] hid-generic 0003:1038:1842.002E: input,hidraw8: USB HID v1.11 Keyboard [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input1
[34493.846172] input: SteelSeries SteelSeries Prime Wireless as /devices/pci0000:00/0000:00:07.1/0000:0e:00.3/usb3/3-1/3-1.3/3-1.3:1.2/0003:1038:1842.002F/input/input42
[34493.898052] hid-generic 0003:1038:1842.002F: input,hidraw9: USB HID v1.11 Device [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input2
[34493.898999] hid-generic 0003:1038:1842.0030: hiddev1,hidraw10: USB HID v1.11 Device [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input3
[34493.899802] hid-generic 0003:1038:1842.0031: hiddev4,hidraw11: USB HID v1.11 Device [SteelSeries SteelSeries Prime Wireless] on usb-0000:0e:00.3-1.3/input4

lsusb:

$ lsusb -d 1038:1842 --verbose

Bus 003 Device 018: ID 1038:1842 SteelSeries ApS SteelSeries Prime Wireless
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x1038 SteelSeries ApS
  idProduct          0x1842 
  bcdDevice            1.10
  iManufacturer           1 SteelSeries
  iProduct                2 SteelSeries Prime Wireless
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0086
    bNumInterfaces          5
    bConfigurationValue     1
    iConfiguration          3 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              380mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      98
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      43
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      25
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      37
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        4
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      21
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1

Logs generated on:

$ lsb_release -a && uname -a
LSB Version:    1.0
Distributor ID: VoidLinux
Description:    Void Linux
Release:    rolling
Codename:   void
Linux caprica 5.13.19_1 #1 SMP Sat Sep 18 18:18:26 UTC 2021 x86_64 GNU/Linux
flozz commented 2 years ago

Thank you for all the detail.

If someone is able to reverse engineer the device, I can help to implement it in Rivalcfg :)

haemka commented 2 years ago

What do you need? I can probably do some USB packet traces from a Windows 10 QEMU VM. Do you have a sepcific test schema/plan I could work with?

flozz commented 2 years ago

Yes I need some packet capture.

While capturing packets, you have to change one setting at time in the SSE3 and match the changed setting with captured packets.

I wrote articles about that on my blog (they are in French but Google Translate should help):

Here is an example of of the work done for the Aerox 3 Wireless:

As it is a Wireless mouse, the work must be done twice:

(ProductID and commands are a bit different in wired and wireless modes)

:)

haemka commented 2 years ago

So, I finally found the time to look into this. This is what I got so far: https://gist.github.com/haemka/45f135661090438518fbd97a64dde52f

But I'm having a really hard time, finding any hint at battery levels. I was able to reproduce your reverse engineering process of battery levels for my Arctis 7 but that does not seem to help with this mouse. The protocol seems to communicate battery levels in another way. In some reddit comments I found out, that newer mouses such as the Aerox 3 and Prime Wireless never showed battery percentage but only 3-bar-levels in SSE3.

Maybe you (@flozz) or @gort818 could give me some pointers, where to look for this last missing piece?

Edit: Unknown but maybe interesting captured packets are listed, here: https://gist.github.com/haemka/45f135661090438518fbd97a64dde52f#otherunknown-packets

flozz commented 1 year ago

Hello !

I started working on the Prime Wireless.

Currently I implemented DPI, Polling Rate and Color in wired mode:

SteelSeries Prime Wireless (wired mode) Options:
  -s SENSITIVITY, --sensitivity SENSITIVITY
                        Set sensitivity preset (DPI) (up to 5 settings, from 100 dpi to
                        18000 dpi, default: '400, 800, 1200, 2400, 3200')
  -p POLLING_RATE, --polling-rate POLLING_RATE
                        Set polling rate (Hz) (values: 125, 250, 500, 1000, default: 1000)
  -c COLOR, --color COLOR
                        Set the mouse LED color (e.g. red, #ff0000, ff0000, #f00, f00,
                        default: red)
  -r, --reset           Reset all settings to their factory default

Can someone test it works? The work is in the prime-wireless branch :)

flozz commented 1 year ago

Update:

  -b BUTTONS_MAPPING, --buttons BUTTONS_MAPPING
                        Set the mapping of the buttons (default: buttons(button1=button1;
                        button2=button2; button3=button3; button4=button4; button5=button5;
                        button6=dpi; scrollup=scrollup; scrolldown=scrolldown;
                        layout=qwerty))

:)

haemka commented 1 year ago

Thanks for your work!

So far everything listed above seems to work.

Only shortcoming (not sure if that's intended) I realized is, that I can't use the dpi-Button to cycle through sensitivity. The button seems to only switch to the next higher level until the highest level is reached. From there on a reset of sensitivity levels or full settings reset is needed, which will also re-select the lowest level from where "upwards selection" is possible again.

flozz commented 1 year ago

@haemka for the dpi button, its behavior is implemented by the mouse firmware so I cannot do anything for this :/


I get some info about reading the battery level so I added it:

--battery-level       Print the battery level of the mouse and exit

can someone test this too? :)

haemka commented 1 year ago

can someone test this too? :)

$ sudo rivalcfg --battery-level
Discharging [=         ] 15 %

;)

flozz commented 1 year ago

I added Sleep Timer and Dim Timer:

  -t SLEEP_TIMER, --sleep-timer SLEEP_TIMER
                        Set the IDLE time before the mouse goes to sleep mode (minutes, 0 =
                        disable) (from 0 to 20, default: 5)
  -T DIM_TIMER, --dim-timer DIM_TIMER
                        Set the IDLE time before the mouse light is dimmed (seconds, 0 =
                        disable) (from 0 to 1200, default: 30)

If someone can confirm it works before I merge this to master :)


Note: I will not implement brightness setting (as it is already possible to do this using a darker color). I will not implement smart mode neither for now.

haemka commented 1 year ago

Sleep timer seems to work. At least when testing with 1 minute (-t 1).

Dim timer seems to behave somewhat strange. But I'm pretty sure this is the default for this device as I haven't seen any other behavior since I got it. Regardless of the setting the LED will light up bright for about half a second when the mouse is moved and dims afterwards. If movement persists the LED keeps turned off.

I recorded a short video of the behavior: https://youtu.be/Iane0guFExI

flozz commented 1 year ago

Hum... Is it possible that the smart mode disable the light when moving? Maybe 0x01 enables it instead of disabling it?

image


EDIT: Can you try to change rivalcfg/devices/prime_wireless_wired.py:102 from

"command": [0x23, 0x0F, 0x01, 0x01],

to

"command": [0x23, 0x0F, 0x01, 0x00],

?

flozz commented 1 year ago

Hum The timing is probably wrong too, I forget a byte ... Can you also try with

"command": [0x23, 0x0F, 0x01, 0x01, 0x00],

and

"command": [0x23, 0x0F, 0x01, 0x00, 0x00],
haemka commented 1 year ago
"command": [0x23, 0x0F, 0x01, 0x00],

Stops turning off the LED on movement. But does not change any timings

"command": [0x23, 0x0F, 0x01, 0x01, 0x00],

Turns the LED off on movement and dims immediately after stopping (same behavior as before).

"command": [0x23, 0x0F, 0x01, 0x00, 0x00],

Lights up on movement and dims after the specified amount of seconds. This seems right.

But that "accidental implementation" of smart mode (which I had probably always enabled and didn't remember) was also nice. :)

flozz commented 1 year ago

Thank you, I fixed the implementation :)

flozz commented 1 year ago

This mouse is now supported by Rivalcfg v4.6.0 :)