2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
7 #include <proto/keymap.h>
8 #include <proto/intuition.h>
10 #include <intuition/intuition.h>
11 #include <exec/libraries.h>
16 VOID
HandleEvents(struct Window
*win
, UBYTE
*buffer
, LONG bufsize
);
18 struct IntuitionBase
*IntuitionBase
;
19 struct Library
*KeymapBase
;
21 int main (int argc
, char **argv
)
23 UBYTE buffer
[BUFSIZE
];
25 KeymapBase
= OpenLibrary("keymap.library", 37);
27 printf("Failed to open keymap.library v37\n");
30 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 37);
32 printf("Failed to open intuition.library v37\n");
37 win
= OpenWindowTags(NULL
,
40 WA_Title
, (IPTR
)"Maprawkey test (ESC to exit)",
41 WA_Flags
, WFLG_ACTIVATE
,
42 WA_IDCMP
, IDCMP_RAWKEY
,
46 printf("Could not open window\n");
49 HandleEvents(win
, buffer
, BUFSIZE
);
53 CloseLibrary((struct Library
*)IntuitionBase
);
55 CloseLibrary(KeymapBase
);
63 VOID
HandleEvents(struct Window
*win
, UBYTE
*buffer
, LONG bufsize
)
65 struct IntuiMessage
*imsg
;
66 struct MsgPort
*port
= win
->UserPort
;
67 BOOL terminated
= FALSE
;
69 struct InputEvent ie
={0,};
71 ie
.ie_Class
= IECLASS_RAWKEY
;
75 if ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
81 case IDCMP_REFRESHWINDOW
:
83 EndRefresh(win
, TRUE
);
87 ie
.ie_Code
= imsg
->Code
;
88 ie
.ie_Qualifier
= imsg
->Qualifier
;
89 printf("rawkey: code=$%04x, qual=$%04x\n",
90 ie
.ie_Code
, ie
.ie_Qualifier
);
92 ie
.ie_EventAddress
= imsg
->IAddress
;
94 written
= MapRawKey(&ie
, buffer
, bufsize
, NULL
);
96 printf("Buffer owerflow !!\n");
100 Write(Output(), buffer
, written
);
103 if (ie
.ie_Code
== 197)
107 } /* switch (imsg->Class) */
108 ReplyMsg((struct Message
*)imsg
);
111 } /* if ((imsg = GetMsg(port)) != NULL) */
114 Wait(1L << port
->mp_SigBit
);
116 } /* while (!terminated) */
119 } /* HandleEvents() */