|
@@ -57,7 +57,6 @@ MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\")
|
|
|
struct apple_sc {
|
|
struct apple_sc {
|
|
|
unsigned long quirks;
|
|
unsigned long quirks;
|
|
|
unsigned int fn_on;
|
|
unsigned int fn_on;
|
|
|
- DECLARE_BITMAP(pressed_fn, KEY_CNT);
|
|
|
|
|
DECLARE_BITMAP(pressed_numlock, KEY_CNT);
|
|
DECLARE_BITMAP(pressed_numlock, KEY_CNT);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -184,6 +183,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
|
|
|
{
|
|
{
|
|
|
struct apple_sc *asc = hid_get_drvdata(hid);
|
|
struct apple_sc *asc = hid_get_drvdata(hid);
|
|
|
const struct apple_key_translation *trans, *table;
|
|
const struct apple_key_translation *trans, *table;
|
|
|
|
|
+ bool do_translate;
|
|
|
|
|
+ u16 code = 0;
|
|
|
|
|
|
|
|
if (usage->code == KEY_FN) {
|
|
if (usage->code == KEY_FN) {
|
|
|
asc->fn_on = !!value;
|
|
asc->fn_on = !!value;
|
|
@@ -192,8 +193,6 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (fnmode) {
|
|
if (fnmode) {
|
|
|
- int do_translate;
|
|
|
|
|
-
|
|
|
|
|
if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
|
|
if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
|
|
|
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
|
|
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
|
|
|
table = macbookair_fn_keys;
|
|
table = macbookair_fn_keys;
|
|
@@ -205,25 +204,33 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
|
|
|
trans = apple_find_translation (table, usage->code);
|
|
trans = apple_find_translation (table, usage->code);
|
|
|
|
|
|
|
|
if (trans) {
|
|
if (trans) {
|
|
|
- if (test_bit(usage->code, asc->pressed_fn))
|
|
|
|
|
- do_translate = 1;
|
|
|
|
|
- else if (trans->flags & APPLE_FLAG_FKEY)
|
|
|
|
|
- do_translate = (fnmode == 2 && asc->fn_on) ||
|
|
|
|
|
- (fnmode == 1 && !asc->fn_on);
|
|
|
|
|
- else
|
|
|
|
|
- do_translate = asc->fn_on;
|
|
|
|
|
-
|
|
|
|
|
- if (do_translate) {
|
|
|
|
|
- if (value)
|
|
|
|
|
- set_bit(usage->code, asc->pressed_fn);
|
|
|
|
|
- else
|
|
|
|
|
- clear_bit(usage->code, asc->pressed_fn);
|
|
|
|
|
-
|
|
|
|
|
- input_event(input, usage->type, trans->to,
|
|
|
|
|
- value);
|
|
|
|
|
-
|
|
|
|
|
- return 1;
|
|
|
|
|
|
|
+ if (test_bit(trans->from, input->key))
|
|
|
|
|
+ code = trans->from;
|
|
|
|
|
+ else if (test_bit(trans->to, input->key))
|
|
|
|
|
+ code = trans->to;
|
|
|
|
|
+
|
|
|
|
|
+ if (!code) {
|
|
|
|
|
+ if (trans->flags & APPLE_FLAG_FKEY) {
|
|
|
|
|
+ switch (fnmode) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ do_translate = !asc->fn_on;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ do_translate = asc->fn_on;
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ /* should never happen */
|
|
|
|
|
+ do_translate = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ do_translate = asc->fn_on;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ code = do_translate ? trans->to : trans->from;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ input_event(input, usage->type, code, value);
|
|
|
|
|
+ return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
|
|
if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
|