Skip to content

Commit cce2dbd

Browse files
bentissJiri Kosina
authored andcommitted
HID: uclogic: name the input nodes based on their tool
We append "Pen", "Pad", "Mouse", "Keyboard", "Consumer Control" or "System Control" suffix to the appropriate input node to match what the Wacom driver does and be more convenient for the user to know which one is which. Reviewed-by: Nikolai Kondrashov <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 08177f4 commit cce2dbd

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

drivers/hid/hid-uclogic.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,51 @@ static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
713713
return rdesc;
714714
}
715715

716+
static void uclogic_input_configured(struct hid_device *hdev,
717+
struct hid_input *hi)
718+
{
719+
char *name;
720+
const char *suffix = NULL;
721+
struct hid_field *field;
722+
size_t len;
723+
724+
/* no report associated (HID_QUIRK_MULTI_INPUT not set) */
725+
if (!hi->report)
726+
return;
727+
728+
field = hi->report->field[0];
729+
730+
switch (field->application) {
731+
case HID_GD_KEYBOARD:
732+
suffix = "Keyboard";
733+
break;
734+
case HID_GD_MOUSE:
735+
suffix = "Mouse";
736+
break;
737+
case HID_GD_KEYPAD:
738+
suffix = "Pad";
739+
break;
740+
case HID_DG_PEN:
741+
suffix = "Pen";
742+
break;
743+
case HID_CP_CONSUMER_CONTROL:
744+
suffix = "Consumer Control";
745+
break;
746+
case HID_GD_SYSTEM_CONTROL:
747+
suffix = "System Control";
748+
break;
749+
}
750+
751+
if (suffix) {
752+
len = strlen(hdev->name) + 2 + strlen(suffix);
753+
name = devm_kzalloc(&hi->input->dev, len, GFP_KERNEL);
754+
if (name) {
755+
snprintf(name, len, "%s %s", hdev->name, suffix);
756+
hi->input->name = name;
757+
}
758+
}
759+
}
760+
716761
/**
717762
* Enable fully-functional tablet mode and determine device parameters.
718763
*
@@ -901,6 +946,7 @@ static struct hid_driver uclogic_driver = {
901946
.probe = uclogic_probe,
902947
.report_fixup = uclogic_report_fixup,
903948
.raw_event = uclogic_raw_event,
949+
.input_configured = uclogic_input_configured,
904950
};
905951
module_hid_driver(uclogic_driver);
906952

0 commit comments

Comments
 (0)