1 /**************************************************************************
4 * Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
7 * Additional mouse supported added by David Megginson, 1999.
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.
24 **************************************************************************/
31 #include <simgear/compiler.h>
33 #ifdef SG_MATH_EXCEPTION_CLASH
41 #include <Main/fg_os.hxx>
43 #if defined(FX) && defined(XMESA)
44 # include <GL/xmesa.h>
52 #include <simgear/constants.h>
53 #include <simgear/debug/logstream.hxx>
54 #include <simgear/misc/sg_path.hxx>
56 #include <Include/general.hxx>
57 #include <Aircraft/aircraft.hxx>
58 #include <Aircraft/controls.hxx>
59 #include <Airports/simple.hxx>
60 #include <Cockpit/panel.hxx>
61 #include <FDM/flight.hxx>
62 #include <Main/fg_init.hxx>
63 #include <Main/fg_props.hxx>
64 #include <Main/viewmgr.hxx>
67 #include "gui_local.hxx"
72 /* --------------------------------------------------------------------
74 ---------------------------------------------------------------------*/
76 static int mouse_active = 0;
78 static int MOUSE_XSIZE = 0;
79 static int MOUSE_YSIZE = 0;
81 /* --------------------------------------------------------------------
82 Support for mouse as control yoke (david@megginson.com)
84 - right button toggles between pointer and yoke
85 - horizontal drag with no buttons moves ailerons
86 - vertical drag with no buttons moves elevators
87 - horizontal drag with left button moves brakes (left=on)
88 - vertical drag with left button moves throttle (up=more)
89 - horizontal drag with middle button moves rudder
90 - vertical drag with middle button moves trim
92 For the *_sensitivity variables, a lower number means more sensitive.
94 TODO: figure out how to keep pointer from leaving window in yoke mode.
95 TODO: add thresholds and null zones
96 TODO: sensitivity should be configurable at user option.
97 TODO: allow differential braking (this will be useful if FlightGear
98 ever supports tail-draggers like the DC-3)
99 ---------------------------------------------------------------------*/
101 MouseMode mouse_mode = MOUSE_POINTER;
103 void guiInitMouse(int width, int height)
106 MOUSE_YSIZE = height;
109 void TurnCursorOn( void )
113 switch (mouse_mode) {
115 fgSetMouseCursor(MOUSE_CURSOR_POINTER);
118 fgSetMouseCursor(MOUSE_CURSOR_CROSSHAIR);
121 fgSetMouseCursor(MOUSE_CURSOR_LEFTRIGHT);
125 #if defined(X_CURSOR_TWEAKS)
126 fgWarpMouse( MOUSE_XSIZE/2, MOUSE_YSIZE/2 );
130 void TurnCursorOff( void )
133 #if defined(WIN32_CURSOR_TWEAKS)
134 fgSetMouseCursor(MOUSE_CURSOR_NONE);
135 #elif defined(X_CURSOR_TWEAKS)
136 fgWarpMouse( MOUSE_XSIZE, MOUSE_YSIZE );
140 void maybeToggleMouse( void )
142 #if defined(WIN32_CURSOR_TWEAKS_OFF)
143 static int first_time = ~0;
144 static int mouse_changed = 0;
148 mouse_changed = ~mouse_changed;
152 if( mouse_mode != MOUSE_POINTER )
154 if( mouse_changed ) {
155 mouse_changed = ~mouse_changed;
161 first_time = ~first_time;
162 #endif // #ifdef WIN32