Add properties for raw axis and button values, for use
in joystick configuration function. Also rationalize references to /sim/fg-home into a global property.
This commit is contained in:
parent
ced478cf95
commit
cce186a57c
11 changed files with 42 additions and 15 deletions
|
@ -272,7 +272,7 @@ FGGroundNetwork::~FGGroundNetwork()
|
||||||
bool saveData = false;
|
bool saveData = false;
|
||||||
ofstream cachefile;
|
ofstream cachefile;
|
||||||
if (fgGetBool("/sim/ai/groundnet-cache")) {
|
if (fgGetBool("/sim/ai/groundnet-cache")) {
|
||||||
SGPath cacheData(fgGetString("/sim/fg-home"));
|
SGPath cacheData(globals->get_fg_home());
|
||||||
cacheData.append("ai");
|
cacheData.append("ai");
|
||||||
string airport = parent->getId();
|
string airport = parent->getId();
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ void FGGroundNetwork::saveElevationCache() {
|
||||||
bool saveData = false;
|
bool saveData = false;
|
||||||
ofstream cachefile;
|
ofstream cachefile;
|
||||||
if (fgGetBool("/sim/ai/groundnet-cache")) {
|
if (fgGetBool("/sim/ai/groundnet-cache")) {
|
||||||
SGPath cacheData(fgGetString("/sim/fg-home"));
|
SGPath cacheData(globals->get_fg_home());
|
||||||
cacheData.append("ai");
|
cacheData.append("ai");
|
||||||
string airport = parent->getId();
|
string airport = parent->getId();
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ void FGGroundNetwork::init()
|
||||||
//cerr << "Done initializing ground network" << endl;
|
//cerr << "Done initializing ground network" << endl;
|
||||||
//exit(1);
|
//exit(1);
|
||||||
if (fgGetBool("/sim/ai/groundnet-cache")) {
|
if (fgGetBool("/sim/ai/groundnet-cache")) {
|
||||||
SGPath cacheData(fgGetString("/sim/fg-home"));
|
SGPath cacheData(globals->get_fg_home());
|
||||||
cacheData.append("ai");
|
cacheData.append("ai");
|
||||||
string airport = parent->getId();
|
string airport = parent->getId();
|
||||||
|
|
||||||
|
|
|
@ -483,7 +483,7 @@ namespace
|
||||||
if (_path.create_dir( 0755 )) {
|
if (_path.create_dir( 0755 )) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot create screenshot directory '"
|
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot create screenshot directory '"
|
||||||
<< dir << "'. Trying home directory.");
|
<< dir << "'. Trying home directory.");
|
||||||
dir = fgGetString("/sim/fg-home");
|
dir = globals->get_fg_home();
|
||||||
}
|
}
|
||||||
|
|
||||||
char filename[24];
|
char filename[24];
|
||||||
|
@ -588,7 +588,7 @@ bool fgDumpSnapShot ()
|
||||||
if (path.create_dir( 0755 )) {
|
if (path.create_dir( 0755 )) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot create screenshot directory '"
|
SG_LOG(SG_GENERAL, SG_ALERT, "Cannot create screenshot directory '"
|
||||||
<< dir << "'. Trying home directory.");
|
<< dir << "'. Trying home directory.");
|
||||||
dir = fgGetString("/sim/fg-home");
|
dir = globals->get_fg_home();
|
||||||
}
|
}
|
||||||
|
|
||||||
char filename[24];
|
char filename[24];
|
||||||
|
|
|
@ -39,6 +39,7 @@ FGDeviceConfigurationMap::FGDeviceConfigurationMap( const char * relative_path,
|
||||||
childname(aChildname)
|
childname(aChildname)
|
||||||
{
|
{
|
||||||
int index = 1000;
|
int index = 1000;
|
||||||
|
scan_dir( SGPath(globals->get_fg_home(), relative_path), &index);
|
||||||
scan_dir( SGPath(globals->get_fg_root(), relative_path), &index);
|
scan_dir( SGPath(globals->get_fg_root(), relative_path), &index);
|
||||||
|
|
||||||
PropertyList childNodes = base->getChildren(childname);
|
PropertyList childNodes = base->getChildren(childname);
|
||||||
|
|
|
@ -104,6 +104,7 @@ void FGJoystickInput::init()
|
||||||
jsInit();
|
jsInit();
|
||||||
SG_LOG(SG_INPUT, SG_DEBUG, "Initializing joystick bindings");
|
SG_LOG(SG_INPUT, SG_DEBUG, "Initializing joystick bindings");
|
||||||
SGPropertyNode_ptr js_nodes = fgGetNode("/input/joysticks", true);
|
SGPropertyNode_ptr js_nodes = fgGetNode("/input/joysticks", true);
|
||||||
|
status_node = fgGetNode("/devices/status/joysticks", true);
|
||||||
|
|
||||||
FGDeviceConfigurationMap configMap("Input/Joysticks", js_nodes, "js-named");
|
FGDeviceConfigurationMap configMap("Input/Joysticks", js_nodes, "js-named");
|
||||||
|
|
||||||
|
@ -311,6 +312,16 @@ void FGJoystickInput::update( double dt )
|
||||||
if (js->notWorking()) // If js is disconnected
|
if (js->notWorking()) // If js is disconnected
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Update device status
|
||||||
|
SGPropertyNode_ptr status = status_node->getChild("joystick", i, true);
|
||||||
|
for (int j = 0; j < MAX_JOYSTICK_AXES; j++) {
|
||||||
|
status->getChild("axis", j, true)->setFloatValue(axis_values[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < MAX_JOYSTICK_BUTTONS; j++) {
|
||||||
|
status->getChild("button", j, true)->setBoolValue((buttons & (1u << j)) > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
// Fire bindings for the axes.
|
// Fire bindings for the axes.
|
||||||
for (int j = 0; j < bindings[i].naxes; j++) {
|
for (int j = 0; j < bindings[i].naxes; j++) {
|
||||||
axis &a = bindings[i].axes[j];
|
axis &a = bindings[i].axes[j];
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _remove(bool all);
|
void _remove(bool all);
|
||||||
|
SGPropertyNode_ptr status_node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings for a single joystick axis.
|
* Settings for a single joystick axis.
|
||||||
|
|
|
@ -407,6 +407,8 @@ bool fgInitConfig ( int argc, char **argv )
|
||||||
if (fg_home)
|
if (fg_home)
|
||||||
dataPath = fg_home;
|
dataPath = fg_home;
|
||||||
|
|
||||||
|
globals->set_fg_home(dataPath.c_str());
|
||||||
|
|
||||||
simgear::Dir exportDir(simgear::Dir(dataPath).file("Export"));
|
simgear::Dir exportDir(simgear::Dir(dataPath).file("Export"));
|
||||||
if (!exportDir.exists()) {
|
if (!exportDir.exists()) {
|
||||||
exportDir.create(0777);
|
exportDir.create(0777);
|
||||||
|
@ -589,7 +591,7 @@ static bool fgSetPosFromAirportIDandParkpos( const string& id, const string& par
|
||||||
string acOperator;
|
string acOperator;
|
||||||
SGPath acData;
|
SGPath acData;
|
||||||
try {
|
try {
|
||||||
acData = fgGetString("/sim/fg-home");
|
acData = globals->get_fg_home();
|
||||||
acData.append("aircraft-data");
|
acData.append("aircraft-data");
|
||||||
string acfile = fgGetString("/sim/aircraft") + string(".xml");
|
string acfile = fgGetString("/sim/aircraft") + string(".xml");
|
||||||
acData.append(acfile);
|
acData.append(acfile);
|
||||||
|
|
|
@ -128,6 +128,7 @@ FGGlobals::FGGlobals() :
|
||||||
event_mgr( new SGEventMgr ),
|
event_mgr( new SGEventMgr ),
|
||||||
sim_time_sec( 0.0 ),
|
sim_time_sec( 0.0 ),
|
||||||
fg_root( "" ),
|
fg_root( "" ),
|
||||||
|
fg_home( "" ),
|
||||||
time_params( NULL ),
|
time_params( NULL ),
|
||||||
ephem( NULL ),
|
ephem( NULL ),
|
||||||
mag( NULL ),
|
mag( NULL ),
|
||||||
|
@ -214,7 +215,6 @@ FGGlobals::~FGGlobals()
|
||||||
locale = NULL;
|
locale = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// set the fg_root path
|
// set the fg_root path
|
||||||
void FGGlobals::set_fg_root (const string &root) {
|
void FGGlobals::set_fg_root (const string &root) {
|
||||||
SGPath tmp(root);
|
SGPath tmp(root);
|
||||||
|
@ -242,6 +242,12 @@ void FGGlobals::set_fg_root (const string &root) {
|
||||||
simgear::ResourceManager::PRIORITY_DEFAULT);
|
simgear::ResourceManager::PRIORITY_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the fg_home path
|
||||||
|
void FGGlobals::set_fg_home (const string &home) {
|
||||||
|
SGPath tmp(home);
|
||||||
|
fg_home = tmp.realpath();
|
||||||
|
}
|
||||||
|
|
||||||
void FGGlobals::append_fg_scenery (const string &paths)
|
void FGGlobals::append_fg_scenery (const string &paths)
|
||||||
{
|
{
|
||||||
// fg_scenery.clear();
|
// fg_scenery.clear();
|
||||||
|
@ -483,7 +489,7 @@ FGGlobals::saveUserSettings()
|
||||||
// don't save settings more than once on shutdown
|
// don't save settings more than once on shutdown
|
||||||
haveUserSettings = false;
|
haveUserSettings = false;
|
||||||
|
|
||||||
SGPath autosaveFile(fgGetString("/sim/fg-home"));
|
SGPath autosaveFile(globals->get_fg_home());
|
||||||
autosaveFile.append( "autosave.xml" );
|
autosaveFile.append( "autosave.xml" );
|
||||||
autosaveFile.create_dir( 0700 );
|
autosaveFile.create_dir( 0700 );
|
||||||
SG_LOG(SG_IO, SG_INFO, "Saving user settings to " << autosaveFile.str());
|
SG_LOG(SG_IO, SG_INFO, "Saving user settings to " << autosaveFile.str());
|
||||||
|
|
|
@ -98,6 +98,9 @@ private:
|
||||||
// Root of FlightGear data tree
|
// Root of FlightGear data tree
|
||||||
std::string fg_root;
|
std::string fg_root;
|
||||||
|
|
||||||
|
// Users home directory for data
|
||||||
|
std::string fg_home;
|
||||||
|
|
||||||
// Roots of FlightGear scenery tree
|
// Roots of FlightGear scenery tree
|
||||||
string_list fg_scenery;
|
string_list fg_scenery;
|
||||||
|
|
||||||
|
@ -192,6 +195,9 @@ public:
|
||||||
inline const std::string &get_fg_root () const { return fg_root; }
|
inline const std::string &get_fg_root () const { return fg_root; }
|
||||||
void set_fg_root (const std::string &root);
|
void set_fg_root (const std::string &root);
|
||||||
|
|
||||||
|
inline const std::string &get_fg_home () const { return fg_home; }
|
||||||
|
void set_fg_home (const std::string &home);
|
||||||
|
|
||||||
inline const string_list &get_fg_scenery () const { return fg_scenery; }
|
inline const string_list &get_fg_scenery () const { return fg_scenery; }
|
||||||
void append_fg_scenery (const std::string &scenery);
|
void append_fg_scenery (const std::string &scenery);
|
||||||
|
|
||||||
|
|
|
@ -1182,7 +1182,7 @@ fgOptVersion( const char *arg )
|
||||||
cerr << "Revision: " << REVISION << endl;
|
cerr << "Revision: " << REVISION << endl;
|
||||||
cerr << "Build-Id: " << HUDSON_BUILD_ID << endl;
|
cerr << "Build-Id: " << HUDSON_BUILD_ID << endl;
|
||||||
cerr << "FG_ROOT=" << globals->get_fg_root() << endl;
|
cerr << "FG_ROOT=" << globals->get_fg_root() << endl;
|
||||||
cerr << "FG_HOME=" << fgGetString("/sim/fg-home") << endl;
|
cerr << "FG_HOME=" << globals->get_fg_home() << endl;
|
||||||
cerr << "FG_SCENERY=";
|
cerr << "FG_SCENERY=";
|
||||||
|
|
||||||
int didsome = 0;
|
int didsome = 0;
|
||||||
|
@ -2031,7 +2031,7 @@ void Options::processOptions()
|
||||||
if (fgGetBool("/sim/terrasync/enabled")) {
|
if (fgGetBool("/sim/terrasync/enabled")) {
|
||||||
string terrasyncDir = fgGetString("/sim/terrasync/scenery-dir");
|
string terrasyncDir = fgGetString("/sim/terrasync/scenery-dir");
|
||||||
if (terrasyncDir.empty()) {
|
if (terrasyncDir.empty()) {
|
||||||
SGPath p(fgGetString("/sim/fg-home"));
|
SGPath p(globals->get_fg_home());
|
||||||
p.append("TerraSync");
|
p.append("TerraSync");
|
||||||
if (!p.exists()) {
|
if (!p.exists()) {
|
||||||
simgear::Dir dd(p);
|
simgear::Dir dd(p);
|
||||||
|
|
|
@ -73,7 +73,7 @@ double FGRadioAntenna::calculate_gain(double bearing, double angle) {
|
||||||
|
|
||||||
void FGRadioAntenna::load_NEC_antenna_pattern(string type) {
|
void FGRadioAntenna::load_NEC_antenna_pattern(string type) {
|
||||||
|
|
||||||
//SGPath pattern_file(fgGetString("/sim/fg-home"));
|
//SGPath pattern_file(globals->get_fg_home());
|
||||||
SGPath pattern_file(globals->get_fg_root());
|
SGPath pattern_file(globals->get_fg_root());
|
||||||
pattern_file.append("Navaids/Antennas");
|
pattern_file.append("Navaids/Antennas");
|
||||||
pattern_file.append(type + ".txt");
|
pattern_file.append(type + ".txt");
|
||||||
|
|
|
@ -99,7 +99,7 @@ void FGTrafficManager::shutdown()
|
||||||
bool saveData = false;
|
bool saveData = false;
|
||||||
ofstream cachefile;
|
ofstream cachefile;
|
||||||
if (fgGetBool("/sim/traffic-manager/heuristics")) {
|
if (fgGetBool("/sim/traffic-manager/heuristics")) {
|
||||||
SGPath cacheData(fgGetString("/sim/fg-home"));
|
SGPath cacheData(globals->get_fg_home());
|
||||||
cacheData.append("ai");
|
cacheData.append("ai");
|
||||||
string airport = fgGetString("/sim/presets/airport-id");
|
string airport = fgGetString("/sim/presets/airport-id");
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ void FGTrafficManager::loadHeuristics()
|
||||||
HeuristicMap heurMap;
|
HeuristicMap heurMap;
|
||||||
//cerr << "Processing Heuristics" << endl;
|
//cerr << "Processing Heuristics" << endl;
|
||||||
// Load the heuristics data
|
// Load the heuristics data
|
||||||
SGPath cacheData(fgGetString("/sim/fg-home"));
|
SGPath cacheData(globals->get_fg_home());
|
||||||
cacheData.append("ai");
|
cacheData.append("ai");
|
||||||
string airport = fgGetString("/sim/presets/airport-id");
|
string airport = fgGetString("/sim/presets/airport-id");
|
||||||
if ((airport) != "") {
|
if ((airport) != "") {
|
||||||
|
|
Loading…
Add table
Reference in a new issue