HID: lg-g15: Add a lg_g15_handle_lcd_menu_keys() helper function
authorHans de Goede <hdegoede@redhat.com>
Fri, 16 Apr 2021 13:13:19 +0000 (15:13 +0200)
committerJiri Kosina <jkosina@suse.cz>
Wed, 5 May 2021 12:39:24 +0000 (14:39 +0200)
Factor out the handling of the G15 LCD menu keys out of
lg_g15_event() into a new lg_g15_handle_lcd_menu_keys() helper function.

This is a preparation patch for adding support for the LCD menu
keys on the Logitech Z-10 speakers (with LCD) which use the same
funky HID report format.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-lg-g15.c

index b887af72957cd88fa1545102d555f341f3bcab31..75a27b48d9c9fecc8b7a0a5c2e6c64a3700e3f2c 100644 (file)
@@ -464,6 +464,19 @@ static int lg_g15_get_initial_led_brightness(struct lg_g15_data *g15)
 /******** Input functions ********/
 
 /* On the G15 Mark I Logitech has been quite creative with which bit is what */
+static void lg_g15_handle_lcd_menu_keys(struct lg_g15_data *g15, u8 *data)
+{
+       int i, val;
+
+       /* Most left (round/display) button below the LCD */
+       input_report_key(g15->input, KEY_KBD_LCD_MENU1, data[8] & 0x80);
+       /* 4 other buttons below the LCD */
+       for (i = 0; i < 4; i++) {
+               val = data[i + 2] & 0x80;
+               input_report_key(g15->input, KEY_KBD_LCD_MENU2 + i, val);
+       }
+}
+
 static int lg_g15_event(struct lg_g15_data *g15, u8 *data)
 {
        int i, val;
@@ -494,13 +507,7 @@ static int lg_g15_event(struct lg_g15_data *g15, u8 *data)
        /* MR */
        input_report_key(g15->input, KEY_MACRO_RECORD_START, data[7] & 0x40);
 
-       /* Most left (round) button below the LCD */
-       input_report_key(g15->input, KEY_KBD_LCD_MENU1, data[8] & 0x80);
-       /* 4 other buttons below the LCD */
-       for (i = 0; i < 4; i++) {
-               val = data[i + 2] & 0x80;
-               input_report_key(g15->input, KEY_KBD_LCD_MENU2 + i, val);
-       }
+       lg_g15_handle_lcd_menu_keys(g15, data);
 
        /* Backlight cycle button pressed? */
        if (data[1] & 0x80)