@@ -187,6 +187,15 @@ static const struct apple_key_translation *apple_find_translation(
187187 return NULL ;
188188}
189189
190+ static void input_event_with_scancode (struct input_dev * input ,
191+ __u8 type , __u16 code , unsigned int hid , __s32 value )
192+ {
193+ if (type == EV_KEY &&
194+ (!test_bit (code , input -> key )) == value )
195+ input_event (input , EV_MSC , MSC_SCAN , hid );
196+ input_event (input , type , code , value );
197+ }
198+
190199static int hidinput_apple_event (struct hid_device * hid , struct input_dev * input ,
191200 struct hid_usage * usage , __s32 value )
192201{
@@ -199,7 +208,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
199208
200209 if (usage -> code == fn_keycode ) {
201210 asc -> fn_on = !!value ;
202- input_event (input , usage -> type , KEY_FN , value );
211+ input_event_with_scancode (input , usage -> type , KEY_FN ,
212+ usage -> hid , value );
203213 return 1 ;
204214 }
205215
@@ -240,7 +250,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
240250 code = do_translate ? trans -> to : trans -> from ;
241251 }
242252
243- input_event (input , usage -> type , code , value );
253+ input_event_with_scancode (input , usage -> type , code ,
254+ usage -> hid , value );
244255 return 1 ;
245256 }
246257
@@ -258,8 +269,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
258269 clear_bit (usage -> code ,
259270 asc -> pressed_numlock );
260271
261- input_event (input , usage -> type , trans -> to ,
262- value );
272+ input_event_with_scancode (input , usage -> type ,
273+ trans -> to , usage -> hid , value );
263274 }
264275
265276 return 1 ;
@@ -270,7 +281,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
270281 if (hid -> country == HID_COUNTRY_INTERNATIONAL_ISO ) {
271282 trans = apple_find_translation (apple_iso_keyboard , usage -> code );
272283 if (trans ) {
273- input_event (input , usage -> type , trans -> to , value );
284+ input_event_with_scancode (input , usage -> type ,
285+ trans -> to , usage -> hid , value );
274286 return 1 ;
275287 }
276288 }
@@ -279,15 +291,17 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
279291 if (swap_opt_cmd ) {
280292 trans = apple_find_translation (swapped_option_cmd_keys , usage -> code );
281293 if (trans ) {
282- input_event (input , usage -> type , trans -> to , value );
294+ input_event_with_scancode (input , usage -> type ,
295+ trans -> to , usage -> hid , value );
283296 return 1 ;
284297 }
285298 }
286299
287300 if (swap_fn_leftctrl ) {
288301 trans = apple_find_translation (swapped_fn_leftctrl_keys , usage -> code );
289302 if (trans ) {
290- input_event (input , usage -> type , trans -> to , value );
303+ input_event_with_scancode (input , usage -> type ,
304+ trans -> to , usage -> hid , value );
291305 return 1 ;
292306 }
293307 }
@@ -306,8 +320,8 @@ static int apple_event(struct hid_device *hdev, struct hid_field *field,
306320
307321 if ((asc -> quirks & APPLE_INVERT_HWHEEL ) &&
308322 usage -> code == REL_HWHEEL ) {
309- input_event (field -> hidinput -> input , usage -> type , usage -> code ,
310- - value );
323+ input_event_with_scancode (field -> hidinput -> input , usage -> type ,
324+ usage -> code , usage -> hid , - value );
311325 return 1 ;
312326 }
313327
0 commit comments