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