1 // FGMouseInput.hxx -- handle user input from mouse devices
3 // Written by Torsten Dreyer, started August 2009
4 // Based on work from David Megginson, started May 2001.
6 // Copyright (C) 2009 Torsten Dreyer, Torsten (at) t3r _dot_ de
7 // Copyright (C) 2001 David Megginson, david@megginson.com
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #ifndef _FGMOUSEINPUT_HXX
27 #define _FGMOUSEINPUT_HXX
30 # error This library requires C++
33 #include "FGCommonInput.hxx"
34 #include "FGButton.hxx"
38 #include <simgear/structure/subsystem_mgr.hxx>
39 #include <simgear/scene/util/SGPickCallback.hxx>
40 #include <Main/renderer.hxx>
42 * List of currently pressed mouse button events
44 class ActivePickCallbacks : public std::map<int, std::list<SGSharedPtr<SGPickCallback> > > {
46 void update( double dt );
47 void init( int b, const osgGA::GUIEventAdapter* ea );
51 ////////////////////////////////////////////////////////////////////////
52 // The Mouse Input Class
53 ////////////////////////////////////////////////////////////////////////
54 class FGMouseInput : public SGSubsystem,FGCommonInput {
57 virtual ~FGMouseInput();
60 virtual void update( double dt );
62 static const int MAX_MICE = 1;
63 static const int MAX_MOUSE_BUTTONS = 8;
66 void doMouseClick (int b, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter* ea);
67 void doMouseMotion (int x, int y);
68 static FGMouseInput * mouseInput;
69 static void mouseClickHandler(int button, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter*);
70 static void mouseMotionHandler(int x, int y);
72 ActivePickCallbacks activePickCallbacks;
74 * Settings for a mouse mode.
78 virtual ~mouse_mode ();
83 binding_list_t x_bindings[KEYMOD_MAX];
84 binding_list_t y_bindings[KEYMOD_MAX];
89 * Settings for a mouse.
98 SGPropertyNode_ptr mode_node;
99 SGPropertyNode_ptr mouse_button_nodes[MAX_MOUSE_BUTTONS];
107 // Map of all known cursor names
108 // This used to contain all the Glut cursors, but those are
109 // not defined by other toolkits. It now supports only the cursor
110 // images we actually use, in the interest of portability. Someday,
111 // it would be cool to write an OpenGL cursor renderer, with the
112 // cursors defined as textures referenced in the property tree. This
113 // list could then be eliminated. -Andy
115 const static struct MouseCursorMap {
118 } mouse_cursor_map[];
120 mouse bindings[MAX_MICE];