From 94f745e3ea7282696b7384b3b7519a561b187589 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 23 May 2001 23:01:15 +0000 Subject: [PATCH] I'm attaching diffs to add a new FGInput module to FlightGear (src/Input). So far, FGInput replaces most of src/Main/keyboard.cxx (I've left a tiny stub); in the very near future, it will also take over control of the joystick, mouse (Norm permitting), and panel instrument interactions, so that there is a single mechanism for configuring all input devices. The new format should be (close to) self-explanatory by looking at the new base-package file keyboard.xml, which is now included by preferences.xml (I'll do the same thing for the joystick when I have a chance). I have not managed to move all keybindings into this file yet, but I've made a good start. I'm including Tony in the recipient list so that he can see how bindings can use an external XML file. This patch also adds support for multiple bindings for a single key, special keys (i.e. keypad and function keys), and key modifiers (shift/alt/ctrl); special keys use the PUI convention of adding 256 to the Glut key code. Unfortunately, everything comes with a price; in this case, I have not yet found a general mechanism for the old (hard-coded) modal bindings, which behaved differently depending on the autopilot state (i.e. left rudder or move AP heading left); with my patches, this functionality disappears, but you can still adjust the autopilot using the panel or the GUI input dialogs. --- src/Main/Makefile.am | 1 + src/Main/fg_init.cxx | 9 + src/Main/fg_props.cxx | 6 +- src/Main/fg_props.hxx | 17 +- src/Main/keyboard.cxx | 812 +++--------------------------------------- src/Makefile.am | 1 + 6 files changed, 74 insertions(+), 772 deletions(-) diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index 15af75a39..6ec4a21f9 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -75,6 +75,7 @@ fgfs_LDADD = \ $(top_builddir)/src/Objects/libObjects.a \ $(top_builddir)/src/Time/libTime.a \ $(WEATHER_LIBS) \ + $(top_builddir)/src/Input/libInput.a \ $(top_builddir)/src/Joystick/libJoystick.a \ -lsgroute -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen \ -lsgmath -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \ diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 3ffd176f4..3765b09e9 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -754,6 +755,14 @@ bool fgInitSubsystems( void ) { controls.bind(); + //////////////////////////////////////////////////////////////////// + // Initialize the input subsystem. + //////////////////////////////////////////////////////////////////// + + current_input.init(); + current_input.bind(); + + //////////////////////////////////////////////////////////////////////// // End of subsystem initialization. //////////////////////////////////////////////////////////////////// diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 3444e138b..70f5ffb38 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -1,8 +1,8 @@ -// fg_props.cxx -- support for +// fg_props.cxx -- support for FlightGear properties. // -// Written by David Megginson, started November 1999. +// Written by David Megginson, started 2000. // -// Copyright (C) 1999, 2000 David Megginson - david@megginson.com +// Copyright (C) 2000, 2001 David Megginson - david@megginson.com // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 8a6c28bcd..9e794d384 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -19,13 +19,28 @@ extern bool fgLoadFlight (istream &input); // Convenience functions for getting property values. //////////////////////////////////////////////////////////////////////// + +/** + * Get a property node. + * + * @param path The path of the node, relative to root. + * @param create true to create the node if it doesn't exist. + */ +inline SGPropertyNode * +fgGetNode (const string &path, bool create = false) +{ + return globals->get_props()->getNode(path, create); +} + + /** * Get an SGValue pointer that can be queried repeatedly. * * If the property value is going to be accessed within the loop, * it is best to use this method for maximum efficiency. */ -inline SGValue * fgGetValue (const string &name, bool create = false) +inline SGValue * +fgGetValue (const string &name, bool create = false) { return globals->get_props()->getValue(name, create); } diff --git a/src/Main/keyboard.cxx b/src/Main/keyboard.cxx index c2dc81145..7882c8ff2 100644 --- a/src/Main/keyboard.cxx +++ b/src/Main/keyboard.cxx @@ -29,796 +29,72 @@ # include #endif +#include + +#include + #include -#include -#include - -#if defined(FX) && defined(XMESA) -#include -#endif - -#include -#include - -#include STL_FSTREAM - -#include // plib include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include