source: trunk/src/kernel32/console/test2.cpp

Last change on this file was 5024, checked in by sandervl, 25 years ago

added preliminary console code

File size: 1.5 KB
Line 
1#define INCL_DOS
2#define INCL_PM
3#define INCL_WIN
4#define INCL_VIO
5#define INCL_SUB
6#define INCL_DOSERRORS
7#define INCL_DOSDEVICES
8#include <os2.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <MonitorApi.h>
12
13#pragma pack(1)
14#define MOUSE_MONSIZE (1024 - 20)
15typedef struct _MOUSE_MONIN { /* mnin */
16 USHORT cb;
17 BYTE abReserved[18];
18 BYTE abBuffer[MOUSE_MONSIZE];
19} MOUSE_MONIN;
20
21typedef struct _MOUSE_MONOUT { /* mnout */
22 USHORT cb;
23 BYTE abReserved[18];
24 BYTE abBuffer[MOUSE_MONSIZE];
25} MOUSE_MONOUT;
26#pragma pack(4)
27
28void main(){
29
30 HMONITOR mon;
31 APIRET rc = DosMonOpen("MOUSE$",&mon);
32printf("rc = %i\n",rc);
33 if (rc != 0){
34 DosMonClose(mon);
35 return;
36 }
37
38 MOUSE_MONIN monin;
39 monin.cb = sizeof(monin);
40 MOUSE_MONOUT monout;
41 monout.cb = sizeof(monout);
42 rc = DosMonReg(mon,(BYTE *)&monin,(BYTE *)&monout,0,-1);
43printf("rc = %i\n",rc);
44 if (rc != 0) {
45 DosMonClose(mon);
46 return;
47 }
48
49 DosSetPriority(PRTYS_THREAD,PRTYC_FOREGROUNDSERVER,10,0);
50
51 while(1){
52 ULONG buffer[8];
53 USHORT bufSize = sizeof(buffer);
54 rc = DosMonRead((PBYTE)&monin,DCWW_WAIT,(PBYTE)&buffer,&bufSize);
55printf("rc = %i bs =%i\n",rc,bufSize);
56 if (rc != 0) break;
57 printf(">>%08x %08x %08x %08x %08x %08x %08x %08x\n",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4],buffer[5],buffer[6],buffer[7]);
58 rc = DosMonWrite((PBYTE)&monout,(PBYTE)&buffer,bufSize);
59
60 if (rc != 0) break;
61 }
62 DosMonClose(mon);
63}
Note: See TracBrowser for help on using the repository browser.