FlightGear next
input.cxx
Go to the documentation of this file.
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, david@megginson.com
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 #elif defined(__OpenBSD__)
45 // we use HID
46 #else
47 #include "FGLinuxEventInput.hxx"
48 #define INPUTEVENT_CLASS FGLinuxEventInput
49 #endif
50
51 #if defined(ENABLE_HID_INPUT)
52 #include "FGHIDEventInput.hxx"
53 #endif
54#endif // of WITH_EVENTINPUT
55
57// Implementation of FGInput.
59
60
62{
63 if( fgGetBool("/sim/input/no-mouse-input",false) ) {
64 SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Mouse input disabled!");
65 } else {
66 set_subsystem( FGMouseInput::staticSubsystemClassId(), new FGMouseInput() );
67 }
68
69 if( fgGetBool("/sim/input/no-keyboard-input",false) ) {
70 SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Keyboard input disabled!");
71 } else {
72 set_subsystem( "input-keyboard", new FGKeyboardInput() );
73 }
74
75#if defined(ENABLE_PLIB_JOYSTICK)
76 if( fgGetBool("/sim/input/no-joystick-input",false) ) {
77 SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Joystick input disabled!");
78 } else {
79 set_subsystem( "input-joystick", new FGJoystickInput() );
80 }
81#endif
82
83#ifdef INPUTEVENT_CLASS
84 if( fgGetBool("/sim/input/no-event-input",false) ) {
85 SG_LOG(SG_INPUT,SG_MANDATORY_INFO,"Event input disabled!");
86 } else {
87 set_subsystem( "input-event", new INPUTEVENT_CLASS() );
88 }
89#endif
90
91#if defined(ENABLE_HID_INPUT) && defined(WITH_EVENTINPUT)
92 if (fgGetBool("/sim/input/no-hid-input", false)) {
93 SG_LOG(SG_INPUT, SG_MANDATORY_INFO, "HID-based event input disabled");
94 } else {
95 set_subsystem( "input-event-hid", new FGHIDEventInput() );
96 }
97#endif
98}
99
101{
102 // SGSubsystemGroup deletes all subsystem in it's destructor
103}
104
105
106// Register the subsystem.
107SGSubsystemMgr::Registrant<FGInput> registrantFGInput;
virtual ~FGInput()
Destructor.
Definition input.cxx:100
FGInput()
Default constructor.
Definition input.cxx:61
static const char * staticSubsystemClassId()
SGSubsystemMgr::Registrant< FGInput > registrantFGInput
Definition input.cxx:107
bool fgGetBool(char const *name, bool def)
Get a bool value for a property.
Definition proptest.cpp:25