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

Commit 57ac86cf authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina
Browse files

HID: logitech-hidpp: add support of the first Logitech Wireless Touchpad



This touchpad differs from the T650 in several ways:
- the resolution is not correctly returned by the device
- it presents physical buttons, so the button flag in the raw touch report
  is not filled.

Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Tested-by: default avatarAndrew de los Reyes <adlr@chromium.org>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 586bdc4e
Loading
Loading
Loading
Loading
+27 −5
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ MODULE_AUTHOR("Nestor Lopez Casado <nlopezcasad@logitech.com>");


/* bits 1..20 are reserved for classes */
/* bits 1..20 are reserved for classes */
#define HIDPP_QUIRK_DELAYED_INIT		BIT(21)
#define HIDPP_QUIRK_DELAYED_INIT		BIT(21)
#define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS	BIT(22)


/*
/*
 * There are two hidpp protocols in use, the first version hidpp10 is known
 * There are two hidpp protocols in use, the first version hidpp10 is known
@@ -596,6 +597,8 @@ static void hidpp_touchpad_raw_xy_event(struct hidpp_device *hidpp_dev,
/* Touchpad HID++ devices                                                     */
/* Touchpad HID++ devices                                                     */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */


#define WTP_MANUAL_RESOLUTION				39

struct wtp_data {
struct wtp_data {
	struct input_dev *input;
	struct input_dev *input;
	u16 x_size, y_size;
	u16 x_size, y_size;
@@ -634,6 +637,9 @@ static void wtp_populate_input(struct hidpp_device *hidpp,


	input_set_capability(input_dev, EV_KEY, BTN_LEFT);
	input_set_capability(input_dev, EV_KEY, BTN_LEFT);


	if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)
		input_set_capability(input_dev, EV_KEY, BTN_RIGHT);
	else
		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);


	input_mt_init_slots(input_dev, wd->maxcontacts, INPUT_MT_POINTER |
	input_mt_init_slots(input_dev, wd->maxcontacts, INPUT_MT_POINTER |
@@ -676,7 +682,8 @@ static void wtp_send_raw_xy_event(struct hidpp_device *hidpp,
	for (i = 0; i < 2; i++)
	for (i = 0; i < 2; i++)
		wtp_touch_event(wd, &(raw->fingers[i]));
		wtp_touch_event(wd, &(raw->fingers[i]));


	if (raw->end_of_frame)
	if (raw->end_of_frame &&
	    !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS))
		input_event(wd->input, EV_KEY, BTN_LEFT, raw->button);
		input_event(wd->input, EV_KEY, BTN_LEFT, raw->button);


	if (raw->end_of_frame || raw->finger_count <= 2) {
	if (raw->end_of_frame || raw->finger_count <= 2) {
@@ -736,9 +743,17 @@ static int wtp_raw_event(struct hid_device *hdev, u8 *data, int size)


	switch (data[0]) {
	switch (data[0]) {
	case 0x02:
	case 0x02:
		if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) {
			input_event(wd->input, EV_KEY, BTN_LEFT,
					!!(data[1] & 0x01));
			input_event(wd->input, EV_KEY, BTN_RIGHT,
					!!(data[1] & 0x02));
			input_sync(wd->input);
		} else {
			if (size < 21)
			if (size < 21)
				return 1;
				return 1;
			return wtp_mouse_raw_xy_event(hidpp, &data[7]);
			return wtp_mouse_raw_xy_event(hidpp, &data[7]);
		}
	case REPORT_ID_HIDPP_LONG:
	case REPORT_ID_HIDPP_LONG:
		if ((report->fap.feature_index != wd->mt_feature_index) ||
		if ((report->fap.feature_index != wd->mt_feature_index) ||
		    (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY))
		    (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY))
@@ -775,6 +790,8 @@ static int wtp_get_config(struct hidpp_device *hidpp)
	wd->maxcontacts = raw_info.maxcontacts;
	wd->maxcontacts = raw_info.maxcontacts;
	wd->flip_y = raw_info.origin == TOUCHPAD_RAW_XY_ORIGIN_LOWER_LEFT;
	wd->flip_y = raw_info.origin == TOUCHPAD_RAW_XY_ORIGIN_LOWER_LEFT;
	wd->resolution = raw_info.res;
	wd->resolution = raw_info.res;
	if (!wd->resolution)
		wd->resolution = WTP_MANUAL_RESOLUTION;


	return 0;
	return 0;
}
}
@@ -1130,6 +1147,11 @@ static void hidpp_remove(struct hid_device *hdev)
}
}


static const struct hid_device_id hidpp_devices[] = {
static const struct hid_device_id hidpp_devices[] = {
	{ /* wireless touchpad */
	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
		USB_VENDOR_ID_LOGITECH, 0x4011),
	  .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT |
			 HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS },
	{ /* wireless touchpad T650 */
	{ /* wireless touchpad T650 */
	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
		USB_VENDOR_ID_LOGITECH, 0x4101),
		USB_VENDOR_ID_LOGITECH, 0x4101),