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

Commit 571f572f authored by Jason Gerecke's avatar Jason Gerecke Committed by Jiri Kosina
Browse files

HID: wacom: Further clean up wacom_intuos_general packet decoder



Continue re-organizing and trimming cases to make it easier to wrap
the brain around. A number of changes were made after consulting the
protocol spec and so don't necessarily follow from the code itself.

Signed-off-by: default avatarJason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent a8a09c85
Loading
Loading
Loading
Loading
+41 −46
Original line number Diff line number Diff line
@@ -925,7 +925,6 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
		break;

	case 0x0a:
	case 0x0b:
		/* airbrush second packet */
		input_report_abs(input, ABS_WHEEL,
				(data[6] << 2) | ((data[7] >> 6) & 3));
@@ -935,7 +934,6 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
		break;

	case 0x05:
	case 0x07:
		/* Rotation packet */
		if (features->type >= INTUOS3S) {
			/* I3 marker pen rotation */
@@ -944,19 +942,15 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
				((t-1) / 2 + 450)) : (450 - t / 2) ;
			input_report_abs(input, ABS_Z, t);
		} else {
			/* 4D mouse rotation packet */
			/* 4D mouse 2nd packet */
			t = (data[6] << 3) | ((data[7] >> 5) & 7);
			input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
				((t - 1) / 2) : -t / 2);
		}
		break;

	/* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
	case 0x04:
	case 0x06:
	case 0x08:
		if (features->type < INTUOS3S && type != 0x08) {
			/* 4D mouse packet */
		/* 4D mouse 1st packet */
		input_report_key(input, BTN_LEFT,   data[8] & 0x01);
		input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
		input_report_key(input, BTN_RIGHT,  data[8] & 0x04);
@@ -965,10 +959,10 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
		input_report_key(input, BTN_EXTRA,  data[8] & 0x10);
		t = (data[6] << 2) | ((data[7] >> 6) & 3);
		input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
		}
		else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
		break;

	case 0x06:
		/* I4 mouse */
			if (features->type >= INTUOS4S && features->type <= INTUOSPL) {
		input_report_key(input, BTN_LEFT,   data[6] & 0x01);
		input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
		input_report_key(input, BTN_RIGHT,  data[6] & 0x04);
@@ -980,7 +974,10 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
		input_report_abs(input, ABS_TILT_X,
			(((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
		input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
			} else {
		break;

	case 0x08:
		if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
			/* 2D mouse packet */
			input_report_key(input, BTN_LEFT,   data[8] & 0x04);
			input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
@@ -994,11 +991,7 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
				input_report_key(input, BTN_EXTRA,  data[8] & 0x20);
			}
		}
		}
		else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
		          features->type == INTUOS4L || features->type == INTUOS5L ||
		          features->type == INTUOSPL) &&
		         wacom->tool[idx] == BTN_TOOL_LENS) {
		else if (wacom->tool[idx] == BTN_TOOL_LENS) {
			/* Lens cursor packets */
			input_report_key(input, BTN_LEFT,   data[8] & 0x01);
			input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
@@ -1008,7 +1001,9 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
		}
		break;

	case 0x07:
	case 0x09:
	case 0x0b:
	case 0x0c:
	case 0x0d:
	case 0x0e: