Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83ed79c5 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Jiri Kosina
Browse files

HID: length resolution should be reported units/mm



Input ABI requires reporting resolution on main axes in units per
millimeter, not units per inch, so we need to convert accordingly.

Tested-by: default avatarNikolai Kondrashov <spbnick@gmail.com>
Acked-by: default avatarNikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent d65c3768
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -162,8 +162,8 @@ static int hidinput_setkeycode(struct input_dev *dev,
 *
 * as seen in the HID specification v1.11 6.2.2.7 Global Items.
 *
 * Only exponent 1 length units are processed. Centimeters are converted to
 * inches. Degrees are converted to radians.
 * Only exponent 1 length units are processed. Centimeters and inches are
 * converted to millimeters. Degrees are converted to radians.
 */
static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
{
@@ -184,13 +184,16 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
	 */
	if (code == ABS_X || code == ABS_Y || code == ABS_Z) {
		if (field->unit == 0x11) {		/* If centimeters */
			/* Convert to inches */
			prev = logical_extents;
			logical_extents *= 254;
			if (logical_extents < prev)
			/* Convert to millimeters */
			unit_exponent += 1;
		} else if (field->unit == 0x13) {	/* If inches */
			/* Convert to millimeters */
			prev = physical_extents;
			physical_extents *= 254;
			if (physical_extents < prev)
				return 0;
			unit_exponent += 2;
		} else if (field->unit != 0x13) {	/* If not inches */
			unit_exponent -= 1;
		} else {
			return 0;
		}
	} else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) {