mouse button #1 emulation for mac_hid
Subsystems (2)
PATCH 1/1 mouse button #1 emulation for mac_hid
Dear all,
I am not sure what the future of mac_hid is (the source says will be removed, but since 9 years). In case it stays in kernel the attached patch adds support for mouse button 1 emulation. If this driver stays in the kernel I would also suggest to rename it - it is not mac specific (I am using this on a netbook).
Rationale? Broken touchpads, within linux unsupported (multi-)touch pads where click and hold + moving the mouse does not work.
Soeren
Signature · 2 lines
For the one fact about the future of which we can be certain is that it will be utterly fantastic. -- Arthur C. Clarke, 1962
drivers/macintosh/mac_hid.c +22 -5
@@ -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 =KEY_RIGHTSHIFT ;/* right shift key */ 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,
@@ -83,16 +92,24 @@ static struct ctl_table_header *mac_hid_sysctl_header;int mac_hid_mouse_emulate_buttons (int caller,unsigned int keycode,int down) { +unsigned int reportcode; +switch (caller) {case 1 :/* Called from keyboard.c */ if (mouse_emulate_buttons - && (keycode == mouse_button2_keycode - || keycode == mouse_button3_keycode)) { + && (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); +if (keycode==mouse_button1_keycode) + reportcode=BTN_LEFT ; +else if (keycode==mouse_button2_keycode) + reportcode=BTN_MIDDLE ; +else + reportcode=BTN_RIGHT ; + +input_report_key (emumousebtn, reportcode, down);input_sync (emumousebtn);return 1 ; }
include/linux/sysctl.h +4 -3
@@ -913,9 +913,10 @@ enum {DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES =1 ,DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES =2 ,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_MOUSE_BUTTON1_KEYCODE =4 , +DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE =5 , +DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE =6 , + DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=7 };/* /proc/sys/dev/scsi */
kernel/sysctl_check.c +1 -0
@@ -816,6 +816,7 @@ static const struct trans_ctl_table trans_mac_hid_files[] = {/* 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 */