home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
300-399
/
ff332.lzh
/
RevBut
/
RevBut.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-20
|
2KB
|
95 lines
#include <exec/exec.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
#include <devices/inputevent.h>
#include <devices/input.h>
void HandlerInterface();
struct MsgPort *inPort;
struct IOStdReq *inReq;
struct Interrupt HandlerData =
{ { NULL,NULL,0,55,NULL }, NULL, &HandlerInterface };
int down = NULL;
BOOL on = TRUE;
struct InputEvent *myHandler(event, data)
struct InputEvent *event;
APTR data;
{ register struct InputEvent *e, *oe = NULL, *ne = NULL;
Forbid();
for(e=event; e != NULL; e = ne)
{ ne = e->ie_NextEvent;
if(on && e->ie_Class == IECLASS_RAWMOUSE &&
(e->ie_Code & IECODE_COMM_CODE_LAST) == IECODE_RBUTTON)
{ if(e->ie_Code & IECODE_UP_PREFIX) /* Loslass-Event: entfernen */
{ if(oe) oe->ie_NextEvent = ne;
else event = ne;
e = 0;
}
else /* sonst: kippen */
{ e->ie_Code = down | IECODE_RBUTTON;
down = IECODE_UP_PREFIX - down;
}
}
else if(e->ie_Class == IECLASS_RAWKEY &&
e->ie_Code == 0x42 && e->ie_Qualifier & IEQUALIFIER_LSHIFT)
{ on = !on; /* Lshift-Tab: Ein/Aus */
if(oe) oe->ie_NextEvent = ne;
else event = ne;
e = 0;
}
if(e) oe = e;
}
Permit();
return(event);
}
void HandlerInterface()
{
#asm
movem.l a4,-(sp)
jsr _geta4#
movem.l a0/a1,-(sp)
jsr _myHandler
addq.l #8,sp
move.l (sp)+,a4
#endasm
}
Init()
{
inPort = CreatePort(0,0);
inReq = CreateStdIO(inPort);
OpenDevice("input.device",0,inReq,0);
inReq->io_Command = IND_ADDHANDLER;
inReq->io_Data = (APTR)&HandlerData;
DoIO(inReq);
}
Quit()
{
inReq->io_Command = IND_REMHANDLER;
inReq->io_Data = (APTR)&HandlerData;
DoIO(inReq);
CloseDevice(inReq);
DeleteStdIO(inReq);
DeletePort(inPort);
exit(0);
}
main()
{
Init();
Wait(SIGBREAKF_CTRL_C);
Quit();
}