aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/maple_keyb.c166
1 files changed, 0 insertions, 166 deletions
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
deleted file mode 100644
index 99836b3af47b..000000000000
--- a/drivers/input/keyboard/maple_keyb.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/*
2 * $Id: maple_keyb.c,v 1.4 2004/03/22 01:18:15 lethal Exp $
3 * SEGA Dreamcast keyboard driver
4 * Based on drivers/usb/usbkbd.c
5 */
6
7#include <linux/kernel.h>
8#include <linux/slab.h>
9#include <linux/input.h>
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/timer.h>
13#include <linux/maple.h>
14
15MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>");
16MODULE_DESCRIPTION("SEGA Dreamcast keyboard driver");
17MODULE_LICENSE("GPL");
18
19static unsigned char dc_kbd_keycode[256] = {
20 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
21 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
22 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
23 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
24 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
25 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
26 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,
27 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,
28 115,114, 0, 0, 0,121, 0, 89, 93,124, 92, 94, 95, 0, 0, 0,
29 122,123, 90, 91, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
35 150,158,159,128,136,177,178,176,142,152,173,140
36};
37
38
39struct dc_kbd {
40 struct input_dev *dev;
41 unsigned char new[8];
42 unsigned char old[8];
43};
44
45
46static void dc_scan_kbd(struct dc_kbd *kbd)
47{
48 int i;
49 struct input_dev *dev = kbd->dev;
50
51 for (i = 0; i < 8; i++)
52 input_report_key(dev, dc_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1);
53
54 for (i = 2; i < 8; i++) {
55
56 if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == NULL) {
57 if (dc_kbd_keycode[kbd->old[i]])
58 input_report_key(dev, dc_kbd_keycode[kbd->old[i]], 0);
59 else
60 printk("Unknown key (scancode %#x) released.",
61 kbd->old[i]);
62 }
63
64 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) != NULL) {
65 if(dc_kbd_keycode[kbd->new[i]])
66 input_report_key(dev, dc_kbd_keycode[kbd->new[i]], 1);
67 else
68 printk("Unknown key (scancode %#x) pressed.",
69 kbd->new[i]);
70 }
71 }
72
73 input_sync(dev);
74
75 memcpy(kbd->old, kbd->new, 8);
76}
77
78
79static void dc_kbd_callback(struct mapleq *mq)
80{
81 struct maple_device *mapledev = mq->dev;
82 struct dc_kbd *kbd = mapledev->private_data;
83 unsigned long *buf = mq->recvbuf;
84
85 if (buf[1] == mapledev->function) {
86 memcpy(kbd->new, buf + 2, 8);
87 dc_scan_kbd(kbd);
88 }
89}
90
91static int dc_kbd_connect(struct maple_device *dev)
92{
93 struct dc_kbd *kbd;
94 struct input_dev *input_dev;
95 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
96 int i;
97 int err;
98
99 dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL);
100 input_dev = input_allocate_device();
101 if (!kbd || !input_dev) {
102 err = -ENOMEM;
103 goto fail;
104 }
105
106 kbd->dev = input_dev;
107
108 input_dev->name = dev->product_name;
109 input_dev->id.bustype = BUS_MAPLE;
110 input_dev->private = kbd;
111 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
112 for (i = 0; i < 255; i++)
113 set_bit(dc_kbd_keycode[i], input_dev->keybit);
114 clear_bit(0, input_dev->keybit);
115
116 err = input_register_device(kbd->dev);
117 if (err)
118 goto fail;
119
120 maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD);
121 return 0;
122
123 fail: input_free_device(input_dev);
124 kfree(kbd);
125 return err;
126}
127
128
129static void dc_kbd_disconnect(struct maple_device *dev)
130{
131 struct dc_kbd *kbd = dev->private_data;
132
133 input_unregister_device(kbd->dev);
134 kfree(kbd);
135}
136
137
138static struct maple_driver dc_kbd_driver = {
139 .function = MAPLE_FUNC_KEYBOARD,
140 .name = "Dreamcast keyboard",
141 .connect = dc_kbd_connect,
142 .disconnect = dc_kbd_disconnect,
143};
144
145
146static int __init dc_kbd_init(void)
147{
148 maple_register_driver(&dc_kbd_driver);
149 return 0;
150}
151
152
153static void __exit dc_kbd_exit(void)
154{
155 maple_unregister_driver(&dc_kbd_driver);
156}
157
158
159module_init(dc_kbd_init);
160module_exit(dc_kbd_exit);
161
162/*
163 * Local variables:
164 * c-basic-offset: 8
165 * End:
166 */