Merge branch 'attenuation' into navaids-radio
This commit is contained in:
commit
d8e4f8035d
18 changed files with 185 additions and 216 deletions
|
@ -80,8 +80,11 @@ IF(APPLE)
|
||||||
list(APPEND PLATFORM_LIBS ${COCOA_LIBRARY} ${CORESERVICES_LIBRARY})
|
list(APPEND PLATFORM_LIBS ${COCOA_LIBRARY} ${CORESERVICES_LIBRARY})
|
||||||
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
# disabled while DBus / HAL / udev issues are decided
|
find_package(UDev)
|
||||||
#set(EVENT_INPUT_DEFAULT 1)
|
|
||||||
|
if(UDEV_FOUND)
|
||||||
|
set(EVENT_INPUT_DEFAULT 1)
|
||||||
|
endif(UDEV_FOUND)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
@ -160,19 +163,23 @@ endif (MSVC AND MSVC_3RDPARTY_ROOT)
|
||||||
|
|
||||||
if(EVENT_INPUT)
|
if(EVENT_INPUT)
|
||||||
message(STATUS "checking event-based Input")
|
message(STATUS "checking event-based Input")
|
||||||
|
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
find_package(DBus)
|
if(NOT UDEV_FOUND)
|
||||||
if(NOT DBUS_FOUND)
|
message(WARNING "UDev not found, event input is disabled!")
|
||||||
message(WARNING "DBus not found, event input will be disabled")
|
set(EVENT_INPUT 0)
|
||||||
set(EVENT_INPUT 0)
|
else()
|
||||||
endif()
|
set(EVENT_INPUT_LIBRARIES ${UDEV_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
message(WARNING "event input is not supported on this platform yet")
|
message(WARNING "event input is not supported on this platform yet")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Keep PLIB INPUT enabled as long as EventInput does not replace current joystick configurations.
|
||||||
|
set(ENABLE_PLIB_JOYSTICK 1)
|
||||||
else(EVENT_INPUT)
|
else(EVENT_INPUT)
|
||||||
set(ENABLE_PLIB_JOYSTICK 1)
|
set(ENABLE_PLIB_JOYSTICK 1)
|
||||||
endif(EVENT_INPUT)
|
endif(EVENT_INPUT)
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
# - Try to find the low-level D-Bus library
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# DBUS_FOUND - system has D-Bus
|
|
||||||
# DBUS_INCLUDE_DIR - the D-Bus include directory
|
|
||||||
# DBUS_ARCH_INCLUDE_DIR - the D-Bus architecture-specific include directory
|
|
||||||
# DBUS_LIBRARIES - the libraries needed to use D-Bus
|
|
||||||
|
|
||||||
# Copyright (c) 2008, Kevin Kofler, <kevin.kofler@chello.at>
|
|
||||||
# modeled after FindLibArt.cmake:
|
|
||||||
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
|
|
||||||
#
|
|
||||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
||||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
|
||||||
|
|
||||||
if (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
# in cache already
|
|
||||||
SET(DBUS_FOUND TRUE)
|
|
||||||
|
|
||||||
else (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
IF (NOT WIN32)
|
|
||||||
FIND_PACKAGE(PkgConfig)
|
|
||||||
IF (PKG_CONFIG_FOUND)
|
|
||||||
# use pkg-config to get the directories and then use these values
|
|
||||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
|
||||||
pkg_check_modules(_DBUS_PC QUIET dbus-1)
|
|
||||||
ENDIF (PKG_CONFIG_FOUND)
|
|
||||||
ENDIF (NOT WIN32)
|
|
||||||
|
|
||||||
FIND_PATH(DBUS_INCLUDE_DIR dbus/dbus.h
|
|
||||||
${_DBUS_PC_INCLUDE_DIRS}
|
|
||||||
/usr/include
|
|
||||||
/usr/include/dbus-1.0
|
|
||||||
/usr/local/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_PATH(DBUS_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h
|
|
||||||
${_DBUS_PC_INCLUDE_DIRS}
|
|
||||||
/usr/lib${LIB_SUFFIX}/include
|
|
||||||
/usr/lib${LIB_SUFFIX}/dbus-1.0/include
|
|
||||||
/usr/lib64/include
|
|
||||||
/usr/lib64/dbus-1.0/include
|
|
||||||
/usr/lib/include
|
|
||||||
/usr/lib/dbus-1.0/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(DBUS_LIBRARIES NAMES dbus-1 dbus
|
|
||||||
PATHS
|
|
||||||
${_DBUS_PC_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
set(DBUS_FOUND TRUE)
|
|
||||||
endif (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
|
|
||||||
if (DBUS_FOUND)
|
|
||||||
if (NOT DBus_FIND_QUIETLY)
|
|
||||||
message(STATUS "Found D-Bus: ${DBUS_LIBRARIES}")
|
|
||||||
endif (NOT DBus_FIND_QUIETLY)
|
|
||||||
else (DBUS_FOUND)
|
|
||||||
if (DBus_FIND_REQUIRED)
|
|
||||||
message(FATAL_ERROR "Could NOT find D-Bus")
|
|
||||||
endif (DBus_FIND_REQUIRED)
|
|
||||||
endif (DBUS_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(DBUS_INCLUDE_DIR DBUS_ARCH_INCLUDE_DIR DBUS_LIBRARIES)
|
|
||||||
|
|
||||||
endif (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES)
|
|
53
CMakeModules/FindUDev.cmake
Normal file
53
CMakeModules/FindUDev.cmake
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# Configure libudev environment
|
||||||
|
#
|
||||||
|
# UDEV_FOUND - system has a libudev
|
||||||
|
# UDEV_INCLUDE_DIR - where to find header files
|
||||||
|
# UDEV_LIBRARIES - the libraries to link against udev
|
||||||
|
# UDEV_STABLE - it's true when is the version greater or equals to 143 - version when the libudev was stabilized in its API
|
||||||
|
#
|
||||||
|
# copyright (c) 2011 Petr Vanek <petr@scribus.info>
|
||||||
|
# Redistribution and use of this file is allowed according to the terms of the BSD license.
|
||||||
|
#
|
||||||
|
|
||||||
|
FIND_PATH(
|
||||||
|
UDEV_INCLUDE_DIR
|
||||||
|
libudev.h
|
||||||
|
/usr/include
|
||||||
|
/usr/local/include
|
||||||
|
${UDEV_PATH_INCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(
|
||||||
|
UDEV_LIBRARIES
|
||||||
|
NAMES udev libudev
|
||||||
|
PATHS
|
||||||
|
/usr/${CMAKE_INSTALL_LIBDIR}
|
||||||
|
/usr/local/${CMAKE_INSTALL_LIBDIR}
|
||||||
|
${UDEV_PATH_LIB}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
|
||||||
|
SET(UDEV_FOUND "YES")
|
||||||
|
execute_process(COMMAND pkg-config --atleast-version=143 libudev RESULT_VARIABLE UDEV_STABLE)
|
||||||
|
# retvale is 0 of the condition is "true" so we need to negate the value...
|
||||||
|
if (UDEV_STABLE)
|
||||||
|
set(UDEV_STABLE 0)
|
||||||
|
else (UDEV_STABLE)
|
||||||
|
set(UDEV_STABLE 1)
|
||||||
|
endif (UDEV_STABLE)
|
||||||
|
message(STATUS "libudev stable: ${UDEV_STABLE}")
|
||||||
|
ENDIF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF (UDEV_FOUND)
|
||||||
|
MESSAGE(STATUS "Found UDev: ${UDEV_LIBRARIES}")
|
||||||
|
MESSAGE(STATUS " include: ${UDEV_INCLUDE_DIR}")
|
||||||
|
ELSE (UDEV_FOUND)
|
||||||
|
MESSAGE(STATUS "UDev not found.")
|
||||||
|
MESSAGE(STATUS "UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include")
|
||||||
|
MESSAGE(STATUS " currently found includes: ${UDEV_INCLUDE_DIR}")
|
||||||
|
MESSAGE(STATUS "UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib")
|
||||||
|
MESSAGE(STATUS " currently found libs: ${UDEV_LIBRARIES}")
|
||||||
|
IF (UDev_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR "Could not find UDev library")
|
||||||
|
ENDIF (UDev_FIND_REQUIRED)
|
||||||
|
ENDIF (UDEV_FOUND)
|
|
@ -147,7 +147,10 @@ FGAIBase::~FGAIBase() {
|
||||||
|
|
||||||
if (_refID != 0 && _refID != 1) {
|
if (_refID != 0 && _refID != 1) {
|
||||||
SGSoundMgr *smgr = globals->get_soundmgr();
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
smgr->remove("aifx:"+_refID);
|
stringstream name;
|
||||||
|
name << "aifx:";
|
||||||
|
name << _refID;
|
||||||
|
smgr->remove(name.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fp;
|
delete fp;
|
||||||
|
@ -221,10 +224,11 @@ void FGAIBase::update(double dt) {
|
||||||
_fx->set_orientation( orient );
|
_fx->set_orientation( orient );
|
||||||
|
|
||||||
SGVec3d velocity;
|
SGVec3d velocity;
|
||||||
velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec, pitch*speed );
|
velocity = SGVec3d( speed_north_deg_sec, speed_east_deg_sec,
|
||||||
|
pitch*speed );
|
||||||
_fx->set_velocity( velocity );
|
_fx->set_velocity( velocity );
|
||||||
}
|
}
|
||||||
else if (_aimodel)
|
else if ((_aimodel)&&(fgGetBool("/sim/sound/aimodels/enabled",false)))
|
||||||
{
|
{
|
||||||
string fxpath = _aimodel->get_sound_path();
|
string fxpath = _aimodel->get_sound_path();
|
||||||
if (fxpath != "")
|
if (fxpath != "")
|
||||||
|
@ -234,7 +238,10 @@ void FGAIBase::update(double dt) {
|
||||||
|
|
||||||
// initialize the sound configuration
|
// initialize the sound configuration
|
||||||
SGSoundMgr *smgr = globals->get_soundmgr();
|
SGSoundMgr *smgr = globals->get_soundmgr();
|
||||||
_fx = new FGFX(smgr, "aifx:"+_refID, props);
|
stringstream name;
|
||||||
|
name << "aifx:";
|
||||||
|
name << _refID;
|
||||||
|
_fx = new FGFX(smgr, name.str(), props);
|
||||||
_fx->init();
|
_fx->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,6 +492,8 @@ void FGAIBase::unbind() {
|
||||||
|
|
||||||
props->setBoolValue("/sim/controls/radar/", true);
|
props->setBoolValue("/sim/controls/radar/", true);
|
||||||
|
|
||||||
|
// drop reference to sound effects now
|
||||||
|
_fx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double FGAIBase::UpdateRadar(FGAIManager* manager) {
|
double FGAIBase::UpdateRadar(FGAIManager* manager) {
|
||||||
|
|
|
@ -101,6 +101,7 @@ void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) {
|
||||||
setFixedTurnRadius(scFileNode->getDoubleValue("fixed-turn-radius-ft", 500));
|
setFixedTurnRadius(scFileNode->getDoubleValue("fixed-turn-radius-ft", 500));
|
||||||
setSpeedConstant(scFileNode->getDoubleValue("speed-constant", 0.5));
|
setSpeedConstant(scFileNode->getDoubleValue("speed-constant", 0.5));
|
||||||
setSMPath(scFileNode->getStringValue("submodel-path", ""));
|
setSMPath(scFileNode->getStringValue("submodel-path", ""));
|
||||||
|
setRollFactor(scFileNode->getDoubleValue("roll-factor", 1));
|
||||||
|
|
||||||
if (!flightplan.empty()) {
|
if (!flightplan.empty()) {
|
||||||
SG_LOG(SG_AI, SG_ALERT, "getting flightplan: " << _name );
|
SG_LOG(SG_AI, SG_ALERT, "getting flightplan: " << _name );
|
||||||
|
@ -560,6 +561,10 @@ void FGAIShip::setFixedTurnRadius(double ftr) {
|
||||||
_fixed_turn_radius = ftr;
|
_fixed_turn_radius = ftr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGAIShip::setRollFactor(double rf) {
|
||||||
|
_roll_factor = rf * -0.0083335;
|
||||||
|
}
|
||||||
|
|
||||||
void FGAIShip::setInitialTunnel(bool t) {
|
void FGAIShip::setInitialTunnel(bool t) {
|
||||||
_initial_tunnel = t;
|
_initial_tunnel = t;
|
||||||
setTunnel(_initial_tunnel);
|
setTunnel(_initial_tunnel);
|
||||||
|
|
|
@ -61,11 +61,14 @@ public:
|
||||||
void setRudderConstant(double rc);
|
void setRudderConstant(double rc);
|
||||||
void setSpeedConstant(double sc);
|
void setSpeedConstant(double sc);
|
||||||
void setFixedTurnRadius(double ft);
|
void setFixedTurnRadius(double ft);
|
||||||
|
void setRollFactor(double rf);
|
||||||
|
|
||||||
void setTunnel(bool t);
|
void setTunnel(bool t);
|
||||||
void setInitialTunnel(bool t);
|
void setInitialTunnel(bool t);
|
||||||
|
|
||||||
void setWPNames();
|
void setWPNames();
|
||||||
void setWPPos();
|
void setWPPos();
|
||||||
|
|
||||||
double sign(double x);
|
double sign(double x);
|
||||||
|
|
||||||
bool _hdg_lock;
|
bool _hdg_lock;
|
||||||
|
|
|
@ -100,7 +100,7 @@ void FGATCManager::init() {
|
||||||
|
|
||||||
|
|
||||||
FGAirport *apt = FGAirport::findByIdent(airport);
|
FGAirport *apt = FGAirport::findByIdent(airport);
|
||||||
if (apt && onGround && !runway.empty()) {
|
if (apt && onGround) {// && !runway.empty()) {
|
||||||
FGAirportDynamics* dcs = apt->getDynamics();
|
FGAirportDynamics* dcs = apt->getDynamics();
|
||||||
int park_index = dcs->getNrOfParkings() - 1;
|
int park_index = dcs->getNrOfParkings() - 1;
|
||||||
//cerr << "found information: " << runway << " " << airport << ": parking = " << parking << endl;
|
//cerr << "found information: " << runway << " " << airport << ": parking = " << parking << endl;
|
||||||
|
@ -111,16 +111,21 @@ void FGATCManager::init() {
|
||||||
"Failed to find parking position " << parking <<
|
"Failed to find parking position " << parking <<
|
||||||
" at airport " << airport << " at " << SG_ORIGIN);
|
" at airport " << airport << " at " << SG_ORIGIN);
|
||||||
}
|
}
|
||||||
|
// No valid parking location, so either at the runway or at a random location.
|
||||||
if (parking.empty() || (park_index < 0)) {
|
if (parking.empty() || (park_index < 0)) {
|
||||||
controller = apt->getDynamics()->getTowerController();
|
if (!runway.empty()) {
|
||||||
int stationFreq = apt->getDynamics()->getTowerFrequency(2);
|
controller = apt->getDynamics()->getTowerController();
|
||||||
//cerr << "Setting radio frequency to in airfrequency: " << stationFreq << endl;
|
int stationFreq = apt->getDynamics()->getTowerFrequency(2);
|
||||||
fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
|
//cerr << "Setting radio frequency to in airfrequency: " << stationFreq << endl;
|
||||||
leg = 3;
|
fgSetDouble("/instrumentation/comm[0]/frequencies/selected-mhz", ((double) stationFreq / 100.0));
|
||||||
string fltType = "ga";
|
leg = 3;
|
||||||
fp->setRunway(runway);
|
string fltType = "ga";
|
||||||
fp->createTakeOff(&ai_ac, false, apt, 0, fltType);
|
fp->setRunway(runway);
|
||||||
ai_ac.setTakeOffStatus(2);
|
fp->createTakeOff(&ai_ac, false, apt, 0, fltType);
|
||||||
|
ai_ac.setTakeOffStatus(2);
|
||||||
|
} else {
|
||||||
|
// We're on the ground somewhere. Handle this case later.
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
controller = apt->getDynamics()->getStartupController();
|
controller = apt->getDynamics()->getStartupController();
|
||||||
int stationFreq = apt->getDynamics()->getGroundFrequency(1);
|
int stationFreq = apt->getDynamics()->getGroundFrequency(1);
|
||||||
|
|
|
@ -4,7 +4,7 @@ IF(APPLE)
|
||||||
set(EVENT_INPUT_SOURCES FGMacOSXEventInput.cxx)
|
set(EVENT_INPUT_SOURCES FGMacOSXEventInput.cxx)
|
||||||
set(EVENT_INPUT_HEADERS FGMacOSXEventInput.hxx)
|
set(EVENT_INPUT_HEADERS FGMacOSXEventInput.hxx)
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
message(STATUS "EventInput not implemented for Windows yet")
|
message(STATUS "EventInput not implemented for Windows yet")
|
||||||
else()
|
else()
|
||||||
set(EVENT_INPUT_SOURCES FGLinuxEventInput.cxx)
|
set(EVENT_INPUT_SOURCES FGLinuxEventInput.cxx)
|
||||||
set(EVENT_INPUT_HEADERS FGLinuxEventInput.hxx)
|
set(EVENT_INPUT_HEADERS FGLinuxEventInput.hxx)
|
||||||
|
@ -21,36 +21,37 @@ set(SOURCES
|
||||||
FGMouseInput.cxx
|
FGMouseInput.cxx
|
||||||
input.cxx
|
input.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
FGButton.hxx
|
FGButton.hxx
|
||||||
FGCommonInput.hxx
|
FGCommonInput.hxx
|
||||||
FGDeviceConfigurationMap.hxx
|
FGDeviceConfigurationMap.hxx
|
||||||
FGEventInput.hxx
|
FGEventInput.hxx
|
||||||
FGJoystickInput.hxx
|
FGJoystickInput.hxx
|
||||||
FGKeyboardInput.hxx
|
FGKeyboardInput.hxx
|
||||||
FGMouseInput.hxx
|
FGMouseInput.hxx
|
||||||
input.hxx
|
input.hxx
|
||||||
)
|
)
|
||||||
|
|
||||||
if(EVENT_INPUT)
|
if(EVENT_INPUT)
|
||||||
list(APPEND SOURCES ${EVENT_INPUT_SOURCES})
|
list(APPEND SOURCES ${EVENT_INPUT_SOURCES})
|
||||||
list(APPEND SOURCES ${EVENT_INPUT_HEADERS})
|
list(APPEND SOURCES ${EVENT_INPUT_HEADERS})
|
||||||
include_directories(${DBUS_INCLUDE_DIR} ${DBUS_ARCH_INCLUDE_DIR})
|
include_directories(${UDEV_INCLUDE_DIR})
|
||||||
|
add_definitions(-DWITH_EVENTINPUT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(FGJS_SOURCES
|
set(FGJS_SOURCES
|
||||||
fgjs.cxx
|
fgjs.cxx
|
||||||
jsinput.cxx
|
jsinput.cxx
|
||||||
jssuper.cxx
|
jssuper.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(fgjs ${FGJS_SOURCES})
|
add_executable(fgjs ${FGJS_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(fgjs
|
target_link_libraries(fgjs
|
||||||
${SIMGEAR_CORE_LIBRARIES}
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
${PLIB_LIBRARIES}
|
${PLIB_LIBRARIES}
|
||||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
||||||
add_executable(js_demo js_demo.cxx)
|
add_executable(js_demo js_demo.cxx)
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,11 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <poll.h>
|
|
||||||
#include <linux/input.h>
|
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include "FGLinuxEventInput.hxx"
|
#include "FGLinuxEventInput.hxx"
|
||||||
|
|
||||||
|
#include <libudev.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <dbus/dbus.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -445,92 +441,42 @@ void FGLinuxInputDevice::SetDevname( std::string name )
|
||||||
this->devname = name;
|
this->devname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
FGLinuxEventInput::FGLinuxEventInput() :
|
FGLinuxEventInput::FGLinuxEventInput()
|
||||||
halcontext(NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FGLinuxEventInput::~FGLinuxEventInput()
|
FGLinuxEventInput::~FGLinuxEventInput()
|
||||||
{
|
{
|
||||||
if( halcontext != NULL ) {
|
|
||||||
libhal_ctx_shutdown( halcontext, NULL);
|
|
||||||
libhal_ctx_free( halcontext );
|
|
||||||
halcontext = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
//TODO: enable hotplug support
|
|
||||||
static void DeviceAddedCallback (LibHalContext *ctx, const char *udi)
|
|
||||||
{
|
|
||||||
FGLinuxEventInput * linuxEventInput = (FGLinuxEventInput*)libhal_ctx_get_user_data (ctx);
|
|
||||||
linuxEventInput->AddHalDevice( udi );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DeviceRemovedCallback (LibHalContext *ctx, const char *udi)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void FGLinuxEventInput::postinit()
|
void FGLinuxEventInput::postinit()
|
||||||
{
|
{
|
||||||
FGEventInput::postinit();
|
FGEventInput::postinit();
|
||||||
|
|
||||||
DBusConnection * connection;
|
struct udev * udev = udev_new();
|
||||||
DBusError dbus_error;
|
|
||||||
|
|
||||||
dbus_error_init(&dbus_error);
|
struct udev_enumerate *enumerate = udev_enumerate_new(udev);
|
||||||
connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
|
udev_enumerate_add_match_subsystem(enumerate, "input");
|
||||||
if (dbus_error_is_set(&dbus_error)) {
|
udev_enumerate_scan_devices(enumerate);
|
||||||
SG_LOG( SG_INPUT, SG_ALERT, "Can't connect to system bus " << dbus_error.message);
|
struct udev_list_entry *devices = udev_enumerate_get_list_entry(enumerate);
|
||||||
dbus_error_free (&dbus_error);
|
struct udev_list_entry *dev_list_entry;
|
||||||
return;
|
|
||||||
|
udev_list_entry_foreach(dev_list_entry, devices) {
|
||||||
|
const char * path = udev_list_entry_get_name(dev_list_entry);
|
||||||
|
struct udev_device *dev = udev_device_new_from_syspath(udev, path);
|
||||||
|
const char * node = udev_device_get_devnode(dev);
|
||||||
|
|
||||||
|
dev = udev_device_get_parent( dev );
|
||||||
|
const char * name = udev_device_get_sysattr_value(dev,"name");
|
||||||
|
|
||||||
|
SG_LOG(SG_INPUT,SG_ALERT, "name=" << (name?name:"<null>") << ", node=" << (node?node:"<null>"));
|
||||||
|
if( name && node )
|
||||||
|
AddDevice( new FGLinuxInputDevice(name, node) );
|
||||||
|
|
||||||
|
udev_device_unref(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
halcontext = libhal_ctx_new();
|
udev_unref(udev);
|
||||||
|
|
||||||
libhal_ctx_set_dbus_connection (halcontext, connection );
|
|
||||||
dbus_error_init (&dbus_error);
|
|
||||||
|
|
||||||
if( libhal_ctx_init( halcontext, &dbus_error )) {
|
|
||||||
|
|
||||||
int num_devices = 0;
|
|
||||||
char ** devices = libhal_find_device_by_capability(halcontext, "input", &num_devices, NULL);
|
|
||||||
|
|
||||||
for ( int i = 0; i < num_devices; i++)
|
|
||||||
AddHalDevice( devices[i] );
|
|
||||||
|
|
||||||
libhal_free_string_array (devices);
|
|
||||||
|
|
||||||
//TODO: enable hotplug support
|
|
||||||
// libhal_ctx_set_user_data( halcontext, this );
|
|
||||||
// libhal_ctx_set_device_added( halcontext, DeviceAddedCallback );
|
|
||||||
// libhal_ctx_set_device_removed( halcontext, DeviceRemovedCallback );
|
|
||||||
} else {
|
|
||||||
if(dbus_error_is_set (&dbus_error) ) {
|
|
||||||
SG_LOG( SG_INPUT, SG_ALERT, "Can't connect to hald: " << dbus_error.message);
|
|
||||||
dbus_error_free (&dbus_error);
|
|
||||||
} else {
|
|
||||||
SG_LOG( SG_INPUT, SG_ALERT, "Can't connect to hald." );
|
|
||||||
}
|
|
||||||
|
|
||||||
libhal_ctx_free (halcontext);
|
|
||||||
halcontext = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FGLinuxEventInput::AddHalDevice( const char * udi )
|
|
||||||
{
|
|
||||||
char * device = libhal_device_get_property_string( halcontext, udi, "input.device", NULL);
|
|
||||||
char * product = libhal_device_get_property_string( halcontext, udi, "input.product", NULL);
|
|
||||||
|
|
||||||
if( product != NULL && device != NULL )
|
|
||||||
AddDevice( new FGLinuxInputDevice(product, device) );
|
|
||||||
else
|
|
||||||
SG_LOG( SG_INPUT, SG_ALERT, "Can't get device or product property of " << udi );
|
|
||||||
|
|
||||||
if( device != NULL ) libhal_free_string( device );
|
|
||||||
if( product != NULL ) libhal_free_string( product );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include "FGEventInput.hxx"
|
#include "FGEventInput.hxx"
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <hal/libhal.h>
|
|
||||||
|
|
||||||
struct FGLinuxEventData : public FGEventData {
|
struct FGLinuxEventData : public FGEventData {
|
||||||
FGLinuxEventData( struct input_event & event, double dt, int modifiers ) :
|
FGLinuxEventData( struct input_event & event, double dt, int modifiers ) :
|
||||||
|
@ -71,10 +70,7 @@ public:
|
||||||
virtual void update (double dt);
|
virtual void update (double dt);
|
||||||
virtual void postinit();
|
virtual void postinit();
|
||||||
|
|
||||||
void AddHalDevice( const char * udi );
|
|
||||||
protected:
|
protected:
|
||||||
LibHalContext *halcontext;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,12 +61,12 @@ get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS)
|
||||||
#message(STATUS "SG libs ${SIMGEAR_LIBRARIES}")
|
#message(STATUS "SG libs ${SIMGEAR_LIBRARIES}")
|
||||||
|
|
||||||
if(RTI_FOUND)
|
if(RTI_FOUND)
|
||||||
find_sg_component(hla SIMGEAR_LIBRARIES)
|
find_sg_component(hla SIMGEAR_LIBRARIES)
|
||||||
find_sg_component(rti13 SIMGEAR_LIBRARIES)
|
find_sg_component(rti13 SIMGEAR_LIBRARIES)
|
||||||
find_sg_component(rti SIMGEAR_LIBRARIES)
|
find_sg_component(rti SIMGEAR_LIBRARIES)
|
||||||
set(HLA_LIBRARIES ${RTI_LIBRARIES})
|
set(HLA_LIBRARIES ${RTI_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(HLA_LIBRARIES "")
|
set(HLA_LIBRARIES "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(fgfs
|
target_link_libraries(fgfs
|
||||||
|
@ -77,6 +77,7 @@ target_link_libraries(fgfs
|
||||||
${PLIB_LIBRARIES}
|
${PLIB_LIBRARIES}
|
||||||
${JPEG_LIBRARY}
|
${JPEG_LIBRARY}
|
||||||
${HLA_LIBRARIES}
|
${HLA_LIBRARIES}
|
||||||
|
${EVENT_INPUT_LIBRARIES}
|
||||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
|
${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
|
||||||
${PLATFORM_LIBS}
|
${PLATFORM_LIBS}
|
||||||
|
|
|
@ -171,7 +171,8 @@ FGGlobals::~FGGlobals()
|
||||||
ai->unbind();
|
ai->unbind();
|
||||||
delete ai;
|
delete ai;
|
||||||
}
|
}
|
||||||
|
SGSubsystem* sound = subsystem_mgr->remove("sound");
|
||||||
|
|
||||||
subsystem_mgr->shutdown();
|
subsystem_mgr->shutdown();
|
||||||
subsystem_mgr->unbind();
|
subsystem_mgr->unbind();
|
||||||
delete subsystem_mgr;
|
delete subsystem_mgr;
|
||||||
|
@ -205,6 +206,7 @@ FGGlobals::~FGGlobals()
|
||||||
delete tacanlist;
|
delete tacanlist;
|
||||||
delete carrierlist;
|
delete carrierlist;
|
||||||
delete channellist;
|
delete channellist;
|
||||||
|
delete sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,9 @@ FGAircraftModel::reinit()
|
||||||
void
|
void
|
||||||
FGAircraftModel::deinit()
|
FGAircraftModel::deinit()
|
||||||
{
|
{
|
||||||
|
// drop reference
|
||||||
|
_fx = 0;
|
||||||
|
|
||||||
if (!_aircraft) {
|
if (!_aircraft) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
const float THIRD = (1.0/3.0);
|
const double THIRD = (1.0/3.0);
|
||||||
const float f_0 = 47.7; // 47.7 MHz from [Alg 1.1], to convert frequency into wavenumber and vica versa
|
const double f_0 = 47.7; // 47.7 MHz from [Alg 1.1], to convert frequency into wavenumber and vica versa
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -376,14 +376,14 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
|
||||||
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
|
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
|
||||||
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
|
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
|
||||||
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
|
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
|
||||||
clutterLoss(frq_mhz, distance_m, itm_elev, materials, receiver_height, transmitter_height, p_mode, horizons, clutter_loss);
|
clutterLoss(frq_mhz, itm_elev, materials, receiver_height, transmitter_height, p_mode, horizons, clutter_loss);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
point_to_point(itm_elev, transmitter_height, receiver_height,
|
point_to_point(itm_elev, transmitter_height, receiver_height,
|
||||||
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
|
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
|
||||||
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
|
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
|
||||||
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
|
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
|
||||||
clutterLoss(frq_mhz, distance_m, itm_elev, materials, transmitter_height, receiver_height, p_mode, horizons, clutter_loss);
|
clutterLoss(frq_mhz, itm_elev, materials, transmitter_height, receiver_height, p_mode, horizons, clutter_loss);
|
||||||
}
|
}
|
||||||
|
|
||||||
double pol_loss = 0.0;
|
double pol_loss = 0.0;
|
||||||
|
@ -434,11 +434,11 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
|
||||||
* We are only worried about clutter loss, terrain influence
|
* We are only worried about clutter loss, terrain influence
|
||||||
* on the first Fresnel zone is calculated in the ITM functions
|
* on the first Fresnel zone is calculated in the ITM functions
|
||||||
***/
|
***/
|
||||||
void FGRadioTransmission::clutterLoss(double freq, double distance_m, double itm_elev[], deque<string> materials,
|
void FGRadioTransmission::clutterLoss(double freq, double itm_elev[], deque<string> materials,
|
||||||
double transmitter_height, double receiver_height, int p_mode,
|
double transmitter_height, double receiver_height, int p_mode,
|
||||||
double horizons[], double &clutter_loss) {
|
double horizons[], double &clutter_loss) {
|
||||||
|
|
||||||
distance_m = itm_elev[0] * itm_elev[1]; // only consider elevation points
|
double distance_m = itm_elev[0] * itm_elev[1]; // only consider elevation points
|
||||||
|
|
||||||
if (p_mode == 0) { // LOS: take each point and see how clutter height affects first Fresnel zone
|
if (p_mode == 0) { // LOS: take each point and see how clutter height affects first Fresnel zone
|
||||||
int mat = 0;
|
int mat = 0;
|
||||||
|
|
|
@ -58,7 +58,7 @@ private:
|
||||||
double polarization_loss();
|
double polarization_loss();
|
||||||
double ITM_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
|
double ITM_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
|
||||||
double LOS_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
|
double LOS_calculate_attenuation(SGGeod tx_pos, double freq, int ground_to_air);
|
||||||
void clutterLoss(double freq, double distance_m, double itm_elev[], std::deque<string> materials,
|
void clutterLoss(double freq, double itm_elev[], std::deque<string> materials,
|
||||||
double transmitter_height, double receiver_height, int p_mode,
|
double transmitter_height, double receiver_height, int p_mode,
|
||||||
double horizons[], double &clutter_loss);
|
double horizons[], double &clutter_loss);
|
||||||
void get_material_properties(string mat_name, double &height, double &density);
|
void get_material_properties(string mat_name, double &height, double &density);
|
||||||
|
|
|
@ -40,11 +40,21 @@
|
||||||
#include <simgear/sound/xmlsound.hxx>
|
#include <simgear/sound/xmlsound.hxx>
|
||||||
|
|
||||||
FGFX::FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props ) :
|
FGFX::FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props ) :
|
||||||
_props( props ),
|
_props( props )
|
||||||
_enabled( fgGetNode("/sim/sound/effects/enabled", true) ),
|
|
||||||
_volume( fgGetNode("/sim/sound/effects/volume", true) )
|
|
||||||
{
|
{
|
||||||
if (!props) _props = globals->get_props();
|
if (!props) {
|
||||||
|
_is_aimodel = false;
|
||||||
|
_props = globals->get_props();
|
||||||
|
_enabled = fgGetNode("/sim/sound/effects/enabled", true);
|
||||||
|
_volume = fgGetNode("/sim/sound/effects/volume", true);
|
||||||
|
} else {
|
||||||
|
_is_aimodel = true;
|
||||||
|
_enabled = _props->getNode("/sim/sound/aimodels/enabled", true);
|
||||||
|
_enabled->setBoolValue(fgGetBool("/sim/sound/effects/enabled"));
|
||||||
|
_volume = _props->getNode("/sim/sound/aimodels/volume", true);
|
||||||
|
_volume->setFloatValue(fgGetFloat("/sim/sound/effects/volume"));
|
||||||
|
_volume->setFloatValue(0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
_avionics_enabled = _props->getNode("sim/sound/avionics/enabled", true);
|
_avionics_enabled = _props->getNode("sim/sound/avionics/enabled", true);
|
||||||
_avionics_volume = _props->getNode("sim/sound/avionics/volume", true);
|
_avionics_volume = _props->getNode("sim/sound/avionics/volume", true);
|
||||||
|
@ -97,18 +107,17 @@ FGFX::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
node = root.getNode("fx");
|
node = root.getNode("fx");
|
||||||
if(node) {
|
if(node && !_is_aimodel) {
|
||||||
for (int i = 0; i < node->nChildren(); ++i) {
|
for (int i = 0; i < node->nChildren(); ++i) {
|
||||||
SGXmlSound *sound = new SGXmlSound();
|
SGXmlSound *soundfx = new SGXmlSound();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sound->init(globals->get_props(), node->getChild(i), this,
|
soundfx->init( _props, node->getChild(i), this, _avionics,
|
||||||
_avionics, path.dir());
|
path.dir() );
|
||||||
|
_sound.push_back( soundfx );
|
||||||
_sound.push_back(sound);
|
|
||||||
} catch ( sg_exception &e ) {
|
} catch ( sg_exception &e ) {
|
||||||
SG_LOG(SG_SOUND, SG_ALERT, e.getFormattedMessage());
|
SG_LOG(SG_SOUND, SG_ALERT, e.getFormattedMessage());
|
||||||
delete sound;
|
delete soundfx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool _is_aimodel;
|
||||||
SGSharedPtr<SGSampleGroup> _avionics;
|
SGSharedPtr<SGSampleGroup> _avionics;
|
||||||
std::vector<SGXmlSound *> _sound;
|
std::vector<SGXmlSound *> _sound;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue