2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-24 14:45:12 +08:00

Merge branch 'for-5.15/apple' into for-linus

- Support proper EV_MSC emissions to hid-apple (Vincent Lefevre)
This commit is contained in:
Jiri Kosina 2021-09-01 22:11:24 +02:00
commit 46a226b50e

View File

@ -187,6 +187,15 @@ static const struct apple_key_translation *apple_find_translation(
return NULL; return NULL;
} }
static void input_event_with_scancode(struct input_dev *input,
__u8 type, __u16 code, unsigned int hid, __s32 value)
{
if (type == EV_KEY &&
(!test_bit(code, input->key)) == value)
input_event(input, EV_MSC, MSC_SCAN, hid);
input_event(input, type, code, value);
}
static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
struct hid_usage *usage, __s32 value) struct hid_usage *usage, __s32 value)
{ {
@ -199,7 +208,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
if (usage->code == fn_keycode) { if (usage->code == fn_keycode) {
asc->fn_on = !!value; asc->fn_on = !!value;
input_event(input, usage->type, KEY_FN, value); input_event_with_scancode(input, usage->type, KEY_FN,
usage->hid, value);
return 1; return 1;
} }
@ -240,7 +250,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
code = do_translate ? trans->to : trans->from; code = do_translate ? trans->to : trans->from;
} }
input_event(input, usage->type, code, value); input_event_with_scancode(input, usage->type, code,
usage->hid, value);
return 1; return 1;
} }
@ -258,8 +269,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
clear_bit(usage->code, clear_bit(usage->code,
asc->pressed_numlock); asc->pressed_numlock);
input_event(input, usage->type, trans->to, input_event_with_scancode(input, usage->type,
value); trans->to, usage->hid, value);
} }
return 1; return 1;
@ -270,7 +281,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) { if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) {
trans = apple_find_translation(apple_iso_keyboard, usage->code); trans = apple_find_translation(apple_iso_keyboard, usage->code);
if (trans) { if (trans) {
input_event(input, usage->type, trans->to, value); input_event_with_scancode(input, usage->type,
trans->to, usage->hid, value);
return 1; return 1;
} }
} }
@ -279,7 +291,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
if (swap_opt_cmd) { if (swap_opt_cmd) {
trans = apple_find_translation(swapped_option_cmd_keys, usage->code); trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
if (trans) { if (trans) {
input_event(input, usage->type, trans->to, value); input_event_with_scancode(input, usage->type,
trans->to, usage->hid, value);
return 1; return 1;
} }
} }
@ -287,7 +300,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
if (swap_fn_leftctrl) { if (swap_fn_leftctrl) {
trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code); trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code);
if (trans) { if (trans) {
input_event(input, usage->type, trans->to, value); input_event_with_scancode(input, usage->type,
trans->to, usage->hid, value);
return 1; return 1;
} }
} }
@ -306,8 +320,8 @@ static int apple_event(struct hid_device *hdev, struct hid_field *field,
if ((asc->quirks & APPLE_INVERT_HWHEEL) && if ((asc->quirks & APPLE_INVERT_HWHEEL) &&
usage->code == REL_HWHEEL) { usage->code == REL_HWHEEL) {
input_event(field->hidinput->input, usage->type, usage->code, input_event_with_scancode(field->hidinput->input, usage->type,
-value); usage->code, usage->hid, -value);
return 1; return 1;
} }