| 1 | #ifndef _FG_OS_HXX |
| 2 | #define _FG_OS_HXX |
| 3 | |
| 4 | #ifdef HAVE_CONFIG_H |
| 5 | # include <config.h> |
| 6 | #endif |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <osg/ref_ptr> |
| 12 | #include <osg/Camera> |
| 13 | #include <osg/GraphicsContext> |
| 14 | |
| 15 | #include <GUI/MouseCursor.hxx> |
| 16 | |
| 17 | enum { MOUSE_BUTTON_LEFT, |
| 18 | MOUSE_BUTTON_MIDDLE, |
| 19 | MOUSE_BUTTON_RIGHT }; |
| 20 | |
| 21 | enum { MOUSE_BUTTON_DOWN, |
| 22 | MOUSE_BUTTON_UP }; |
| 23 | |
| 24 | enum { KEYMOD_NONE = 0, |
| 25 | KEYMOD_RELEASED = 1, // Not a mod key, indicates "up" action |
| 26 | KEYMOD_SHIFT = 2, |
| 27 | KEYMOD_CTRL = 4, |
| 28 | KEYMOD_ALT = 8, |
| 29 | KEYMOD_META = 16, |
| 30 | KEYMOD_SUPER = 32, |
| 31 | KEYMOD_HYPER = 64, |
| 32 | KEYMOD_MAX = 128 }; |
| 33 | |
| 34 | // A note on key codes: none are defined here. FlightGear has no |
| 35 | // hard-coded interpretations of codes other than modifier keys, so we |
| 36 | // can get away with that. The only firm requirement is that the |
| 37 | // codes passed to the fgKeyHandler function be correctly interpreted |
| 38 | // by the PUI library. Users who need to hard-code key codes |
| 39 | // (probably not a good idea in any case) can use the pu.hxx header |
| 40 | // for definitions. |
| 41 | |
| 42 | // |
| 43 | // OS integration functions |
| 44 | // |
| 45 | |
| 46 | void fgOSInit(int* argc, char** argv); |
| 47 | void fgOSOpenWindow(bool stencil); |
| 48 | void fgOSCloseWindow(); |
| 49 | void fgOSFullScreen(); |
| 50 | int fgOSMainLoop(); |
| 51 | void fgOSExit(int code); |
| 52 | void fgOSResetProperties(); |
| 53 | |
| 54 | void fgSetMouseCursor(FGMouseCursor::Cursor cursor); |
| 55 | FGMouseCursor::Cursor fgGetMouseCursor(); |
| 56 | |
| 57 | void fgWarpMouse(int x, int y); |
| 58 | |
| 59 | int fgGetKeyModifiers(); |
| 60 | |
| 61 | // |
| 62 | // Callbacks and registration API |
| 63 | // |
| 64 | |
| 65 | namespace osg { class Camera; class GraphicsContext; } |
| 66 | namespace osgGA { class GUIEventAdapter; } |
| 67 | |
| 68 | typedef void (*fgIdleHandler)(); |
| 69 | typedef void (*fgDrawHandler)(); |
| 70 | typedef void (*fgWindowResizeHandler)(int w, int h); |
| 71 | |
| 72 | typedef void (*fgKeyHandler)(int key, int keymod, int mousex, int mousey); |
| 73 | typedef void (*fgMouseClickHandler)(int button, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter*); |
| 74 | typedef void (*fgMouseMotionHandler)(int x, int y, const osgGA::GUIEventAdapter*); |
| 75 | |
| 76 | void fgRegisterIdleHandler(fgIdleHandler func); |
| 77 | void fgRegisterDrawHandler(fgDrawHandler func); |
| 78 | void fgRegisterWindowResizeHandler(fgWindowResizeHandler func); |
| 79 | |
| 80 | void fgRegisterKeyHandler(fgKeyHandler func); |
| 81 | void fgRegisterMouseClickHandler(fgMouseClickHandler func); |
| 82 | void fgRegisterMouseMotionHandler(fgMouseMotionHandler func); |
| 83 | #endif // _FG_OS_HXX |