aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
authorAristeu Rozanski <aris@ruivo.org>2007-07-16 16:53:09 -0400
committerPaul Mackerras <paulus@samba.org>2007-09-22 00:49:21 -0400
commit555ddbb4e2191c8823df2d61525218ac39481385 (patch)
treef9c61cbc66a967b1e5981979bd68e4b47e286e0f /drivers/macintosh
parentfc624eae3278330f484669dd8fe85535def7eb78 (diff)
[POWERPC] adbhid: Enable KEY_FN key reporting
When a Fn key is used in combination with another key in ADB keyboards it will generate a Fn event and then a second event that can be a different key than pressed (Fn + F1 for instance can generate Fn + brightness down if it's configured like that). This enables the reporting of the Fn key to the input system. As Fn is a dead key for most purposes, it's useful to report it so applications can make use of it. One example is apple_mouse (https://jake.ruivo.org/uinputd/trunk/apple_mouse/) that emulates the second and third keys using a combination of keyboard keys and the mouse button. Other applications may use the KEY_FN as a modifier as well. I've been updating and using this patch for months without problems. Signed-off-by: Aristeu Rozanski <aris@ruivo.org> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/adbhid.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index b46817f699f1..48d17bf6c927 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -70,7 +70,7 @@ static struct notifier_block adbhid_adb_notifier = {
70#define ADB_KEY_POWER_OLD 0x7e 70#define ADB_KEY_POWER_OLD 0x7e
71#define ADB_KEY_POWER 0x7f 71#define ADB_KEY_POWER 0x7f
72 72
73u8 adb_to_linux_keycodes[128] = { 73u16 adb_to_linux_keycodes[128] = {
74 /* 0x00 */ KEY_A, /* 30 */ 74 /* 0x00 */ KEY_A, /* 30 */
75 /* 0x01 */ KEY_S, /* 31 */ 75 /* 0x01 */ KEY_S, /* 31 */
76 /* 0x02 */ KEY_D, /* 32 */ 76 /* 0x02 */ KEY_D, /* 32 */
@@ -134,7 +134,7 @@ u8 adb_to_linux_keycodes[128] = {
134 /* 0x3c */ KEY_RIGHT, /* 106 */ 134 /* 0x3c */ KEY_RIGHT, /* 106 */
135 /* 0x3d */ KEY_DOWN, /* 108 */ 135 /* 0x3d */ KEY_DOWN, /* 108 */
136 /* 0x3e */ KEY_UP, /* 103 */ 136 /* 0x3e */ KEY_UP, /* 103 */
137 /* 0x3f */ 0, 137 /* 0x3f */ KEY_FN, /* 0x1d0 */
138 /* 0x40 */ 0, 138 /* 0x40 */ 0,
139 /* 0x41 */ KEY_KPDOT, /* 83 */ 139 /* 0x41 */ KEY_KPDOT, /* 83 */
140 /* 0x42 */ 0, 140 /* 0x42 */ 0,
@@ -208,7 +208,7 @@ struct adbhid {
208 int original_handler_id; 208 int original_handler_id;
209 int current_handler_id; 209 int current_handler_id;
210 int mouse_kind; 210 int mouse_kind;
211 unsigned char *keycode; 211 u16 *keycode;
212 char name[64]; 212 char name[64];
213 char phys[32]; 213 char phys[32];
214 int flags; 214 int flags;
@@ -275,7 +275,7 @@ static void
275adbhid_input_keycode(int id, int keycode, int repeat) 275adbhid_input_keycode(int id, int keycode, int repeat)
276{ 276{
277 struct adbhid *ahid = adbhid[id]; 277 struct adbhid *ahid = adbhid[id];
278 int up_flag; 278 int up_flag, key;
279 279
280 up_flag = (keycode & 0x80); 280 up_flag = (keycode & 0x80);
281 keycode &= 0x7f; 281 keycode &= 0x7f;
@@ -321,8 +321,7 @@ adbhid_input_keycode(int id, int keycode, int repeat)
321 } 321 }
322 } else 322 } else
323 ahid->flags |= FLAG_FN_KEY_PRESSED; 323 ahid->flags |= FLAG_FN_KEY_PRESSED;
324 /* Swallow the key press */ 324 break;
325 return;
326 case ADB_KEY_DEL: 325 case ADB_KEY_DEL:
327 /* Emulate Fn+delete = forward delete */ 326 /* Emulate Fn+delete = forward delete */
328 if (ahid->flags & FLAG_FN_KEY_PRESSED) { 327 if (ahid->flags & FLAG_FN_KEY_PRESSED) {
@@ -336,9 +335,9 @@ adbhid_input_keycode(int id, int keycode, int repeat)
336#endif /* CONFIG_PPC_PMAC */ 335#endif /* CONFIG_PPC_PMAC */
337 } 336 }
338 337
339 if (adbhid[id]->keycode[keycode]) { 338 key = adbhid[id]->keycode[keycode];
340 input_report_key(adbhid[id]->input, 339 if (key) {
341 adbhid[id]->keycode[keycode], !up_flag); 340 input_report_key(adbhid[id]->input, key, !up_flag);
342 input_sync(adbhid[id]->input); 341 input_sync(adbhid[id]->input);
343 } else 342 } else
344 printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode, 343 printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode,
@@ -757,8 +756,8 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
757 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); 756 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
758 input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML); 757 input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML);
759 input_dev->event = adbhid_kbd_event; 758 input_dev->event = adbhid_kbd_event;
760 input_dev->keycodemax = 127; 759 input_dev->keycodemax = KEY_FN;
761 input_dev->keycodesize = 1; 760 input_dev->keycodesize = sizeof(hid->keycode[0]);
762 break; 761 break;
763 762
764 case ADB_MOUSE: 763 case ADB_MOUSE: