23 #include <linux/kernel.h>
24 #include <linux/slab.h>
25 #include <linux/input.h>
26 #include <linux/module.h>
34 #define NR_SCANCODES 256
41 struct input_dev *
dev;
47 static const unsigned short dc_kbd_keycode[
NR_SCANCODES] = {
49 KEY_C,
KEY_D,
KEY_E,
KEY_F,
KEY_G,
KEY_H,
KEY_I,
KEY_J,
KEY_K,
KEY_L,
50 KEY_M,
KEY_N,
KEY_O,
KEY_P,
KEY_Q,
KEY_R,
KEY_S,
KEY_T,
KEY_U,
KEY_V,
51 KEY_W,
KEY_X,
KEY_Y,
KEY_Z,
KEY_1,
KEY_2,
KEY_3,
KEY_4,
KEY_5,
KEY_6,
95 static void dc_scan_kbd(
struct dc_kbd *kbd)
97 struct input_dev *
dev = kbd->
dev;
102 for (i = 0; i < 8; i++) {
106 input_report_key(dev, keycode, (kbd->
new[0] >> i) & 1);
109 for (i = 2; i < 8; i++) {
112 if (code > 3 && ptr ==
NULL) {
116 input_report_key(dev, keycode, 0);
119 "Unknown key (scancode %#x) released.",
124 if (code > 3 && ptr) {
128 input_report_key(dev, keycode, 1);
131 "Unknown key (scancode %#x) pressed.",
139 static void dc_kbd_callback(
struct mapleq *mq)
143 unsigned long *
buf = (
unsigned long *)(mq->
recvbuf->buf);
160 static int probe_maple_kbd(
struct device *dev)
166 struct input_dev *
idev;
177 idev = input_allocate_device();
180 goto fail_idev_alloc;
189 idev->keycodesize =
sizeof(
unsigned short);
192 idev->dev.parent = &mdev->
dev;
195 __set_bit(dc_kbd_keycode[i], idev->keybit);
199 input_set_drvdata(idev, kbd);
201 error = input_register_device(idev);
217 input_free_device(idev);
224 static int remove_maple_kbd(
struct device *dev)
231 input_unregister_device(kbd->
dev);
243 .name =
"Dreamcast_keyboard",
244 .probe = probe_maple_kbd,
245 .remove = remove_maple_kbd,
249 static int __init dc_kbd_init(
void)
254 static void __exit dc_kbd_exit(
void)