Skip to contentSkip to conversation

input/powermac: Cleanup of mac_hid and support for ctrl+click and command+click

PATCH Michael Hanselmann 1 participant 1 message May 20, 2006

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

This patch cleans up mac_hid and adds support for Ctrl+Click (right click) and Command+Click (middle click) emulation. The latter is similar to Mac OS X.

---

drivers/char/keyboard.c +5 -5
diff -Nrup --exclude-from linux-exclude-from linux-2.6.17-rc4.orig/drivers/char/keyboard.c linux-2.6.17-rc4/drivers/char/keyboard.c
@@ -40,6 +40,10 @@
 #include <linux/sysrq.h>
 #include <linux/input.h>
 
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+#include <asm/mac_hid.h>
+#endif
+
 static void kbd_disconnect(struct input_handle *handle);
 extern void ctrl_alt_del(void);
 
@@ -1052,10 +1056,6 @@ static unsigned short x86_keycodes[256] 
 	308,310,313,314,315,317,318,319,320,357,322,323,324,325,276,330,
 	332,340,365,342,343,344,345,346,356,270,341,368,369,370,371,372 };
 
-#ifdef CONFIG_MAC_EMUMOUSEBTN
-extern int mac_hid_mouse_emulate_buttons(int, int, int);
-#endif /* CONFIG_MAC_EMUMOUSEBTN */
-
 #ifdef CONFIG_SPARC
 static int sparc_l1_a_state = 0;
 extern void sun_do_break(void);
@@ -1151,7 +1151,7 @@ static void kbd_keycode(unsigned int key
 	rep = (down == 2);
 
 #ifdef CONFIG_MAC_EMUMOUSEBTN
-	if (mac_hid_mouse_emulate_buttons(1, keycode, down))
+	if (mac_hid_mouse_emulate_buttons(keycode, down))
 		return;
 #endif /* CONFIG_MAC_EMUMOUSEBTN */
 
drivers/input/input.c +14 -2
diff -Nrup --exclude-from linux-exclude-from linux-2.6.17-rc4.orig/drivers/input/input.c linux-2.6.17-rc4/drivers/input/input.c
@@ -24,6 +24,10 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+#include <asm/mac_hid.h>
+#endif
+
 MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
 MODULE_DESCRIPTION("Input core");
 MODULE_LICENSE("GPL");
@@ -194,8 +198,16 @@ static void input_repeat_key(unsigned lo
 	if (!test_bit(dev->repeat_key, dev->key))
 		return;
 
-	input_event(dev, EV_KEY, dev->repeat_key, 2);
-	input_sync(dev);
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+	if (!mac_hid_repeat_key(dev->repeat_key)) {
+#endif
+
+		input_event(dev, EV_KEY, dev->repeat_key, 2);
+		input_sync(dev);
+
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+	}
+#endif
 
 	if (dev->rep[REP_PERIOD])
 		mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD]));
drivers/input/mousedev.c +8 -1
diff -Nrup --exclude-from linux-exclude-from linux-2.6.17-rc4.orig/drivers/input/mousedev.c linux-2.6.17-rc4/drivers/input/mousedev.c
@@ -27,6 +27,9 @@
 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
 #include <linux/miscdevice.h>
 #endif
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+#include <asm/mac_hid.h>
+#endif
 
 MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
 MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
@@ -316,8 +319,12 @@ static void mousedev_event(struct input_
 			if (value != 2) {
 				if (code == BTN_TOUCH && test_bit(BTN_TOOL_FINGER, handle->dev->keybit))
 					mousedev_touchpad_touch(mousedev, value);
-				else
+				else {
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+					code = mac_hid_mouse_click(code, value);
+#endif
 					mousedev_key_event(mousedev, code, value);
+				}
 			}
 			break;
 
drivers/macintosh/Kconfig +4 -0
diff -Nrup --exclude-from linux-exclude-from linux-2.6.17-rc4.orig/drivers/macintosh/Kconfig linux-2.6.17-rc4/drivers/macintosh/Kconfig
@@ -144,6 +144,10 @@ config MAC_EMUMOUSEBTN
 	  /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/key_click
+
+	  When key_click is enabled by writing a value other than 0 into it,
+	  Ctrl+Click is for right click and Command+Click for middle click.
 
 	  If you have an Apple machine with a 1-button mouse, say Y here.
 
drivers/macintosh/mac_hid.c +103 -37

190 lines not on this page · raw message

include/asm-powerpc/mac_hid.h +13 -0
diff -Nrup --exclude-from linux-exclude-from linux-2.6.17-rc4.orig/include/asm-powerpc/mac_hid.h linux-2.6.17-rc4/include/asm-powerpc/mac_hid.h
@@ -0,0 +1,13 @@
+/*
+ * HID support stuff for Macintosh computers.
+ */
+#ifndef __ASM_POWERPC_MAC_HID_H
+#define __ASM_POWERPC_MAC_HID_H
+#ifdef __KERNEL__
+
+extern int mac_hid_mouse_emulate_buttons(unsigned int keycode, int down);
+extern int mac_hid_mouse_click(unsigned int code, int value);
+extern int mac_hid_repeat_key(unsigned int keycode);
+
+#endif
+#endif
include/linux/sysctl.h +2 -1
diff -Nrup --exclude-from linux-exclude-from linux-2.6.17-rc4.orig/include/linux/sysctl.h linux-2.6.17-rc4/include/linux/sysctl.h
@@ -870,7 +870,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_KEY_CLICK=7,
 };
 
 /* /proc/sys/dev/scsi */