5 * $Id: gameport.h,v 1.8 2000/06/03 20:18:52 vojtech Exp $
7 * Copyright (c) 1999-2000 Vojtech Pavlik
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Should you need to contact me, the author, you can do so either by
28 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
29 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
50 void (*trigger
)(struct gameport
*);
51 unsigned char (*read
)(struct gameport
*);
52 int (*cooked_read
)(struct gameport
*, int *, int *);
53 int (*calibrate
)(struct gameport
*, int *, int *);
54 int (*open
)(struct gameport
*, int);
55 void (*close
)(struct gameport
*);
57 struct gameport_dev
*dev
;
59 struct gameport
*next
;
66 void (*connect
)(struct gameport
*, struct gameport_dev
*dev
);
67 void (*disconnect
)(struct gameport
*);
69 struct gameport_dev
*next
;
72 int gameport_open(struct gameport
*gameport
, struct gameport_dev
*dev
, int mode
);
73 void gameport_close(struct gameport
*gameport
);
74 void gameport_rescan(struct gameport
*gameport
);
76 void gameport_register_port(struct gameport
*gameport
);
77 void gameport_unregister_port(struct gameport
*gameport
);
78 void gameport_register_device(struct gameport_dev
*dev
);
79 void gameport_unregister_device(struct gameport_dev
*dev
);
81 #define GAMEPORT_MODE_DISABLED 0
82 #define GAMEPORT_MODE_RAW 1
83 #define GAMEPORT_MODE_COOKED 2
85 #define GAMEPORT_ISA 0
86 #define GAMEPORT_PNP 1
87 #define GAMEPORT_EXT 2
89 #define GAMEPORT_ID_VENDOR_ANALOG 0x0001
90 #define GAMEPORT_ID_VENDOR_MADCATZ 0x0002
91 #define GAMEPORT_ID_VENDOR_LOGITECH 0x0003
92 #define GAMEPORT_ID_VENDOR_CREATIVE 0x0004
93 #define GAMEPORT_ID_VENDOR_GENIUS 0x0005
94 #define GAMEPORT_ID_VENDOR_INTERACT 0x0006
95 #define GAMEPORT_ID_VENDOR_MICROSOFT 0x0007
96 #define GAMEPORT_ID_VENDOR_THRUSTMASTER 0x0008
97 #define GAMEPORT_ID_VENDOR_GRAVIS 0x0009
99 static __inline__
void gameport_trigger(struct gameport
*gameport
)
101 if (gameport
->trigger
)
102 gameport
->trigger(gameport
);
104 outb(0xff, gameport
->io
);
107 static __inline__
unsigned char gameport_read(struct gameport
*gameport
)
110 return gameport
->read(gameport
);
112 return inb(gameport
->io
);
115 static __inline__
int gameport_cooked_read(struct gameport
*gameport
, int *axes
, int *buttons
)
117 if (gameport
->cooked_read
)
118 return gameport
->cooked_read(gameport
, axes
, buttons
);
123 static __inline__
int gameport_calibrate(struct gameport
*gameport
, int *axes
, int *max
)
125 if (gameport
->calibrate
)
126 return gameport
->calibrate(gameport
, axes
, max
);
131 static __inline__
int gameport_time(struct gameport
*gameport
, int time
)
133 return (time
* gameport
->speed
) / 1000;
136 static __inline__
void wait_ms(unsigned int ms
)
138 current
->state
= TASK_UNINTERRUPTIBLE
;
139 schedule_timeout(1 + ms
* HZ
/ 1000);