Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: Mac button emulation - allow compiling as a module

Not all systems require Mac-style button emulation, however distributions
enable it by default so it is readily available. Allow compiling it as a
module so it can be loaded only on systems that actually require it.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

+16 -5
+5 -3
drivers/macintosh/Kconfig
··· 171 171 If unsure, say Y. 172 172 173 173 config MAC_EMUMOUSEBTN 174 - bool "Support for mouse button 2+3 emulation" 175 - depends on SYSCTL 176 - select INPUT 174 + tristate "Support for mouse button 2+3 emulation" 175 + depends on SYSCTL && INPUT 177 176 help 178 177 This provides generic support for emulating the 2nd and 3rd mouse 179 178 button with keypresses. If you say Y here, the emulation is still ··· 183 184 /proc/sys/dev/mac_hid/mouse_button3_keycode 184 185 185 186 If you have an Apple machine with a 1-button mouse, say Y here. 187 + 188 + To compile this driver as a module, choose M here: the 189 + module will be called mac_hid. 186 190 187 191 config THERM_WINDTUNNEL 188 192 tristate "Support for thermal management on Windtunnel G4s"
+11 -2
drivers/macintosh/mac_hid.c
··· 14 14 #include <linux/input.h> 15 15 #include <linux/module.h> 16 16 17 + MODULE_LICENSE("GPL"); 18 + 17 19 static int mouse_emulate_buttons; 18 20 static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ 19 21 static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ ··· 254 252 255 253 static struct ctl_table_header *mac_hid_sysctl_header; 256 254 257 - 258 255 static int __init mac_hid_init(void) 259 256 { 260 257 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir); ··· 262 261 263 262 return 0; 264 263 } 264 + module_init(mac_hid_init); 265 265 266 - device_initcall(mac_hid_init); 266 + static void __exit mac_hid_exit(void) 267 + { 268 + unregister_sysctl_table(mac_hid_sysctl_header); 269 + 270 + if (mouse_emulate_buttons) 271 + mac_hid_stop_emulation(); 272 + } 273 + module_exit(mac_hid_exit);