]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_os.hxx
48a29cdc6f3cc58be0c964c097fa37a28602eea8
[flightgear.git] / src / Main / fg_os.hxx
1 #ifndef _FG_OS_HXX
2 #define _FG_OS_HXX
3
4 // Plib pui needs to know at compile time what toolkit is in use.
5 // Change this when we move to something other than glut.
6 // #define PU_USE_GLUT -- moved to configure.ac -- EMH
7 #ifdef HAVE_CONFIG_H
8 #  include <config.h>
9 #endif
10
11
12 enum { MOUSE_BUTTON_LEFT,
13        MOUSE_BUTTON_MIDDLE,
14        MOUSE_BUTTON_RIGHT };
15
16 enum { MOUSE_BUTTON_DOWN,
17        MOUSE_BUTTON_UP };
18
19 enum { MOUSE_CURSOR_NONE,
20        MOUSE_CURSOR_POINTER,
21        MOUSE_CURSOR_WAIT,
22        MOUSE_CURSOR_CROSSHAIR,
23        MOUSE_CURSOR_LEFTRIGHT };
24
25 enum { KEYMOD_NONE     = 0,
26        KEYMOD_RELEASED = 1, // Not a mod key, indicates "up" action
27        KEYMOD_SHIFT    = 2,
28        KEYMOD_CTRL     = 4,
29        KEYMOD_ALT      = 8,
30        KEYMOD_META     = 16,
31        KEYMOD_SUPER    = 32,
32        KEYMOD_HYPER    = 64,
33        KEYMOD_MAX      = 128 };
34
35 // A note on key codes: none are defined here.  FlightGear has no
36 // hard-coded interpretations of codes other than modifier keys, so we
37 // can get away with that.  The only firm requirement is that the
38 // codes passed to the fgKeyHandler function be correctly interpreted
39 // by the PUI library.  Users who need to hard-code key codes
40 // (probably not a good idea in any case) can use the pu.hxx header
41 // for definitions.
42
43 //
44 // OS integration functions
45 //
46
47 void fgOSInit(int* argc, char** argv);
48 void fgOSOpenWindow(int w, int h, int bpp, bool alpha, bool stencil,
49                     bool fullscreen);
50 void fgOSFullScreen();
51 void fgOSMainLoop();
52 void fgOSExit(int code);
53
54 void fgSetMouseCursor(int cursor);
55 int  fgGetMouseCursor();
56 void fgWarpMouse(int x, int y);
57
58 int  fgGetKeyModifiers();
59
60 void fgRequestRedraw();
61
62 //
63 // Callbacks and registration API
64 //
65
66 namespace osg { class Camera; class GraphicsContext; }
67 namespace osgGA { class GUIEventAdapter; }
68
69 typedef void (*fgIdleHandler)();
70 typedef void (*fgDrawHandler)();
71 typedef void (*fgWindowResizeHandler)(int w, int h);
72
73 typedef void (*fgKeyHandler)(int key, int keymod, int mousex, int mousey);
74 typedef void (*fgMouseClickHandler)(int button, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter*);
75 typedef void (*fgMouseMotionHandler)(int x, int y);
76
77 void fgRegisterIdleHandler(fgIdleHandler func);
78 void fgRegisterDrawHandler(fgDrawHandler func);
79 void fgRegisterWindowResizeHandler(fgWindowResizeHandler func);
80
81 void fgRegisterKeyHandler(fgKeyHandler func);
82 void fgRegisterMouseClickHandler(fgMouseClickHandler func);
83 void fgRegisterMouseMotionHandler(fgMouseMotionHandler func);
84
85 void fgMakeCurrent();
86
87 bool fgOSIsMainCamera(const osg::Camera* camera);
88 bool fgOSIsMainContext(const osg::GraphicsContext* context);
89
90 #endif // _FG_OS_HXX