Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.24-rc2 161 lines 3.9 kB view raw
1/* 2 * Atari mouse driver for Linux/m68k 3 * 4 * Copyright (c) 2005 Michael Schmitz 5 * 6 * Based on: 7 * Amiga mouse driver for Linux/m68k 8 * 9 * Copyright (c) 2000-2002 Vojtech Pavlik 10 * 11 */ 12/* 13 * The low level init and interrupt stuff is handled in arch/mm68k/atari/atakeyb.c 14 * (the keyboard ACIA also handles the mouse and joystick data, and the keyboard 15 * interrupt is shared with the MIDI ACIA so MIDI data also get handled there). 16 * This driver only deals with handing key events off to the input layer. 17 * 18 * Largely based on the old: 19 * 20 * Atari Mouse Driver for Linux 21 * by Robert de Vries (robert@and.nl) 19Jul93 22 * 23 * 16 Nov 1994 Andreas Schwab 24 * Compatibility with busmouse 25 * Support for three button mouse (shamelessly stolen from MiNT) 26 * third button wired to one of the joystick directions on joystick 1 27 * 28 * 1996/02/11 Andreas Schwab 29 * Module support 30 * Allow multiple open's 31 * 32 * Converted to use new generic busmouse code. 5 Apr 1998 33 * Russell King <rmk@arm.uk.linux.org> 34 */ 35 36 37/* 38 * This program is free software; you can redistribute it and/or modify it 39 * under the terms of the GNU General Public License version 2 as published by 40 * the Free Software Foundation 41 */ 42 43#include <linux/module.h> 44#include <linux/init.h> 45#include <linux/input.h> 46#include <linux/interrupt.h> 47 48#include <asm/irq.h> 49#include <asm/setup.h> 50#include <asm/system.h> 51#include <asm/uaccess.h> 52#include <asm/atarihw.h> 53#include <asm/atarikb.h> 54#include <asm/atariints.h> 55 56MODULE_AUTHOR("Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>"); 57MODULE_DESCRIPTION("Atari mouse driver"); 58MODULE_LICENSE("GPL"); 59 60static int mouse_threshold[2] = {2,2}; 61 62#ifdef __MODULE__ 63MODULE_PARM(mouse_threshold, "2i"); 64#endif 65#ifdef FIXED_ATARI_JOYSTICK 66extern int atari_mouse_buttons; 67#endif 68static int atamouse_used = 0; 69 70static struct input_dev *atamouse_dev; 71 72static void atamouse_interrupt(char *buf) 73{ 74 int buttons, dx, dy; 75 76 buttons = (buf[0] & 1) | ((buf[0] & 2) << 1); 77#ifdef FIXED_ATARI_JOYSTICK 78 buttons |= atari_mouse_buttons & 2; 79 atari_mouse_buttons = buttons; 80#endif 81 82 /* only relative events get here */ 83 dx = buf[1]; 84 dy = -buf[2]; 85 86 input_report_rel(atamouse_dev, REL_X, dx); 87 input_report_rel(atamouse_dev, REL_Y, dy); 88 89 input_report_key(atamouse_dev, BTN_LEFT, buttons & 0x1); 90 input_report_key(atamouse_dev, BTN_MIDDLE, buttons & 0x2); 91 input_report_key(atamouse_dev, BTN_RIGHT, buttons & 0x4); 92 93 input_sync(atamouse_dev); 94 95 return; 96} 97 98static int atamouse_open(struct input_dev *dev) 99{ 100 if (atamouse_used++) 101 return 0; 102 103#ifdef FIXED_ATARI_JOYSTICK 104 atari_mouse_buttons = 0; 105#endif 106 ikbd_mouse_y0_top(); 107 ikbd_mouse_thresh(mouse_threshold[0], mouse_threshold[1]); 108 ikbd_mouse_rel_pos(); 109 atari_input_mouse_interrupt_hook = atamouse_interrupt; 110 return 0; 111} 112 113static void atamouse_close(struct input_dev *dev) 114{ 115 if (!--atamouse_used) { 116 ikbd_mouse_disable(); 117 atari_mouse_interrupt_hook = NULL; 118 } 119} 120 121static int __init atamouse_init(void) 122{ 123 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP)) 124 return -ENODEV; 125 126 if (!(atari_keyb_init())) 127 return -ENODEV; 128 129 atamouse_dev = input_allocate_device(); 130 if (!atamouse_dev) 131 return -ENOMEM; 132 133 atamouse_dev->name = "Atari mouse"; 134 atamouse_dev->phys = "atamouse/input0"; 135 atamouse_dev->id.bustype = BUS_HOST; 136 atamouse_dev->id.vendor = 0x0001; 137 atamouse_dev->id.product = 0x0002; 138 atamouse_dev->id.version = 0x0100; 139 140 atamouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 141 atamouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 142 atamouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | 143 BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); 144 atamouse_dev->open = atamouse_open; 145 atamouse_dev->close = atamouse_close; 146 147 if (input_register_device(atamouse_dev)) { 148 input_free_device(atamouse_dev); 149 return -ENOMEM; 150 } 151 152 return 0; 153} 154 155static void __exit atamouse_exit(void) 156{ 157 input_unregister_device(atamouse_dev); 158} 159 160module_init(atamouse_init); 161module_exit(atamouse_exit);