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",
36 WA_Flags
, WFLG_ACTIVATE
,
37 WA_IDCMP
, IDCMP_RAWKEY
,
41 printf("Could not open window\n");
45 HandleEvents(win
, buffer
, BUFSIZE
);
49 CloseLibrary((struct Library
*)IntuitionBase
);
51 CloseLibrary(KeymapBase
);
59 VOID
HandleEvents(struct Window
*win
, UBYTE
*buffer
, LONG bufsize
)
61 struct IntuiMessage
*imsg
;
62 struct MsgPort
*port
= win
->UserPort
;
63 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
);
84 ie
.ie_Code
= imsg
->Code
;
85 ie
.ie_Qualifier
= imsg
->Qualifier
;
86 printf("rawkey: code=$%04x, qual=$%04x\n",
87 ie
.ie_Code
, ie
.ie_Qualifier
);
89 ie
.ie_EventAddress
= imsg
->IAddress
;
91 written
= MapRawKey(&ie
, buffer
, bufsize
, NULL
);
93 printf("Buffer owerflow !!\n");
97 Write(Output(), buffer
, written
);
103 } /* switch (imsg->Class) */
104 ReplyMsg((struct Message
*)imsg
);
107 } /* if ((imsg = GetMsg(port)) != NULL) */
110 Wait(1L << port
->mp_SigBit
);
112 } /* while (!terminated) */
115 } /* HandleEvents() */