]> err.no Git - linux-2.6/commitdiff
HID: Report usage codes of keys as EV_MSC scancode events
authorJiri Kosina <jkosina@suse.cz>
Mon, 20 Aug 2007 10:13:34 +0000 (12:13 +0200)
committerJiri Kosina <jkosina@suse.cz>
Sun, 14 Oct 2007 11:40:01 +0000 (13:40 +0200)
Current HID layer does not report usage codes to the input layer. This feature
was previously removed, because it caused unnecessary storm of events in cases
of positioning devices, etc.

This patch adds reporting of usage codes as EV_MSC events only for key events.
We issue the EV_MSC event only if the state of the key corresponding to the
given code has changed, so that we don't report usages that are sent in every
report even if the state hasn't changed (for example Shift/Caps Lock/...
states as sent by various keyboards).

This functionality is required at least by KeyTouch in order to provide
convenient means for remapping the usage codes.

Cc: Marvin Raaijmakers <marvin.nospam@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-input.c

index f80b57142cd4eb313c3188fc96a182cb3ec55eec..36be431888fb45192fb6a3a9358c4b7dd19793a5 100644 (file)
@@ -921,6 +921,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                set_bit(KEY_VOLUMEDOWN, input->keybit);
        }
 
+       if (usage->type == EV_KEY) {
+               set_bit(EV_MSC, input->evbit);
+               set_bit(MSC_SCAN, input->mscbit);
+       }
+
        hid_resolv_event(usage->type, usage->code);
 
        dbg_hid_line("\n");
@@ -1043,6 +1048,9 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
                        input_event(input, usage->type, last_key, 0);
                }
        }
+       /* report the usage code as scancode if the key status has changed */
+       if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value)
+               input_event(input, EV_MSC, MSC_SCAN, usage->hid);
 
        input_event(input, usage->type, usage->code, value);