Fix clipping when rendering a single icon so that it takes the objects dimensions...
[AROS.git] / test / keymaptest.c
blob1b95ac5d4d38816bcb542053c473ee9e7f643818
1 #include <proto/exec.h>
2 #include <proto/keymap.h>
3 #include <proto/intuition.h>
4 #include <proto/dos.h>
5 #include <intuition/intuition.h>
6 #include <exec/libraries.h>
8 #include <stdio.h>
10 #define BUFSIZE 10
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);
21 if (!KeymapBase)
22 printf("Failed to open keymap.library v37\n");
23 else
25 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
26 if (!IntuitionBase)
27 printf("Failed to open intuition.library v37\n");
28 else
30 struct Window *win;
32 win = OpenWindowTags(NULL,
33 WA_Width, 100,
34 WA_Height, 60,
35 WA_Title, (IPTR)"Maprawkey test",
36 WA_Flags, WFLG_ACTIVATE,
37 WA_IDCMP, IDCMP_RAWKEY,
38 TAG_DONE);
40 if (!win)
41 printf("Could not open window\n");
42 else
45 HandleEvents(win, buffer, BUFSIZE);
47 CloseWindow(win);
49 CloseLibrary((struct Library *)IntuitionBase);
51 CloseLibrary(KeymapBase);
53 return (0);
56 /*******************
57 ** HandleEvents **
58 *******************/
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;
68 while (!terminated)
70 if ((imsg = (struct IntuiMessage *)GetMsg(port)) != NULL)
73 switch (imsg->Class)
76 case IDCMP_REFRESHWINDOW:
77 BeginRefresh(win);
78 EndRefresh(win, TRUE);
79 break;
81 case IDCMP_RAWKEY: {
82 WORD written;
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);
92 if (written == -1)
93 printf("Buffer owerflow !!\n");
94 else if (written)
96 printf("Map:");
97 Write(Output(), buffer, written);
98 printf("\n");
101 } break;
103 } /* switch (imsg->Class) */
104 ReplyMsg((struct Message *)imsg);
107 } /* if ((imsg = GetMsg(port)) != NULL) */
108 else
110 Wait(1L << port->mp_SigBit);
112 } /* while (!terminated) */
114 return;
115 } /* HandleEvents() */