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

RIVAL 3 WIRELESS Support? #146

Open SecretSQL opened 3 years ago

SecretSQL commented 3 years ago

I have a new RIVAL 3 WIRELESS mouse, which has both USB and Bluetooth support. https://steelseries.com/gaming-mice/rival-3-wireless

I purchased it for the Bluetooth support. The mouse 'works' with both Bluetooth and USB. I installed rivalcfg and see that the Rival 3 Wireless is not supported. (Although I tried anyway. )

I am running a Debian derivative (Linux Mint 20). When connected via the USB dongle, the USB device lsusb info is: $ lsusb ID 1038:1830 SteelSeries ApS SteelSeries Rival 3 Wireless

When connected via Bluetooth, lsusb does not list the device. However hcitool lists the address: $ hcitool con Connections: < LE 28:9A:4B:A0:B3:D9 handle 7 state 1 lm MASTER AUTH ENCRYPT

Any chance of adding the Rival 3 wireless to the supported devices?

I am willing to help, but would need pointers on reverse engineering. I have some python experience, and have had a quick look through your code base, which is very well organized. Thanks.

flozz commented 3 years ago

Hello,

Currently I am working on the Sensei TEN, and then I have to work on the Rival 500 and the Rival 650. Then I will ask SteelSeries for a Wireless Rival 3 to work on it.

I think this device will be supported in USB mode first, and maybe we will be able to support it in Bluetooth mode (but probably only on Linux, as the kernel's hidraw backend abstracts the communication part of HID devices).

kosmiciatakuja commented 3 years ago

Hi, I code in python everyday and I have the mouse in question. Is there any info on how to go about implementing a new mouse in your code, I would be happy to try creating a PR, if I can manage that. I guess the mouse has very similar capabilities to the wired rival 3 so at least the USB mode should be easy, I guess. Thanks for the great work anyway!

FFY00 commented 3 years ago

@flozz actually it should work OOTB if you are using hidapi with the hidraw backend, instead of the libusb one, which is the default in Linux for some reason. This is the case in Arch Linux for eg. It should be a matter of just adding the bluetooth IDs there.

el1-x commented 3 years ago

Keen to get this added as well. I have one and am happy to pass on anything required.

flozz commented 3 years ago

@el1-x After installing Rivalcfg, can execute one of the following command (depending which python version your Rivalcfg installation is using):

sudo python -c "import hid;print(hid.enumerate())"
sudo python3 -c "import hid;print(hid.enumerate())"

and give me the output? :)

el1-x commented 3 years ago

Here is the output. I don't have python2 installed. https://gist.github.com/el1-x/0ca999c2eff6f08783baa3ca45141a37

flozz commented 3 years ago

Thank you.

Can you change 0x1824 by 0x1830 in the rivalcfg/devices/rival3.py file of your Rivalcfg installation:

And test if everything work?

NOTE¹: you may need to run rivalcfg as root as udev rules will not be up to date with this change NOTE²: if you do not know where Rivalcfg is installed, be sure you have the v4.3.0 (released monday), and run the following command: rivalcfg --print-debug. It will tell you where the module is installed :)

el1-x commented 3 years ago

I'm using Arch and the AUR package is out of date. I just flagged it.

Update: Making the changes specified provides more options when using --help as opposed to prior to the changes being made. As of writing this i am yet to attempt to make any changes to the mouse configuration.

Error when run as standard user

Traceback (most recent call last):
  File "/usr/bin/rivalcfg", line 33, in <module>
    sys.exit(load_entry_point('rivalcfg==4.2.0', 'console_scripts', 'rivalcfg')())
  File "/usr/lib/python3.9/site-packages/rivalcfg/__main__.py", line 45, in main
    mouse = get_first_mouse()
  File "/usr/lib/python3.9/site-packages/rivalcfg/__init__.py", line 27, in get_first_mouse
    return mouse.get_mouse(
  File "/usr/lib/python3.9/site-packages/rivalcfg/mouse.py", line 30, in get_mouse
    hid_device = usbhid.open_device(vendor_id, product_id, profile["endpoint"])
  File "/usr/lib/python3.9/site-packages/rivalcfg/usbhid.py", line 93, in open_device
    device.open_path(path)
  File "hidraw.pyx", line 74, in hid.device.open_path
OSError: open failed

Output from rivalcfg --list SteelSeries Rival 3:

1038:1830 | SteelSeries Rival 3 1038:184c | SteelSeries Rival 3 (firmware v0.37.0.0)

Output from rivalcfg --help

SteelSeries Rival 3 Options:
  -s SENSITIVITY, --sensitivity SENSITIVITY
                        Set sensitivity preset (DPI) (up to 5 settings,
                        from 200 dpi to 8500 dpi, default: '800, 1600')
  -p POLLING_RATE, --polling-rate POLLING_RATE
                        Set polling rate (Hz) (values: 125, 250, 500,
                        1000, default: 1000)
  --strip-top-color Z1_COLOR, --z1 Z1_COLOR
                        Set the color of the top LED of the strip (e.g.
                        red, #ff0000, ff0000, #f00, f00, default: red)
  --strip-middle-color Z2_COLOR, --z2 Z2_COLOR
                        Set the color of the middle LED of the strip (e.g.
                        red, #ff0000, ff0000, #f00, f00, default: lime)
  --strip-bottom-color Z3_COLOR, --z3 Z3_COLOR
                        Set the color of the bottom LED of the strip (e.g.
                        red, #ff0000, ff0000, #f00, f00, default: blue)
  -c LOGO_COLOR, --logo-color LOGO_COLOR, --z4 LOGO_COLOR
                        Set the color of the logo LED (e.g. red, #ff0000,
                        ff0000, #f00, f00, default: purple)
  -e LIGHT_EFFECT, --light-effect LIGHT_EFFECT
                        Set the light effect (values: rainbow-shift,
                        breath-fast, breath, breath-slow, steady, rainbow-
                        breath, disco, default: steady)
  -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))
  -r, --reset           Reset all settings to their factory default
flozz commented 3 years ago

Thank you @el1-x

flozz commented 3 years ago

(AUR package updated!)

el1-x commented 3 years ago

I have updated to the latest release via the AUR.

I attempted to make a change to the polling rate and set it to 500. I assume because i received no error message that the change was successful. However, i checked the setting via the Steelseries Engine software and it was reporting the polling rate remained at 1000.

Here is the --print-debug output.

RIVALCFG
========
Version: 4.3.0
udev rules installed: True
udev rules up to date: True
Installation path: /usr/lib/python3.9/site-packages/rivalcfg

OPERATING SYSTEM
================
OS: Linux
Platform: Linux-5.10.13-arch1-1-x86_64-with-glibc2.32
Version: #1 SMP PREEMPT Wed, 03 Feb 2021 23:44:07 +0000
Distribution issue: Arch Linux \r (\l)

PYTHON
======
Python version: 3.9.1
HIDAPI version: 0.10.1

PLUGGED STEELSERIES DEVICES ENDPOINTS
=====================================
1038:1830 | 00 | SteelSeries Rival 3 Wireless (firmware v)
1038:1830 | 00 | SteelSeries Rival 3 Wireless (firmware v)
1038:1830 | 01 | SteelSeries Rival 3 Wireless (firmware v)
1038:1830 | 01 | SteelSeries Rival 3 Wireless (firmware v)
1038:1830 | 02 | SteelSeries Rival 3 Wireless (firmware v)
1038:1830 | 03 | SteelSeries Rival 3 Wireless (firmware v)

I have updated the firmware using Windows and the Steelseris Engine software. Here is a screenshot of the software and available mouse settings. The Rival 3 Wireless is a no frills mouse so all of the RGB settings available for the standard Rival 3 are of no use.

steelseries-rival3w-engine

flozz commented 3 years ago

For the DPI Settings, you will not be able to check them back in the SSE3. SSE3 will not read them from the mouse, it will just send the settings it saved on you HDD to the device when you plug it.

So to check the DPI, set the lowest available DPI to your mouse, move it (it should be slow), then set the maximum DPI and the cursor should move very quickly.


For colors... if there is no LED those options will not do anything... ^^'

→ I will implement this device as se separated mouse family to not have useless options :)


You can also check the button mapping setting:

rivalcfg --buttons "buttons(button5=A)"

Now the B5 of the mouse should correspond to the keyboard "A" button (of a QWERTY keyboard)

To reset this setting:

rivalcfg --buttons default

:)

el1-x commented 3 years ago

Neither adjusting the buttons, nor the DPI had any effect.

rivalcfg -b "buttons(button5=A)" rivalcfg -s 2000

flozz commented 3 years ago

OK... So this device will need some reverse engineering then...

el1-x commented 3 years ago

What do you need from me?

flozz commented 3 years ago

Hello, sorry for the long time I took to answer...

If you are able to do some reverse engineering, it would help, else I will have to find an other way to work on this device :)

el1-x commented 3 years ago

Don't worry about taking time to answer, life gets in the way. I'm just the same. What do you need me to do specifically? I will give you whatever information I can.

flozz commented 3 years ago

I wrote articles about reverse engineering USB devices:

The articles are in French but Google Translate should help. I think it should not be too difficult to try on the Wireless Rival 3 using the USB dongle (I have no experience with the Bluetooth mode).

What you can do is to capture packets as described in the articles and post what you get here:

so we will see what we can do :)

GoboTheGeek commented 2 years ago

Hi,

i've a problem with my new Rival 3 Wireless. After some days, wheel start blinking green (or yellow) and then stops. I've replaced batteries and it was ok for (may be) ten days. And then green blinking starts again and mouse stops working. Any idea?

Thanks for your help

G.

el1-x commented 2 years ago

That is normal operation. The flashing green/yellow indicator lets you know the batteries are low. It will blink faster as the battery drains. From my experience you'll never get the advertised 400hr battery life from the device, to extend it as far as possible you need to enable 'High Efficiency Mode' which disables all lighting and drops the polling rate to 125Hz. This needs to be done using the Windows based software.

tomaszg7 commented 2 years ago

What is your average battery life time? In my case it drains in about a week or so with several hours a day of use. It is without battery saving mode.

el1-x commented 2 years ago

My experience is the about the same as yours @tomaszg7

GoboTheGeek commented 2 years ago

It's hard to estimate battery life time but i'll say around 35 hours (approx. 15 days as i mainly use my computer on week-ends). This mouse is not expensive to buy but if i need to change 1 battery set (or more) per month, it's a wreck and i'll have to think about changing it...

For now, i've set polling rate to 250.

TheBready commented 2 years ago

Hey, nice to see other people having the same needs. Any news on reverse engineering?

TheBready commented 2 years ago

I followed your manual and was tracking the data fragments for some things. Is this helpful? I was not able to test it but I was able to reproduce it in Wireshark.

rival3w.txt

flozz commented 2 years ago

Yes, it is very useful. Here what I learn for DPI and Polling rate with the data you provided:

Sensitivity

Polling rate

TheBready commented 2 years ago

The increments of the sensitivity are 100. If my math is correct then there are 180 levels. Is it possible to add a profile for the rival 3 wireless that? I would try it myself but I am not really used working with data like that. Would be a real hassle to get into.

flozz commented 2 years ago

The sensor of the Rival 3 Wireless is the same as the one of the Aerox 3 Wireless (and Prime Wireless and Prime Mini Wireless too). So I already know it is not perfectly linear:

Capture d’écran de 2021-11-15 13-22-21

So we will be able have an increment of 50 dpi with a +/- 50 dpi of error margin:

Capture d’écran de 2021-11-16 13-01-48


I am currently working on the Rival 650, but I will try to start a branch with a minimal set of feature to let you test if it work :)

TheBready commented 2 years ago

That sounds great. I think +/- 50 dpi is nothing noticeable. Let me know when the branch is ready for testing.

Have this coffee.

flozz commented 2 years ago

Thank you for the coffee :coffee: :)


I implemented the sensitivity and the polling rate. But as the save command is missing, you will have to add the --no-save parameter to test:

python -m rivalcfg --no-save --sensitivity 100
python -m rivalcfg --no-save --sensitivity 400,800,1600
python -m rivalcfg --no-save --polling-rate 125
python -m rivalcfg --no-save --polling-rate 1000

You will find everything in the rival3-wireless branch, please test with various configuration to check if it works :)


I need to know what is the save command in order to have a minimal working profile. When you hit the "save" button of the SSE/GG Engine, what is the last packet sent to the device? (generally it is 09, but it is different on some devices)


Also this device seems to have a LED on the wheel, can you capture packets when you change the LED color?

TheBready commented 2 years ago

Thanks for creating the branch. I can always see this data fragment after a command: 09000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 So it seems to be 0x09.

I can't see any commands when changing the LEDs when saving.

Changing the sensitivity is not working and tbh I don't know if the polling rate is changing.

flozz commented 2 years ago

So it seems to be 0x09.

Ok, cool,

I can't see any commands when changing the LEDs when saving.

The LED probably changes in real time when you set a command (so it will not be sent again when you hit the "save" button)

Changing the sensitivity is not working

Hum... Maybe it is a matter of packet length or the repport type... Can you give me the values of the wValue and the wLength fields?

image

TheBready commented 2 years ago

Here I changed the sensitivity to Level 1 400 DPI: image The packets always appear with four.

For the LED are ten packets send. Here I switched to steady #ff0000: image

flozz commented 2 years ago

The packets always appear with four.

What did you mean?


I think I found why it not worked... I assumed that the command endpoint is the 0... but wIndex is 3... :)


tomaszg7 commented 2 years ago

I can confirm that sensitivity now seems to work. However the settings seem to be saved even with --nosave option. I tried removing USB dongle and switching off the mouse but settings seem to persist.

TheBready commented 2 years ago

Yes, now it is working like a charm. Thanks a lot. To be honest that is enough for me. I don't need RGB. breathing red is all I need. However, let me know if you need something else. Will the change come to the AUR?

flozz commented 2 years ago

Cool if it work \o/

I will continue to work on it a bit to try to support RGB and powering features. If it is too complicated, I may release a Rivalcfg version with a partial support for the device.

Will the change come to the AUR?

I completely forget I was now the maintainer of both AUR packages... I will try to update it by the end of the year... And I will try to update the package publishing, if it is possible.

flozz commented 2 years ago

I found someone to lend me the mouse today, so I was able to study it a little more:

What I have not found yet is

image

flozz commented 2 years ago

Button bindings are now working. :)

For example, the following command will make the left button write "q" (if the keyboard layout is QWERTY) instead of clicking:

rivalcfg -b "buttons(button1=q)"

To reset to default:

rivalcfg -b default
TheBready commented 2 years ago

That's awesome work!

flozz commented 2 years ago

Battery level can now be read (--battery-level) and I added doc. I will not have time to do much more by the end of the year so I merged this initial support on master to have it in the next release :)

tianleq commented 2 years ago

I am a little bit confused here.

@el1-x After installing Rivalcfg, can execute one of the following command (depending which python version your Rivalcfg installation is using):

sudo python -c "import hid;print(hid.enumerate())"
sudo python3 -c "import hid;print(hid.enumerate())"

and give me the output? :)

I get nothing when connecting through bluetooth. So you assume using 2.4G here?

flozz commented 2 years ago

@tianleq on Linux, the hidraw kernel module (that should be used by Rivalcfg on Linux) can access both USB and Bluetooth HID devices. If the previous command returns nothing when the mouse is connected with Bluetooth, Rivalcfg will not be able to support it (at least not through the hidraw backend).

I gave this command to check if there were something easy we can do to support the Rival 3 over Bluetooth, but it seems it is not the case.

tianleq commented 2 years ago

@flozz Thanks for the clarification.

winteriscariot commented 1 year ago
  • I found how powering options work

was this ever implemented? i go through a pair of batteries about once every week or two (rechargeable AAAs ftw) and i'm looking to try to improve this

flozz commented 1 year ago

@winteriscariot No this is not implemented yet.

In the mean time, you can send the power configuration command to the mouse manually. Here is some Python code that does the trick:

#!/usr/bin/env python3

import rivalcfg

mouse = rivalcfg.get_first_mouse()
mouse._hid_write(data=[
    0x2B,
    0x01,        # High Efficiency (0x00 = OFF, 0x01 = ON)
    0x64,        # Smart illumination (0x00 = OFF, 0x32 or 0x64 = ON)
    0x2C, 0x01,  # Unknown
    0x2C, 0x01,  # Sleep timer (seconds, little endian)
                 #   0x3C, 0x00 =  1 min
                 #   0x78, 0x00 =  2 min
                 #   0xB4, 0x00 =  3 min
                 #   0xF0, 0x00 =  4 min
                 #   0x2C, 0x01 =  5 min
                 #   0xB4, 0x04 = 20 min
])
mouse.save()
winteriscariot commented 1 year ago

awesome, workarounds work too. thank you!

faptaincrunch commented 11 months ago

Was the RGB wheel ever figured out? The blinking orange kills me lol. Thanks

flozz commented 10 months ago

@faptaincrunch No the RGB of the wheel is not implemented but it is in my TODO list. :)

Firminator commented 4 months ago

Hi there, Thanks on the work on the Rival 3 Wireless so far. I'm going to play with the rivalcfg but before I hit a rabbithole had a few questions..

You can also check the button mapping setting:

rivalcfg --buttons "buttons(button5=A)"

Now the B5 of the mouse should correspond to the keyboard "A" button (of a QWERTY keyboard)

To reset this setting:

rivalcfg --buttons default

Are the functions keys (F1 to F12) supported and if yes would I just substitue A with F12 for example?

Also since the below quoted code was verified by @winteriscariot to be working could this be implemented in one of the next updates:

@winteriscariot No this is not implemented yet.

In the mean time, you can send the power configuration command to the mouse manually. Here is some Python code that does the trick:

#!/usr/bin/env python3

import rivalcfg

mouse = rivalcfg.get_first_mouse()
mouse._hid_write(data=[
    0x2B,
    0x01,        # High Efficiency (0x00 = OFF, 0x01 = ON)
    0x64,        # Smart illumination (0x00 = OFF, 0x32 or 0x64 = ON)
    0x2C, 0x01,  # Unknown
    0x2C, 0x01,  # Sleep timer (seconds, little endian)
                 #   0x3C, 0x00 =  1 min
                 #   0x78, 0x00 =  2 min
                 #   0xB4, 0x00 =  3 min
                 #   0xF0, 0x00 =  4 min
                 #   0x2C, 0x01 =  5 min
                 #   0xB4, 0x04 = 20 min
])
mouse.save()

Any news regarding RGB wheel lightning or firmware readout? I didn't find any hints regarding firmware readout on your reverse-engineering blog @ https://blog.flozz.fr/2016/03/27/steelseries-rival-100-reverse-engineering-dun-peripherique-usb/ Here's my dmesg output... I'm using Wireless mode; bcdDevice=0.20 is not what I assumed the firmware but rather the Device Release Number indicating the device-defined revision number accd. to https://beyondlogic.org/usbnutshell/usb5.shtml ... well was worth a try :)

usb 3-3.4: New USB device found, idVendor=1038, idProduct=1830, bcdDevice= 0.20
usb 3-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 3-3.4: Product: SteelSeries Rival 3 Wireless
usb 3-3.4: Manufacturer: SteelSeries
input: SteelSeries SteelSeries Rival 3 Wireless as /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4:1.0/0003:1038:1830.000D/input/input27
hid-generic 0003:1038:1830.000D: input,hidraw8: USB HID v1.11 Mouse [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input0
input: SteelSeries SteelSeries Rival 3 Wireless Keyboard as /devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.4/3-3.4:1.1/0003:1038:1830.000E/input/input28
hid-generic 0003:1038:1830.000E: input,hidraw9: USB HID v1.11 Keyboard [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input1
hid-generic 0003:1038:1830.000F: hiddev3,hidraw10: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input2
hid-generic 0003:1038:1830.0010: hiddev4,hidraw11: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0011: hiddev4,hidraw11: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0012: hiddev4,hidraw11: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0013: hiddev4,hidraw11: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0014: hiddev4,hidraw11: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0015: hiddev4,hidraw12: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0016: hiddev4,hidraw12: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0017: hiddev4,hidraw12: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0018: hiddev4,hidraw12: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.0019: hiddev4,hidraw12: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.001A: hiddev4,hidraw13: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.001B: hiddev4,hidraw13: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3
hid-generic 0003:1038:1830.001C: hiddev4,hidraw13: USB HID v1.11 Device [SteelSeries SteelSeries Rival 3 Wireless] on usb-0000:00:14.0-3.4/input3

Odd that the kernel detects 10+ devices and also a 'Wireless Keyboard'. Anyone have an explanation for this behaviour?