1 | #define INCL_WIN
|
---|
2 | #define INCL_DOS
|
---|
3 | #define INCL_VIO
|
---|
4 | #define INCL_SUB
|
---|
5 | #define INCL_DOSERRORS
|
---|
6 | #include <os2.h>
|
---|
7 | #include <stdio.h>
|
---|
8 | #include <stdlib.h>
|
---|
9 |
|
---|
10 | #include "vio32private.h"
|
---|
11 | #include "vio32SharedData.h"
|
---|
12 | #include "vio32Errors.h"
|
---|
13 |
|
---|
14 | void kbd32SharedData::Init(){
|
---|
15 | nOfWindows = 0;
|
---|
16 | for (int i=0;i<MAX_VIO32;i++) {
|
---|
17 | clientWindows[i] = 0;
|
---|
18 | frameWindows[i] = 0;
|
---|
19 | processId[i] = 0;
|
---|
20 | mode[i] = 0;
|
---|
21 | pos[i] = &events[i * MAX_PRIMARY_Q_LEN];
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 |
|
---|
26 | BOOL kbd32SharedData::searchByHwndClient(HWND hwndClient,HWND &hwndFrame,PID &pid,int &ix){
|
---|
27 | ix = 0;
|
---|
28 | for (;(ix<nOfWindows) && (clientWindows[ix] != hwndClient);ix++);
|
---|
29 | if (ix < nOfWindows){
|
---|
30 | pid = processId[ix];
|
---|
31 | hwndFrame = frameWindows[ix];
|
---|
32 | return TRUE;
|
---|
33 | }
|
---|
34 | return FALSE;
|
---|
35 | }
|
---|
36 |
|
---|
37 | BOOL kbd32SharedData::searchByHwndFrame(HWND hwndFrame,HWND &hwndClient,PID &pid,int &ix){
|
---|
38 | ix = 0;
|
---|
39 | for (;(ix<nOfWindows) && (frameWindows[ix] != hwndFrame);ix++);
|
---|
40 | if (ix < nOfWindows){
|
---|
41 | pid = processId[ix];
|
---|
42 | hwndClient = clientWindows[ix];
|
---|
43 | return TRUE;
|
---|
44 | }
|
---|
45 | return FALSE;
|
---|
46 | }
|
---|
47 |
|
---|
48 | BOOL kbd32SharedData::searchByPid(PID pid,HWND &hwndClient,HWND &hwndFrame,int &ix){
|
---|
49 | ix = 0;
|
---|
50 | for (;(ix<nOfWindows) && (processId[ix] != pid);ix++);
|
---|
51 | if (ix < nOfWindows){
|
---|
52 | hwndClient = clientWindows[ix];
|
---|
53 | hwndFrame = frameWindows[ix];
|
---|
54 | return TRUE;
|
---|
55 | }
|
---|
56 | return FALSE;
|
---|
57 | }
|
---|
58 |
|
---|
59 | VIO32EVENTINFO *kbd32SharedData::getBuffer(int ix){
|
---|
60 | if (ix < nOfWindows){
|
---|
61 | VIO32EVENTINFO *maxPos = &events[(ix+1)*MAX_PRIMARY_Q_LEN];
|
---|
62 | if (pos[ix] >= maxPos) pos[ix] = &events[ix*MAX_PRIMARY_Q_LEN];
|
---|
63 | return pos[ix];
|
---|
64 | }
|
---|
65 | return NULL;
|
---|
66 | }
|
---|
67 |
|
---|
68 | APIRET kbd32SharedData::SetMode(ULONG mode,ULONG pid){
|
---|
69 | for (int ix=0;(ix<nOfWindows) && (processId[ix] != pid);ix++);
|
---|
70 | if (ix >= nOfWindows) return VIO32_NOTINSTALLED;
|
---|
71 | this->mode[ix] = mode;
|
---|
72 | return 0;
|
---|
73 | }
|
---|
74 |
|
---|
75 | APIRET kbd32SharedData::GetMode(ULONG &mode,ULONG pid){
|
---|
76 | for (int ix=0;(ix<nOfWindows) && (processId[ix] != pid);ix++);
|
---|
77 | if (ix >= nOfWindows) return VIO32_NOTINSTALLED;
|
---|
78 | mode = this->mode[ix];
|
---|
79 | return 0;
|
---|
80 | }
|
---|
81 |
|
---|
82 | APIRET kbd32SharedData::InstallApplication(ULONG pid,BOOL windowed){
|
---|
83 | HWND hwndClient = -1;
|
---|
84 | HWND hwndFrame = -1;
|
---|
85 | if (windowed){
|
---|
86 | hwndClient = VIOWindowClient();
|
---|
87 | hwndFrame = VIOWindowFrame();
|
---|
88 | if (hwndClient == 0) return VIO32_NOTWINDOWED;
|
---|
89 | if (hwndFrame == 0) return VIO32_NOTWINDOWED;
|
---|
90 | }
|
---|
91 |
|
---|
92 | APIRET ret = FALSE;
|
---|
93 | for (int ix=0;(ix<nOfWindows) && (clientWindows[ix] != hwndClient);ix++);
|
---|
94 | if (ix < nOfWindows) ret = VIO32_ALREADYINSTALLED;
|
---|
95 | else {
|
---|
96 | for (int ix=0;(ix<nOfWindows) && (clientWindows[ix] != 0);ix++);
|
---|
97 | if (ix < nOfWindows){
|
---|
98 | clientWindows[ix] = hwndClient;
|
---|
99 | frameWindows[ix] = hwndFrame;
|
---|
100 | processId[ix] = pid;
|
---|
101 | mode[ix] = 0;
|
---|
102 | ret = 0;
|
---|
103 | } else
|
---|
104 | if (nOfWindows < MAX_VIO32){
|
---|
105 | clientWindows[nOfWindows] = hwndClient;
|
---|
106 | frameWindows[nOfWindows] = hwndFrame;
|
---|
107 | processId[nOfWindows] = pid;
|
---|
108 | mode[nOfWindows] = 0;
|
---|
109 | nOfWindows++;
|
---|
110 | ret = 0;
|
---|
111 | } else ret = VIO32_TOOMANYAPPS;
|
---|
112 | }
|
---|
113 | return ret;
|
---|
114 | }
|
---|
115 |
|
---|
116 | BOOL kbd32SharedData::UninstallApplication(ULONG pid){
|
---|
117 |
|
---|
118 | APIRET ret;
|
---|
119 | for (int ix=0;(ix<nOfWindows) && (processId[ix] != pid);ix++);
|
---|
120 | if (ix < nOfWindows){
|
---|
121 | ret = 0;
|
---|
122 | clientWindows[ix] = 0;
|
---|
123 | frameWindows[ix] = 0;
|
---|
124 | processId[ix] = 0;
|
---|
125 | if (ix == (nOfWindows-1)) nOfWindows--;
|
---|
126 | } else VIO32_NOTINSTALLED;
|
---|
127 | return ret;
|
---|
128 | }
|
---|
129 |
|
---|