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