linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>, Peter Hoeg <peter@hoeg.com>,
	linux-input@vger.kernel.org
Subject: [PATCH 2/6] HID: lg-g15: Add a lg_g15_handle_lcd_menu_keys() helper function
Date: Fri, 16 Apr 2021 15:13:19 +0200	[thread overview]
Message-ID: <20210416131323.233184-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20210416131323.233184-1-hdegoede@redhat.com>

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>
---
 drivers/hid/hid-lg-g15.c | 21 ++++++++++++++-------
 1 file 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)
-- 
2.31.1


  parent reply	other threads:[~2021-04-16 13:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 13:13 [PATCH 0/6] HID: lg-g15: Add support for the Logitech Z-10 speakers Hans de Goede
2021-04-16 13:13 ` [PATCH 1/6] HID: lg-g15: Remove unused size argument from lg_*_event() functions Hans de Goede
2021-04-16 13:13 ` Hans de Goede [this message]
2021-04-16 13:13 ` [PATCH 3/6] HID: lg-g15: Add a lg_g15_init_input_dev() helper function Hans de Goede
2021-04-16 13:13 ` [PATCH 4/6] HID: lg-g15: Make the LED-name used by lg_g15_register_led() a parameter Hans de Goede
2021-04-16 13:13 ` [PATCH 5/6] HID: lg-g15: Add support for the Logitech Z-10 speakers Hans de Goede
2021-04-16 13:13 ` [PATCH 6/6] HID: lg-g15 + ite: Add MODULE_AUTHOR Hans de Goede
2021-05-05 12:40 ` [PATCH 0/6] HID: lg-g15: Add support for the Logitech Z-10 speakers Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210416131323.233184-3-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=peter@hoeg.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).