aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/maplemouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/mouse/maplemouse.c')
-rw-r--r--drivers/input/mouse/maplemouse.c73
1 files changed, 22 insertions, 51 deletions
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
index 088f69406558..e90c60cbbf05 100644
--- a/drivers/input/mouse/maplemouse.c
+++ b/drivers/input/mouse/maplemouse.c
@@ -15,80 +15,51 @@
15MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); 15MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>");
16MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); 16MODULE_DESCRIPTION("SEGA Dreamcast mouse driver");
17 17
18struct dc_mouse {
19 struct input_dev dev;
20 int open;
21};
22
23
24static void dc_mouse_callback(struct mapleq *mq) 18static void dc_mouse_callback(struct mapleq *mq)
25{ 19{
26 int buttons, relx, rely, relz; 20 int buttons, relx, rely, relz;
27 struct maple_device *mapledev = mq->dev; 21 struct maple_device *mapledev = mq->dev;
28 struct dc_mouse *mouse = mapledev->private_data; 22 struct input_dev *dev = mapledev->private_data;
29 struct input_dev *dev = &mouse->dev;
30 unsigned char *res = mq->recvbuf; 23 unsigned char *res = mq->recvbuf;
31 24
32 buttons = ~res[8]; 25 buttons = ~res[8];
33 relx=*(unsigned short *)(res+12)-512; 26 relx = *(unsigned short *)(res + 12) - 512;
34 rely=*(unsigned short *)(res+14)-512; 27 rely = *(unsigned short *)(res + 14) - 512;
35 relz=*(unsigned short *)(res+16)-512; 28 relz = *(unsigned short *)(res + 16) - 512;
36 29
37 input_report_key(dev, BTN_LEFT, buttons&4); 30 input_report_key(dev, BTN_LEFT, buttons & 4);
38 input_report_key(dev, BTN_MIDDLE, buttons&9); 31 input_report_key(dev, BTN_MIDDLE, buttons & 9);
39 input_report_key(dev, BTN_RIGHT, buttons&2); 32 input_report_key(dev, BTN_RIGHT, buttons & 2);
40 input_report_rel(dev, REL_X, relx); 33 input_report_rel(dev, REL_X, relx);
41 input_report_rel(dev, REL_Y, rely); 34 input_report_rel(dev, REL_Y, rely);
42 input_report_rel(dev, REL_WHEEL, relz); 35 input_report_rel(dev, REL_WHEEL, relz);
43 input_sync(dev); 36 input_sync(dev);
44} 37}
45 38
46
47static int dc_mouse_open(struct input_dev *dev)
48{
49 struct dc_mouse *mouse = dev->private;
50 mouse->open++;
51 return 0;
52}
53
54
55static void dc_mouse_close(struct input_dev *dev)
56{
57 struct dc_mouse *mouse = dev->private;
58 mouse->open--;
59}
60
61
62static int dc_mouse_connect(struct maple_device *dev) 39static int dc_mouse_connect(struct maple_device *dev)
63{ 40{
64 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); 41 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
65 struct dc_mouse *mouse; 42 struct input_dev *input_dev;
66 43
67 if (!(mouse = kmalloc(sizeof(struct dc_mouse), GFP_KERNEL))) 44 if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL)))
68 return -1; 45 return -1;
69 memset(mouse, 0, sizeof(struct dc_mouse));
70
71 dev->private_data = mouse;
72
73 mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
74 mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
75 mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
76 46
77 init_input_dev(&mouse->dev); 47 dev->private_data = input_dev;
78 48
79 mouse->dev.private = mouse; 49 memset(input_dev, 0, sizeof(struct dc_mouse));
80 mouse->dev.open = dc_mouse_open; 50 init_input_dev(input_dev);
81 mouse->dev.close = dc_mouse_close; 51 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
82 mouse->dev.event = NULL; 52 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
53 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
83 54
84 mouse->dev.name = dev->product_name; 55 input_dev->name = dev->product_name;
85 mouse->dev.id.bustype = BUS_MAPLE; 56 input_dev->id.bustype = BUS_MAPLE;
86 57
87 input_register_device(&mouse->dev); 58 input_register_device(input_dev);
88 59
89 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); 60 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE);
90 61
91 printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, mouse->dev.name); 62 printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name);
92 63
93 return 0; 64 return 0;
94} 65}
@@ -96,10 +67,10 @@ static int dc_mouse_connect(struct maple_device *dev)
96 67
97static void dc_mouse_disconnect(struct maple_device *dev) 68static void dc_mouse_disconnect(struct maple_device *dev)
98{ 69{
99 struct dc_mouse *mouse = dev->private_data; 70 struct input_dev *input_dev = dev->private_data;
100 71
101 input_unregister_device(&mouse->dev); 72 input_unregister_device(input_dev);
102 kfree(mouse); 73 kfree(input_dev);
103} 74}
104 75
105 76