Revert "Enable compatibility with libconfig older than v1.5"

This commit is contained in:
pixl 2020-11-23 15:42:29 -05:00 committed by GitHub
parent 1d6a89881f
commit ec8115634d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 44 additions and 44 deletions

View File

@ -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()) {

View File

@ -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",
@ -76,4 +76,4 @@ std::shared_ptr<Action> Action::makeAction(Device *device, libconfig::Setting
setting.getSourceLine()); setting.getSourceLine());
throw InvalidAction(); throw InvalidAction();
} }
} }

View File

@ -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());
@ -106,4 +106,4 @@ uint16_t ChangeDPI::Config::interval() const
uint8_t ChangeDPI::Config::sensor() const uint8_t ChangeDPI::Config::sensor() const
{ {
return _sensor; return _sensor;
} }

View File

@ -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;
@ -116,4 +116,4 @@ uint8_t ChangeHostAction::Config::nextHost(hidpp20::ChangeHost::HostInfo info)
} else } else
return _host; return _host;
} }
} }

View File

@ -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());
@ -130,4 +130,4 @@ bool CycleDPI::Config::empty() const
uint8_t CycleDPI::Config::sensor() const uint8_t CycleDPI::Config::sensor() const
{ {
return _sensor; return _sensor;
} }

View File

@ -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, "
@ -288,4 +288,4 @@ std::map<GestureAction::Direction, std::shared_ptr<Gesture>>&
std::shared_ptr<Action> GestureAction::Config::noneAction() std::shared_ptr<Action> GestureAction::Config::noneAction()
{ {
return _none_action; return _none_action;
} }

View File

@ -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++) {
@ -86,4 +86,4 @@ KeypressAction::Config::Config(Device* device, libconfig::Setting& config) :
std::vector<uint>& KeypressAction::Config::keys() std::vector<uint>& KeypressAction::Config::keys()
{ {
return _keys; return _keys;
} }

View File

@ -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;
@ -168,4 +168,4 @@ void AxisGesture::Config::setHiresMultiplier(double multiplier)
} }
_hires_multiplier = multiplier; _hires_multiplier = multiplier;
} }

View File

@ -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,"
@ -118,4 +118,4 @@ int16_t Gesture::Config::threshold() const
std::shared_ptr<Action> Gesture::Config::action() std::shared_ptr<Action> Gesture::Config::action()
{ {
return _action; return _action;
} }

View File

@ -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());
@ -93,4 +93,4 @@ IntervalGesture::Config::Config(Device *device, libconfig::Setting &setting) :
int16_t IntervalGesture::Config::interval() const int16_t IntervalGesture::Config::interval() const
{ {
return _interval; return _interval;
} }

View File

@ -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()) {
@ -258,4 +258,4 @@ const std::shared_ptr<logid::actions::Gesture>&
HiresScroll::Config::downAction() const HiresScroll::Config::downAction() const
{ {
return _down_action; return _down_action;
} }

View File

@ -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());
@ -206,4 +206,4 @@ void RemapButton::Config::_parseButton(libconfig::Setting &setting)
const std::map<uint8_t, std::shared_ptr<Action>>& RemapButton::Config::buttons() const std::map<uint8_t, std::shared_ptr<Action>>& RemapButton::Config::buttons()
{ {
return _buttons; return _buttons;
} }

View File

@ -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()) {
@ -297,4 +297,4 @@ const std::shared_ptr<actions::Action>& ThumbWheel::Config::tapAction() const
const std::shared_ptr<actions::Action>& ThumbWheel::Config::touchAction() const const std::shared_ptr<actions::Action>& ThumbWheel::Config::touchAction() const
{ {
return _touch_action; return _touch_action;
} }