summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-lg-g15.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2021-04-16 16:13:19 +0300
committerJiri Kosina <jkosina@suse.cz>2021-05-05 15:39:24 +0300
commitba3e054e7a70d447aa95883dab87a4eae641d6bc (patch)
tree93667511fad7e0965e1ebebbcbfa590a716d800c /drivers/hid/hid-lg-g15.c
parent042d05b2e30e8a2bb378ecb668a85790dce39355 (diff)
downloadlinux-ba3e054e7a70d447aa95883dab87a4eae641d6bc.tar.xz
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 <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-lg-g15.c')
-rw-r--r--drivers/hid/hid-lg-g15.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c
index b887af72957c..75a27b48d9c9 100644
--- a/drivers/hid/hid-lg-g15.c
+++ b/drivers/hid/hid-lg-g15.c
@@ -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)