chiark / gitweb /
extras/input_id: Correctly identify touchpads
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 30 Nov 2009 22:03:05 +0000 (23:03 +0100)
committerMartin Pitt <martin.pitt@ubuntu.com>
Mon, 30 Nov 2009 22:03:05 +0000 (23:03 +0100)
BTN_TOUCH (as well as ABS_PRESSURE) is used not only by touchpads but
by touchscreens as well. The proper check for a touchpad is presence
of BTN_TOOL_FINGER and absence of BTN_TOOL_PEN (the latter to filter
out some tablets that use BTN_TOOL_FINGER).

Tablet matching should be on either BTN_TOOL_PEN or BTN_STYLUS.

extras/input_id/input_id.c

index 393a05d53a0e8879e0f148125aaead1de965b392..2e143a5628ccc508fc5baf8b6383e8f1e7f188b3 100644 (file)
@@ -75,13 +75,10 @@ static void test_pointers (const unsigned long* bitmask_abs, const unsigned long
        int is_mouse = 0;
        int is_touchpad = 0;
 
        int is_mouse = 0;
        int is_touchpad = 0;
 
-       if (test_bit (ABS_PRESSURE, bitmask_abs))
-               is_touchpad = 1;
-
        if (test_bit (ABS_X, bitmask_abs) && test_bit (ABS_Y, bitmask_abs)) {
        if (test_bit (ABS_X, bitmask_abs) && test_bit (ABS_Y, bitmask_abs)) {
-               if (test_bit (BTN_STYLUS, bitmask_key))
+               if (test_bit (BTN_STYLUS, bitmask_key) || test_bit (BTN_TOOL_PEN, bitmask_key))
                        puts("ID_INPUT_TABLET=1");
                        puts("ID_INPUT_TABLET=1");
-               else if (test_bit (BTN_TOUCH, bitmask_key))
+               else if (test_bit (BTN_TOOL_FINGER, bitmask_key) && !test_bit (BTN_TOOL_PEN, bitmask_key))
                        is_touchpad = 1;
                else if (test_bit (BTN_TRIGGER, bitmask_key) || 
                         test_bit (BTN_A, bitmask_key) || 
                        is_touchpad = 1;
                else if (test_bit (BTN_TRIGGER, bitmask_key) || 
                         test_bit (BTN_A, bitmask_key) ||