Skip to contentSkip to conversation

Right-click modifier

PATCH In review Colin Leroy 3 participants 4 messages Oct 14, 2003

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Right-click modifier

[Forwarding, just in case.]

Quoted 9 lines

Hi,

this patch adds an entry in /proc,
/proc/sys/dev/mac_hid/rclick_key_modifier.

It lets the kernel report a right-click when KEY+Left click are pressed, where KEY is the KEY specified by echoing its code to the /proc entry.

ie, "echo 29 > /proc/sys/dev/mac_hid/rclick_key_modifier" and you'll

have

Quoted 8 lines

Ctrl-click = right click.

It's a patch against linuxppc-2.5-benh tree rsync'ed tonight from source.mvista.com.

hope it's useful,
--
Colin

drivers/input/input.c renamed from drivers/input/input.c.orig +8 -1
@@ -63,6 +63,10 @@
 }
 
 
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+extern int mac_hid_mouse_emulate_buttons(int,int,int);
+#endif
+
 void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
 {
 	struct input_handle *handle;
@@ -91,7 +95,10 @@
 			break;
 
 		case EV_KEY:
-
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+			if (mac_hid_mouse_emulate_buttons(2, code, value))
+				code = BTN_RIGHT;
+#endif
 			if (code > KEY_MAX || !test_bit(code, dev->keybit) || !!test_bit(code, dev->key) == value)
 				return;
 
drivers/macintosh/mac_hid.c renamed from drivers/macintosh/mac_hid.c.orig +19 -0
@@ -21,7 +21,9 @@
 static int mouse_emulate_buttons = 0;
 static int mouse_button2_keycode = KEY_RIGHTCTRL;	/* right control key */
 static int mouse_button3_keycode = KEY_RIGHTALT;	/* right option key */
+static int rclick_key_modifier   = 0;			/* disabled */
 static int mouse_last_keycode = 0;
+static int rclick_key_modifier_down = 0;
 
 #if defined(CONFIG_SYSCTL)
 /* file(s) in /proc/sys/dev/mac_hid */
@@ -50,6 +52,14 @@
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec,
 	},
+	{
+		.ctl_name       = DEV_MAC_HID_RCLICK_KEY_MODIFIER,
+		.procname       = "rclick_key_modifier",
+		.data           = &rclick_key_modifier,
+		.maxlen         = sizeof(int),
+                .mode           = 0644,
+		.proc_handler   = &proc_dointvec,
+	},
 	{ .ctl_name = 0 }
 };
 
@@ -98,6 +108,15 @@
 			}
 			mouse_last_keycode = down ? keycode : 0;
 		}
+		if (rclick_key_modifier 
+		    && keycode == rclick_key_modifier)
+			rclick_key_modifier_down = down;
+
+		break;
+	case 2:
+		/* Called from input.c */
+		if (keycode == BTN_LEFT && rclick_key_modifier && rclick_key_modifier_down)
+			return 1;
 		break;
 	}
 	return 0;
include/linux/sysctl.h renamed from include/linux/sysctl.h.orig +2 -1
@@ -681,7 +681,8 @@
 	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_RCLICK_KEY_MODIFIER=7
 };
 
 /* /proc/sys/dev/scsi */
arch/ppc/Kconfig renamed from arch/ppc/Kconfig.orig +5 -0
@@ -1243,6 +1243,11 @@
 	  /proc/sys/dev/mac_hid/mouse_button_emulation
 	  /proc/sys/dev/mac_hid/mouse_button2_keycode
 	  /proc/sys/dev/mac_hid/mouse_button3_keycode
+	  /proc/sys/dev/mac_hid/rclick_key_modifier
+
+	  rclick_key_modifier allows the kernel to handle "Key+LClick" as a 
+	  right-click. It's disabled by default. Echo a keycode to it to 
+	  enable it.
 
 	  If you have an Apple machine with a 1-button mouse, say Y here.
 
arch/m68k/Kconfig renamed from arch/m68k/Kconfig.orig +5 -0
@@ -932,6 +932,11 @@
 	  /proc/sys/dev/mac_hid/mouse_button_emulation
 	  /proc/sys/dev/mac_hid/mouse_button2_keycode
 	  /proc/sys/dev/mac_hid/mouse_button3_keycode
+ 	  /proc/sys/dev/mac_hid/rclick_key_modifier
+ 
+	  rclick_key_modifier allows the kernel to handle "Key+LClick" as a 
+	  right-click. It's disabled by default. Echo a keycode to it to 
+	  enable it.
 
 config ADB_KEYBOARD
 	bool "Support for ADB keyboard (old driver)"
#1 lore raw
Quoted 9 lines · Colin Leroy

[Forwarding, just in case.]

Quoted 7 lines

Hi,

this patch adds an entry in /proc,
/proc/sys/dev/mac_hid/rclick_key_modifier.

It lets the kernel report a right-click when KEY+Left click are pressed, where KEY is the KEY specified by echoing its code to the /proc entry.

Its certainly a nice thing, but all this mouse button emulation stuff should be handled in userland. Its just the question how and where.

--
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw

On 14 Oct 2003 at 11h36, Olaf Hering wrote:

Hi,

Quoted 2 lines

Its certainly a nice thing, but all this mouse button emulation stuff should be handled in userland. Its just the question how and where.

Any pointer about how it could be done?
--
Colin
http://ayttm.sf.net/

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#3 lore raw
Quoted 8 lines · Colin Leroy

On 14 Oct 2003 at 11h36, Olaf Hering wrote:

Hi,

Quoted 2 lines

Its certainly a nice thing, but all this mouse button emulation stuff should be handled in userland. Its just the question how and where.

Any pointer about how it could be done?

Well, all this button emulation stuff currently is a hack that should go away, so Olaf is right here. Colin's patch itself is unacceptable to the kernel people, so it would be a benh-tree only solution at best.

But since there is now the possibility to "grab" (input_grab_device()) away input devices from the input handler chain, one could write a input device kernel module that grabs keyboard and 1/2-button mice devices, massages the events and gives them back to the input layer via input_event(). I guess this is the only in-kernel solution acceptable to the kernel people.

Franz.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/