Commit 555ddbb4 authored by Aristeu Rozanski's avatar Aristeu Rozanski Committed by Paul Mackerras

[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: default avatarAristeu Rozanski <aris@ruivo.org>
Acked-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent fc624eae
...@@ -70,7 +70,7 @@ static struct notifier_block adbhid_adb_notifier = { ...@@ -70,7 +70,7 @@ static struct notifier_block adbhid_adb_notifier = {
#define ADB_KEY_POWER_OLD 0x7e #define ADB_KEY_POWER_OLD 0x7e
#define ADB_KEY_POWER 0x7f #define ADB_KEY_POWER 0x7f
u8 adb_to_linux_keycodes[128] = { u16 adb_to_linux_keycodes[128] = {
/* 0x00 */ KEY_A, /* 30 */ /* 0x00 */ KEY_A, /* 30 */
/* 0x01 */ KEY_S, /* 31 */ /* 0x01 */ KEY_S, /* 31 */
/* 0x02 */ KEY_D, /* 32 */ /* 0x02 */ KEY_D, /* 32 */
...@@ -134,7 +134,7 @@ u8 adb_to_linux_keycodes[128] = { ...@@ -134,7 +134,7 @@ u8 adb_to_linux_keycodes[128] = {
/* 0x3c */ KEY_RIGHT, /* 106 */ /* 0x3c */ KEY_RIGHT, /* 106 */
/* 0x3d */ KEY_DOWN, /* 108 */ /* 0x3d */ KEY_DOWN, /* 108 */
/* 0x3e */ KEY_UP, /* 103 */ /* 0x3e */ KEY_UP, /* 103 */
/* 0x3f */ 0, /* 0x3f */ KEY_FN, /* 0x1d0 */
/* 0x40 */ 0, /* 0x40 */ 0,
/* 0x41 */ KEY_KPDOT, /* 83 */ /* 0x41 */ KEY_KPDOT, /* 83 */
/* 0x42 */ 0, /* 0x42 */ 0,
...@@ -208,7 +208,7 @@ struct adbhid { ...@@ -208,7 +208,7 @@ struct adbhid {
int original_handler_id; int original_handler_id;
int current_handler_id; int current_handler_id;
int mouse_kind; int mouse_kind;
unsigned char *keycode; u16 *keycode;
char name[64]; char name[64];
char phys[32]; char phys[32];
int flags; int flags;
...@@ -275,7 +275,7 @@ static void ...@@ -275,7 +275,7 @@ static void
adbhid_input_keycode(int id, int keycode, int repeat) adbhid_input_keycode(int id, int keycode, int repeat)
{ {
struct adbhid *ahid = adbhid[id]; struct adbhid *ahid = adbhid[id];
int up_flag; int up_flag, key;
up_flag = (keycode & 0x80); up_flag = (keycode & 0x80);
keycode &= 0x7f; keycode &= 0x7f;
...@@ -321,8 +321,7 @@ adbhid_input_keycode(int id, int keycode, int repeat) ...@@ -321,8 +321,7 @@ adbhid_input_keycode(int id, int keycode, int repeat)
} }
} else } else
ahid->flags |= FLAG_FN_KEY_PRESSED; ahid->flags |= FLAG_FN_KEY_PRESSED;
/* Swallow the key press */ break;
return;
case ADB_KEY_DEL: case ADB_KEY_DEL:
/* Emulate Fn+delete = forward delete */ /* Emulate Fn+delete = forward delete */
if (ahid->flags & FLAG_FN_KEY_PRESSED) { if (ahid->flags & FLAG_FN_KEY_PRESSED) {
...@@ -336,9 +335,9 @@ adbhid_input_keycode(int id, int keycode, int repeat) ...@@ -336,9 +335,9 @@ adbhid_input_keycode(int id, int keycode, int repeat)
#endif /* CONFIG_PPC_PMAC */ #endif /* CONFIG_PPC_PMAC */
} }
if (adbhid[id]->keycode[keycode]) { key = adbhid[id]->keycode[keycode];
input_report_key(adbhid[id]->input, if (key) {
adbhid[id]->keycode[keycode], !up_flag); input_report_key(adbhid[id]->input, key, !up_flag);
input_sync(adbhid[id]->input); input_sync(adbhid[id]->input);
} else } else
printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode, 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,8 +756,8 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML); input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML);
input_dev->event = adbhid_kbd_event; input_dev->event = adbhid_kbd_event;
input_dev->keycodemax = 127; input_dev->keycodemax = KEY_FN;
input_dev->keycodesize = 1; input_dev->keycodesize = sizeof(hid->keycode[0]);
break; break;
case ADB_MOUSE: case ADB_MOUSE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment