Skip to content

Commit 429722e

Browse files
committed
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>
1 parent 99b089c commit 429722e

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎drivers/macintosh/Kconfig‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ config INPUT_ADBHID
171171
If unsure, say Y.
172172

173173
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
177176
help
178177
This provides generic support for emulating the 2nd and 3rd mouse
179178
button with keypresses. If you say Y here, the emulation is still
@@ -185,6 +184,9 @@ config MAC_EMUMOUSEBTN
185184

186185
If you have an Apple machine with a 1-button mouse, say Y here.
187186

187+
To compile this driver as a module, choose M here: the
188+
module will be called mac_hid.
189+
188190
config THERM_WINDTUNNEL
189191
tristate "Support for thermal management on Windtunnel G4s"
190192
depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64

‎drivers/macintosh/mac_hid.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/input.h>
1515
#include <linux/module.h>
1616

17+
MODULE_LICENSE("GPL");
18+
1719
static int mouse_emulate_buttons;
1820
static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */
1921
static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */
@@ -252,7 +254,6 @@ static ctl_table mac_hid_root_dir[] = {
252254

253255
static struct ctl_table_header *mac_hid_sysctl_header;
254256

255-
256257
static int __init mac_hid_init(void)
257258
{
258259
mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir);
@@ -261,5 +262,13 @@ static int __init mac_hid_init(void)
261262

262263
return 0;
263264
}
265+
module_init(mac_hid_init);
264266

265-
device_initcall(mac_hid_init);
267+
static void __exit mac_hid_exit(void)
268+
{
269+
unregister_sysctl_table(mac_hid_sysctl_header);
270+
271+
if (mouse_emulate_buttons)
272+
mac_hid_stop_emulation();
273+
}
274+
module_exit(mac_hid_exit);

0 commit comments

Comments
 (0)