diff options
Diffstat (limited to 'drivers/macintosh/mac_hid.c')
| -rw-r--r-- | drivers/macintosh/mac_hid.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index 5ad3a5a9eb7f..a66636116f0b 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c | |||
| @@ -16,8 +16,8 @@ | |||
| 16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | static struct input_dev emumousebtn; | 19 | static struct input_dev *emumousebtn; |
| 20 | static void emumousebtn_input_register(void); | 20 | static int emumousebtn_input_register(void); |
| 21 | static int mouse_emulate_buttons = 0; | 21 | static int mouse_emulate_buttons = 0; |
| 22 | static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ | 22 | static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ |
| 23 | static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ | 23 | static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ |
| @@ -90,10 +90,10 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down) | |||
| 90 | && (keycode == mouse_button2_keycode | 90 | && (keycode == mouse_button2_keycode |
| 91 | || keycode == mouse_button3_keycode)) { | 91 | || keycode == mouse_button3_keycode)) { |
| 92 | if (mouse_emulate_buttons == 1) { | 92 | if (mouse_emulate_buttons == 1) { |
| 93 | input_report_key(&emumousebtn, | 93 | input_report_key(emumousebtn, |
| 94 | keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT, | 94 | keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT, |
| 95 | down); | 95 | down); |
| 96 | input_sync(&emumousebtn); | 96 | input_sync(emumousebtn); |
| 97 | return 1; | 97 | return 1; |
| 98 | } | 98 | } |
| 99 | mouse_last_keycode = down ? keycode : 0; | 99 | mouse_last_keycode = down ? keycode : 0; |
| @@ -105,30 +105,34 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down) | |||
| 105 | 105 | ||
| 106 | EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons); | 106 | EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons); |
| 107 | 107 | ||
| 108 | static void emumousebtn_input_register(void) | 108 | static int emumousebtn_input_register(void) |
| 109 | { | 109 | { |
| 110 | emumousebtn.name = "Macintosh mouse button emulation"; | 110 | emumousebtn = input_allocate_device(); |
| 111 | if (!emumousebtn) | ||
| 112 | return -ENOMEM; | ||
| 111 | 113 | ||
| 112 | init_input_dev(&emumousebtn); | 114 | emumousebtn->name = "Macintosh mouse button emulation"; |
| 115 | emumousebtn->id.bustype = BUS_ADB; | ||
| 116 | emumousebtn->id.vendor = 0x0001; | ||
| 117 | emumousebtn->id.product = 0x0001; | ||
| 118 | emumousebtn->id.version = 0x0100; | ||
| 113 | 119 | ||
| 114 | emumousebtn.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | 120 | emumousebtn->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
| 115 | emumousebtn.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); | 121 | emumousebtn->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); |
| 116 | emumousebtn.relbit[0] = BIT(REL_X) | BIT(REL_Y); | 122 | emumousebtn->relbit[0] = BIT(REL_X) | BIT(REL_Y); |
| 117 | 123 | ||
| 118 | emumousebtn.id.bustype = BUS_ADB; | 124 | input_register_device(emumousebtn); |
| 119 | emumousebtn.id.vendor = 0x0001; | ||
| 120 | emumousebtn.id.product = 0x0001; | ||
| 121 | emumousebtn.id.version = 0x0100; | ||
| 122 | 125 | ||
| 123 | input_register_device(&emumousebtn); | 126 | return 0; |
| 124 | |||
| 125 | printk(KERN_INFO "input: Macintosh mouse button emulation\n"); | ||
| 126 | } | 127 | } |
| 127 | 128 | ||
| 128 | int __init mac_hid_init(void) | 129 | int __init mac_hid_init(void) |
| 129 | { | 130 | { |
| 131 | int err; | ||
| 130 | 132 | ||
| 131 | emumousebtn_input_register(); | 133 | err = emumousebtn_input_register(); |
| 134 | if (err) | ||
| 135 | return err; | ||
| 132 | 136 | ||
| 133 | #if defined(CONFIG_SYSCTL) | 137 | #if defined(CONFIG_SYSCTL) |
| 134 | mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1); | 138 | mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1); |
