Re: Bug: changing keycodes generated by sony-laptop doesn't work

From: John Hughes
Date: Mon Oct 17 2011 - 05:13:10 EST


On 16/10/11 15:30, John Hughes wrote:

All the scancodes are 7 off, setting the mapping for scancode 0x14 changes the mapping for what the driver claims is scancode 0x1B.
Actually it's a bit worse than that.

The "scancodes" used by the sony-laptop driver are the indexes into sony_laptop_input_keycode_map and not the "event" codes at all.

This patch (not yet tested) should fix the scancodes reported by /lib/udev/keymap.

This just leaves a bug in the keymap files included with udev. I guess the sony-laptop file in Documentation needs to say where to find the scancodes.


diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index bbd182e..f148459 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -347,6 +347,7 @@ static void sony_laptop_report_input_event(u8 event)
struct input_dev *jog_dev = sony_laptop_input.jog_dev;
struct input_dev *key_dev = sony_laptop_input.key_dev;
struct sony_laptop_keypress kp = { NULL };
+ int scancode;

if (event == SONYPI_EVENT_FNKEY_RELEASED ||
event == SONYPI_EVENT_ANYBUTTON_RELEASED) {
@@ -380,8 +381,8 @@ static void sony_laptop_report_input_event(u8 event)
dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
break;
}
- if (sony_laptop_input_index[event] != -1) {
- kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]];
+ if ((scancode = sony_laptop_input_index[event]) != -1) {
+ kp.key = sony_laptop_input_keycode_map[scancode];
if (kp.key != KEY_UNKNOWN)
kp.dev = key_dev;
}
@@ -389,9 +390,9 @@ static void sony_laptop_report_input_event(u8 event)
}

if (kp.dev) {
- input_report_key(kp.dev, kp.key, 1);
/* we emit the scancode so we can always remap the key */
- input_event(kp.dev, EV_MSC, MSC_SCAN, event);
+ input_event(kp.dev, EV_MSC, MSC_SCAN, scancode);
+ input_report_key(kp.dev, kp.key, 1);
input_sync(kp.dev);

/* schedule key release */