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