hclausen@adspdk.CBMNET (Henrik Clausen) (03/18/90)
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) ***