revert between 56095 -> 55830 in arch
[AROS.git] / arch / .unmaintained / m68k-pp-native / dos / hidds.c
blobb17fb6875f539fbc7f4ea104e4da333886a6bc56
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Begining of AROS kernel
6 Lang: English
7 */
9 #define AROS_USE_OOP
11 #define DEBUG 1
12 #include <aros/debug.h>
14 #include <intuition/intuition.h>
16 #include <exec/memory.h>
17 #include <exec/types.h>
19 #include <devices/trackdisk.h>
21 #include <proto/exec.h>
22 #include <graphics/gfx.h>
23 #include <utility/tagitem.h>
24 #include <proto/graphics.h>
25 #include <proto/intuition.h>
27 #include <hidd/hidd.h>
28 #include <hidd/serial.h>
30 #include <stdio.h>
31 #include <string.h>
33 #include <clib/arossupport_protos.h>
35 #define ioStd(x) ((struct IOStdReq *)x)
37 static void BlackPrint(struct RastPort *RPort, char *String, UWORD height, struct GfxBase * GfxBase);
38 static void WhitePrint(struct RastPort *RPort, char *String, UWORD height, struct GfxBase * GfxBase);
41 void hidd_demo(struct ExecBase * SysBase)
43 D(bug("graphics.hidd = %08.8lx\n",OpenLibrary("graphics.hidd",0)));
44 D(bug("display.hidd = %08.8lx\n",OpenLibrary("display.hidd",0)));
46 OpenLibrary("hidd.gfx.display",0);
48 struct GfxBase *GfxBase;
49 BOOL success = FALSE;
51 D(bug("init_gfx(hiddbase=%s)\n", "hidd.gfx.display"));
53 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37);
54 if (GfxBase)
57 /* Call private gfx.library call to init the HIDD.
58 Gfx library is responsable for closing the HIDD
59 library (although it will probably not be neccesary).
62 D(bug("calling private gfx LateGfxInit()\n"));
63 if (LateGfxInit("hidd.gfx.display"))
65 struct IntuitionBase *IntuitionBase;
67 D(bug("lategfxinit okay\n"));
69 /* Now that gfx. is guaranteed to be up & working, let intuition open WB screen */
70 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
71 D(bug("ibase = %lx\n", IntuitionBase));
72 if (IntuitionBase)
74 if (LateIntuiInit(NULL))
76 success = TRUE;
78 CloseLibrary((struct Library *)IntuitionBase);
81 D(bug("Closing gfx\n"));
83 CloseLibrary((struct Library *)GfxBase);
85 if (success == FALSE)
87 D(bug("There is something wrong with hidd subsystem..."));
88 while(1) {};
94 #if 0
96 struct IORequest *io;
97 struct MsgPort *mp;
99 mp=CreateMsgPort();
100 io=CreateIORequest(mp,sizeof(struct IOStdReq));
101 D(bug("Result of opening device %d\n",
102 OpenDevice("gameport.device",0,io,0)));
103 D(bug("Doing CMD_HIDDINIT...\n"));
105 UBYTE *data;
106 data = AllocMem(100, MEMF_PUBLIC);
107 strcpy(data, "hidd.bus.mouse");
108 ioStd(io)->io_Command=32000;
109 ioStd(io)->io_Data=data;
110 ioStd(io)->io_Length=strlen(data);
111 DoIO(io);
112 D(bug("Got io_ERROR=%d",io->io_Error));
115 #endif
117 struct IntuitionBase *IntuitionBase;
118 struct GfxBase *GfxBase;
119 struct Window * win = NULL;
120 #define XSTART 50
121 #define YSTART 50
122 int x = XSTART;
123 int y = YSTART;
126 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
127 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37);
128 if (IntuitionBase)
131 struct TagItem tags[] = {
132 {WA_Width, 100},
133 {WA_Height, 100},
134 {WA_Left, x},
135 {WA_Top, y},
136 {WA_MinWidth, 100},
137 {WA_MinHeight, 100},
138 {WA_MaxWidth, 120},
139 {WA_MaxHeight, 120},
140 {WA_Title, (ULONG)"AROS Dream :-)"},
141 {WA_Activate, 1},
142 {WA_SizeGadget, TRUE},
143 {WA_DepthGadget, TRUE},
144 {TAG_DONE, 0}};
145 win = OpenWindowTagList(0, tags);
148 DrawEllipse(win->RPort,160/2-35,120/2-4,80/2,80/2);
149 DrawEllipse(win->RPort,185/2-35,90/2-4,15/2,15/2);
150 DrawEllipse(win->RPort,135/2-35,90/2-4,15/2,15/2);
152 Move(win->RPort,125/2-35,140/2-4);
153 Draw(win->RPort,140/2-35,150/2-4);
154 Draw(win->RPort,180/2-35,150/2-4);
155 Draw(win->RPort,195/2-35,140/2-4);
157 #if 0
158 if (win)
160 while (x < 100)
162 MoveWindow(win,1,0);
163 x++;
165 while (y < 100)
167 MoveWindow(win,0,1);
168 y++;
170 while (x > XSTART)
172 MoveWindow(win,-1,0);
173 x--;
175 while (y > YSTART)
177 MoveWindow(win,0,-1);
178 y--;
181 #endif
182 #if 0
183 if (IntuitionBase)
185 struct Screen *screen;
186 struct Window *win2;
187 struct IntuiMessage *msg;
188 char ScreenInfo[40];
190 if ((screen = LockPubScreen(NULL)))
192 struct TagItem tags[] = {
193 {WA_Width, 640},
194 {WA_Height, 100},
195 {WA_Left, 0},
196 {WA_Top, 79},
197 {WA_MinWidth, 200},
198 {WA_MinHeight, 100},
199 {WA_MaxWidth, 640},
200 {WA_MaxHeight, 480},
201 {WA_Title, (ULONG)"AROS !ext" },
202 {WA_Activate, 1},
203 {WA_CloseGadget, TRUE},
204 {WA_SizeGadget, TRUE},
205 {WA_DepthGadget, TRUE},
206 {WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_MOUSEMOVE | IDCMP_RAWKEY},
207 {WA_ReportMouse, TRUE},
208 {TAG_DONE, 0}};
209 win2 = OpenWindowTagList(0, tags);
211 sprintf(ScreenInfo,"ScreenWidth: %d, ScreenHeight: %d", screen->Width, screen->Height);
213 if (win2)
215 BlackPrint(win2->RPort, ScreenInfo, 40, GfxBase);
217 for(;;)
219 BOOL quitme = FALSE;
221 WaitPort(win2->UserPort);
222 while((msg = ((struct IntuiMessage *)GetMsg(win2->UserPort))))
224 switch(msg->Class)
226 case IDCMP_RAWKEY:
228 static char hex[] = "0123456789ABCDEF";
229 char s[9];
231 s[0] = 'K';
232 s[1] = 'e';
233 s[2] = 'y';
234 s[3] = ' ';
235 s[4] = hex[(msg->Code >> 12) & 0xF];
236 s[5] = hex[(msg->Code >> 8) & 0xF];
237 s[6] = hex[(msg->Code >> 4) & 0xF];
238 s[7] = hex[(msg->Code >> 0) & 0xF];
239 s[8] = '\0';
241 BlackPrint(win2->RPort, s, 60, GfxBase);
243 if (msg->Code == 0x45) quitme = TRUE;
245 break;
247 case IDCMP_MOUSEMOVE:
249 WORD mx = win2->WScreen->MouseX;
250 WORD my = win2->WScreen->MouseY;
252 char s[20];
254 sprintf(s, "Mouse: %4d, %4d", mx, my);
256 WhitePrint(win2->RPort, s, 80, GfxBase);
257 #if 0
258 mx &= 511;
259 my &= 255;
261 SetAPen(&win2->WScreen->RastPort, 1);
262 SetDrMd(&win2->WScreen->RastPort, JAM2);
263 WritePixel(&win2->WScreen->RastPort, mx, my);
264 #endif
266 break;
268 case IDCMP_CLOSEWINDOW:
270 quitme = TRUE;
272 break;
275 ReplyMsg((struct Message *)msg);
278 if (quitme) break;
280 CloseWindow(win2);
282 UnlockPubScreen(NULL,screen);
285 #endif
289 static void BlackPrint(struct RastPort *RPort, char *String, UWORD height, struct GfxBase * GfxBase)
291 SetAPen(RPort, 2);
292 SetBPen(RPort, 1);
293 SetDrMd(RPort, JAM2);
294 Move(RPort,20,height);
295 Text(RPort, String, strlen(String));
298 static void WhitePrint(struct RastPort *RPort, char *String, UWORD height, struct GfxBase * GfxBase)
300 SetAPen(RPort, 1);
301 SetBPen(RPort, 2);
302 SetDrMd(RPort, JAM2);
303 Move(RPort,20,height);
304 Text(RPort, String, strlen(String));