Article View: comp.sys.amiga.tech
Article #2994Closing the Gameport device?
From: Henrik Clausen
Date: Sat, 17 Mar 1990 17:10
Date: Sat, 17 Mar 1990 17:10
43 lines
1891 bytes
1891 bytes
I'm writing a program (not a game :-)) that uses the gameport port to
read a switch. I have a couple of questions regarding the use of this
device:
I want the buttondown/up events as well as timeout. I do the following
loop to read events:
SendIO(&Request);
[play with my other MsgPort - possibly being told to exit the loop.]
if (CheckIO(&Request)) { /* Got input */
WaitIO(&Request); /* Get the request off the port */
[Process input]
When I exit this loop, I have an IORequest hanging and wish to clean up
the device. To close it, I use this code, reopening the device just to shut
it down:
if (GameIoRequest) {
if (GameIoRequest->io_Device) {
if (MyRequest = CreateStdIO(GameMsgPort)) {
OpenDevice("gameport.device",1,MyRequest,0);
GameIoRequest->io_Command = CMD_RESET;
DoIO(MyRequest);
WaitIO(GameIoRequest); /* Wait for the other Request */
CloseDevice(MyRequest); /* Close second opening */
DeleteStdIO(MyRequest);
}
CloseDevice(GameIoRequest); /* Close first opening */
}
DeleteStdIO(GameIoRequest);
This looks unhandy to me, but the gameport device does not seem to
implement AbortIO(), and this seems to work. Is there a more decent way to
do this? I reuse the GameMsgPort for both IORequests.
Email replies would be fine - will be nice to see it work.
-Henrik
--
*** Henrik Clausen, Graffiti Data (Fido: 2:230/22.33, UseNet: hrc@daimi.dk) ***
Technical Details
Message-ID:
<00499.AA00499@adspdk.CBMNET>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cbmvax!cbmehq!cbmdeo!adspdk!hclausenShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cbmvax!cbmehq!cbmdeo!adspdk!hclausen From: hclausen@adspdk.CBMNET (Henrik Clausen) Newsgroups: comp.sys.amiga.tech Subject: Closing the Gameport device? Keywords: GamePort, I/O, Flushing Message-ID: <00499.AA00499@adspdk.CBMNET> Date: 17 Mar 90 17:10:23 GMT Followup-To: comp.sys.amiga.tech Lines: 43