Re-init support on HID-event-input
To ensure the device-configuration-map is re-read, added a default ctor and moved the config-map creation to init()
This commit is contained in:
parent
13857e001e
commit
0cdd6c4e70
7 changed files with 33 additions and 9 deletions
|
@ -38,6 +38,11 @@
|
|||
using simgear::PropertyList;
|
||||
using std::string;
|
||||
|
||||
FGDeviceConfigurationMap::FGDeviceConfigurationMap()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FGDeviceConfigurationMap::FGDeviceConfigurationMap( const string& relative_path,
|
||||
SGPropertyNode* nodePath,
|
||||
const std::string& nodeName)
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
class FGDeviceConfigurationMap
|
||||
{
|
||||
public:
|
||||
FGDeviceConfigurationMap();
|
||||
|
||||
FGDeviceConfigurationMap ( const std::string& relative_path,
|
||||
SGPropertyNode* nodePath,
|
||||
const std::string& nodeName);
|
||||
|
@ -45,6 +47,7 @@ public:
|
|||
SGPropertyNode_ptr configurationForDeviceName(const std::string& name);
|
||||
|
||||
bool hasConfiguration(const std::string& name) const;
|
||||
|
||||
private:
|
||||
void scan_dir(const SGPath & path);
|
||||
|
||||
|
|
|
@ -327,8 +327,7 @@ void FGInputDevice::SendFeatureReport(unsigned int reportId, const std::string&
|
|||
|
||||
const char * FGEventInput::PROPERTY_ROOT = "/input/event";
|
||||
|
||||
FGEventInput::FGEventInput() :
|
||||
configMap( "Input/Event", fgGetNode(PROPERTY_ROOT, true), "device-named")
|
||||
FGEventInput::FGEventInput()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -348,6 +347,9 @@ void FGEventInput::shutdown()
|
|||
|
||||
void FGEventInput::init( )
|
||||
{
|
||||
configMap = FGDeviceConfigurationMap( "Input/Event",
|
||||
fgGetNode(PROPERTY_ROOT, true),
|
||||
"device-named");
|
||||
}
|
||||
|
||||
void FGEventInput::postinit ()
|
||||
|
|
|
@ -292,10 +292,10 @@ class FGEventInput : public SGSubsystem,FGCommonInput {
|
|||
public:
|
||||
FGEventInput();
|
||||
virtual ~FGEventInput();
|
||||
virtual void init();
|
||||
virtual void postinit();
|
||||
virtual void update( double dt );
|
||||
virtual void shutdown() override;
|
||||
void init() override;
|
||||
void postinit() override;
|
||||
void update( double dt ) override;
|
||||
void shutdown() override;
|
||||
|
||||
const static unsigned MAX_DEVICES = 1000;
|
||||
const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1;
|
||||
|
|
|
@ -711,8 +711,18 @@ void FGHIDEventInput::init()
|
|||
// requires Nasal to be running
|
||||
}
|
||||
|
||||
void FGHIDEventInput::reinit()
|
||||
{
|
||||
SG_LOG(SG_INPUT, SG_INFO, "Re-Initializing HID input bindings");
|
||||
FGHIDEventInput::shutdown();
|
||||
FGHIDEventInput::init();
|
||||
FGHIDEventInput::postinit();
|
||||
}
|
||||
|
||||
void FGHIDEventInput::postinit()
|
||||
{
|
||||
SG_LOG(SG_INPUT, SG_INFO, "HID event input starting up");
|
||||
|
||||
hid_init();
|
||||
|
||||
hid_device_info* devices = hid_enumerate(0 /* vendor ID */, 0 /* product ID */);
|
||||
|
@ -726,6 +736,7 @@ void FGHIDEventInput::postinit()
|
|||
|
||||
void FGHIDEventInput::shutdown()
|
||||
{
|
||||
SG_LOG(SG_INPUT, SG_INFO, "HID event input shutting down");
|
||||
FGEventInput::shutdown();
|
||||
|
||||
hid_exit();
|
||||
|
|
|
@ -35,8 +35,11 @@ public:
|
|||
|
||||
void update(double dt) override;
|
||||
void init() override;
|
||||
void reinit() override;
|
||||
void postinit();
|
||||
void shutdown() override;
|
||||
|
||||
static const char* subsystemName() { return "input-hid"; }
|
||||
private:
|
||||
class FGHIDEventInputPrivate;
|
||||
|
||||
|
|
|
@ -85,10 +85,10 @@ FGInput::FGInput ()
|
|||
#endif
|
||||
|
||||
#if defined(ENABLE_HID_INPUT) && defined(WITH_EVENTINPUT)
|
||||
if (fgGetBool("/sim/input/enable-hid", true)) {
|
||||
set_subsystem( "input-event-hid", new FGHIDEventInput() );
|
||||
} else {
|
||||
if (fgGetBool("/sim/input/no-hid-input", false)) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "HID-based event input disabled");
|
||||
} else {
|
||||
set_subsystem( "input-event-hid", new FGHIDEventInput() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue