- added GCC warning -Wstrict-prototypes
[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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_kModifierKeyOS,
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 /** Constants for the answer to the blender exit request */
120 typedef enum {
121         GHOST_kExitCancel = 0,
122         GHOST_kExitNow
123 } GHOST_TExitRequestResponse;
124
125 typedef enum {
126         GHOST_kWindowOrderTop = 0,
127         GHOST_kWindowOrderBottom
128 } GHOST_TWindowOrder;
129
130
131 typedef enum {
132         GHOST_kDrawingContextTypeNone = 0,
133         GHOST_kDrawingContextTypeOpenGL
134 } GHOST_TDrawingContextType;
135
136
137 typedef enum {
138         GHOST_kButtonMaskLeft = 0,
139         GHOST_kButtonMaskMiddle,
140         GHOST_kButtonMaskRight,
141         GHOST_kButtonMaskButton4,
142         GHOST_kButtonMaskButton5,
143         GHOST_kButtonNumMasks
144 } GHOST_TButtonMask;
145
146
147 typedef enum {
148         GHOST_kEventUnknown = 0,
149
150         GHOST_kEventCursorMove,         /// Mouse move event
151         GHOST_kEventButtonDown,         /// Mouse button event
152         GHOST_kEventButtonUp,           /// Mouse button event
153         GHOST_kEventWheel,                      /// Mouse wheel event
154         GHOST_kEventTrackpad,           /// Trackpad event
155
156         GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
157         GHOST_kEventNDOFButton,         /// N degree of freedom device button event
158
159         GHOST_kEventKeyDown,
160         GHOST_kEventKeyUp,
161 //      GHOST_kEventKeyAuto,
162
163         GHOST_kEventQuit,
164
165         GHOST_kEventWindowClose,
166         GHOST_kEventWindowActivate,
167         GHOST_kEventWindowDeactivate,
168         GHOST_kEventWindowUpdate,
169         GHOST_kEventWindowSize,
170         GHOST_kEventWindowMove,
171         
172         GHOST_kEventDraggingEntered,
173         GHOST_kEventDraggingUpdated,
174         GHOST_kEventDraggingExited,
175         GHOST_kEventDraggingDropDone,
176         
177         GHOST_kEventOpenMainFile, // Needed for Cocoa to open double-clicked .blend file at startup
178
179         GHOST_kEventTimer,
180
181         GHOST_kNumEventTypes
182 } GHOST_TEventType;
183
184
185 typedef enum {
186         GHOST_kStandardCursorFirstCursor = 0,
187         GHOST_kStandardCursorDefault = 0,
188         GHOST_kStandardCursorRightArrow,
189         GHOST_kStandardCursorLeftArrow,
190         GHOST_kStandardCursorInfo, 
191         GHOST_kStandardCursorDestroy,
192         GHOST_kStandardCursorHelp,    
193         GHOST_kStandardCursorCycle,
194         GHOST_kStandardCursorSpray,
195         GHOST_kStandardCursorWait,
196         GHOST_kStandardCursorText,
197         GHOST_kStandardCursorCrosshair,
198         GHOST_kStandardCursorUpDown,
199         GHOST_kStandardCursorLeftRight,
200         GHOST_kStandardCursorTopSide,
201         GHOST_kStandardCursorBottomSide,
202         GHOST_kStandardCursorLeftSide,
203         GHOST_kStandardCursorRightSide,
204         GHOST_kStandardCursorTopLeftCorner,
205         GHOST_kStandardCursorTopRightCorner,
206         GHOST_kStandardCursorBottomRightCorner,
207         GHOST_kStandardCursorBottomLeftCorner,
208         GHOST_kStandardCursorCopy,
209         GHOST_kStandardCursorCustom, 
210         GHOST_kStandardCursorNumCursors, 
211         GHOST_kStandardCursorPencil
212 } GHOST_TStandardCursor;
213
214
215 typedef enum {
216         GHOST_kKeyUnknown = -1,
217         GHOST_kKeyBackSpace,
218         GHOST_kKeyTab,
219         GHOST_kKeyLinefeed,
220         GHOST_kKeyClear,
221         GHOST_kKeyEnter  = 0x0D,
222         
223         GHOST_kKeyEsc    = 0x1B,
224         GHOST_kKeySpace  = ' ',
225         GHOST_kKeyQuote  = 0x27,
226         GHOST_kKeyComma  = ',',
227         GHOST_kKeyMinus  = '-',
228         GHOST_kKeyPeriod = '.',
229         GHOST_kKeySlash  = '/',
230
231         // Number keys
232         GHOST_kKey0 = '0',
233         GHOST_kKey1,
234         GHOST_kKey2,
235         GHOST_kKey3,
236         GHOST_kKey4,
237         GHOST_kKey5,
238         GHOST_kKey6,
239         GHOST_kKey7,
240         GHOST_kKey8,
241         GHOST_kKey9,
242
243         GHOST_kKeySemicolon = ';',
244         GHOST_kKeyEqual     = '=',
245
246         // Character keys
247         GHOST_kKeyA = 'A',
248         GHOST_kKeyB,
249         GHOST_kKeyC,
250         GHOST_kKeyD,
251         GHOST_kKeyE,
252         GHOST_kKeyF,
253         GHOST_kKeyG,
254         GHOST_kKeyH,
255         GHOST_kKeyI,
256         GHOST_kKeyJ,
257         GHOST_kKeyK,
258         GHOST_kKeyL,
259         GHOST_kKeyM,
260         GHOST_kKeyN,
261         GHOST_kKeyO,
262         GHOST_kKeyP,
263         GHOST_kKeyQ,
264         GHOST_kKeyR,
265         GHOST_kKeyS,
266         GHOST_kKeyT,
267         GHOST_kKeyU,
268         GHOST_kKeyV,
269         GHOST_kKeyW,
270         GHOST_kKeyX,
271         GHOST_kKeyY,
272         GHOST_kKeyZ,
273
274         GHOST_kKeyLeftBracket  = '[',
275         GHOST_kKeyRightBracket = ']',
276         GHOST_kKeyBackslash    = 0x5C,
277         GHOST_kKeyAccentGrave  = '`',
278
279         
280         GHOST_kKeyLeftShift = 0x100,
281         GHOST_kKeyRightShift,
282         GHOST_kKeyLeftControl,
283         GHOST_kKeyRightControl,
284         GHOST_kKeyLeftAlt,
285         GHOST_kKeyRightAlt,
286         GHOST_kKeyOS,           // Command key on Apple, Windows key(s) on Windows
287         GHOST_kKeyGrLess ,              // German PC only!
288
289         GHOST_kKeyCapsLock,
290         GHOST_kKeyNumLock,
291         GHOST_kKeyScrollLock,
292
293         GHOST_kKeyLeftArrow,
294         GHOST_kKeyRightArrow,
295         GHOST_kKeyUpArrow,
296         GHOST_kKeyDownArrow,
297
298         GHOST_kKeyPrintScreen,
299         GHOST_kKeyPause,
300
301         GHOST_kKeyInsert,
302         GHOST_kKeyDelete,
303         GHOST_kKeyHome,
304         GHOST_kKeyEnd,
305         GHOST_kKeyUpPage,
306         GHOST_kKeyDownPage,
307
308         // Numpad keys
309         GHOST_kKeyNumpad0,
310         GHOST_kKeyNumpad1,
311         GHOST_kKeyNumpad2,
312         GHOST_kKeyNumpad3,
313         GHOST_kKeyNumpad4,
314         GHOST_kKeyNumpad5,
315         GHOST_kKeyNumpad6,
316         GHOST_kKeyNumpad7,
317         GHOST_kKeyNumpad8,
318         GHOST_kKeyNumpad9,
319         GHOST_kKeyNumpadPeriod,
320         GHOST_kKeyNumpadEnter,
321         GHOST_kKeyNumpadPlus,
322         GHOST_kKeyNumpadMinus,
323         GHOST_kKeyNumpadAsterisk,
324         GHOST_kKeyNumpadSlash,
325
326         // Function keys
327         GHOST_kKeyF1,
328         GHOST_kKeyF2,
329         GHOST_kKeyF3,
330         GHOST_kKeyF4,
331         GHOST_kKeyF5,
332         GHOST_kKeyF6,
333         GHOST_kKeyF7,
334         GHOST_kKeyF8,
335         GHOST_kKeyF9,
336         GHOST_kKeyF10,
337         GHOST_kKeyF11,
338         GHOST_kKeyF12,
339         GHOST_kKeyF13,
340         GHOST_kKeyF14,
341         GHOST_kKeyF15,
342         GHOST_kKeyF16,
343         GHOST_kKeyF17,
344         GHOST_kKeyF18,
345         GHOST_kKeyF19,
346         GHOST_kKeyF20,
347         GHOST_kKeyF21,
348         GHOST_kKeyF22,
349         GHOST_kKeyF23,
350         GHOST_kKeyF24
351 } GHOST_TKey;
352
353 typedef enum {
354         GHOST_kGrabDisable = 0, /* grab not set */
355         GHOST_kGrabNormal,      /* no cursor adjustments */
356         GHOST_kGrabWrap,                /* wrap the mouse location to prevent limiting screen bounds */
357         GHOST_kGrabHide,                /* hide the mouse while grabbing and restore the original location on release (numbuts) */
358 } GHOST_TGrabCursorMode;
359
360 typedef void* GHOST_TEventDataPtr;
361
362 typedef struct {
363         /** The x-coordinate of the cursor position. */
364         GHOST_TInt32 x;
365         /** The y-coordinate of the cursor position. */
366         GHOST_TInt32 y;
367 } GHOST_TEventCursorData;
368
369 typedef struct {
370         /** The mask of the mouse button. */
371         GHOST_TButtonMask button;
372 } GHOST_TEventButtonData;
373
374 typedef struct {
375         /** Displacement of a mouse wheel. */
376         GHOST_TInt32 z; 
377 } GHOST_TEventWheelData;
378
379 typedef enum {
380         GHOST_kTrackpadEventUnknown =0,
381         GHOST_kTrackpadEventScroll,
382         GHOST_kTrackpadEventRotate,
383         GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */
384         GHOST_kTrackpadEventMagnify
385 } GHOST_TTrackpadEventSubTypes;
386         
387
388 typedef struct {
389         /** The event subtype */
390         GHOST_TTrackpadEventSubTypes subtype;
391         /** The x-location of the trackpad event */
392         GHOST_TInt32 x;
393         /** The y-location of the trackpad event */
394         GHOST_TInt32 y;
395         /** The x-delta or value of the trackpad event */
396         GHOST_TInt32 deltaX;
397         /** The y-delta (currently only for scroll subtype) of the trackpad event */
398         GHOST_TInt32 deltaY;
399 } GHOST_TEventTrackpadData;
400
401
402 typedef enum {
403         GHOST_kDragnDropTypeUnknown =0,
404         GHOST_kDragnDropTypeFilenames, /*Array of strings representing file names (full path) */
405         GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string */
406         GHOST_kDragnDropTypeBitmap /*Bitmap image data */
407 } GHOST_TDragnDropTypes;
408
409 typedef struct {
410         /** The x-coordinate of the cursor position. */
411         GHOST_TInt32 x;
412         /** The y-coordinate of the cursor position. */
413         GHOST_TInt32 y;
414         /** The dropped item type */
415         GHOST_TDragnDropTypes dataType;
416         /** The "dropped content" */
417         GHOST_TEventDataPtr data;
418 } GHOST_TEventDragnDropData;
419
420 typedef struct {
421         int count;
422         GHOST_TUns8 **strings;
423 } GHOST_TStringArray;
424
425
426 /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
427 /* as all USB device controls are likely to use ints, this is also more future proof */
428 //typedef struct {
429 //   /** N-degree of freedom device data */
430 //   float tx, ty, tz;   /** -x left, +y up, +z forward */
431 //   float rx, ry, rz;
432 //   float dt;
433 //} GHOST_TEventNDOFData;
434
435 typedef struct {
436    /** N-degree of freedom device data v2*/
437    int changed;
438    GHOST_TUns64 client;
439    GHOST_TUns64 address;
440    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
441    GHOST_TInt16 rx, ry, rz;
442    GHOST_TInt16 buttons;
443    GHOST_TUns64 time;
444    GHOST_TUns64 delta;
445 } GHOST_TEventNDOFData;
446
447 typedef int     (*GHOST_NDOFLibraryInit_fp)(void);
448 typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
449 typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
450
451 // original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
452 // not necessary faster, but better integration with other events. 
453
454 //typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
455 //typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
456
457 typedef struct {
458         /** The key code. */
459         GHOST_TKey              key;
460         /** The ascii code for the key event ('\0' if none). */
461         char                    ascii;
462 } GHOST_TEventKeyData;
463
464 typedef struct {
465         /** Number of pixels on a line. */
466         GHOST_TUns32    xPixels;
467         /** Number of lines. */
468         GHOST_TUns32    yPixels;
469         /** Numberof bits per pixel. */
470         GHOST_TUns32    bpp;
471         /** Refresh rate (in Hertz). */
472         GHOST_TUns32    frequency;
473 } GHOST_DisplaySetting;
474
475
476 #ifdef _WIN32
477 typedef long GHOST_TEmbedderWindowID;
478 #endif // _WIN32
479
480 #ifndef _WIN32
481 // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
482 typedef int GHOST_TEmbedderWindowID;
483 #endif // _WIN32
484
485 /**
486  * A timer task callback routine.
487  * @param task The timer task object.
488  * @param time The current time.
489  */
490 #ifdef __cplusplus
491 class GHOST_ITimerTask;
492 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
493 #else
494 struct GHOST_TimerTaskHandle__;
495 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
496 #endif
497
498 #endif // _GHOST_TYPES_H_
499