mouse
Factory Function
- rivalcfg.mouse.get_mouse(vendor_id=4152, product_id=None)
Get a
Mouse
instance to manipulate requested device.- Parameters:
vendor_id (int) – The vendor id of the device (optional, by default this is set to the SteelSeries vendor id (
0x1038
)).product_id (int) – The product id of one of the supported device (e.g.
0x1702
).
- Raises:
rivalcfg.devices.UnsupportedDevice – The requested device is not supported by rivalcfg.
- Return type:
>>> from rivalcfg.mouse import get_mouse >>> get_mouse(vendor_id=0x1038, product_id=0x1702) <Mouse SteelSeries Rival 100 (1038:1702:00)>
Mouse Class
- class rivalcfg.mouse.Mouse(hid_device, mouse_profile, mouse_settings, command_delay=0.05)
Generic class to handle any supported mouse.
Note
Additional methods are available in this class depending on the loaded profile. Read device specific documentation for more information.
Warning
You should not instanciate this class yourself. Use the
get_mouse()
factory function instead.- Parameters:
hid_device – The HID device to write in (provided by the
rivalcfg.usbhid.open_device()
).mouse_profile – One of the rivalcfg mouse profile (provided by
rivalcfg.devices.get_profile()
).command_delay (float) – Waiting time beween two commands to not overload the device.
>>> from rivalcfg import usbhid >>> from rivalcfg import devices >>> from rivalcfg.mouse import Mouse >>> from rivalcfg.mouse_settings import get_mouse_settings >>> profile = devices.get_profile(vendor_id=0x1038, product_id=0x1702) >>> settings = get_mouse_settings(0x1038, 0x1702, profile) >>> Mouse( ... usbhid.open_device(vendor_id=0x1038, product_id=0x1702, endpoint=0), ... profile, ... settings, ... ) <Mouse SteelSeries Rival 100 (1038:1702:00)>
- _hid_write(report_type=2, report_id=0, data=[], packet_length=0)
Write data to the device.
- Parameters:
report_type (int) – The HID report type (
rivalcfg.usbhid.HID_REPORT_TYPE_OUTPUT
orrivalcfg.usbhid.HID_REPORT_TYPE_FEATURE
).report_id (int) – The id of the report (always
0x00
).data (list(int)) – The data to send to the mouse.
packet_length (int) – The fixed length of the packet that will be sent to the device (default:
0
(no fixed length)).
- Raises:
ValueError – Invalid report type, or HID device not openned.
- property battery
Information about the device battery.
- Return type:
dict
- Returns:
{"is_charging": True|False|None, "level": int(0-100)|None}
.
Note
A value of
None
means the feature is not supported or that the mouse is turned off.
- close()
Close the device.
Warning
Once called, any access of the Mouse class properties or function may raise an error.
- property command_delay
Waiting time beween two commands to not overload the device.
Warning
Setting this value too low can hang the device. Some mice like the Kinzu v2 are known to become laggy or even to crash when commands are sent too quickly.
- property firmware_version
The firmware version as an human readable string (e.g.
"1.33"
,"0"
if not available).
- property firmware_version_tuple
The firmware version of the device as a tuple (e.g.``(1, 33)``,
(0,)
if not available).
- mouse_profile = None
The mouse settings (
rivalcfg.devices.*
)
- mouse_settings = None
The mouse settings (
rivalcfg.mouse_settings.MouseSettings
)
- property name
The mouse name.
- property product_id
The mouse product id.
- reset_settings()
Sets all settings to their factory default values.
- save()
Save current config to the mouse internal memory.
- property vendor_id
The mouse vendor id.