small merge needed for testing new animsys in 2.5 BGE, mixing own changes with merge...
[blender-staging.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 struct GHOST_TabletData {
68         char Active; /* 0=None, 1=Stylus, 2=Eraser */
69         float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
70         float Xtilt;    /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
71         float Ytilt;    /* as above */
72 } GHOST_TabletData;
73
74
75 typedef enum {
76         GHOST_kNotVisible = 0,
77         GHOST_kPartiallyVisible,
78         GHOST_kFullyVisible
79 } GHOST_TVisibility;
80
81
82 typedef enum {
83         GHOST_kFireTimeNever = 0xFFFFFFFF
84 } GHOST_TFireTimeConstant;
85
86 typedef enum {
87     GHOST_kModifierKeyLeftShift = 0,
88     GHOST_kModifierKeyRightShift,
89     GHOST_kModifierKeyLeftAlt,
90     GHOST_kModifierKeyRightAlt,
91     GHOST_kModifierKeyLeftControl,
92     GHOST_kModifierKeyRightControl,
93     GHOST_kModifierKeyCommand,          // APPLE only
94     GHOST_kModifierKeyNumMasks
95 } GHOST_TModifierKeyMask;
96
97
98 typedef enum {
99         GHOST_kWindowStateNormal = 0,
100         GHOST_kWindowStateMaximized,
101         GHOST_kWindowStateMinimized,
102         GHOST_kWindowStateFullScreen,
103         GHOST_kWindowStateEmbedded,
104         GHOST_kWindowState8Normal = 8,
105         GHOST_kWindowState8Maximized,
106         GHOST_kWindowState8Minimized,
107         GHOST_kWindowState8FullScreen,
108         GHOST_kWindowStateModified,
109         GHOST_kWindowStateUnModified
110 } GHOST_TWindowState;
111
112
113 typedef enum {
114         GHOST_kWindowOrderTop = 0,
115         GHOST_kWindowOrderBottom
116 } GHOST_TWindowOrder;
117
118
119 typedef enum {
120         GHOST_kDrawingContextTypeNone = 0,
121         GHOST_kDrawingContextTypeOpenGL
122 } GHOST_TDrawingContextType;
123
124
125 typedef enum {
126         GHOST_kButtonMaskLeft = 0,
127         GHOST_kButtonMaskMiddle,
128         GHOST_kButtonMaskRight,
129         GHOST_kButtonNumMasks
130 } GHOST_TButtonMask;
131
132
133 typedef enum {
134         GHOST_kEventUnknown = 0,
135
136         GHOST_kEventCursorMove,         /// Mouse move event
137         GHOST_kEventButtonDown,         /// Mouse button event
138         GHOST_kEventButtonUp,           /// Mouse button event
139         GHOST_kEventWheel,                      /// Mouse wheel event
140
141         GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
142         GHOST_kEventNDOFButton,         /// N degree of freedom device button event
143
144         GHOST_kEventKeyDown,
145         GHOST_kEventKeyUp,
146 //      GHOST_kEventKeyAuto,
147
148         GHOST_kEventQuit,
149
150         GHOST_kEventWindowClose,
151         GHOST_kEventWindowActivate,
152         GHOST_kEventWindowDeactivate,
153         GHOST_kEventWindowUpdate,
154         GHOST_kEventWindowSize,
155         GHOST_kEventWindowMove,
156
157         GHOST_kEventTimer,
158
159         GHOST_kNumEventTypes
160 } GHOST_TEventType;
161
162
163 typedef enum {
164         GHOST_kStandardCursorFirstCursor = 0,
165         GHOST_kStandardCursorDefault = 0,
166         GHOST_kStandardCursorRightArrow,
167         GHOST_kStandardCursorLeftArrow,
168         GHOST_kStandardCursorInfo, 
169         GHOST_kStandardCursorDestroy,
170         GHOST_kStandardCursorHelp,    
171         GHOST_kStandardCursorCycle,
172         GHOST_kStandardCursorSpray,
173         GHOST_kStandardCursorWait,
174         GHOST_kStandardCursorText,
175         GHOST_kStandardCursorCrosshair,
176         GHOST_kStandardCursorUpDown,
177         GHOST_kStandardCursorLeftRight,
178         GHOST_kStandardCursorTopSide,
179         GHOST_kStandardCursorBottomSide,
180         GHOST_kStandardCursorLeftSide,
181         GHOST_kStandardCursorRightSide,
182         GHOST_kStandardCursorTopLeftCorner,
183         GHOST_kStandardCursorTopRightCorner,
184         GHOST_kStandardCursorBottomRightCorner,
185         GHOST_kStandardCursorBottomLeftCorner,
186         GHOST_kStandardCursorCustom, 
187         GHOST_kStandardCursorNumCursors, 
188         GHOST_kStandardCursorPencil
189 } GHOST_TStandardCursor;
190
191
192 typedef enum {
193         GHOST_kKeyUnknown = -1,
194         GHOST_kKeyBackSpace,
195         GHOST_kKeyTab,
196         GHOST_kKeyLinefeed,
197         GHOST_kKeyClear,
198         GHOST_kKeyEnter  = 0x0D,
199         
200         GHOST_kKeyEsc    = 0x1B,
201         GHOST_kKeySpace  = ' ',
202         GHOST_kKeyQuote  = 0x27,
203         GHOST_kKeyComma  = ',',
204         GHOST_kKeyMinus  = '-',
205         GHOST_kKeyPeriod = '.',
206         GHOST_kKeySlash  = '/',
207
208         // Number keys
209         GHOST_kKey0 = '0',
210         GHOST_kKey1,
211         GHOST_kKey2,
212         GHOST_kKey3,
213         GHOST_kKey4,
214         GHOST_kKey5,
215         GHOST_kKey6,
216         GHOST_kKey7,
217         GHOST_kKey8,
218         GHOST_kKey9,
219
220         GHOST_kKeySemicolon = ';',
221         GHOST_kKeyEqual     = '=',
222
223         // Character keys
224         GHOST_kKeyA = 'A',
225         GHOST_kKeyB,
226         GHOST_kKeyC,
227         GHOST_kKeyD,
228         GHOST_kKeyE,
229         GHOST_kKeyF,
230         GHOST_kKeyG,
231         GHOST_kKeyH,
232         GHOST_kKeyI,
233         GHOST_kKeyJ,
234         GHOST_kKeyK,
235         GHOST_kKeyL,
236         GHOST_kKeyM,
237         GHOST_kKeyN,
238         GHOST_kKeyO,
239         GHOST_kKeyP,
240         GHOST_kKeyQ,
241         GHOST_kKeyR,
242         GHOST_kKeyS,
243         GHOST_kKeyT,
244         GHOST_kKeyU,
245         GHOST_kKeyV,
246         GHOST_kKeyW,
247         GHOST_kKeyX,
248         GHOST_kKeyY,
249         GHOST_kKeyZ,
250
251         GHOST_kKeyLeftBracket  = '[',
252         GHOST_kKeyRightBracket = ']',
253         GHOST_kKeyBackslash    = 0x5C,
254         GHOST_kKeyAccentGrave  = '`',
255
256         
257         GHOST_kKeyLeftShift = 0x100,
258         GHOST_kKeyRightShift,
259         GHOST_kKeyLeftControl,
260         GHOST_kKeyRightControl,
261         GHOST_kKeyLeftAlt,
262         GHOST_kKeyRightAlt,
263     GHOST_kKeyCommand,                          // APPLE only!
264     GHOST_kKeyGrLess ,          // German PC only!
265
266         GHOST_kKeyCapsLock,
267         GHOST_kKeyNumLock,
268         GHOST_kKeyScrollLock,
269
270         GHOST_kKeyLeftArrow,
271         GHOST_kKeyRightArrow,
272         GHOST_kKeyUpArrow,
273         GHOST_kKeyDownArrow,
274
275         GHOST_kKeyPrintScreen,
276         GHOST_kKeyPause,
277
278         GHOST_kKeyInsert,
279         GHOST_kKeyDelete,
280         GHOST_kKeyHome,
281         GHOST_kKeyEnd,
282         GHOST_kKeyUpPage,
283         GHOST_kKeyDownPage,
284
285         // Numpad keys
286         GHOST_kKeyNumpad0,
287         GHOST_kKeyNumpad1,
288         GHOST_kKeyNumpad2,
289         GHOST_kKeyNumpad3,
290         GHOST_kKeyNumpad4,
291         GHOST_kKeyNumpad5,
292         GHOST_kKeyNumpad6,
293         GHOST_kKeyNumpad7,
294         GHOST_kKeyNumpad8,
295         GHOST_kKeyNumpad9,
296         GHOST_kKeyNumpadPeriod,
297         GHOST_kKeyNumpadEnter,
298         GHOST_kKeyNumpadPlus,
299         GHOST_kKeyNumpadMinus,
300         GHOST_kKeyNumpadAsterisk,
301         GHOST_kKeyNumpadSlash,
302
303         // Function keys
304         GHOST_kKeyF1,
305         GHOST_kKeyF2,
306         GHOST_kKeyF3,
307         GHOST_kKeyF4,
308         GHOST_kKeyF5,
309         GHOST_kKeyF6,
310         GHOST_kKeyF7,
311         GHOST_kKeyF8,
312         GHOST_kKeyF9,
313         GHOST_kKeyF10,
314         GHOST_kKeyF11,
315         GHOST_kKeyF12,
316         GHOST_kKeyF13,
317         GHOST_kKeyF14,
318         GHOST_kKeyF15,
319         GHOST_kKeyF16,
320         GHOST_kKeyF17,
321         GHOST_kKeyF18,
322         GHOST_kKeyF19,
323         GHOST_kKeyF20,
324         GHOST_kKeyF21,
325         GHOST_kKeyF22,
326         GHOST_kKeyF23,
327         GHOST_kKeyF24
328 } GHOST_TKey;
329
330
331 typedef void* GHOST_TEventDataPtr;
332
333 typedef struct {
334         /** The x-coordinate of the cursor position. */
335         GHOST_TInt32 x;
336         /** The y-coordinate of the cursor position. */
337         GHOST_TInt32 y;
338 } GHOST_TEventCursorData;
339
340 typedef struct {
341         /** The mask of the mouse button. */
342         GHOST_TButtonMask button;
343 } GHOST_TEventButtonData;
344
345 typedef struct {
346         /** Displacement of a mouse wheel. */
347         GHOST_TInt32 z; 
348 } GHOST_TEventWheelData;
349
350
351 /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
352 /* as all USB device controls are likely to use ints, this is also more future proof */
353 //typedef struct {
354 //   /** N-degree of freedom device data */
355 //   float tx, ty, tz;   /** -x left, +y up, +z forward */
356 //   float rx, ry, rz;
357 //   float dt;
358 //} GHOST_TEventNDOFData;
359
360 typedef struct {
361    /** N-degree of freedom device data v2*/
362    int changed;
363    GHOST_TUns64 client;
364    GHOST_TUns64 address;
365    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
366    GHOST_TInt16 rx, ry, rz;
367    GHOST_TInt16 buttons;
368    GHOST_TUns64 time;
369    GHOST_TUns64 delta;
370 } GHOST_TEventNDOFData;
371
372 typedef int     (*GHOST_NDOFLibraryInit_fp)();
373 typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
374 typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
375
376 // original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
377 // not necessary faster, but better integration with other events. 
378
379 //typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
380 //typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
381
382 typedef struct {
383         /** The key code. */
384         GHOST_TKey              key;
385         /** The ascii code for the key event ('\0' if none). */
386         char                    ascii;
387 } GHOST_TEventKeyData;
388
389 typedef struct {
390         /** Number of pixels on a line. */
391         GHOST_TUns32    xPixels;
392         /** Number of lines. */
393         GHOST_TUns32    yPixels;
394         /** Numberof bits per pixel. */
395         GHOST_TUns32    bpp;
396         /** Refresh rate (in Hertz). */
397         GHOST_TUns32    frequency;
398 } GHOST_DisplaySetting;
399
400
401 #ifdef _WIN32
402 typedef long GHOST_TEmbedderWindowID;
403 #endif // _WIN32
404
405 #ifndef _WIN32
406 // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
407 typedef int GHOST_TEmbedderWindowID;
408 #endif // _WIN32
409
410 /**
411  * A timer task callback routine.
412  * @param task The timer task object.
413  * @param time The current time.
414  */
415 #ifdef __cplusplus
416 class GHOST_ITimerTask;
417 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
418 #else
419 struct GHOST_TimerTaskHandle__;
420 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
421 #endif
422
423 #endif // _GHOST_TYPES_H_
424