-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'device-prime-mini' (closes #227)
- Loading branch information
Showing
7 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |