| 1 | // input.cxx -- handle user input from various sources. |
| 2 | // |
| 3 | // Written by David Megginson, started May 2001. |
| 4 | // Major redesign by Torsten Dreyer, started August 2009 |
| 5 | // |
| 6 | // Copyright (C) 2001 David Megginson, [email protected] |
| 7 | // Copyright (C) 2009 Torsten Dreyer, Torsten (at) t3r _dot_ de |
| 8 | // |
| 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. |
| 13 | // |
| 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. |
| 18 | // |
| 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. |
| 22 | // |
| 23 | // $Id$ |
| 24 | |
| 25 | #include <config.h> |
| 26 | |
| 27 | #include "input.hxx" |
| 28 | |
| 29 | #include <simgear/compiler.h> |
| 30 | |
| 31 | #include <Main/fg_props.hxx> |
| 32 | #include "FGMouseInput.hxx" |
| 33 | #include "FGKeyboardInput.hxx" |
| 34 | |
| 35 | #if defined(ENABLE_PLIB_JOYSTICK) |
| 36 | #include "FGJoystickInput.hxx" |
| 37 | #endif |
| 38 | |
| 39 | #ifdef WITH_EVENTINPUT |
| 40 | #if defined ( SG_MAC ) |
| 41 | // we use HID |
| 42 | #elif defined(SG_WINDOWS) |
| 43 | // we use HID |
| 44 | #else |
| 45 | #include "FGLinuxEventInput.hxx" |
| 46 | #define INPUTEVENT_CLASS FGLinuxEventInput |
| 47 | #endif |
| 48 | |
| 49 | #if defined(ENABLE_HID_INPUT) |
| 50 | #include "FGHIDEventInput.hxx" |
| 51 | #endif |
| 52 | #endif // of WITH_EVENTINPUT |
| 53 | |
| 54 | //////////////////////////////////////////////////////////////////////// |
| 55 | // Implementation of FGInput. |
| 56 | //////////////////////////////////////////////////////////////////////// |
| 57 | |
| 58 | |
| 59 | FGInput::FGInput () |
| 60 | { |
| 61 | if( fgGetBool("/sim/input/no-mouse-input",false) ) { |
| 62 | SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Mouse input disabled!"); |
| 63 | } else { |
| 64 | set_subsystem( FGMouseInput::staticSubsystemClassId(), new FGMouseInput() ); |
| 65 | } |
| 66 | |
| 67 | if( fgGetBool("/sim/input/no-keyboard-input",false) ) { |
| 68 | SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Keyboard input disabled!"); |
| 69 | } else { |
| 70 | set_subsystem( "input-keyboard", new FGKeyboardInput() ); |
| 71 | } |
| 72 | |
| 73 | #if defined(ENABLE_PLIB_JOYSTICK) |
| 74 | if( fgGetBool("/sim/input/no-joystick-input",false) ) { |
| 75 | SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Joystick input disabled!"); |
| 76 | } else { |
| 77 | set_subsystem( "input-joystick", new FGJoystickInput() ); |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | #ifdef INPUTEVENT_CLASS |
| 82 | if( fgGetBool("/sim/input/no-event-input",false) ) { |
| 83 | SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Event input disabled!"); |
| 84 | } else { |
| 85 | set_subsystem( "input-event", new INPUTEVENT_CLASS() ); |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | #if defined(ENABLE_HID_INPUT) && defined(WITH_EVENTINPUT) |
| 90 | if (fgGetBool("/sim/input/no-hid-input", false)) { |
| 91 | SG_LOG(SG_INPUT, SG_MANDATORY_INFO, "HID-based event input disabled"); |
| 92 | } else { |
| 93 | set_subsystem( "input-event-hid", new FGHIDEventInput() ); |
| 94 | } |
| 95 | #endif |
| 96 | } |
| 97 | |
| 98 | FGInput::~FGInput () |
| 99 | { |
| 100 | // SGSubsystemGroup deletes all subsystem in it's destructor |
| 101 | } |
| 102 | |
| 103 | |
| 104 | // Register the subsystem. |
| 105 | SGSubsystemMgr::Registrant<FGInput> registrantFGInput; |