@@ -202,6 +202,15 @@ static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
202202 { }
203203};
204204
205+ static inline void apple_setup_key_translation (struct input_dev * input ,
206+ const struct apple_key_translation * table )
207+ {
208+ const struct apple_key_translation * trans ;
209+
210+ for (trans = table ; trans -> from ; trans ++ )
211+ set_bit (trans -> to , input -> keybit );
212+ }
213+
205214static const struct apple_key_translation * apple_find_translation (
206215 const struct apple_key_translation * table , u16 from )
207216{
@@ -452,30 +461,17 @@ static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
452461
453462static void apple_setup_input (struct input_dev * input )
454463{
455- const struct apple_key_translation * trans ;
456-
457464 set_bit (KEY_NUMLOCK , input -> keybit );
458465
459466 /* Enable all needed keys */
460- for (trans = apple_fn_keys ; trans -> from ; trans ++ )
461- set_bit (trans -> to , input -> keybit );
462-
463- for (trans = powerbook_fn_keys ; trans -> from ; trans ++ )
464- set_bit (trans -> to , input -> keybit );
465-
466- for (trans = powerbook_numlock_keys ; trans -> from ; trans ++ )
467- set_bit (trans -> to , input -> keybit );
468-
469- for (trans = apple_iso_keyboard ; trans -> from ; trans ++ )
470- set_bit (trans -> to , input -> keybit );
471-
472- for (trans = apple2021_fn_keys ; trans -> from ; trans ++ )
473- set_bit (trans -> to , input -> keybit );
474-
475- if (swap_fn_leftctrl ) {
476- for (trans = swapped_fn_leftctrl_keys ; trans -> from ; trans ++ )
477- set_bit (trans -> to , input -> keybit );
478- }
467+ apple_setup_key_translation (input , apple_fn_keys );
468+ apple_setup_key_translation (input , powerbook_fn_keys );
469+ apple_setup_key_translation (input , powerbook_numlock_keys );
470+ apple_setup_key_translation (input , apple_iso_keyboard );
471+ apple_setup_key_translation (input , apple2021_fn_keys );
472+
473+ if (swap_fn_leftctrl )
474+ apple_setup_key_translation (input , swapped_fn_leftctrl_keys );
479475}
480476
481477static int apple_input_mapping (struct hid_device * hdev , struct hid_input * hi ,
0 commit comments