linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: PrakarshPanwar via B4 Relay <devnull+prakarshpanwar.gmail.com@kernel.org>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	 PrakarshPanwar <prakarshpanwar@gmail.com>
Subject: [PATCH] HID: EVision: input mapping fix for K552 keyboard
Date: Fri, 05 Dec 2025 19:27:29 +0530	[thread overview]
Message-ID: <20251205-evision-k552-mapping-fix-v1-1-848d086c43ee@gmail.com> (raw)

From: PrakarshPanwar <prakarshpanwar@gmail.com>

Added fix for Media Key in Redragon K552 keyboard
In Windows, this keyboard F1 Key opens Media Player,
but in Linux it opens System Settings.

This commit is a fix for that bug it remaps K552 F1 key
which outputs KEY_CONFIG(171) now outputs KEY_MEDIA(226)

It also restructures the input mapping code in hid-evision

Signed-off-by: PrakarshPanwar <prakarshpanwar@gmail.com>
---
 drivers/hid/hid-evision.c | 39 ++++++++++++++++++++++++++++++++++++---
 drivers/hid/hid-ids.h     |  1 +
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-evision.c b/drivers/hid/hid-evision.c
index 3e7f43ab80bb63ba073bc71f72acdb5ffaed8202..f78861863d4fc8a1305948385aa561ab374ceb49 100644
--- a/drivers/hid/hid-evision.c
+++ b/drivers/hid/hid-evision.c
@@ -14,14 +14,29 @@
 
 #include "hid-ids.h"
 
-static int evision_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+static int evision_k552_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 		struct hid_field *field, struct hid_usage *usage,
 		unsigned long **bit, int *max)
 {
-	/* mapping only applies to USB_DEVICE_ID_EVISION_ICL01 */
-	if (hdev->product != USB_DEVICE_ID_EVISION_ICL01)
+	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
+		return 0;
+
+	switch (usage->hid & HID_USAGE) {
+	/* report 3 */
+	case 0x183:
+		hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_MEDIA);
+		break;
+	default:
 		return 0;
+	}
+
+	return 1;
+}
 
+static int evision_icl01_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+		struct hid_field *field, struct hid_usage *usage,
+		unsigned long **bit, int *max)
+{
 	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
 		return 0;
 
@@ -41,6 +56,23 @@ static int evision_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 	return 0;
 }
 
+static int evision_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+		struct hid_field *field, struct hid_usage *usage,
+		unsigned long **bit, int *max)
+{
+	int ret = 0;
+
+	if (hdev->product == USB_DEVICE_ID_EVISION_ICL01) {
+		ret = evision_icl01_input_mapping(hdev, hi,
+			field, usage, bit, max);
+	} else if (hdev->product == USB_DEVICE_ID_EVISION_K552) {
+		ret = evision_k552_input_mapping(hdev, hi,
+			field, usage, bit, max);
+	}
+
+	return ret;
+}
+
 #define REP_DSC_SIZE 236
 #define USAGE_MAX_INDEX 59
 
@@ -59,6 +91,7 @@ static const __u8 *evision_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 static const struct hid_device_id evision_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_EVISION, USB_DEVICE_ID_EVISION_ICL01) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_EVISION, USB_DEVICE_ID_EV_TELINK_RECEIVER) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_EVISION, USB_DEVICE_ID_EVISION_K552) },
 	{ }
 };
 MODULE_DEVICE_TABLE(hid, evision_devices);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index d31711f1aaeccb4ec93c5a9056af605d1775e0c5..f30b383036c74ad48b2d6880a44b2f2ac5dab46e 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -478,6 +478,7 @@
 
 #define USB_VENDOR_ID_EVISION           0x320f
 #define USB_DEVICE_ID_EV_TELINK_RECEIVER 0x226f
+#define USB_DEVICE_ID_EVISION_K552      0X5000
 #define USB_DEVICE_ID_EVISION_ICL01     0x5041
 
 #define USB_VENDOR_ID_FFBEAST		0x045b

---
base-commit: 2061f18ad76ecaddf8ed17df81b8611ea88dbddd
change-id: 20251205-evision-k552-mapping-fix-3eb3cc692393

Best regards,
-- 
PrakarshPanwar <prakarshpanwar@gmail.com>



                 reply	other threads:[~2025-12-05 13:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251205-evision-k552-mapping-fix-v1-1-848d086c43ee@gmail.com \
    --to=devnull+prakarshpanwar.gmail.com@kernel.org \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prakarshpanwar@gmail.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).