multidpi_range_choice
The “multidpi_range_choice” type alows to pick values in an input range and transforms it into values from a fixed output list. If the input values do not correspond to one of the available output choices, they are rounded to match the nearest DPI.
This type is used to support devices where we can configure from 1 to n
DPI settings in a single command, like the Aerox 3.
For example with an input range like [0, 1000, 100] and an output range
like {0: 0, 100: 1, 200: 2, 300: 4,...}, you can have the following pair:
0->0100->1110->1(1100rounded to100)190->2(1900rounded to200)200->2300->4…
Device Profile
Example of a multidpi_range_choice value type in a device profile:
profile = {
# ...
"settings": {
"sensitivity1": {
"label": "Sensitivity presets",
"description": "Set sensitivity presets (DPI)",
"cli": ["-s", "--sensitivity"],
"report_type": usbhid.HID_REPORT_TYPE_OUTPUT,
"command": [0x0B, 0x00],
"value_type": "multidpi_range_choice",
"input_range": [100, 18000, 100],
"output_choices": {
100: 0x00,
200: 0x02,
300: 0x03,
400: 0x04,
...
18000: 0xD6,
},
"dpi_length_byte": 1, # Little endian
"first_preset": 1,
"max_preset_count": 5,
"default": "800, 1600",
},
},
# ...
}
CLI
Example of CLI option generated with this handler:
-s SENSITIVITY, --sensitivity SENSITIVITY
Set sensitivity preset (DPI) (up to 5 settings, from 200 dpi to 8500
dpi, default: '800, 1600')
Example of CLI usage:
rivalcfg --sensitivity 1600
rivalcfg --sensitivity "800,1600"
rivalcfg --sensitivity "200, 400, 800, 1600, 8000"
Functions
- rivalcfg.handlers.multidpi_range_choice.add_cli_option(cli_parser, setting_name, setting_info)
Add the given “range” type setting to the given CLI arguments parser.
- Parameters:
cli_parser (ArgumentParser) – An
ArgumentParserinstance.setting_name (str) – The name of the setting.
setting_info (dict) – The information dict of the setting from the device profile.
- rivalcfg.handlers.multidpi_range_choice.process_value(setting_info, value, selected_preset=None)
Called by the
rivalcfg.mouse.Mouseclass when processing a “multidpi_range_choice” type setting.- Parameters:
setting_info (dict) – The information dict of the setting from the device profile.
value – The input value.
selected_preset (int) – The DPI preset to select (0 is always the first preset).
- Return type:
list[int]