Three primary steps are required to open the input device:
* Create a message port using CreatePort(). Reply messages from the
device must be directed to a message port.
* Create an I/O request structure of type IOStdReq or timerequest. The
I/O request created by the CreateExtIO() function will be used to
pass commands and data to the input device.
* Open the Input device. Call OpenDevice(), passing the I/O request.
struct MsgPort *InputMP; /* Message port pointer */
struct IOStdReq *InputIO; /* I/O request pointer */
if (InputMP=CreatePort(0,0) )
if (InputIO=(struct IOStdReq *)
CreateExtIO(InputMP,sizeof(struct IOStdReq)) )
if (OpenDevice("input.device",0L,(struct IORequest *)InputIO,0))
printf("input.device did not open\n");
The above code will work for all the input device commands except for the
ones which require a time specification. For those, the code would look
like this:
#include <devices/timer.h>
struct MsgPort *InputMP; /* Message port pointer */
struct timerequest *InputIO; /* I/O request pointer */
if (InputMP=CreatePort(0,0) )
if (InputIO=(struct timerequest *)
CreateExtIO(InputMP,sizeof(struct timerequest)) )
if (OpenDevice("input.device",0L,(struct IORequest *)InputIO,0))
printf("input.device did not open\n");