* [PATCH] macintosh/hid: keycode-mapping for left click
@ 2009-09-14 20:33 ` John Ogness
0 siblings, 0 replies; 3+ messages in thread
From: John Ogness @ 2009-09-14 20:33 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: Franz.Sirl-kernel, linux-kernel, linux-input
Hi,
This patch adds support for mapping the left mouse button to a
keycode. The driver already mapped the middle and right buttons.
Since the single mouse-button on my Apple laptop broke, I figured the
driver might as well support all three buttons. Now I can keep using my
laptop without problems.
The patch is against 2.6.31.
John Ogness
(I do not belong to either linux-input or linux-kernel mailing lists, so
please reply directly. Thanks.)
Signed off by: <john.ogness@linutronix.de>
---
drivers/macintosh/mac_hid.c | 24 ++++++++++++++++++++----
include/linux/sysctl.h | 3 ++-
kernel/sysctl_check.c | 1 +
3 files changed, 23 insertions(+), 5 deletions(-)
Index: linux-2.6.31/drivers/macintosh/mac_hid.c
===================================================================
--- linux-2.6.31.orig/drivers/macintosh/mac_hid.c
+++ linux-2.6.31/drivers/macintosh/mac_hid.c
@@ -19,6 +19,7 @@
static struct input_dev *emumousebtn;
static int emumousebtn_input_register(void);
static int mouse_emulate_buttons;
+static int mouse_button1_keycode; /* no default */
static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */
static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */
static int mouse_last_keycode;
@@ -35,6 +36,14 @@ static ctl_table mac_hid_files[] = {
.proc_handler = &proc_dointvec,
},
{
+ .ctl_name = DEV_MAC_HID_MOUSE_BUTTON1_KEYCODE,
+ .procname = "mouse_button1_keycode",
+ .data = &mouse_button1_keycode,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec,
+ },
+ {
.ctl_name = DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE,
.procname = "mouse_button2_keycode",
.data = &mouse_button2_keycode,
@@ -87,12 +96,19 @@ int mac_hid_mouse_emulate_buttons(int ca
case 1:
/* Called from keyboard.c */
if (mouse_emulate_buttons
- && (keycode == mouse_button2_keycode
+ && ((keycode == mouse_button1_keycode
+ && mouse_button1_keycode)
+ || keycode == mouse_button2_keycode
|| keycode == mouse_button3_keycode)) {
if (mouse_emulate_buttons == 1) {
- input_report_key(emumousebtn,
- keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT,
- down);
+ unsigned int code;
+ if (keycode == mouse_button1_keycode)
+ code = BTN_LEFT;
+ else if (keycode == mouse_button2_keycode)
+ code = BTN_MIDDLE;
+ else
+ code = BTN_RIGHT;
+ input_report_key(emumousebtn, code, down);
input_sync(emumousebtn);
return 1;
}
Index: linux-2.6.31/include/linux/sysctl.h
===================================================================
--- linux-2.6.31.orig/include/linux/sysctl.h
+++ linux-2.6.31/include/linux/sysctl.h
@@ -916,7 +916,8 @@ enum {
DEV_MAC_HID_MOUSE_BUTTON_EMULATION=3,
DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE=4,
DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE=5,
- DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6
+ DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6,
+ DEV_MAC_HID_MOUSE_BUTTON1_KEYCODE=7,
};
/* /proc/sys/dev/scsi */
Index: linux-2.6.31/kernel/sysctl_check.c
===================================================================
--- linux-2.6.31.orig/kernel/sysctl_check.c
+++ linux-2.6.31/kernel/sysctl_check.c
@@ -816,6 +816,7 @@ static const struct trans_ctl_table tran
/* DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES unused */
/* DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES unused */
{ DEV_MAC_HID_MOUSE_BUTTON_EMULATION, "mouse_button_emulation" },
+ { DEV_MAC_HID_MOUSE_BUTTON1_KEYCODE, "mouse_button1_keycode" },
{ DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, "mouse_button2_keycode" },
{ DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, "mouse_button3_keycode" },
/* DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES unused */
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] macintosh/hid: keycode-mapping for left click
@ 2009-09-14 20:33 ` John Ogness
0 siblings, 0 replies; 3+ messages in thread
From: John Ogness @ 2009-09-14 20:33 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: Franz.Sirl-kernel, linux-kernel, linux-input
Hi,
This patch adds support for mapping the left mouse button to a
keycode. The driver already mapped the middle and right buttons.
Since the single mouse-button on my Apple laptop broke, I figured the
driver might as well support all three buttons. Now I can keep using my
laptop without problems.
The patch is against 2.6.31.
John Ogness
(I do not belong to either linux-input or linux-kernel mailing lists, so
please reply directly. Thanks.)
Signed off by: <john.ogness@linutronix.de>
---
drivers/macintosh/mac_hid.c | 24 ++++++++++++++++++++----
include/linux/sysctl.h | 3 ++-
kernel/sysctl_check.c | 1 +
3 files changed, 23 insertions(+), 5 deletions(-)
Index: linux-2.6.31/drivers/macintosh/mac_hid.c
===================================================================
--- linux-2.6.31.orig/drivers/macintosh/mac_hid.c
+++ linux-2.6.31/drivers/macintosh/mac_hid.c
@@ -19,6 +19,7 @@
static struct input_dev *emumousebtn;
static int emumousebtn_input_register(void);
static int mouse_emulate_buttons;
+static int mouse_button1_keycode; /* no default */
static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */
static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */
static int mouse_last_keycode;
@@ -35,6 +36,14 @@ static ctl_table mac_hid_files[] = {
.proc_handler = &proc_dointvec,
},
{
+ .ctl_name = DEV_MAC_HID_MOUSE_BUTTON1_KEYCODE,
+ .procname = "mouse_button1_keycode",
+ .data = &mouse_button1_keycode,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec,
+ },
+ {
.ctl_name = DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE,
.procname = "mouse_button2_keycode",
.data = &mouse_button2_keycode,
@@ -87,12 +96,19 @@ int mac_hid_mouse_emulate_buttons(int ca
case 1:
/* Called from keyboard.c */
if (mouse_emulate_buttons
- && (keycode == mouse_button2_keycode
+ && ((keycode == mouse_button1_keycode
+ && mouse_button1_keycode)
+ || keycode == mouse_button2_keycode
|| keycode == mouse_button3_keycode)) {
if (mouse_emulate_buttons == 1) {
- input_report_key(emumousebtn,
- keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT,
- down);
+ unsigned int code;
+ if (keycode == mouse_button1_keycode)
+ code = BTN_LEFT;
+ else if (keycode == mouse_button2_keycode)
+ code = BTN_MIDDLE;
+ else
+ code = BTN_RIGHT;
+ input_report_key(emumousebtn, code, down);
input_sync(emumousebtn);
return 1;
}
Index: linux-2.6.31/include/linux/sysctl.h
===================================================================
--- linux-2.6.31.orig/include/linux/sysctl.h
+++ linux-2.6.31/include/linux/sysctl.h
@@ -916,7 +916,8 @@ enum {
DEV_MAC_HID_MOUSE_BUTTON_EMULATION=3,
DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE=4,
DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE=5,
- DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6
+ DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6,
+ DEV_MAC_HID_MOUSE_BUTTON1_KEYCODE=7,
};
/* /proc/sys/dev/scsi */
Index: linux-2.6.31/kernel/sysctl_check.c
===================================================================
--- linux-2.6.31.orig/kernel/sysctl_check.c
+++ linux-2.6.31/kernel/sysctl_check.c
@@ -816,6 +816,7 @@ static const struct trans_ctl_table tran
/* DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES unused */
/* DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES unused */
{ DEV_MAC_HID_MOUSE_BUTTON_EMULATION, "mouse_button_emulation" },
+ { DEV_MAC_HID_MOUSE_BUTTON1_KEYCODE, "mouse_button1_keycode" },
{ DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, "mouse_button2_keycode" },
{ DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, "mouse_button3_keycode" },
/* DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES unused */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] macintosh/hid: keycode-mapping for left click
2009-09-14 20:33 ` John Ogness
(?)
@ 2009-09-15 6:19 ` Dmitry Torokhov
-1 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2009-09-15 6:19 UTC (permalink / raw)
To: John Ogness; +Cc: Franz.Sirl-kernel, linux-kernel, linux-input
Hi John,
On Mon, Sep 14, 2009 at 10:33:20PM +0200, John Ogness wrote:
> Hi,
>
> This patch adds support for mapping the left mouse button to a
> keycode. The driver already mapped the middle and right buttons.
>
> Since the single mouse-button on my Apple laptop broke, I figured the
> driver might as well support all three buttons. Now I can keep using my
> laptop without problems.
>
Thank you for the patch however I will not apply it. While kernel has a
lot of quirks to work around broken hardware those apply to the design
brokenness, not old-age brokenness.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-15 6:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-14 20:33 [PATCH] macintosh/hid: keycode-mapping for left click John Ogness
2009-09-14 20:33 ` John Ogness
2009-09-15 6:19 ` Dmitry Torokhov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.