linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Strobach <lalochcz@gmail.com>
To: linux-input@vger.kernel.org
Subject: [PATCH] HID: hid-kensington: add alternative button mapping
Date: Fri, 20 Oct 2017 14:41:33 +0200	[thread overview]
Message-ID: <2082258.qPnAmo2zZ4@str> (raw)

The current mapping of the proprietary Kensington Slimblade buttons
is as follows:
 +---+---+
 | 2 | 8 |
 +---X---+
 | 1 | 3 |
 +---+---+

This modification adds an alternative button mapping for users,
who prefer to use middle mouse button emulation (buttons 1+3) in
order to get one extra button at the top right. The alternative
button mapping is:
 +---+---+
 | 9 | 8 |
 +---X---+
 | 1 | 3 |
 +---+---+

The desired behavior should ideally be achievable in userland,
but in reality only recent evdev Xorg driver since v2.10.5 is
able to handle middle mouse button remapping together with middle
button emulation.
---
 drivers/hid/hid-kensington.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-kensington.c b/drivers/hid/hid-kensington.c
index fe9a99dd8d08..1673e461338f 100644
--- a/drivers/hid/hid-kensington.c
+++ b/drivers/hid/hid-kensington.c
@@ -20,6 +20,11 @@
 
 #define ks_map_key(c)	hid_map_usage(hi, usage, bit, max, EV_KEY, (c))
 
+static bool use_alt_mapping;
+module_param(use_alt_mapping, bool, S_IRUGO);
+MODULE_PARM_DESC(use_alt_mapping,
+        "Use alternative button mapping (default = false)");
+
 static int ks_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 		struct hid_field *field, struct hid_usage *usage,
 		unsigned long **bit, int *max)
@@ -28,8 +33,18 @@ static int ks_input_mapping(struct hid_device *hdev, struct 
hid_input *hi,
 		return 0;
 
 	switch (usage->hid & HID_USAGE) {
-	case 0x01: ks_map_key(BTN_MIDDLE);	break;
-	case 0x02: ks_map_key(BTN_SIDE);	break;
+	case 0x01:
+		if (use_alt_mapping)
+			ks_map_key(BTN_SIDE);
+		else
+			ks_map_key(BTN_MIDDLE);
+		break;
+	case 0x02:
+		if (use_alt_mapping)
+			ks_map_key(BTN_EXTRA);
+		else
+			ks_map_key(BTN_SIDE);
+		break;
 	default:
 		return 0;
 	}
-- 
2.14.2




             reply	other threads:[~2017-10-20 12:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 12:41 David Strobach [this message]
2017-10-20 13:15 ` [PATCH] HID: hid-kensington: add alternative button mapping David Strobach

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=2082258.qPnAmo2zZ4@str \
    --to=lalochcz@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /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).