* add p cc
[mascara-docs.git] / i386 / linux / linux-2.3.21 / drivers / char / atarimouse.c
blobb831bd49c5334413f154a2f22b61243ffd05024d
1 /*
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
11 * Module support
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>
23 #include <linux/mm.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>
33 #include "busmouse.h"
35 static int msedev;
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)
42 int buttons;
44 /* ikbd_mouse_disable(); */
46 buttons = ((buf[0] & 1)
47 | ((buf[0] & 2) << 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)
57 ikbd_mouse_disable();
59 atari_mouse_interrupt_hook = NULL;
60 MOD_DEC_USE_COUNT;
61 return 0;
64 static int open_mouse(struct inode *inode, struct file *file)
66 atari_mouse_buttons = 0;
67 ikbd_mouse_y0_top ();
68 ikbd_mouse_thresh (mouse_threshold[0], mouse_threshold[1]);
69 ikbd_mouse_rel_pos();
70 MOD_INC_USE_COUNT;
71 atari_mouse_interrupt_hook = atari_mouse_interrupt;
72 return 0;
75 static struct busmouse atarimouse = {
76 ATARIMOUSE_MINOR, "atarimouse", open_mouse, release_mouse, 0
79 int __init atari_mouse_init(void)
81 if (!MACH_IS_ATARI)
82 return -ENODEV;
83 msedev = register_busmouse(&atarimouse);
84 if (msedev < 0)
85 printk(KERN_WARNING "Unable to register Atari mouse driver.\n");
86 else
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 )
97 if (ints[0] < 1) {
98 printk( "atari_mouse_setup: no arguments!\n" );
99 return;
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" );
107 else {
108 mouse_threshold[0] = ints[1];
109 mouse_threshold[1] = ints[1];
110 if (ints[0] > 1) {
111 if (ints[2] < MIN_THRESHOLD || ints[2] > MAX_THRESHOLD)
112 printk("atari_mouse_setup: bad threshold value (ignored)\n" );
113 else
114 mouse_threshold[1] = ints[2];
120 #ifdef MODULE
121 int init_module(void)
123 return atari_mouse_init();
126 void cleanup_module(void)
128 unregister_busmouse(msedev);
130 #endif