Path: blob/master/drivers/input/mouse/atarimouse.c
15111 views
/*1* Atari mouse driver for Linux/m68k2*3* Copyright (c) 2005 Michael Schmitz4*5* Based on:6* Amiga mouse driver for Linux/m68k7*8* Copyright (c) 2000-2002 Vojtech Pavlik9*10*/11/*12* The low level init and interrupt stuff is handled in arch/mm68k/atari/atakeyb.c13* (the keyboard ACIA also handles the mouse and joystick data, and the keyboard14* interrupt is shared with the MIDI ACIA so MIDI data also get handled there).15* This driver only deals with handing key events off to the input layer.16*17* Largely based on the old:18*19* Atari Mouse Driver for Linux20* by Robert de Vries ([email protected]) 19Jul9321*22* 16 Nov 1994 Andreas Schwab23* Compatibility with busmouse24* Support for three button mouse (shamelessly stolen from MiNT)25* third button wired to one of the joystick directions on joystick 126*27* 1996/02/11 Andreas Schwab28* Module support29* Allow multiple open's30*31* Converted to use new generic busmouse code. 5 Apr 199832* Russell King <[email protected]>33*/343536/*37* This program is free software; you can redistribute it and/or modify it38* under the terms of the GNU General Public License version 2 as published by39* the Free Software Foundation40*/4142#include <linux/module.h>43#include <linux/init.h>44#include <linux/input.h>45#include <linux/interrupt.h>4647#include <asm/irq.h>48#include <asm/setup.h>49#include <asm/system.h>50#include <asm/uaccess.h>51#include <asm/atarihw.h>52#include <asm/atarikb.h>53#include <asm/atariints.h>5455MODULE_AUTHOR("Michael Schmitz <[email protected]>");56MODULE_DESCRIPTION("Atari mouse driver");57MODULE_LICENSE("GPL");5859static int mouse_threshold[2] = {2, 2};60module_param_array(mouse_threshold, int, NULL, 0);6162#ifdef FIXED_ATARI_JOYSTICK63extern int atari_mouse_buttons;64#endif6566static struct input_dev *atamouse_dev;6768static void atamouse_interrupt(char *buf)69{70int buttons, dx, dy;7172buttons = (buf[0] & 1) | ((buf[0] & 2) << 1);73#ifdef FIXED_ATARI_JOYSTICK74buttons |= atari_mouse_buttons & 2;75atari_mouse_buttons = buttons;76#endif7778/* only relative events get here */79dx = buf[1];80dy = buf[2];8182input_report_rel(atamouse_dev, REL_X, dx);83input_report_rel(atamouse_dev, REL_Y, dy);8485input_report_key(atamouse_dev, BTN_LEFT, buttons & 0x4);86input_report_key(atamouse_dev, BTN_MIDDLE, buttons & 0x2);87input_report_key(atamouse_dev, BTN_RIGHT, buttons & 0x1);8889input_sync(atamouse_dev);9091return;92}9394static int atamouse_open(struct input_dev *dev)95{96#ifdef FIXED_ATARI_JOYSTICK97atari_mouse_buttons = 0;98#endif99ikbd_mouse_y0_top();100ikbd_mouse_thresh(mouse_threshold[0], mouse_threshold[1]);101ikbd_mouse_rel_pos();102atari_input_mouse_interrupt_hook = atamouse_interrupt;103104return 0;105}106107static void atamouse_close(struct input_dev *dev)108{109ikbd_mouse_disable();110atari_input_mouse_interrupt_hook = NULL;111}112113static int __init atamouse_init(void)114{115int error;116117if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))118return -ENODEV;119120error = atari_keyb_init();121if (error)122return error;123124atamouse_dev = input_allocate_device();125if (!atamouse_dev)126return -ENOMEM;127128atamouse_dev->name = "Atari mouse";129atamouse_dev->phys = "atamouse/input0";130atamouse_dev->id.bustype = BUS_HOST;131atamouse_dev->id.vendor = 0x0001;132atamouse_dev->id.product = 0x0002;133atamouse_dev->id.version = 0x0100;134135atamouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);136atamouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);137atamouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |138BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);139140atamouse_dev->open = atamouse_open;141atamouse_dev->close = atamouse_close;142143error = input_register_device(atamouse_dev);144if (error) {145input_free_device(atamouse_dev);146return error;147}148149return 0;150}151152static void __exit atamouse_exit(void)153{154input_unregister_device(atamouse_dev);155}156157module_init(atamouse_init);158module_exit(atamouse_exit);159160161