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