Skip to contentSkip to conversation

keymap function for quickstart driver

PATCH New Rainer Koenig 1 participant 1 message Mar 19, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 keymap function for quickstart driver

Hi,

back again with a patch for the quickstart driver that implements a keymap for the runtime events that quickstart generates. A custom keymap can be assigned via a simple udev rule.

Background for this: Fujitsu is going to ship very small systems with no direct eject button for the optical drive. Instead you have a hotkey that is recognized by the quickstart driver. This patch now allows to map the key event (0x1) to the keycode "ejectcd" and then react to this in your desktop manager software.

drivers/staging/quickstart/quickstart.c 2012-03-19 09:03:02.000000000 +0100 renamed from drivers/staging/quickstart/quickstart.c 2012-03-19 08:25:33.000000000 +0100 +19 -4
@@ -216,6 +216,8 @@
 static void quickstart_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
        struct quickstart_acpi *quickstart = data;
+        unsigned int key;
+        struct input_keymap_entry ke;
 
        if (!quickstart)
                return;
@@ -223,9 +225,13 @@
        if (event == QUICKSTART_EVENT_WAKE)
                quickstart_data.pressed = quickstart->btn;
        else if (event == QUICKSTART_EVENT_RUNTIME) {
-               input_report_key(quickstart_input, quickstart->btn->id, 1);
+                ke.flags = INPUT_KEYMAP_BY_INDEX;
+                ke.index = quickstart->btn->id;
+                quickstart_input->getkeycode(quickstart_input, &ke);
+                key = ke.keycode;
+               input_report_key(quickstart_input, key, 1);
                input_sync(quickstart_input);
-               input_report_key(quickstart_input, quickstart->btn->id, 0);
+               input_report_key(quickstart_input, key, 0);
                input_sync(quickstart_input);
        }
        return;
@@ -374,8 +380,9 @@
 static int __init quickstart_init_input(void)
 {
        struct quickstart_btn **ptr = &quickstart_data.btn_lst;
-       int count;
        int ret;
+        int maxkey = 0, id;
+        unsigned int *keymap;
 
        quickstart_input = input_allocate_device();
 
@@ -386,11 +393,30 @@
        quickstart_input->id.bustype = BUS_HOST;
 
        while (*ptr) {
-               count++;
                set_bit(EV_KEY, quickstart_input->evbit);
                set_bit((*ptr)->id, quickstart_input->keybit);
+                if ((*ptr)->id > maxkey)
+                  maxkey = (*ptr)->id;
                ptr = &((*ptr)->next);
        }
+
+        /* build a character map that at the moment maps GHID ids to keycodes */
+        /* this map can be replaced from userspace to map the correct keycodes */
+        maxkey++;
+        quickstart_input->keycodemax = maxkey;
+        quickstart_input->keycodesize = sizeof(unsigned int);
+        quickstart_input->keycode =

kzalloc(quickstart_input->keycodemax*quickstart_input->keycodesize, GFP_KERNEL);
+ if (!quickstart_input->keycode)
+ return -ENOMEM;
+
+ keymap = quickstart_input->keycode;
+
+ ptr = &quickstart_data.btn_lst;
+ while(*ptr) {

+            id = (*ptr)->id;
+            keymap[id] = id;
+            ptr = &((*ptr)->next);

+ }

        ret = input_register_device(quickstart_input);
        if (ret) {
Signature · 19 lines
Dipl.-Inf. (FH) Rainer Koenig
Project Manager Linux Clients
Dept. PDG WPS R&D SW OSE

Fujitsu Technology Solutions
Bürgermeister-Ullrich-Str. 100
86199 Augsburg
Germany

Telephone: +49-821-804-3321
Telefax:   +49-821-804-2131
Mail:      mailto:[email protected]

Internet         ts.fujtsu.com
Company Details  ts.fujitsu.com/imprint.html
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html