Skip to content

Commit ba3e054

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
HID: lg-g15: Add a lg_g15_handle_lcd_menu_keys() helper function
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 042d05b commit ba3e054

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/hid/hid-lg-g15.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,19 @@ static int lg_g15_get_initial_led_brightness(struct lg_g15_data *g15)
464464
/******** Input functions ********/
465465

466466
/* On the G15 Mark I Logitech has been quite creative with which bit is what */
467+
static void lg_g15_handle_lcd_menu_keys(struct lg_g15_data *g15, u8 *data)
468+
{
469+
int i, val;
470+
471+
/* Most left (round/display) button below the LCD */
472+
input_report_key(g15->input, KEY_KBD_LCD_MENU1, data[8] & 0x80);
473+
/* 4 other buttons below the LCD */
474+
for (i = 0; i < 4; i++) {
475+
val = data[i + 2] & 0x80;
476+
input_report_key(g15->input, KEY_KBD_LCD_MENU2 + i, val);
477+
}
478+
}
479+
467480
static int lg_g15_event(struct lg_g15_data *g15, u8 *data)
468481
{
469482
int i, val;
@@ -494,13 +507,7 @@ static int lg_g15_event(struct lg_g15_data *g15, u8 *data)
494507
/* MR */
495508
input_report_key(g15->input, KEY_MACRO_RECORD_START, data[7] & 0x40);
496509

497-
/* Most left (round) button below the LCD */
498-
input_report_key(g15->input, KEY_KBD_LCD_MENU1, data[8] & 0x80);
499-
/* 4 other buttons below the LCD */
500-
for (i = 0; i < 4; i++) {
501-
val = data[i + 2] & 0x80;
502-
input_report_key(g15->input, KEY_KBD_LCD_MENU2 + i, val);
503-
}
510+
lg_g15_handle_lcd_menu_keys(g15, data);
504511

505512
/* Backlight cycle button pressed? */
506513
if (data[1] & 0x80)

0 commit comments

Comments
 (0)