Skip to contentSkip to conversation

Input: set INPUT_PROP_POINTING_STICK in hid-lenovo

PATCH Superseded Andreas Fleig 2 participants 3 messages Apr 7, 2015 – Apr 8, 2015

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: set INPUT_PROP_POINTING_STICK in hid-lenovo

Set flags INPUT_PROP_POINTER and INPUT_PROP_POINTING_STICK for the trackpoint integrated in Lenovo USB and Bluetooth keyboards. Libinput checks these flags to enable features such as middle-button-scrolling by default.

drivers/hid/hid-lenovo.c +0 -0
index c4c3f09..4cb7235 100644
@@ -762,6 +762,16 @@ static void lenovo_remove(struct hid_device *hdev)
	hid_hw_stop(hdev);
}

+static void lenovo_input_configured(struct hid_device *hdev,
+ struct hid_input *hi)
+{
+ if (*hi->input->ledbit == 0) {
+ /* set only for trackpoint device, identify by missing LEDs */
+ __set_bit(INPUT_PROP_POINTER, hi->input->propbit);
+ __set_bit(INPUT_PROP_POINTING_STICK, hi->input->propbit);
+ }
+}
+
static const struct hid_device_id lenovo_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD) }, { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD)
},
@@ -774,6 +784,7 @@ MODULE_DEVICE_TABLE(hid, lenovo_devices);

static struct hid_driver lenovo_driver = {
	.name = "lenovo",
	.id_table = lenovo_devices,

+ .input_configured = lenovo_input_configured,
.input_mapping = lenovo_input_mapping,
.probe = lenovo_probe,
.remove = lenovo_remove,

#1 lore raw

Hi Andreas,

Quoted 12 lines · Andreas Fleig

Set flags INPUT_PROP_POINTER and INPUT_PROP_POINTING_STICK for the trackpoint integrated in Lenovo USB and Bluetooth keyboards. Libinput checks these flags to enable features such as middle-button-scrolling by default.

drivers/hid/hid-lenovo.c +0 -0
index c4c3f09..4cb7235 100644

drivers/hid/hid-lenovo.c static void lenovo_remove(struct hid_device *hdev) · line 768

Quoted 7 lines
drivers/hid/hid-lenovo.c +4 -0
@@ -762,6 +762,16 @@ static void lenovo_remove(struct hid_device *hdev)
        hid_hw_stop(hdev);
 }
 
+static void lenovo_input_configured(struct hid_device *hdev,
+               struct hid_input *hi)
+{
+       if (*hi->input->ledbit == 0) {

Without commenting on validity of making this decision based on presence or absence of LEDs the proper test would be:

        if (!test_bit(EV_LED, hi->input->evbit)) {
                ...
        }
Quoted 14 lines
drivers/hid/hid-lenovo.c +6 -0
+               /* set only for trackpoint device, identify by missing LEDs
 */
+               __set_bit(INPUT_PROP_POINTER, hi->input->propbit);
+               __set_bit(INPUT_PROP_POINTING_STICK, hi->input->propbit);
+       }
+}
+
 static const struct hid_device_id lenovo_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_TPKBD)

},
{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_CUSBKBD)
},

drivers/hid/hid-lenovo.c MODULE_DEVICE_TABLE(hid, lenovo_devices); · line 790

Quoted 7 lines
drivers/hid/hid-lenovo.c +1 -0
@@ -774,6 +784,7 @@ MODULE_DEVICE_TABLE(hid, lenovo_devices);
 static struct hid_driver lenovo_driver = {
        .name = "lenovo",
        .id_table = lenovo_devices,
+       .input_configured = lenovo_input_configured,
        .input_mapping = lenovo_input_mapping,
        .probe = lenovo_probe,
        .remove = lenovo_remove,

Thanks.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 4 lines · Dmitry Torokhov

Without commenting on validity of making this decision based on presence or absence of LEDs the proper test would be:

        if (!test_bit(EV_LED, hi->input->evbit)) {

Thanks, that's much cleaner. I'll also test for EV_REL instead, which makes more sense, especially since the keyboard doesn't actually have physical LEDs.

Andreas