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 <Viewer/renderer.hxx>
43 * List of currently pressed mouse button events
45 class ActivePickCallbacks : public std::map<int, std::list<SGSharedPtr<SGPickCallback> > > {
47 void update( double dt );
48 void init( int b, const osgGA::GUIEventAdapter* ea );
52 ////////////////////////////////////////////////////////////////////////
53 // The Mouse Input Class
54 ////////////////////////////////////////////////////////////////////////
55 class FGMouseInput : public SGSubsystem,FGCommonInput {
58 virtual ~FGMouseInput();
61 virtual void update( double dt );
63 static const int MAX_MICE = 1;
64 static const int MAX_MOUSE_BUTTONS = 8;
67 void doMouseClick (int b, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter* ea);
68 void doMouseMotion (int x, int y);
69 static FGMouseInput * mouseInput;
70 static void mouseClickHandler(int button, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter*);
71 static void mouseMotionHandler(int x, int y);
73 ActivePickCallbacks activePickCallbacks;
75 * Settings for a mouse mode.
79 virtual ~mouse_mode ();
84 binding_list_t x_bindings[KEYMOD_MAX];
85 binding_list_t y_bindings[KEYMOD_MAX];
90 * Settings for a mouse.
99 SGPropertyNode_ptr mode_node;
100 SGPropertyNode_ptr mouse_button_nodes[MAX_MOUSE_BUTTONS];
108 // Map of all known cursor names
109 // This used to contain all the Glut cursors, but those are
110 // not defined by other toolkits. It now supports only the cursor
111 // images we actually use, in the interest of portability. Someday,
112 // it would be cool to write an OpenGL cursor renderer, with the
113 // cursors defined as textures referenced in the property tree. This
114 // list could then be eliminated. -Andy
116 const static struct MouseCursorMap {
119 } mouse_cursor_map[];
121 mouse bindings[MAX_MICE];
125 SGPropertyNode_ptr xSizeNode;
126 SGPropertyNode_ptr ySizeNode;
127 SGPropertyNode_ptr xAccelNode;
128 SGPropertyNode_ptr yAccelNode;
129 SGPropertyNode_ptr hideCursorNode;
130 SGPropertyNode_ptr cursorTimeoutNode;