aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/mac_hid.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/macintosh/mac_hid.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/macintosh/mac_hid.c')
-rw-r--r--drivers/macintosh/mac_hid.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
new file mode 100644
index 000000000000..5ad3a5a9eb7f
--- /dev/null
+++ b/drivers/macintosh/mac_hid.c
@@ -0,0 +1,140 @@
1/*
2 * drivers/macintosh/mac_hid.c
3 *
4 * HID support stuff for Macintosh computers.
5 *
6 * Copyright (C) 2000 Franz Sirl.
7 *
8 * This file will soon be removed in favor of an uinput userspace tool.
9 */
10
11#include <linux/config.h>
12#include <linux/init.h>
13#include <linux/proc_fs.h>
14#include <linux/sysctl.h>
15#include <linux/input.h>
16#include <linux/module.h>
17
18
19static struct input_dev emumousebtn;
20static void emumousebtn_input_register(void);
21static int mouse_emulate_buttons = 0;
22static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */
23static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */
24static int mouse_last_keycode = 0;
25
26#if defined(CONFIG_SYSCTL)
27/* file(s) in /proc/sys/dev/mac_hid */
28ctl_table mac_hid_files[] = {
29 {
30 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON_EMULATION,
31 .procname = "mouse_button_emulation",
32 .data = &mouse_emulate_buttons,
33 .maxlen = sizeof(int),
34 .mode = 0644,
35 .proc_handler = &proc_dointvec,
36 },
37 {
38 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE,
39 .procname = "mouse_button2_keycode",
40 .data = &mouse_button2_keycode,
41 .maxlen = sizeof(int),
42 .mode = 0644,
43 .proc_handler = &proc_dointvec,
44 },
45 {
46 .ctl_name = DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE,
47 .procname = "mouse_button3_keycode",
48 .data = &mouse_button3_keycode,
49 .maxlen = sizeof(int),
50 .mode = 0644,
51 .proc_handler = &proc_dointvec,
52 },
53 { .ctl_name = 0 }
54};
55
56/* dir in /proc/sys/dev */
57ctl_table mac_hid_dir[] = {
58 {
59 .ctl_name = DEV_MAC_HID,
60 .procname = "mac_hid",
61 .maxlen = 0,
62 .mode = 0555,
63 .child = mac_hid_files,
64 },
65 { .ctl_name = 0 }
66};
67
68/* /proc/sys/dev itself, in case that is not there yet */
69ctl_table mac_hid_root_dir[] = {
70 {
71 .ctl_name = CTL_DEV,
72 .procname = "dev",
73 .maxlen = 0,
74 .mode = 0555,
75 .child = mac_hid_dir,
76 },
77 { .ctl_name = 0 }
78};
79
80static struct ctl_table_header *mac_hid_sysctl_header;
81
82#endif /* endif CONFIG_SYSCTL */
83
84int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down)
85{
86 switch (caller) {
87 case 1:
88 /* Called from keyboard.c */
89 if (mouse_emulate_buttons
90 && (keycode == mouse_button2_keycode
91 || keycode == mouse_button3_keycode)) {
92 if (mouse_emulate_buttons == 1) {
93 input_report_key(&emumousebtn,
94 keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT,
95 down);
96 input_sync(&emumousebtn);
97 return 1;
98 }
99 mouse_last_keycode = down ? keycode : 0;
100 }
101 break;
102 }
103 return 0;
104}
105
106EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons);
107
108static void emumousebtn_input_register(void)
109{
110 emumousebtn.name = "Macintosh mouse button emulation";
111
112 init_input_dev(&emumousebtn);
113
114 emumousebtn.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
115 emumousebtn.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
116 emumousebtn.relbit[0] = BIT(REL_X) | BIT(REL_Y);
117
118 emumousebtn.id.bustype = BUS_ADB;
119 emumousebtn.id.vendor = 0x0001;
120 emumousebtn.id.product = 0x0001;
121 emumousebtn.id.version = 0x0100;
122
123 input_register_device(&emumousebtn);
124
125 printk(KERN_INFO "input: Macintosh mouse button emulation\n");
126}
127
128int __init mac_hid_init(void)
129{
130
131 emumousebtn_input_register();
132
133#if defined(CONFIG_SYSCTL)
134 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1);
135#endif /* CONFIG_SYSCTL */
136
137 return 0;
138}
139
140device_initcall(mac_hid_init);