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
32 #include <linux/sched.h>
51 void (*trigger
)(struct gameport
*);
52 unsigned char (*read
)(struct gameport
*);
53 int (*cooked_read
)(struct gameport
*, int *, int *);
54 int (*calibrate
)(struct gameport
*, int *, int *);
55 int (*open
)(struct gameport
*, int);
56 void (*close
)(struct gameport
*);
58 struct gameport_dev
*dev
;
60 struct gameport
*next
;
67 void (*connect
)(struct gameport
*, struct gameport_dev
*dev
);
68 void (*disconnect
)(struct gameport
*);
70 struct gameport_dev
*next
;
73 int gameport_open(struct gameport
*gameport
, struct gameport_dev
*dev
, int mode
);
74 void gameport_close(struct gameport
*gameport
);
75 void gameport_rescan(struct gameport
*gameport
);
77 void gameport_register_port(struct gameport
*gameport
);
78 void gameport_unregister_port(struct gameport
*gameport
);
79 void gameport_register_device(struct gameport_dev
*dev
);
80 void gameport_unregister_device(struct gameport_dev
*dev
);
82 #define GAMEPORT_MODE_DISABLED 0
83 #define GAMEPORT_MODE_RAW 1
84 #define GAMEPORT_MODE_COOKED 2
86 #define GAMEPORT_ISA 0
87 #define GAMEPORT_PNP 1
88 #define GAMEPORT_EXT 2
90 #define GAMEPORT_ID_VENDOR_ANALOG 0x0001
91 #define GAMEPORT_ID_VENDOR_MADCATZ 0x0002
92 #define GAMEPORT_ID_VENDOR_LOGITECH 0x0003
93 #define GAMEPORT_ID_VENDOR_CREATIVE 0x0004
94 #define GAMEPORT_ID_VENDOR_GENIUS 0x0005
95 #define GAMEPORT_ID_VENDOR_INTERACT 0x0006
96 #define GAMEPORT_ID_VENDOR_MICROSOFT 0x0007
97 #define GAMEPORT_ID_VENDOR_THRUSTMASTER 0x0008
98 #define GAMEPORT_ID_VENDOR_GRAVIS 0x0009
100 static __inline__
void gameport_trigger(struct gameport
*gameport
)
102 if (gameport
->trigger
)
103 gameport
->trigger(gameport
);
105 outb(0xff, gameport
->io
);
108 static __inline__
unsigned char gameport_read(struct gameport
*gameport
)
111 return gameport
->read(gameport
);
113 return inb(gameport
->io
);
116 static __inline__
int gameport_cooked_read(struct gameport
*gameport
, int *axes
, int *buttons
)
118 if (gameport
->cooked_read
)
119 return gameport
->cooked_read(gameport
, axes
, buttons
);
124 static __inline__
int gameport_calibrate(struct gameport
*gameport
, int *axes
, int *max
)
126 if (gameport
->calibrate
)
127 return gameport
->calibrate(gameport
, axes
, max
);
132 static __inline__
int gameport_time(struct gameport
*gameport
, int time
)
134 return (time
* gameport
->speed
) / 1000;
137 static __inline__
void wait_ms(unsigned int ms
)
139 current
->state
= TASK_UNINTERRUPTIBLE
;
140 schedule_timeout(1 + ms
* HZ
/ 1000);