HID: hid-kensington: add alternative button mapping
PATCH 1/1 HID: hid-kensington: add alternative button mapping
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(-)
drivers/hid/hid-kensington.c +5 -0
@@ -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;
}
Signature · 1 line
2.14.2
Quoted 18 lines · On 20/10/2017 14:41:33 CEST David Strobach wrote:
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:
+---+---+
Quoted 7 lines
| 9 | 8 |
+---X---+
| 1 | 3 |
+---+---+
Ouch, it's actually
+---+---+ | 8 | 9 | +---X---+ | 1 | 3 | +---+---+
Cheers
David