All input devices are defined in the [input_device] table. Currently supported input device types include:
A rotary encoder is a common input device that can be used for volume control, page scrolling, and other functions. It can be defined in the configuration file as follows:
Multiple encoders can be added, and their indices are determined by the order of addition:
A joystick is an analog input device that can be used for mouse control and other functions. Currently only NRF series chips are supported.
name: Unique name for the joystick. If you have multiple joysticks, they need different namespin_x: Pin for X-axispin_y: Pin for Y-axispin_z: Pin for Z-axistransform: Transformation matrix for the joystickbias: Bias value for each axisresolution: Resolution for each axisAxis Configuration Note:
_indicates that the axis does not exist.
_is only allowed for:
- Both y and z axes are missing
- Only z axis is missing
For example:
pin_x = "_"pin_y = "P0_29"pin_z = "P0_30"is not allowed
Device reads values from each axis
Adds bias value to each axis to make the value close to 0 when the joystick is released
About the transform matrix:
If transform[new_axis][old_axis] is 0, that old axis value is ignored.
Since the value range read by the ADC device is usually much larger than the mouse report range of -256~255, transform is designed as a divisor.
Each axis value is adjusted to the largest integer multiple of resolution that is less than its original value to reduce noise from ADC device readings.
First set bias to 0, resolution to 1, and transform to [[1, 0, 0], [0, 1, 0], [0, 0, 1]] (matrix dimension depends on the number of axes)
Find the optimal bias value:
JoystickProcessor::generate_report: record = [axis_x, axis_y, axis_z] in debug informationbias value that makes each axis closest to 0 when the joystick is releasedIf the mouse moves too fast, gradually increase the transform value until you find the right sensitivity
If the mouse jitters, gradually increase the resolution value until the jitter disappears
Pointing devices (such as touchpads) can be connected via I2C or SPI interface. Configuration examples:
or
instance: I2C instance namescl: Clock pinsda: Data pininstance: SPI instance namesck: Clock pinmosi: Master Out Slave In pinmiso: Master In Slave Out pincs: Chip Select pin (optional)cpi: Counts Per Inch (optional)