2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <intuition/intuitionbase.h>
8 #include <devices/input.h>
9 #include <devices/inputevent.h>
10 #include <proto/exec.h>
11 #include <proto/intuition.h>
13 #include LC_LIBDEFS_FILE
15 void dprintf(const char *, ...);
17 /* Dump intuition's state if F10 is pressed while F1 is down */
19 struct InputEvent
*handler(void)
21 struct InputEvent
*events
= (APTR
)REG_A0
;
22 struct InputEvent
*event
;
23 static BOOL F1_pressed
= FALSE
;
25 for (event
= events
; event
; event
= event
->ie_NextEvent
)
27 if (event
->ie_Class
== IECLASS_RAWKEY
)
29 switch (event
->ie_Code
)
35 case 0xd0: /* F1 up */
42 REG_A6
= (ULONG
)IntuitionBase
;
43 MyEmulHandle
->EmulCallDirectOS(-152 * 6);
53 struct EmulLibEntry gate
=
55 TRAP_LIB
, 0, (void(*)(void))handler
58 struct Interrupt interrupt
=
61 NULL
, NULL
, NT_INTERRUPT
, 120, "FreezeDemon"
69 if (IntuitionBase
->LibNode
.lib_Version
== VERSION_NUMBER
)
71 struct MsgPort
*port
= CreateMsgPort();
74 struct IOStdReq
*req
= CreateIORequest(port
, sizeof(*req
));
77 if (OpenDevice("input.device", 0, req
, 0) == 0)
81 req
->io_Command
= IND_ADDHANDLER
;
82 req
->io_Data
= &interrupt
;
85 /* Make sure we have a higher priority than the
86 * input.device, in case it gets trapped in an
89 old_pri
= SetTaskPri(FindTask(NULL
), 50);
91 /* Also dump if intuition's input handler has been
92 * frozen for more than 2s.
96 ULONG old_secs
= IntuitionBase
->Seconds
;
97 ULONG old_micros
= IntuitionBase
->Micros
;
101 if (old_secs
== IntuitionBase
->Seconds
&&
102 old_micros
== IntuitionBase
->Micros
)
104 REG_A6
= (ULONG
)IntuitionBase
;
105 MyEmulHandle
->EmulCallDirectOS(-152 * 6);
111 while (old_secs
== IntuitionBase
->Seconds
&&
112 old_micros
== IntuitionBase
->Micros
);
116 while ((SetSignal(0,0) & 0x1000) == 0);
118 SetTaskPri(FindTask(NULL
), old_pri
);
120 req
->io_Command
= IND_REMHANDLER
;
121 req
->io_Data
= &interrupt
;
127 DeleteIORequest(req
);