Merge pull request #159 from PixlOne/revert-157-master
Revert "Enable compatibility with libconfig older than v1.5"
This commit is contained in:
commit
1c209edaad
|
@ -98,7 +98,7 @@ Configuration::Configuration(const std::string& config_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& ignore = root["ignore"];
|
auto& ignore = root.lookup("ignore");
|
||||||
if(ignore.getType() == libconfig::Setting::TypeInt) {
|
if(ignore.getType() == libconfig::Setting::TypeInt) {
|
||||||
_ignore_list.insert((int)ignore);
|
_ignore_list.insert((int)ignore);
|
||||||
} else if(ignore.isList() || ignore.isArray()) {
|
} else if(ignore.isList() || ignore.isArray()) {
|
||||||
|
@ -116,7 +116,7 @@ Configuration::Configuration(const std::string& config_file)
|
||||||
} catch(const SettingNotFoundException& e) {
|
} catch(const SettingNotFoundException& e) {
|
||||||
// May be called blacklist
|
// May be called blacklist
|
||||||
try {
|
try {
|
||||||
auto& ignore = root["blacklist"];
|
auto& ignore = root.lookup("blacklist");
|
||||||
if(ignore.getType() == libconfig::Setting::TypeInt) {
|
if(ignore.getType() == libconfig::Setting::TypeInt) {
|
||||||
_ignore_list.insert((int)ignore);
|
_ignore_list.insert((int)ignore);
|
||||||
} else if(ignore.isList() || ignore.isArray()) {
|
} else if(ignore.isList() || ignore.isArray()) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ std::shared_ptr<Action> Action::makeAction(Device *device, libconfig::Setting
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& action_type = setting["type"];
|
auto& action_type = setting.lookup("type");
|
||||||
|
|
||||||
if(action_type.getType() != libconfig::Setting::TypeString) {
|
if(action_type.getType() != libconfig::Setting::TypeString) {
|
||||||
logPrintf(WARN, "Line %d: Action type must be a string",
|
logPrintf(WARN, "Line %d: Action type must be a string",
|
||||||
|
|
|
@ -77,7 +77,7 @@ ChangeDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& inc = config["inc"];
|
auto& inc = config.lookup("inc");
|
||||||
if(inc.getType() != libconfig::Setting::TypeInt)
|
if(inc.getType() != libconfig::Setting::TypeInt)
|
||||||
logPrintf(WARN, "Line %d: inc must be an integer",
|
logPrintf(WARN, "Line %d: inc must be an integer",
|
||||||
inc.getSourceLine());
|
inc.getSourceLine());
|
||||||
|
@ -88,7 +88,7 @@ ChangeDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& sensor = config["sensor"];
|
auto& sensor = config.lookup("sensor");
|
||||||
if(sensor.getType() != libconfig::Setting::TypeInt)
|
if(sensor.getType() != libconfig::Setting::TypeInt)
|
||||||
logPrintf(WARN, "Line %d: sensor must be an integer",
|
logPrintf(WARN, "Line %d: sensor must be an integer",
|
||||||
sensor.getSourceLine());
|
sensor.getSourceLine());
|
||||||
|
|
|
@ -62,7 +62,7 @@ ChangeHostAction::Config::Config(Device *device, libconfig::Setting& config)
|
||||||
: Action::Config(device)
|
: Action::Config(device)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto& host = config["host"];
|
auto& host = config.lookup("host");
|
||||||
if(host.getType() == libconfig::Setting::TypeInt) {
|
if(host.getType() == libconfig::Setting::TypeInt) {
|
||||||
_offset = false;
|
_offset = false;
|
||||||
_host = host;
|
_host = host;
|
||||||
|
|
|
@ -77,7 +77,7 @@ CycleDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& sensor = config["sensor"];
|
auto& sensor = config.lookup("sensor");
|
||||||
if(sensor.getType() != Setting::TypeInt)
|
if(sensor.getType() != Setting::TypeInt)
|
||||||
logPrintf(WARN, "Line %d: sensor must be an integer",
|
logPrintf(WARN, "Line %d: sensor must be an integer",
|
||||||
sensor.getSourceLine());
|
sensor.getSourceLine());
|
||||||
|
@ -87,7 +87,7 @@ CycleDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& dpis = config["dpis"];
|
auto& dpis = config.lookup("dpis");
|
||||||
if(!dpis.isList() && !dpis.isArray()) {
|
if(!dpis.isList() && !dpis.isArray()) {
|
||||||
logPrintf(WARN, "Line %d: dpis must be a list or array, skipping.",
|
logPrintf(WARN, "Line %d: dpis must be a list or array, skipping.",
|
||||||
dpis.getSourceLine());
|
dpis.getSourceLine());
|
||||||
|
|
|
@ -180,7 +180,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||||
Action::Config(device)
|
Action::Config(device)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto& gestures = root["gestures"];
|
auto& gestures = root.lookup("gestures");
|
||||||
|
|
||||||
if(!gestures.isList()) {
|
if(!gestures.isList()) {
|
||||||
logPrintf(WARN, "Line %d: gestures must be a list, ignoring.",
|
logPrintf(WARN, "Line %d: gestures must be a list, ignoring.",
|
||||||
|
@ -199,7 +199,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||||
|
|
||||||
Direction d;
|
Direction d;
|
||||||
try {
|
try {
|
||||||
auto& direction = gestures[i]["direction"];
|
auto& direction = gestures[i].lookup("direction");
|
||||||
if(direction.getType() != libconfig::Setting::TypeString) {
|
if(direction.getType() != libconfig::Setting::TypeString) {
|
||||||
logPrintf(WARN, "Line %d: direction must be a string, "
|
logPrintf(WARN, "Line %d: direction must be a string, "
|
||||||
"skipping.", direction.getSourceLine());
|
"skipping.", direction.getSourceLine());
|
||||||
|
@ -228,7 +228,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||||
|
|
||||||
if(d == None) {
|
if(d == None) {
|
||||||
try {
|
try {
|
||||||
auto& mode = gestures[i]["mode"];
|
auto& mode = gestures[i].lookup("mode");
|
||||||
if(mode.getType() == libconfig::Setting::TypeString) {
|
if(mode.getType() == libconfig::Setting::TypeString) {
|
||||||
std::string mode_str = mode;
|
std::string mode_str = mode;
|
||||||
std::transform(mode_str.begin(), mode_str.end(),
|
std::transform(mode_str.begin(), mode_str.end(),
|
||||||
|
@ -251,10 +251,10 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_none_action = Action::makeAction(_device,
|
_none_action = Action::makeAction(_device,
|
||||||
gestures[i]["action"]);
|
gestures[i].lookup("action"));
|
||||||
} catch (InvalidAction& e) {
|
} catch (InvalidAction& e) {
|
||||||
logPrintf(WARN, "Line %d: %s is not a valid action, "
|
logPrintf(WARN, "Line %d: %s is not a valid action, "
|
||||||
"skipping.", gestures[i]["action"]
|
"skipping.", gestures[i].lookup("action")
|
||||||
.getSourceLine(), e.what());
|
.getSourceLine(), e.what());
|
||||||
} catch (libconfig::SettingNotFoundException& e) {
|
} catch (libconfig::SettingNotFoundException& e) {
|
||||||
logPrintf(WARN, "Line %d: action is a required field, "
|
logPrintf(WARN, "Line %d: action is a required field, "
|
||||||
|
|
|
@ -57,7 +57,7 @@ KeypressAction::Config::Config(Device* device, libconfig::Setting& config) :
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &keys = config["keys"];
|
auto &keys = config.lookup("keys");
|
||||||
if(keys.isArray() || keys.isList()) {
|
if(keys.isArray() || keys.isList()) {
|
||||||
int key_count = keys.getLength();
|
int key_count = keys.getLength();
|
||||||
for(int i = 0; i < key_count; i++) {
|
for(int i = 0; i < key_count; i++) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ AxisGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||||
Gesture::Config(device, setting, false)
|
Gesture::Config(device, setting, false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto& axis = setting["axis"];
|
auto& axis = setting.lookup("axis");
|
||||||
if(axis.isNumber()) {
|
if(axis.isNumber()) {
|
||||||
_axis = axis;
|
_axis = axis;
|
||||||
} else if(axis.getType() == libconfig::Setting::TypeString) {
|
} else if(axis.getType() == libconfig::Setting::TypeString) {
|
||||||
|
@ -123,7 +123,7 @@ AxisGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& multiplier = setting["axis_multiplier"];
|
auto& multiplier = setting.lookup("axis_multiplier");
|
||||||
if(multiplier.isNumber()) {
|
if(multiplier.isNumber()) {
|
||||||
if(multiplier.getType() == libconfig::Setting::TypeFloat)
|
if(multiplier.getType() == libconfig::Setting::TypeFloat)
|
||||||
_multiplier = multiplier;
|
_multiplier = multiplier;
|
||||||
|
|
|
@ -38,7 +38,7 @@ Gesture::Config::Config(Device* device, libconfig::Setting& root,
|
||||||
if(action_required) {
|
if(action_required) {
|
||||||
try {
|
try {
|
||||||
_action = Action::makeAction(_device,
|
_action = Action::makeAction(_device,
|
||||||
root["action"]);
|
root.lookup("action"));
|
||||||
} catch (libconfig::SettingNotFoundException &e) {
|
} catch (libconfig::SettingNotFoundException &e) {
|
||||||
throw InvalidGesture("action is missing");
|
throw InvalidGesture("action is missing");
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ Gesture::Config::Config(Device* device, libconfig::Setting& root,
|
||||||
|
|
||||||
_threshold = LOGID_GESTURE_DEFAULT_THRESHOLD;
|
_threshold = LOGID_GESTURE_DEFAULT_THRESHOLD;
|
||||||
try {
|
try {
|
||||||
auto& threshold = root["threshold"];
|
auto& threshold = root.lookup("threshold");
|
||||||
if(threshold.getType() == libconfig::Setting::TypeInt) {
|
if(threshold.getType() == libconfig::Setting::TypeInt) {
|
||||||
_threshold = (int)threshold;
|
_threshold = (int)threshold;
|
||||||
if(_threshold <= 0) {
|
if(_threshold <= 0) {
|
||||||
|
@ -76,7 +76,7 @@ std::shared_ptr<Gesture> Gesture::makeGesture(Device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& gesture_mode = setting["mode"];
|
auto& gesture_mode = setting.lookup("mode");
|
||||||
|
|
||||||
if(gesture_mode.getType() != libconfig::Setting::TypeString) {
|
if(gesture_mode.getType() != libconfig::Setting::TypeString) {
|
||||||
logPrintf(WARN, "Line %d: Gesture mode must be a string,"
|
logPrintf(WARN, "Line %d: Gesture mode must be a string,"
|
||||||
|
|
|
@ -66,7 +66,7 @@ IntervalGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||||
Gesture::Config(device, setting)
|
Gesture::Config(device, setting)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto& interval = setting["interval"];
|
auto& interval = setting.lookup("interval");
|
||||||
if(interval.getType() != libconfig::Setting::TypeInt) {
|
if(interval.getType() != libconfig::Setting::TypeInt) {
|
||||||
logPrintf(WARN, "Line %d: interval must be an integer, skipping.",
|
logPrintf(WARN, "Line %d: interval must be an integer, skipping.",
|
||||||
interval.getSourceLine());
|
interval.getSourceLine());
|
||||||
|
@ -76,7 +76,7 @@ IntervalGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||||
} catch(libconfig::SettingNotFoundException& e) {
|
} catch(libconfig::SettingNotFoundException& e) {
|
||||||
try {
|
try {
|
||||||
// pixels is an alias for interval
|
// pixels is an alias for interval
|
||||||
auto& interval = setting["pixels"];
|
auto& interval = setting.lookup("pixels");
|
||||||
if(interval.getType() != libconfig::Setting::TypeInt) {
|
if(interval.getType() != libconfig::Setting::TypeInt) {
|
||||||
logPrintf(WARN, "Line %d: pixels must be an integer, skipping.",
|
logPrintf(WARN, "Line %d: pixels must be an integer, skipping.",
|
||||||
interval.getSourceLine());
|
interval.getSourceLine());
|
||||||
|
|
|
@ -157,7 +157,7 @@ HiresScroll::Config::Config(Device *dev) : DeviceFeature::Config(dev)
|
||||||
_mode = 0;
|
_mode = 0;
|
||||||
_mask = 0;
|
_mask = 0;
|
||||||
try {
|
try {
|
||||||
auto& hires = config_root["hires"];
|
auto& hires = config_root.lookup("hires");
|
||||||
if(hires.getType() == libconfig::Setting::TypeBoolean) {
|
if(hires.getType() == libconfig::Setting::TypeBoolean) {
|
||||||
_mask |= hidpp20::HiresScroll::Mode::HiRes;
|
_mask |= hidpp20::HiresScroll::Mode::HiRes;
|
||||||
if(hires)
|
if(hires)
|
||||||
|
@ -169,7 +169,7 @@ HiresScroll::Config::Config(Device *dev) : DeviceFeature::Config(dev)
|
||||||
} catch(libconfig::SettingNotFoundException& e) { }
|
} catch(libconfig::SettingNotFoundException& e) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& invert = config_root["invert"];
|
auto& invert = config_root.lookup("invert");
|
||||||
if(invert.getType() == libconfig::Setting::TypeBoolean) {
|
if(invert.getType() == libconfig::Setting::TypeBoolean) {
|
||||||
_mask |= hidpp20::HiresScroll::Mode::Inverted;
|
_mask |= hidpp20::HiresScroll::Mode::Inverted;
|
||||||
if(invert)
|
if(invert)
|
||||||
|
@ -181,7 +181,7 @@ HiresScroll::Config::Config(Device *dev) : DeviceFeature::Config(dev)
|
||||||
} catch(libconfig::SettingNotFoundException& e) { }
|
} catch(libconfig::SettingNotFoundException& e) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& target = config_root["target"];
|
auto& target = config_root.lookup("target");
|
||||||
if(target.getType() == libconfig::Setting::TypeBoolean) {
|
if(target.getType() == libconfig::Setting::TypeBoolean) {
|
||||||
_mask |= hidpp20::HiresScroll::Mode::Target;
|
_mask |= hidpp20::HiresScroll::Mode::Target;
|
||||||
if(target)
|
if(target)
|
||||||
|
@ -194,7 +194,7 @@ HiresScroll::Config::Config(Device *dev) : DeviceFeature::Config(dev)
|
||||||
|
|
||||||
if(_mode & hidpp20::HiresScroll::Mode::Target) {
|
if(_mode & hidpp20::HiresScroll::Mode::Target) {
|
||||||
try {
|
try {
|
||||||
auto& up = config_root["up"];
|
auto& up = config_root.lookup("up");
|
||||||
try {
|
try {
|
||||||
auto g = actions::Gesture::makeGesture(dev, up);
|
auto g = actions::Gesture::makeGesture(dev, up);
|
||||||
if(g->wheelCompatibility()) {
|
if(g->wheelCompatibility()) {
|
||||||
|
@ -214,7 +214,7 @@ HiresScroll::Config::Config(Device *dev) : DeviceFeature::Config(dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& down = config_root["down"];
|
auto& down = config_root.lookup("down");
|
||||||
try {
|
try {
|
||||||
auto g = actions::Gesture::makeGesture(dev, down);
|
auto g = actions::Gesture::makeGesture(dev, down);
|
||||||
if(g->wheelCompatibility()) {
|
if(g->wheelCompatibility()) {
|
||||||
|
|
|
@ -178,7 +178,7 @@ void RemapButton::Config::_parseButton(libconfig::Setting &setting)
|
||||||
|
|
||||||
uint16_t cid;
|
uint16_t cid;
|
||||||
try {
|
try {
|
||||||
auto& cid_setting = setting["cid"];
|
auto& cid_setting = setting.lookup("cid");
|
||||||
if(!cid_setting.isNumber()) {
|
if(!cid_setting.isNumber()) {
|
||||||
logPrintf(WARN, "Line %d: cid must be a number, ignoring.",
|
logPrintf(WARN, "Line %d: cid must be a number, ignoring.",
|
||||||
cid_setting.getSourceLine());
|
cid_setting.getSourceLine());
|
||||||
|
@ -193,7 +193,7 @@ void RemapButton::Config::_parseButton(libconfig::Setting &setting)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_buttons.emplace(cid, Action::makeAction(_device,
|
_buttons.emplace(cid, Action::makeAction(_device,
|
||||||
setting["action"]));
|
setting.lookup("action")));
|
||||||
} catch(libconfig::SettingNotFoundException& e) {
|
} catch(libconfig::SettingNotFoundException& e) {
|
||||||
logPrintf(WARN, "Line %d: action is required, ignoring.",
|
logPrintf(WARN, "Line %d: action is required, ignoring.",
|
||||||
setting.getSourceLine());
|
setting.getSourceLine());
|
||||||
|
|
|
@ -184,7 +184,7 @@ ThumbWheel::Config::Config(Device* dev) : DeviceFeature::Config(dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& divert = config_root["divert"];
|
auto& divert = config_root.lookup("divert");
|
||||||
if(divert.getType() == libconfig::Setting::TypeBoolean) {
|
if(divert.getType() == libconfig::Setting::TypeBoolean) {
|
||||||
_divert = divert;
|
_divert = divert;
|
||||||
} else {
|
} else {
|
||||||
|
@ -194,7 +194,7 @@ ThumbWheel::Config::Config(Device* dev) : DeviceFeature::Config(dev)
|
||||||
} catch(libconfig::SettingNotFoundException& e) { }
|
} catch(libconfig::SettingNotFoundException& e) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto& invert = config_root["invert"];
|
auto& invert = config_root.lookup("invert");
|
||||||
if(invert.getType() == libconfig::Setting::TypeBoolean) {
|
if(invert.getType() == libconfig::Setting::TypeBoolean) {
|
||||||
_invert = invert;
|
_invert = invert;
|
||||||
} else {
|
} else {
|
||||||
|
@ -227,7 +227,7 @@ std::shared_ptr<actions::Action> ThumbWheel::Config::_genAction(Device* dev,
|
||||||
libconfig::Setting& config_root, const std::string& name)
|
libconfig::Setting& config_root, const std::string& name)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto& a_group = config_root[name];
|
auto& a_group = config_root.lookup(name);
|
||||||
try {
|
try {
|
||||||
return actions::Action::makeAction(dev, a_group);
|
return actions::Action::makeAction(dev, a_group);
|
||||||
} catch(actions::InvalidAction& e) {
|
} catch(actions::InvalidAction& e) {
|
||||||
|
@ -244,7 +244,7 @@ std::shared_ptr<actions::Gesture> ThumbWheel::Config::_genGesture(Device* dev,
|
||||||
libconfig::Setting& config_root, const std::string& name)
|
libconfig::Setting& config_root, const std::string& name)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto& g_group = config_root[name];
|
auto& g_group = config_root.lookup(name);
|
||||||
try {
|
try {
|
||||||
auto g = actions::Gesture::makeGesture(dev, g_group);
|
auto g = actions::Gesture::makeGesture(dev, g_group);
|
||||||
if(g->wheelCompatibility()) {
|
if(g->wheelCompatibility()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user