[PATCH v5 10/13] HID: haptic: Decouple from hid-multitouch and support other devices
From: Rong Zhang
Date: Sun Nov 29 2026 - 12:58:36 EST
Currently, hid-haptic only works on multitouch devices that have passed
the pressure unit check.
According to [1], a Simple Haptic Controller may be either a Collection
Application (CA) or a Collection Logical (CL):
A CA is a dedicated HID application, i.e., not associated with other HID
applications. Choose the first HID input device to attach the FF device,
as other FF drivers do. Haptic Mouse usually falls into this category as
long as it follows the example in [2].
A CL is contained within another HID application. The HID input device
handling the manual trigger report must be the one handling the
associated HID application. Haptic Touchpad and Stylus usually fall into
this category as long as they follow the examples in [2][3].
When HID_QUIRK_MULTI_INPUT is set, the quirky collection hierarchy makes
no sense anyway, so the first input device is chosen instead.
Fall back to the above strategy when hid-multitouch didn't choose an
input device due to pressure unit check failure or non-multitouch
device. In this case, hid-haptic works without the integration with
hid-multitouch.
With these, hid-plugin now becomes a generic plugin, so also add an info
message for device identification after haptic is connected.
Link: https://usb.org/sites/default/files/hutrr63b_-_haptics_page_redline_0.pdf [1]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/input-haptics-implementation-guide [2]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/haptic-pen-implementation-guide [3]
Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
drivers/hid/hid-haptic.c | 53 ++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 47 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
index 84b35ec8365a..eab7bbaaf504 100644
--- a/drivers/hid/hid-haptic.c
+++ b/drivers/hid/hid-haptic.c
@@ -566,19 +566,55 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
static int hid_haptic_check_prerequisites(struct hid_device *hdev,
struct hid_haptic_device *haptic, struct hid_input *hi)
{
+ struct hid_report *report;
+
if (!haptic->waveform_list_report || !haptic->duration_list_report ||
!haptic->manual_trigger_report)
return -ENOENT;
- if (IS_ERR_OR_NULL(haptic->input_dev))
- return PTR_ERR(haptic->input_dev) ?: -EXDEV;
-
/* Check the prerequisites only. */
if (!hi)
return 1;
- if (haptic->input_dev == hi->input)
- return 0;
+ /*
+ * Honor the HID driver's choice.
+ *
+ * If the driver didn't choose an input device or failed its
+ * prerequisites check, initialize the haptic device without the
+ * integration with the driver.
+ */
+ if (IS_ERR_OR_NULL(haptic->input_dev))
+ haptic->input_dev = NULL;
+ else
+ return haptic->input_dev != hi->input;
+
+ /*
+ * A Simple Haptic Controller may be either a Collection Application
+ * (CA) or a Collection Logical (CL):
+ *
+ * A CA is a dedicated HID application, i.e., not associated with other
+ * HID applications. Choose the first HID input device to attach the FF
+ * device, as other FF drivers do. Haptic Mouse usually falls into this
+ * category.
+ *
+ * A CL is contained within another HID application. The HID input
+ * device handling the manual trigger report must be the one handling
+ * the associated HID application. Haptic Touchpad and Stylus usually
+ * fall into this category.
+ *
+ * When HID_QUIRK_MULTI_INPUT is set, the quirky collection hierarchy
+ * makes no sense anyway, so the first input device is chosen instead.
+ */
+ if (haptic->manual_trigger_report->application == HID_HP_SIMPLECONTROLLER ||
+ hdev->quirks & HID_QUIRK_MULTI_INPUT) {
+ if (list_is_first(&hi->list, &hdev->inputs))
+ return 0;
+ } else {
+ list_for_each_entry(report, &hi->reports, hidinput_list) {
+ if (report == haptic->manual_trigger_report)
+ return 0;
+ }
+ }
return 1; /* Waiting for the relevant input device. */
}
@@ -586,17 +622,22 @@ static int hid_haptic_check_prerequisites(struct hid_device *hdev,
static int __hid_haptic_input_configured(struct hid_device *hdev,
struct hid_haptic_device *haptic, struct hid_input *hi)
{
+ bool driver_integration;
int ret;
ret = hid_haptic_check_prerequisites(hdev, haptic, hi);
if (ret)
return ret;
+ driver_integration = haptic->input_dev == hi->input;
+
ret = hid_haptic_init(hdev, haptic, hi->input);
if (ret)
return ret;
- if (hi->application == HID_DG_TOUCHPAD)
+ hid_info(hdev, "Haptic connected to %s\n", hi->input->name);
+
+ if (driver_integration && hi->application == HID_DG_TOUCHPAD)
__set_bit(INPUT_PROP_PRESSUREPAD, hi->input->propbit);
return 0;
--
2.55.0