summaryrefslogtreecommitdiff
path: root/rhtvision/include/tv/event.h
blob: 0516ef5bc85c5b54553ab5ae2d58d18726d979a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
 *      Turbo Vision - Version 2.0
 *
 *      Copyright (c) 1994 by Borland International
 *      All Rights Reserved.
 *
 * Modified by Robert H”hne to be used for RHIDE.
 * SET: Hardware abstaction with ideas from JASC.
 *
 */

#if defined( Uses_TEvent ) && !defined( __TEvent )
#define __TEvent

struct MouseEventType
{
 uchar buttons;
 Boolean doubleClick;
 TPoint where;
};

// This class is the base hardware interface with the mouse and shouldn't
// be used directly. You should use TMouse instead which is derived from
// it. That's why most members are protected.
// See thwmouse.cc
class CLY_EXPORT THWMouse
{
protected:
 THWMouse();
 THWMouse(const THWMouse&) {};
 virtual ~THWMouse();

 static void show();
 static void hide();

 // Needed by some drivers to communicate the size of the screen.
 static void (*setRange)(ushort, ushort);
 static void getEvent(MouseEventType &me);
 // This function could fail according to the hardware.
 // In TV 2.0 it just doesn't exist when you compile for 32 bits.
 static void (*registerHandler)(unsigned, void (*)());

 static void suspend();
 static void resume();

 // Inline members:
 // Disable mouse
 static void inhibit();
 // Is mouse installed?
 static Boolean present();

 // SET: To override just part of the behavior:
 static void (*Show)();
 static void (*Hide)();
 static void (*Suspend)();
 static void (*Resume)();
 static void (*GetEvent)(MouseEventType &me);

 // SET: This is optional, is only needed if the harware uses forceEvent.
 static int  (*drawMouse)(int x, int y);

 // SET: Default behaviors
 static void defaultShow();
 static void defaultHide();
 static void defaultSetRange(ushort, ushort);
 static void defaultGetEvent(MouseEventType&);
 static void defaultRegisterHandler(unsigned, void (*)());
 static void defaultSuspend();
 static void defaultResume();
 static int  defaultDrawMouse(int x, int y);

public:
 // SET: Used to externally force a mouse event.
 // This is only used internally.
 static void forceEvent(int x, int y, int buttons);

protected:
 // This indicates how many buttons have the mouse. Is also used to determine
 // if the mouse is present, a value of 0 is mouse not available. See the
 // present() member.
 static uchar buttonCount;
 // SET: Suspend sets buttonCount to 0 to disable the mouse. The default
 // resume behavior is to restore this value.
 static uchar oldButtonCount;
 // SET: Just to avoid redundant calls
 static char  visible;
 // SET: Data used to force an event externally
 static MouseEventType forcedME;
 static char forced;
 static uchar btBeforeForce;

 // SET: Moved to the protected section
 static Boolean handlerInstalled;
 static Boolean noMouse;
 // The following counter is incremented when the mouse pointer is updated
 // by the driver. Only useful when done asynchronically.
 static volatile unsigned drawCounter;
};

inline Boolean THWMouse::present()
{
 return Boolean(buttonCount!=0);
}

inline void THWMouse::inhibit()
{
 noMouse=True;
}

// This class exposses the mouse interface.
class CLY_EXPORT TMouse : public THWMouse
{
public:
 TMouse();
 ~TMouse();

 static void show();
 static void hide();

 static void suspend();
 static void resume();

 static void setRange( ushort, ushort );

 static void getEvent( MouseEventType& );
 static void registerHandler( unsigned, void (*)() );
 static Boolean present();

 static void resetDrawCounter();
 static unsigned getDrawCounter();
};

inline void TMouse::show()
{
 THWMouse::show();
}

inline void TMouse::hide()
{
 THWMouse::hide();
}

inline void TMouse::suspend()
{
 THWMouse::suspend();
}

inline void TMouse::resume()
{
 THWMouse::resume();
}

inline void TMouse::setRange(ushort rx, ushort ry)
{
 THWMouse::setRange(rx,ry);
}

inline void TMouse::getEvent(MouseEventType& me)
{
 THWMouse::getEvent(me);
}

inline void TMouse::registerHandler(unsigned mask, void (*func)())
{
 THWMouse::registerHandler(mask,func);
}

inline Boolean TMouse::present()
{
 return THWMouse::present();
}

inline void TMouse::resetDrawCounter()
{
 drawCounter=0;
}

inline unsigned TMouse::getDrawCounter()
{
 return drawCounter;
}
/****************************************************************************************/

struct CharScanType
{
 uchar charCode;
 uchar scanCode;
};

struct KeyDownEvent
{
 CharScanType charScan;
 ushort keyCode;
 ushort shiftState;
 uchar raw_scanCode;
};

struct MessageEvent
{
    ushort command;
    union
        {
        void *infoPtr;
        long infoLong;
        ushort infoWord;
	short infoInt;
        uchar infoByte;
        char infoChar;
        };
};

struct TEvent
{
    ushort what;
    union
    {
        MouseEventType mouse;
        KeyDownEvent keyDown;
	MessageEvent message;
    };
    void getMouseEvent();
    void getKeyEvent();
};

#endif  // Uses_TEvent