1 #include <proto/exec.h>
2 #include <proto/keymap.h>
3 #include <proto/intuition.h>
5 #include <intuition/intuition.h>
6 #include <exec/libraries.h>
11 VOID
HandleEvents(struct Window
*win
, UBYTE
*buffer
, LONG bufsize
);
13 struct IntuitionBase
*IntuitionBase
;
14 struct Library
*KeymapBase
;
16 int main (int argc
, char **argv
)
18 UBYTE buffer
[BUFSIZE
];
20 KeymapBase
= OpenLibrary("keymap.library", 37);
22 printf("Failed to open keymap.library v37\n");
25 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 37);
27 printf("Failed to open intuition.library v37\n");
32 win
= OpenWindowTags(NULL
,
35 WA_Title
, (IPTR
)"Maprawkey test (ESC to exit)",
36 WA_Flags
, WFLG_ACTIVATE
,
37 WA_IDCMP
, IDCMP_RAWKEY
,
41 printf("Could not open window\n");
44 HandleEvents(win
, buffer
, BUFSIZE
);
48 CloseLibrary((struct Library
*)IntuitionBase
);
50 CloseLibrary(KeymapBase
);
58 VOID
HandleEvents(struct Window
*win
, UBYTE
*buffer
, LONG bufsize
)
60 struct IntuiMessage
*imsg
;
61 struct MsgPort
*port
= win
->UserPort
;
62 BOOL terminated
= FALSE
;
64 struct InputEvent ie
={0,};
66 ie
.ie_Class
= IECLASS_RAWKEY
;
70 if ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
76 case IDCMP_REFRESHWINDOW
:
78 EndRefresh(win
, TRUE
);
82 ie
.ie_Code
= imsg
->Code
;
83 ie
.ie_Qualifier
= imsg
->Qualifier
;
84 printf("rawkey: code=$%04x, qual=$%04x\n",
85 ie
.ie_Code
, ie
.ie_Qualifier
);
87 ie
.ie_EventAddress
= imsg
->IAddress
;
89 written
= MapRawKey(&ie
, buffer
, bufsize
, NULL
);
91 printf("Buffer owerflow !!\n");
95 Write(Output(), buffer
, written
);
98 if (ie
.ie_Code
== 197)
102 } /* switch (imsg->Class) */
103 ReplyMsg((struct Message
*)imsg
);
106 } /* if ((imsg = GetMsg(port)) != NULL) */
109 Wait(1L << port
->mp_SigBit
);
111 } /* while (!terminated) */
114 } /* HandleEvents() */