1 #include <intuition/intuitionbase.h>
3 #include <devices/input.h>
4 #include <devices/inputevent.h>
5 #include <proto/exec.h>
6 #include <proto/intuition.h>
8 #include LC_LIBDEFS_FILE
10 void dprintf(const char *, ...);
12 /* Dump intuition's state if F10 is pressed while F1 is down */
14 struct InputEvent
*handler(void)
16 struct InputEvent
*events
= (APTR
)REG_A0
;
17 struct InputEvent
*event
;
18 static BOOL F1_pressed
= FALSE
;
20 for (event
= events
; event
; event
= event
->ie_NextEvent
)
22 if (event
->ie_Class
== IECLASS_RAWKEY
)
24 switch (event
->ie_Code
)
30 case 0xd0: /* F1 up */
37 REG_A6
= (ULONG
)IntuitionBase
;
38 MyEmulHandle
->EmulCallDirectOS(-152 * 6);
48 struct EmulLibEntry gate
=
50 TRAP_LIB
, 0, (void(*)(void))handler
53 struct Interrupt interrupt
=
56 NULL
, NULL
, NT_INTERRUPT
, 120, "FreezeDemon"
64 if (IntuitionBase
->LibNode
.lib_Version
== VERSION_NUMBER
)
66 struct MsgPort
*port
= CreateMsgPort();
69 struct IOStdReq
*req
= CreateIORequest(port
, sizeof(*req
));
72 if (OpenDevice("input.device", 0, req
, 0) == 0)
76 req
->io_Command
= IND_ADDHANDLER
;
77 req
->io_Data
= &interrupt
;
80 /* Make sure we have a higher priority than the
81 * input.device, in case it gets trapped in an
84 old_pri
= SetTaskPri(FindTask(NULL
), 50);
86 /* Also dump if intuition's input handler has been
87 * frozen for more than 2s.
91 ULONG old_secs
= IntuitionBase
->Seconds
;
92 ULONG old_micros
= IntuitionBase
->Micros
;
96 if (old_secs
== IntuitionBase
->Seconds
&&
97 old_micros
== IntuitionBase
->Micros
)
99 REG_A6
= (ULONG
)IntuitionBase
;
100 MyEmulHandle
->EmulCallDirectOS(-152 * 6);
106 while (old_secs
== IntuitionBase
->Seconds
&&
107 old_micros
== IntuitionBase
->Micros
);
111 while ((SetSignal(0,0) & 0x1000) == 0);
113 SetTaskPri(FindTask(NULL
), old_pri
);
115 req
->io_Command
= IND_REMHANDLER
;
116 req
->io_Data
= &interrupt
;
122 DeleteIORequest(req
);