From 4506402c906703df6dc8aa3f501baa343d2bb494 Mon Sep 17 00:00:00 2001 From: Fabien LOISON Date: Fri, 12 Jan 2024 12:09:51 +0100 Subject: [PATCH 1/4] feat: Added support for the Prime Mini device --- rivalcfg/devices/__init__.py | 1 + rivalcfg/devices/prime_mini.py | 100 +++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 rivalcfg/devices/prime_mini.py diff --git a/rivalcfg/devices/__init__.py b/rivalcfg/devices/__init__.py index 3d0f8e3..9310030 100644 --- a/rivalcfg/devices/__init__.py +++ b/rivalcfg/devices/__init__.py @@ -228,6 +228,7 @@ def _generate_profiles(): kanav2, kinzuv2, prime, + prime_mini, prime_wireless_wired, prime_wireless_wireless, rival3, diff --git a/rivalcfg/devices/prime_mini.py b/rivalcfg/devices/prime_mini.py new file mode 100644 index 0000000..9a34ce0 --- /dev/null +++ b/rivalcfg/devices/prime_mini.py @@ -0,0 +1,100 @@ +from .. import usbhid + + +profile = { + "name": "SteelSeries Prime Mini", + "models": [ + { + "name": "SteelSeries Prime Mini", + "vendor_id": 0x1038, + "product_id": 0x184D, + "endpoint": 3, + }, + ], + "settings": { + "sensitivity": { + "label": "Sensitivity presets", + "description": "Set sensitivity preset (DPI)", + "cli": ["-s", "--sensitivity"], + "report_type": usbhid.HID_REPORT_TYPE_OUTPUT, + "command": [0x2D], + "value_type": "multidpi_range", + "input_range": [50, 18000, 50], + "output_range": [0x01, 0x0168, 1], + "dpi_length_byte": 2, + "count_mode": "number", + "first_preset": 0, + "max_preset_count": 5, + "default": "400, 800, 1200, 2400, 3200", + }, + "polling_rate": { + "label": "Polling rate", + "description": "Set polling rate (Hz)", + "cli": ["-p", "--polling-rate"], + "report_type": usbhid.HID_REPORT_TYPE_OUTPUT, + "command": [0x2B], + "value_type": "choice", + "choices": { + 125: 0x04, + 250: 0x03, + 500: 0x02, + 1000: 0x01, + }, + "default": 1000, + }, + "color": { + "label": "LED color", + "description": "Set the mouse LED color", + "cli": ["-c", "--color"], + "report_type": usbhid.HID_REPORT_TYPE_OUTPUT, + "command": [0x21, 0x00], + "value_type": "rgbcolor", + "default": "red", + }, + "buttons_mapping": { + "label": "Buttons mapping", + "description": "Set the mapping of the buttons", + "cli": ["-b", "--buttons"], + "report_type": usbhid.HID_REPORT_TYPE_OUTPUT, + "command": [0x2A], + "value_type": "buttons", + # fmt: off + "buttons": { + "Button1": {"id": 0x01, "offset": 0x00, "default": "button1"}, + "Button2": {"id": 0x02, "offset": 0x05, "default": "button2"}, + "Button3": {"id": 0x03, "offset": 0x0A, "default": "button3"}, + "Button4": {"id": 0x04, "offset": 0x0F, "default": "button4"}, + "Button5": {"id": 0x05, "offset": 0x14, "default": "button5"}, + "Button6": {"id": 0x06, "offset": 0x19, "default": "dpi"}, + "ScrollUp" : {"id": 0x31, "offset": 0x1E, "default": "scrollup"}, + "ScrollDown": {"id": 0x32, "offset": 0x23, "default": "scrolldown"}, + }, + "button_field_length": 5, + "button_disable": 0x00, + "button_keyboard": 0x51, + "button_multimedia": 0x61, + "button_dpi_switch": 0x30, + "button_scroll_up": None, + "button_scroll_down": None, + # fmt: on + "default": "buttons(button1=button1; button2=button2; button3=button3; button4=button4; button5=button5; button6=dpi; scrollup=scrollup; scrolldown=scrolldown; layout=qwerty)", + }, + "default_lighting": { + "label": "Default lighting", + "description": "Set default lighting at mouse startup", + "cli": ["-d", "--default-lighting"], + "report_type": usbhid.HID_REPORT_TYPE_OUTPUT, + "command": [0x27], + "value_type": "choice", + "choices": { + "off": 0x00, + "rainbow": 0x01, + }, + "default": "rainbow", + }, + }, + "save_command": { + "report_type": usbhid.HID_REPORT_TYPE_OUTPUT, + "command": [0x11, 0x00], + }, +} From 1d6417c6783b47381f6e9dc54517e1eac04856c0 Mon Sep 17 00:00:00 2001 From: Fabien LOISON Date: Sat, 13 Jan 2024 14:07:55 +0100 Subject: [PATCH 2/4] test: Added tests for the Prime Mini device --- test/devices/test_prime_mini.py | 149 ++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 test/devices/test_prime_mini.py diff --git a/test/devices/test_prime_mini.py b/test/devices/test_prime_mini.py new file mode 100644 index 0000000..756a4f6 --- /dev/null +++ b/test/devices/test_prime_mini.py @@ -0,0 +1,149 @@ +import pytest + +from rivalcfg import usbhid +from rivalcfg import mouse +from rivalcfg.devices import prime_mini +from rivalcfg import mouse_settings + + +class TestDevice(object): + @pytest.fixture + def mouse(self): + settings = mouse_settings.FakeMouseSettings( + 0x1038, + 0xBAAD, + prime_mini.profile, + ) + return mouse.Mouse( + usbhid.FakeDevice(), + prime_mini.profile, + settings, + ) + + @pytest.mark.parametrize( + "value,expected_hid_report", + [ + (100, b"\x02\x00\x2D\x01\x00\x02\x00"), + ("100", b"\x02\x00\x2D\x01\x00\x02\x00"), + ("500,2500", b"\x02\x00\x2D\x02\x00\x0A\x00\x32\x00"), + ( + "500,2500,11050,18000", + b"\x02\x00\x2D\x04\x00\x0A\x00\x32\x00\xDD\x00\x68\x01", + ), + ], + ) + def test_set_sensitivity(self, mouse, value, expected_hid_report): + mouse.set_sensitivity(value) + mouse._hid_device.bytes.seek(0) + hid_report = mouse._hid_device.bytes.read() + assert hid_report == expected_hid_report + + @pytest.mark.parametrize( + "value,expected_hid_report", + [ + (125, b"\x02\x00\x2b\x04"), + (250, b"\x02\x00\x2b\x03"), + (500, b"\x02\x00\x2b\x02"), + (1000, b"\x02\x00\x2b\x01"), + ], + ) + def test_set_polling_rate(self, mouse, value, expected_hid_report): + mouse.set_polling_rate(value) + mouse._hid_device.bytes.seek(0) + hid_report = mouse._hid_device.bytes.read() + assert hid_report == expected_hid_report + + @pytest.mark.parametrize( + "value,expected_hid_report", + [ + ("#ABCDEF", b"\x02\x00\x21\x00\xAB\xCD\xEF"), + ("red", b"\x02\x00\x21\x00\xFF\x00\x00"), + ], + ) + def test_set_color(self, mouse, value, expected_hid_report): + mouse.set_color(value) + mouse._hid_device.bytes.seek(0) + hid_report = mouse._hid_device.bytes.read() + assert hid_report == expected_hid_report + + @pytest.mark.parametrize( + "value,expected_hid_report", + [ + ( + "default", + b"\x02\x00" + b"\x2a" + b"\x01\x00\x00\x00\x00" + b"\x02\x00\x00\x00\x00" + b"\x03\x00\x00\x00\x00" + b"\x04\x00\x00\x00\x00" + b"\x05\x00\x00\x00\x00" + b"\x30\x00\x00\x00\x00" + b"\x31\x00\x00\x00\x00" + b"\x32\x00\x00\x00\x00", + ), + ( + "buttons(button2=button6)", + b"\x02\x00" + b"\x2a" + b"\x01\x00\x00\x00\x00" + b"\x06\x00\x00\x00\x00" + b"\x03\x00\x00\x00\x00" + b"\x04\x00\x00\x00\x00" + b"\x05\x00\x00\x00\x00" + b"\x30\x00\x00\x00\x00" + b"\x31\x00\x00\x00\x00" + b"\x32\x00\x00\x00\x00", + ), + ( + {"buttons": {"button2": "button6"}}, + b"\x02\x00" + b"\x2a" + b"\x01\x00\x00\x00\x00" + b"\x06\x00\x00\x00\x00" + b"\x03\x00\x00\x00\x00" + b"\x04\x00\x00\x00\x00" + b"\x05\x00\x00\x00\x00" + b"\x30\x00\x00\x00\x00" + b"\x31\x00\x00\x00\x00" + b"\x32\x00\x00\x00\x00", + ), + ( + "buttons(ScrollUp=ScrollDown; ScrollDown=ScrollUp)", + b"\x02\x00" + b"\x2a" + b"\x01\x00\x00\x00\x00" + b"\x02\x00\x00\x00\x00" + b"\x03\x00\x00\x00\x00" + b"\x04\x00\x00\x00\x00" + b"\x05\x00\x00\x00\x00" + b"\x30\x00\x00\x00\x00" + b"\x32\x00\x00\x00\x00" + b"\x31\x00\x00\x00\x00", + ), + ], + ) + def test_set_buttons_mapping(self, mouse, value, expected_hid_report): + mouse.set_buttons_mapping(value) + mouse._hid_device.bytes.seek(0) + hid_report = mouse._hid_device.bytes.read() + assert hid_report == expected_hid_report + + @pytest.mark.parametrize( + "value,expected_hid_report", + [ + ("off", b"\x02\x00\x27\x00"), + ("rainbow", b"\x02\x00\x27\x01"), + ], + ) + def test_set_default_lighting(self, mouse, value, expected_hid_report): + mouse.set_default_lighting(value) + mouse._hid_device.bytes.seek(0) + hid_report = mouse._hid_device.bytes.read() + assert hid_report == expected_hid_report + + def test_save(self, mouse): + mouse.save() + mouse._hid_device.bytes.seek(0) + hid_report = mouse._hid_device.bytes.read() + assert hid_report == b"\x02\x00\x11\x00" From 6636dac4a98419b9bc1a06da87b2efb0379dea16 Mon Sep 17 00:00:00 2001 From: Fabien LOISON Date: Sat, 13 Jan 2024 14:18:09 +0100 Subject: [PATCH 3/4] doc: Added documentation for the Prime Mini device --- doc/devices/index.rst | 1 + doc/devices/prime_mini.rst | 81 ++++++++++++++++++++++++++++++++++ doc/devices/prime_wireless.rst | 4 ++ 3 files changed, 86 insertions(+) create mode 100644 doc/devices/prime_mini.rst diff --git a/doc/devices/index.rst b/doc/devices/index.rst index 838c604..0703e49 100644 --- a/doc/devices/index.rst +++ b/doc/devices/index.rst @@ -14,6 +14,7 @@ Supported Devices ./kanav2.rst ./kinzuv2.rst ./prime.rst + ./prime_mini.rst ./prime_wireless.rst ./rival3.rst ./rival3_wireless.rst diff --git a/doc/devices/prime_mini.rst b/doc/devices/prime_mini.rst new file mode 100644 index 0000000..a380a59 --- /dev/null +++ b/doc/devices/prime_mini.rst @@ -0,0 +1,81 @@ +SteelSeries Prime Mini +====================== + + +.. NOTE:: + + * For Prime Mini Wireless, see :doc:`./prime_wireless`. + + +Supported Models +---------------- + +.. rivalcfg_device_family:: prime_mini + + +Command-Line Usage +------------------ + +.. rivalcfg_device_cli:: prime_mini + + +Sensitivity (DPI) +----------------- + +This mouse supports up to 5 sensitivity presets. You can define them like this: + +:: + + rivalcfg --sensitivity 800 # one preset + rivalcfg --sensitivity 800,1600 # two presets + +You can switch preset using the button under the mouse wheel. + +.. NOTE:: + + When you set the sensitivity through the CLI, the selected preset always + back to the first one. + + +.. NOTE:: From Python API, you can pass an ``int``, a ``tuple`` or a ``list`` + as parameter. You are also able to change the currently selected preset:: + + mouse.sensitivity(800) + mouse.sensitivity("800, 1600") + mouse.sensitivity([800, 1600]) + # select the second preset (1600 dpi) + mouse.sensitivity([800, 1600, 2000, 4000], selected_preset=2) + + +Colors +------ + +This mouse supports colors. Various formats are supported. + +.. include:: ./_colors.rst + +.. IMPORTANT:: + + On newer SteelSeries mice, the color settings are not saved in the onboard + memory anymore (see Default Lighting bellow). + + +Default Lighting +---------------- + +.. include:: ./_default_lighting.rst + + +Buttons +------- + +.. figure:: ./images/prime_buttons.svg + :alt: Prime buttons schema + +.. include:: ./_buttons.rst + + +Python API +---------- + +TODO diff --git a/doc/devices/prime_wireless.rst b/doc/devices/prime_wireless.rst index d4f62d7..833f411 100644 --- a/doc/devices/prime_wireless.rst +++ b/doc/devices/prime_wireless.rst @@ -1,6 +1,10 @@ SteelSeries Prime Wireless ========================== +.. NOTE:: + + * For Prime Mini (non-wireless version), see :doc:`./prime_mini`. + Supported Models ---------------- From 9a06ab2a03f055e83322598231570cf251d6562c Mon Sep 17 00:00:00 2001 From: Fabien LOISON Date: Sat, 13 Jan 2024 14:20:39 +0100 Subject: [PATCH 4/4] docs: Updated changelog --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index b80b336..8850eb1 100644 --- a/README.rst +++ b/README.rst @@ -93,6 +93,10 @@ Supported Devices +------------------------------------------------------------------------+-----------+ | SteelSeries Prime CS:GO Neo Noir Edition | 1038:1856 | +------------------------------------------------------------------------+-----------+ +| **SteelSeries Prime Mini** | ++------------------------------------------------------------------------+-----------+ +| SteelSeries Prime Mini | 1038:184d | ++------------------------------------------------------------------------+-----------+ | **SteelSeries Prime Wireless** | +------------------------------------------------------------------------+-----------+ | SteelSeries Prime Wireless (wired mode) | 1038:1842 | @@ -240,6 +244,7 @@ Changelog * **[NEXT]** (changes on ``master`` that have not been released yet): + * feat: Added Prime Mini support (@flozz, @NextWork123, #227) * chore: Added Python 3.12 support * chore!: Dropped Python 3.7 support