multidpi_range
The “multidpi_range” type alows to pick values in an input range and transforms it into values from an output range. If the input values do not correspond to one of the input range step, they are rounded to match the nearest step.
This type is used to support devices where we can configure from 1
to n
DPI settings in a single command, like the Rival 3.
For example with an input range like [0, 1000, 100]
and an output range
like [0, 10, 1]
, you can have the following pair:
0
->0
100
->1
110
->1
(110
rounded to100
)190
->2
(190
rounded to200
)200
->2
300
->3
…
1000
->10
Device Profile
Example of a multidpi_range 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",
"input_range": [200, 7200, 100],
"output_range": [0x04, 0xA7, 2],
"dpi_length_byte": 1, # Little endian
"first_preset": 1,
"count_mode": "number", # number, flag
"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.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
ArgumentParser
instance.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.process_value(setting_info, value, selected_preset=None)
Called by the
rivalcfg.mouse.Mouse
class when processing a “range” 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]