home *** CD-ROM | disk | FTP | other *** search
- void RawInsert(long code,long qualifier);
- void RemoveHandler(void);
- void InstallHandler(void);
-
- extern void myhandler(void);
- extern APTR data;
-
- struct IOStdReq *inputRequestBlock;
- struct Interrupt handlerStuff;
- struct MsgPort *inputDevPort;
-
- void RemoveHandler(void)
- {
- if (inputRequestBlock) {
- if (inputRequestBlock->io_Device) {
- inputRequestBlock->io_Command = IND_REMHANDLER; /* Remove handler */
- inputRequestBlock->io_Data = (APTR)&handlerStuff;
- DoIO((struct IORequest *)inputRequestBlock);
- CloseDevice((struct IORequest *)inputRequestBlock);
- }
- DeleteStdIO(inputRequestBlock);
- }
- if (inputDevPort) {
- DeletePort(inputDevPort);
- }
- return;
- }
-
- void InstallHandler(void)
- {
- inputRequestBlock = NULL;
- if (!(inputDevPort = CreatePort(0L, 0L))) {
- RemoveHandler();
- }
- if (!(inputRequestBlock = CreateStdIO(inputDevPort))) {
- RemoveHandler();
- }
- if (OpenDevice("input.device", 0L,(struct IORequest *)inputRequestBlock, 0L)) {
- RemoveHandler();
- }
- handlerStuff.is_Node.ln_Name = "MACRO Handler";
- handlerStuff.is_Data = (APTR)&data; /* Set up for installation of */
- handlerStuff.is_Code = myhandler; /* myhandler. */
- handlerStuff.is_Node.ln_Pri = 51; /* Ahead of intuition */
- inputRequestBlock->io_Command = IND_ADDHANDLER;
- inputRequestBlock->io_Data = (APTR)&handlerStuff;
- DoIO((struct IORequest *)inputRequestBlock); /* Add me. */
- return;
- }
-
- void RawInsert(long code,long qualifier) {
- /* Set up an input request */
- struct InputEvent MyNewEvent;
- inputRequestBlock->io_Command = IND_WRITEEVENT;
- inputRequestBlock->io_Flags = 0L;
- inputRequestBlock->io_Length = (long)sizeof(struct InputEvent);
- inputRequestBlock->io_Data = (APTR)&MyNewEvent;
- MyNewEvent.ie_Class = IECLASS_RAWKEY;
- MyNewEvent.ie_Code = code;
- MyNewEvent.ie_Qualifier = qualifier;
- DoIO((struct IORequest *)inputRequestBlock);
- }
-