Skip to contentSkip to conversation

Mac-buttons emulation broken in 2.4.0-test10

DISCUSSION Karim Yaghmour 1 participant 2 messages Nov 13, 2000 Input drivers

lore
Share & tools
lore
#0 lore raw

The mac_hid_mouse_emulate_buttons() in drivers/macintosh/mac_hid.c which takes care of emulating multiple buttons on a mac doesn't seem to be used anywhere. In fact, by doing a "grep -r mac_hid... *" in the kernel's base directory yields only one result and it's the one in mac_hid.c. Shouldn't this be called upon from the keyboard and mouse handlers?

===================================================
Karim Yaghmour
[email protected]
Operating System Consultant
(Linux kernel, real-time and distributed systems)
===================================================
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw

Well, it seems I found a solution to my own problem :)

Here are patches that fix the problem.

Doing this, I discovered there are 2 modes to button emulation (3 if you include no emulation):
Mode 0:
No emulation whatsoever.
Mode 1:
echo "1" > /proc/sys/dev/mac_.../mouse_...
In this mode, when you press on fct-ctrl or fct-alt, then it's like if you pressed on the corresponding mouse button.
Mode 2:
echo "2" > /proc/sys/dev/mac_.../mouse_...
In this mode, you have to hold down fct-ctrl or fct-alt __and__ click the mouse to get the corresponding mouse button.

Cheers

Karim

---------------------------------------------------------------------------------------------------

drivers/input/keybdev.c +11 -1
@@ -90,7 +90,7 @@
 	return 0;
 }
 
-#elif defined(CONFIG_ADB_KEYBOARD)
+#elif defined(CONFIG_ADB_KEYBOARD) || defined(CONFIG_MAC_HID)
 
 static unsigned char mac_keycodes[128] =
 	{ 0, 53, 18, 19, 20, 21, 23, 22, 26, 28, 25, 29, 27, 24, 51, 48,
@@ -129,9 +129,19 @@
 	}
 }
 
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+extern int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down);
+#endif
+
 void keybdev_event(struct input_handle *handle, unsigned int type, unsigned int code, int down)
 {
 	if (type != EV_KEY) return;
+
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+	/* There should be an if() here to determine whether emulate_raw() is to be called or not.
+	 If the key is caught, emulate_raw() should not be called. K.Y. */
+	mac_hid_mouse_emulate_buttons(1, code, down);
+#endif
 
 	if (emulate_raw(code, down))
 		printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", code);
drivers/input/mousedev.c +7 -0
@@ -79,6 +79,10 @@
 static struct mousedev *mousedev_table[MOUSEDEV_MINORS];
 static struct mousedev mousedev_mix;
 
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+extern int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down);
+#endif
+
 static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
 {
 	struct mousedev *mousedevs[3] = { handle->private, &mousedev_mix, NULL };
@@ -132,6 +136,9 @@
 						case BTN_MIDDLE: index = 2; break;	
 						default: return;
 					}
+#ifdef CONFIG_MAC_EMUMOUSEBTN
+				        index = mac_hid_mouse_emulate_buttons(2, index, 0);
+#endif
 					switch (value) {
 						case 0: clear_bit(index, &list->buttons); break;
 						case 1: set_bit(index, &list->buttons); break;

---------------------------------------------------------------------------------------------------

Quoted 8 lines · Karim Yaghmour

The mac_hid_mouse_emulate_buttons() in drivers/macintosh/mac_hid.c which takes care of emulating multiple buttons on a mac doesn't seem to be used anywhere. In fact, by doing a "grep -r mac_hid... *" in the kernel's base directory yields only one result and it's the one in mac_hid.c. Shouldn't this be called upon from the keyboard and mouse handlers?

===================================================
Karim Yaghmour
[email protected]
Operating System Consultant
(Linux kernel, real-time and distributed systems)
===================================================
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/