2 * Atari Mouse Driver for Linux
3 * by Robert de Vries (robert@and.nl) 19Jul93
5 * 16 Nov 1994 Andreas Schwab
6 * Compatibility with busmouse
7 * Support for three button mouse (shamelessly stolen from MiNT)
8 * third button wired to one of the joystick directions on joystick 1
10 * 1996/02/11 Andreas Schwab
12 * Allow multiple open's
14 * Converted to use new generic busmouse code. 5 Apr 1998
15 * Russell King <rmk@arm.uk.linux.org>
18 #include <linux/module.h>
20 #include <linux/sched.h>
21 #include <linux/errno.h>
22 #include <linux/miscdevice.h>
24 #include <linux/random.h>
25 #include <linux/poll.h>
26 #include <linux/init.h>
27 #include <linux/logibusmouse.h>
29 #include <asm/setup.h>
30 #include <asm/atarikb.h>
31 #include <asm/uaccess.h>
36 static int mouse_threshold
[2] = {2,2};
37 MODULE_PARM(mouse_threshold
, "2i");
38 extern int atari_mouse_buttons
;
40 static void atari_mouse_interrupt(char *buf
)
44 /* ikbd_mouse_disable(); */
46 buttons
= ((buf
[0] & 1)
48 | (atari_mouse_buttons
& 2));
49 atari_mouse_buttons
= buttons
;
51 busmouse_add_movementbuttons(msedev
, buf
[1], -buf
[2], buttons
^ 7);
52 /* ikbd_mouse_rel_pos(); */
55 static int release_mouse(struct inode
*inode
, struct file
*file
)
59 atari_mouse_interrupt_hook
= NULL
;
64 static int open_mouse(struct inode
*inode
, struct file
*file
)
66 atari_mouse_buttons
= 0;
68 ikbd_mouse_thresh (mouse_threshold
[0], mouse_threshold
[1]);
71 atari_mouse_interrupt_hook
= atari_mouse_interrupt
;
75 static struct busmouse atarimouse
= {
76 ATARIMOUSE_MINOR
, "atarimouse", open_mouse
, release_mouse
, 0
79 int __init
atari_mouse_init(void)
83 msedev
= register_busmouse(&atarimouse
);
85 printk(KERN_WARNING
"Unable to register Atari mouse driver.\n");
87 printk(KERN_INFO
"Atari mouse installed.\n");
88 return msedev
< 0 ? msedev
: 0;
92 #define MIN_THRESHOLD 1
93 #define MAX_THRESHOLD 20 /* more seems not reasonable... */
95 void __init
atari_mouse_setup( char *str
, int *ints
)
98 printk( "atari_mouse_setup: no arguments!\n" );
101 else if (ints
[0] > 2) {
102 printk( "atari_mouse_setup: too many arguments\n" );
105 if (ints
[1] < MIN_THRESHOLD
|| ints
[1] > MAX_THRESHOLD
)
106 printk( "atari_mouse_setup: bad threshold value (ignored)\n" );
108 mouse_threshold
[0] = ints
[1];
109 mouse_threshold
[1] = ints
[1];
111 if (ints
[2] < MIN_THRESHOLD
|| ints
[2] > MAX_THRESHOLD
)
112 printk("atari_mouse_setup: bad threshold value (ignored)\n" );
114 mouse_threshold
[1] = ints
[2];
121 int init_module(void)
123 return atari_mouse_init();
126 void cleanup_module(void)
128 unregister_busmouse(msedev
);