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 simgear::PropertyList;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
FGDeviceConfigurationMap::FGDeviceConfigurationMap()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
FGDeviceConfigurationMap::FGDeviceConfigurationMap( const string& relative_path,
|
FGDeviceConfigurationMap::FGDeviceConfigurationMap( const string& relative_path,
|
||||||
SGPropertyNode* nodePath,
|
SGPropertyNode* nodePath,
|
||||||
const std::string& nodeName)
|
const std::string& nodeName)
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
class FGDeviceConfigurationMap
|
class FGDeviceConfigurationMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FGDeviceConfigurationMap();
|
||||||
|
|
||||||
FGDeviceConfigurationMap ( const std::string& relative_path,
|
FGDeviceConfigurationMap ( const std::string& relative_path,
|
||||||
SGPropertyNode* nodePath,
|
SGPropertyNode* nodePath,
|
||||||
const std::string& nodeName);
|
const std::string& nodeName);
|
||||||
|
@ -45,6 +47,7 @@ public:
|
||||||
SGPropertyNode_ptr configurationForDeviceName(const std::string& name);
|
SGPropertyNode_ptr configurationForDeviceName(const std::string& name);
|
||||||
|
|
||||||
bool hasConfiguration(const std::string& name) const;
|
bool hasConfiguration(const std::string& name) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void scan_dir(const SGPath & path);
|
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";
|
const char * FGEventInput::PROPERTY_ROOT = "/input/event";
|
||||||
|
|
||||||
FGEventInput::FGEventInput() :
|
FGEventInput::FGEventInput()
|
||||||
configMap( "Input/Event", fgGetNode(PROPERTY_ROOT, true), "device-named")
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,6 +347,9 @@ void FGEventInput::shutdown()
|
||||||
|
|
||||||
void FGEventInput::init( )
|
void FGEventInput::init( )
|
||||||
{
|
{
|
||||||
|
configMap = FGDeviceConfigurationMap( "Input/Event",
|
||||||
|
fgGetNode(PROPERTY_ROOT, true),
|
||||||
|
"device-named");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGEventInput::postinit ()
|
void FGEventInput::postinit ()
|
||||||
|
|
|
@ -292,10 +292,10 @@ class FGEventInput : public SGSubsystem,FGCommonInput {
|
||||||
public:
|
public:
|
||||||
FGEventInput();
|
FGEventInput();
|
||||||
virtual ~FGEventInput();
|
virtual ~FGEventInput();
|
||||||
virtual void init();
|
void init() override;
|
||||||
virtual void postinit();
|
void postinit() override;
|
||||||
virtual void update( double dt );
|
void update( double dt ) override;
|
||||||
virtual void shutdown() override;
|
void shutdown() override;
|
||||||
|
|
||||||
const static unsigned MAX_DEVICES = 1000;
|
const static unsigned MAX_DEVICES = 1000;
|
||||||
const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1;
|
const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1;
|
||||||
|
|
|
@ -711,8 +711,18 @@ void FGHIDEventInput::init()
|
||||||
// requires Nasal to be running
|
// 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()
|
void FGHIDEventInput::postinit()
|
||||||
{
|
{
|
||||||
|
SG_LOG(SG_INPUT, SG_INFO, "HID event input starting up");
|
||||||
|
|
||||||
hid_init();
|
hid_init();
|
||||||
|
|
||||||
hid_device_info* devices = hid_enumerate(0 /* vendor ID */, 0 /* product ID */);
|
hid_device_info* devices = hid_enumerate(0 /* vendor ID */, 0 /* product ID */);
|
||||||
|
@ -726,6 +736,7 @@ void FGHIDEventInput::postinit()
|
||||||
|
|
||||||
void FGHIDEventInput::shutdown()
|
void FGHIDEventInput::shutdown()
|
||||||
{
|
{
|
||||||
|
SG_LOG(SG_INPUT, SG_INFO, "HID event input shutting down");
|
||||||
FGEventInput::shutdown();
|
FGEventInput::shutdown();
|
||||||
|
|
||||||
hid_exit();
|
hid_exit();
|
||||||
|
|
|
@ -35,8 +35,11 @@ public:
|
||||||
|
|
||||||
void update(double dt) override;
|
void update(double dt) override;
|
||||||
void init() override;
|
void init() override;
|
||||||
|
void reinit() override;
|
||||||
void postinit();
|
void postinit();
|
||||||
void shutdown() override;
|
void shutdown() override;
|
||||||
|
|
||||||
|
static const char* subsystemName() { return "input-hid"; }
|
||||||
private:
|
private:
|
||||||
class FGHIDEventInputPrivate;
|
class FGHIDEventInputPrivate;
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,10 @@ FGInput::FGInput ()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_HID_INPUT) && defined(WITH_EVENTINPUT)
|
#if defined(ENABLE_HID_INPUT) && defined(WITH_EVENTINPUT)
|
||||||
if (fgGetBool("/sim/input/enable-hid", true)) {
|
if (fgGetBool("/sim/input/no-hid-input", false)) {
|
||||||
set_subsystem( "input-event-hid", new FGHIDEventInput() );
|
|
||||||
} else {
|
|
||||||
SG_LOG(SG_INPUT, SG_WARN, "HID-based event input disabled");
|
SG_LOG(SG_INPUT, SG_WARN, "HID-based event input disabled");
|
||||||
|
} else {
|
||||||
|
set_subsystem( "input-event-hid", new FGHIDEventInput() );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue