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