73ed0bdd1faa7970f4ee0c1840810337904d99c5
[blender.git] / intern / ghost / GHOST_Types.h
1 /**
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #ifndef _GHOST_TYPES_H_
30 #define _GHOST_TYPES_H_
31
32 typedef char                            GHOST_TInt8;
33 typedef unsigned char           GHOST_TUns8;
34 typedef short                           GHOST_TInt16;
35 typedef unsigned short          GHOST_TUns16;
36 typedef int                                     GHOST_TInt32;
37 typedef unsigned int            GHOST_TUns32;
38
39 #ifdef WIN32
40 #define WM_BLND_NDOF_AXIS       WM_USER + 1
41 #define WM_BLND_NDOF_BTN        WM_USER + 2
42 #endif
43
44 #if defined(WIN32) && !defined(FREE_WINDOWS)
45 typedef __int64                         GHOST_TInt64;
46 typedef unsigned __int64        GHOST_TUns64;
47 #else
48 typedef long long                       GHOST_TInt64;
49 typedef unsigned long long      GHOST_TUns64;
50 #endif
51
52 typedef void*                           GHOST_TUserDataPtr;
53
54 typedef enum
55 {
56         GHOST_kFailure = 0,
57         GHOST_kSuccess
58 } GHOST_TSuccess;
59
60 /* Xtilt and Ytilt represent how much the pen is tilted away from 
61  * vertically upright in either the X or Y direction, with X and Y the
62  * axes of the tablet surface.
63  * In other words, Xtilt and Ytilt are components of a vector created by projecting
64  * the pen's angle in 3D space vertically downwards on to the XY plane
65  * --Matt
66  */
67 typedef enum {
68         GHOST_kTabletModeNone = 0,
69         GHOST_kTabletModeStylus,
70         GHOST_kTabletModeEraser
71 } GHOST_TTabletMode;
72
73 typedef struct GHOST_TabletData {
74         GHOST_TTabletMode Active; /* 0=None, 1=Stylus, 2=Eraser */
75         float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
76         float Xtilt;    /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
77         float Ytilt;    /* as above */
78 } GHOST_TabletData;
79
80
81 typedef enum {
82         GHOST_kNotVisible = 0,
83         GHOST_kPartiallyVisible,
84         GHOST_kFullyVisible
85 } GHOST_TVisibility;
86
87
88 typedef enum {
89         GHOST_kFireTimeNever = 0xFFFFFFFF
90 } GHOST_TFireTimeConstant;
91
92 typedef enum {
93     GHOST_kModifierKeyLeftShift = 0,
94     GHOST_kModifierKeyRightShift,
95     GHOST_kModifierKeyLeftAlt,
96     GHOST_kModifierKeyRightAlt,
97     GHOST_kModifierKeyLeftControl,
98     GHOST_kModifierKeyRightControl,
99     GHOST_kModifierKeyCommand,          // APPLE only
100     GHOST_kModifierKeyNumMasks
101 } GHOST_TModifierKeyMask;
102
103
104 typedef enum {
105         GHOST_kWindowStateNormal = 0,
106         GHOST_kWindowStateMaximized,
107         GHOST_kWindowStateMinimized,
108         GHOST_kWindowStateFullScreen,
109         GHOST_kWindowStateEmbedded,
110         GHOST_kWindowState8Normal = 8,
111         GHOST_kWindowState8Maximized,
112         GHOST_kWindowState8Minimized,
113         GHOST_kWindowState8FullScreen,
114         GHOST_kWindowStateModified,
115         GHOST_kWindowStateUnModified
116 } GHOST_TWindowState;
117
118
119 typedef enum {
120         GHOST_kWindowOrderTop = 0,
121         GHOST_kWindowOrderBottom
122 } GHOST_TWindowOrder;
123
124
125 typedef enum {
126         GHOST_kDrawingContextTypeNone = 0,
127         GHOST_kDrawingContextTypeOpenGL
128 } GHOST_TDrawingContextType;
129
130
131 typedef enum {
132         GHOST_kButtonMaskLeft = 0,
133         GHOST_kButtonMaskMiddle,
134         GHOST_kButtonMaskRight,
135         GHOST_kButtonNumMasks
136 } GHOST_TButtonMask;
137
138
139 typedef enum {
140         GHOST_kEventUnknown = 0,
141
142         GHOST_kEventCursorMove,         /// Mouse move event
143         GHOST_kEventButtonDown,         /// Mouse button event
144         GHOST_kEventButtonUp,           /// Mouse button event
145         GHOST_kEventWheel,                      /// Mouse wheel event
146
147         GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
148         GHOST_kEventNDOFButton,         /// N degree of freedom device button event
149
150         GHOST_kEventKeyDown,
151         GHOST_kEventKeyUp,
152 //      GHOST_kEventKeyAuto,
153
154         GHOST_kEventQuit,
155
156         GHOST_kEventWindowClose,
157         GHOST_kEventWindowActivate,
158         GHOST_kEventWindowDeactivate,
159         GHOST_kEventWindowUpdate,
160         GHOST_kEventWindowSize,
161         GHOST_kEventWindowMove,
162
163         GHOST_kEventTimer,
164
165         GHOST_kNumEventTypes
166 } GHOST_TEventType;
167
168
169 typedef enum {
170         GHOST_kStandardCursorFirstCursor = 0,
171         GHOST_kStandardCursorDefault = 0,
172         GHOST_kStandardCursorRightArrow,
173         GHOST_kStandardCursorLeftArrow,
174         GHOST_kStandardCursorInfo, 
175         GHOST_kStandardCursorDestroy,
176         GHOST_kStandardCursorHelp,    
177         GHOST_kStandardCursorCycle,
178         GHOST_kStandardCursorSpray,
179         GHOST_kStandardCursorWait,
180         GHOST_kStandardCursorText,
181         GHOST_kStandardCursorCrosshair,
182         GHOST_kStandardCursorUpDown,
183         GHOST_kStandardCursorLeftRight,
184         GHOST_kStandardCursorTopSide,
185         GHOST_kStandardCursorBottomSide,
186         GHOST_kStandardCursorLeftSide,
187         GHOST_kStandardCursorRightSide,
188         GHOST_kStandardCursorTopLeftCorner,
189         GHOST_kStandardCursorTopRightCorner,
190         GHOST_kStandardCursorBottomRightCorner,
191         GHOST_kStandardCursorBottomLeftCorner,
192         GHOST_kStandardCursorCustom, 
193         GHOST_kStandardCursorNumCursors, 
194         GHOST_kStandardCursorPencil
195 } GHOST_TStandardCursor;
196
197
198 typedef enum {
199         GHOST_kKeyUnknown = -1,
200         GHOST_kKeyBackSpace,
201         GHOST_kKeyTab,
202         GHOST_kKeyLinefeed,
203         GHOST_kKeyClear,
204         GHOST_kKeyEnter  = 0x0D,
205         
206         GHOST_kKeyEsc    = 0x1B,
207         GHOST_kKeySpace  = ' ',
208         GHOST_kKeyQuote  = 0x27,
209         GHOST_kKeyComma  = ',',
210         GHOST_kKeyMinus  = '-',
211         GHOST_kKeyPeriod = '.',
212         GHOST_kKeySlash  = '/',
213
214         // Number keys
215         GHOST_kKey0 = '0',
216         GHOST_kKey1,
217         GHOST_kKey2,
218         GHOST_kKey3,
219         GHOST_kKey4,
220         GHOST_kKey5,
221         GHOST_kKey6,
222         GHOST_kKey7,
223         GHOST_kKey8,
224         GHOST_kKey9,
225
226         GHOST_kKeySemicolon = ';',
227         GHOST_kKeyEqual     = '=',
228
229         // Character keys
230         GHOST_kKeyA = 'A',
231         GHOST_kKeyB,
232         GHOST_kKeyC,
233         GHOST_kKeyD,
234         GHOST_kKeyE,
235         GHOST_kKeyF,
236         GHOST_kKeyG,
237         GHOST_kKeyH,
238         GHOST_kKeyI,
239         GHOST_kKeyJ,
240         GHOST_kKeyK,
241         GHOST_kKeyL,
242         GHOST_kKeyM,
243         GHOST_kKeyN,
244         GHOST_kKeyO,
245         GHOST_kKeyP,
246         GHOST_kKeyQ,
247         GHOST_kKeyR,
248         GHOST_kKeyS,
249         GHOST_kKeyT,
250         GHOST_kKeyU,
251         GHOST_kKeyV,
252         GHOST_kKeyW,
253         GHOST_kKeyX,
254         GHOST_kKeyY,
255         GHOST_kKeyZ,
256
257         GHOST_kKeyLeftBracket  = '[',
258         GHOST_kKeyRightBracket = ']',
259         GHOST_kKeyBackslash    = 0x5C,
260         GHOST_kKeyAccentGrave  = '`',
261
262         
263         GHOST_kKeyLeftShift = 0x100,
264         GHOST_kKeyRightShift,
265         GHOST_kKeyLeftControl,
266         GHOST_kKeyRightControl,
267         GHOST_kKeyLeftAlt,
268         GHOST_kKeyRightAlt,
269     GHOST_kKeyCommand,                          // APPLE only!
270     GHOST_kKeyGrLess ,          // German PC only!
271
272         GHOST_kKeyCapsLock,
273         GHOST_kKeyNumLock,
274         GHOST_kKeyScrollLock,
275
276         GHOST_kKeyLeftArrow,
277         GHOST_kKeyRightArrow,
278         GHOST_kKeyUpArrow,
279         GHOST_kKeyDownArrow,
280
281         GHOST_kKeyPrintScreen,
282         GHOST_kKeyPause,
283
284         GHOST_kKeyInsert,
285         GHOST_kKeyDelete,
286         GHOST_kKeyHome,
287         GHOST_kKeyEnd,
288         GHOST_kKeyUpPage,
289         GHOST_kKeyDownPage,
290
291         // Numpad keys
292         GHOST_kKeyNumpad0,
293         GHOST_kKeyNumpad1,
294         GHOST_kKeyNumpad2,
295         GHOST_kKeyNumpad3,
296         GHOST_kKeyNumpad4,
297         GHOST_kKeyNumpad5,
298         GHOST_kKeyNumpad6,
299         GHOST_kKeyNumpad7,
300         GHOST_kKeyNumpad8,
301         GHOST_kKeyNumpad9,
302         GHOST_kKeyNumpadPeriod,
303         GHOST_kKeyNumpadEnter,
304         GHOST_kKeyNumpadPlus,
305         GHOST_kKeyNumpadMinus,
306         GHOST_kKeyNumpadAsterisk,
307         GHOST_kKeyNumpadSlash,
308
309         // Function keys
310         GHOST_kKeyF1,
311         GHOST_kKeyF2,
312         GHOST_kKeyF3,
313         GHOST_kKeyF4,
314         GHOST_kKeyF5,
315         GHOST_kKeyF6,
316         GHOST_kKeyF7,
317         GHOST_kKeyF8,
318         GHOST_kKeyF9,
319         GHOST_kKeyF10,
320         GHOST_kKeyF11,
321         GHOST_kKeyF12,
322         GHOST_kKeyF13,
323         GHOST_kKeyF14,
324         GHOST_kKeyF15,
325         GHOST_kKeyF16,
326         GHOST_kKeyF17,
327         GHOST_kKeyF18,
328         GHOST_kKeyF19,
329         GHOST_kKeyF20,
330         GHOST_kKeyF21,
331         GHOST_kKeyF22,
332         GHOST_kKeyF23,
333         GHOST_kKeyF24
334 } GHOST_TKey;
335
336
337 typedef void* GHOST_TEventDataPtr;
338
339 typedef struct {
340         /** The x-coordinate of the cursor position. */
341         GHOST_TInt32 x;
342         /** The y-coordinate of the cursor position. */
343         GHOST_TInt32 y;
344 } GHOST_TEventCursorData;
345
346 typedef struct {
347         /** The mask of the mouse button. */
348         GHOST_TButtonMask button;
349 } GHOST_TEventButtonData;
350
351 typedef struct {
352         /** Displacement of a mouse wheel. */
353         GHOST_TInt32 z; 
354 } GHOST_TEventWheelData;
355
356
357 /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
358 /* as all USB device controls are likely to use ints, this is also more future proof */
359 //typedef struct {
360 //   /** N-degree of freedom device data */
361 //   float tx, ty, tz;   /** -x left, +y up, +z forward */
362 //   float rx, ry, rz;
363 //   float dt;
364 //} GHOST_TEventNDOFData;
365
366 typedef struct {
367    /** N-degree of freedom device data v2*/
368    int changed;
369    GHOST_TUns64 client;
370    GHOST_TUns64 address;
371    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
372    GHOST_TInt16 rx, ry, rz;
373    GHOST_TInt16 buttons;
374    GHOST_TUns64 time;
375    GHOST_TUns64 delta;
376 } GHOST_TEventNDOFData;
377
378 typedef int     (*GHOST_NDOFLibraryInit_fp)();
379 typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
380 typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
381
382 // original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
383 // not necessary faster, but better integration with other events. 
384
385 //typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
386 //typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
387
388 typedef struct {
389         /** The key code. */
390         GHOST_TKey              key;
391         /** The ascii code for the key event ('\0' if none). */
392         char                    ascii;
393 } GHOST_TEventKeyData;
394
395 typedef struct {
396         /** Number of pixels on a line. */
397         GHOST_TUns32    xPixels;
398         /** Number of lines. */
399         GHOST_TUns32    yPixels;
400         /** Numberof bits per pixel. */
401         GHOST_TUns32    bpp;
402         /** Refresh rate (in Hertz). */
403         GHOST_TUns32    frequency;
404 } GHOST_DisplaySetting;
405
406
407 #ifdef _WIN32
408 typedef long GHOST_TEmbedderWindowID;
409 #endif // _WIN32
410
411 #ifndef _WIN32
412 // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
413 typedef int GHOST_TEmbedderWindowID;
414 #endif // _WIN32
415
416 /**
417  * A timer task callback routine.
418  * @param task The timer task object.
419  * @param time The current time.
420  */
421 #ifdef __cplusplus
422 class GHOST_ITimerTask;
423 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
424 #else
425 struct GHOST_TimerTaskHandle__;
426 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
427 #endif
428
429 #endif // _GHOST_TYPES_H_
430