Revert "Enable compatibility with libconfig older than v1.5"
This commit is contained in:
@@ -41,7 +41,7 @@ std::shared_ptr<Action> Action::makeAction(Device *device, libconfig::Setting
|
||||
}
|
||||
|
||||
try {
|
||||
auto& action_type = setting["type"];
|
||||
auto& action_type = setting.lookup("type");
|
||||
|
||||
if(action_type.getType() != libconfig::Setting::TypeString) {
|
||||
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());
|
||||
throw InvalidAction();
|
||||
}
|
||||
}
|
||||
}
|
@@ -77,7 +77,7 @@ ChangeDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||
}
|
||||
|
||||
try {
|
||||
auto& inc = config["inc"];
|
||||
auto& inc = config.lookup("inc");
|
||||
if(inc.getType() != libconfig::Setting::TypeInt)
|
||||
logPrintf(WARN, "Line %d: inc must be an integer",
|
||||
inc.getSourceLine());
|
||||
@@ -88,7 +88,7 @@ ChangeDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||
}
|
||||
|
||||
try {
|
||||
auto& sensor = config["sensor"];
|
||||
auto& sensor = config.lookup("sensor");
|
||||
if(sensor.getType() != libconfig::Setting::TypeInt)
|
||||
logPrintf(WARN, "Line %d: sensor must be an integer",
|
||||
sensor.getSourceLine());
|
||||
@@ -106,4 +106,4 @@ uint16_t ChangeDPI::Config::interval() const
|
||||
uint8_t ChangeDPI::Config::sensor() const
|
||||
{
|
||||
return _sensor;
|
||||
}
|
||||
}
|
@@ -62,7 +62,7 @@ ChangeHostAction::Config::Config(Device *device, libconfig::Setting& config)
|
||||
: Action::Config(device)
|
||||
{
|
||||
try {
|
||||
auto& host = config["host"];
|
||||
auto& host = config.lookup("host");
|
||||
if(host.getType() == libconfig::Setting::TypeInt) {
|
||||
_offset = false;
|
||||
_host = host;
|
||||
@@ -116,4 +116,4 @@ uint8_t ChangeHostAction::Config::nextHost(hidpp20::ChangeHost::HostInfo info)
|
||||
} else
|
||||
return _host;
|
||||
}
|
||||
}
|
||||
}
|
@@ -77,7 +77,7 @@ CycleDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||
}
|
||||
|
||||
try {
|
||||
auto& sensor = config["sensor"];
|
||||
auto& sensor = config.lookup("sensor");
|
||||
if(sensor.getType() != Setting::TypeInt)
|
||||
logPrintf(WARN, "Line %d: sensor must be an integer",
|
||||
sensor.getSourceLine());
|
||||
@@ -87,7 +87,7 @@ CycleDPI::Config::Config(Device *device, libconfig::Setting &config) :
|
||||
}
|
||||
|
||||
try {
|
||||
auto& dpis = config["dpis"];
|
||||
auto& dpis = config.lookup("dpis");
|
||||
if(!dpis.isList() && !dpis.isArray()) {
|
||||
logPrintf(WARN, "Line %d: dpis must be a list or array, skipping.",
|
||||
dpis.getSourceLine());
|
||||
@@ -130,4 +130,4 @@ bool CycleDPI::Config::empty() const
|
||||
uint8_t CycleDPI::Config::sensor() const
|
||||
{
|
||||
return _sensor;
|
||||
}
|
||||
}
|
@@ -180,7 +180,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||
Action::Config(device)
|
||||
{
|
||||
try {
|
||||
auto& gestures = root["gestures"];
|
||||
auto& gestures = root.lookup("gestures");
|
||||
|
||||
if(!gestures.isList()) {
|
||||
logPrintf(WARN, "Line %d: gestures must be a list, ignoring.",
|
||||
@@ -199,7 +199,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||
|
||||
Direction d;
|
||||
try {
|
||||
auto& direction = gestures[i]["direction"];
|
||||
auto& direction = gestures[i].lookup("direction");
|
||||
if(direction.getType() != libconfig::Setting::TypeString) {
|
||||
logPrintf(WARN, "Line %d: direction must be a string, "
|
||||
"skipping.", direction.getSourceLine());
|
||||
@@ -228,7 +228,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||
|
||||
if(d == None) {
|
||||
try {
|
||||
auto& mode = gestures[i]["mode"];
|
||||
auto& mode = gestures[i].lookup("mode");
|
||||
if(mode.getType() == libconfig::Setting::TypeString) {
|
||||
std::string mode_str = mode;
|
||||
std::transform(mode_str.begin(), mode_str.end(),
|
||||
@@ -251,10 +251,10 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
|
||||
|
||||
try {
|
||||
_none_action = Action::makeAction(_device,
|
||||
gestures[i]["action"]);
|
||||
gestures[i].lookup("action"));
|
||||
} catch (InvalidAction& e) {
|
||||
logPrintf(WARN, "Line %d: %s is not a valid action, "
|
||||
"skipping.", gestures[i]["action"]
|
||||
"skipping.", gestures[i].lookup("action")
|
||||
.getSourceLine(), e.what());
|
||||
} catch (libconfig::SettingNotFoundException& e) {
|
||||
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()
|
||||
{
|
||||
return _none_action;
|
||||
}
|
||||
}
|
@@ -57,7 +57,7 @@ KeypressAction::Config::Config(Device* device, libconfig::Setting& config) :
|
||||
}
|
||||
|
||||
try {
|
||||
auto &keys = config["keys"];
|
||||
auto &keys = config.lookup("keys");
|
||||
if(keys.isArray() || keys.isList()) {
|
||||
int key_count = keys.getLength();
|
||||
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()
|
||||
{
|
||||
return _keys;
|
||||
}
|
||||
}
|
@@ -101,7 +101,7 @@ AxisGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||
Gesture::Config(device, setting, false)
|
||||
{
|
||||
try {
|
||||
auto& axis = setting["axis"];
|
||||
auto& axis = setting.lookup("axis");
|
||||
if(axis.isNumber()) {
|
||||
_axis = axis;
|
||||
} else if(axis.getType() == libconfig::Setting::TypeString) {
|
||||
@@ -123,7 +123,7 @@ AxisGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||
}
|
||||
|
||||
try {
|
||||
auto& multiplier = setting["axis_multiplier"];
|
||||
auto& multiplier = setting.lookup("axis_multiplier");
|
||||
if(multiplier.isNumber()) {
|
||||
if(multiplier.getType() == libconfig::Setting::TypeFloat)
|
||||
_multiplier = multiplier;
|
||||
@@ -168,4 +168,4 @@ void AxisGesture::Config::setHiresMultiplier(double multiplier)
|
||||
}
|
||||
|
||||
_hires_multiplier = multiplier;
|
||||
}
|
||||
}
|
@@ -38,7 +38,7 @@ Gesture::Config::Config(Device* device, libconfig::Setting& root,
|
||||
if(action_required) {
|
||||
try {
|
||||
_action = Action::makeAction(_device,
|
||||
root["action"]);
|
||||
root.lookup("action"));
|
||||
} catch (libconfig::SettingNotFoundException &e) {
|
||||
throw InvalidGesture("action is missing");
|
||||
}
|
||||
@@ -49,7 +49,7 @@ Gesture::Config::Config(Device* device, libconfig::Setting& root,
|
||||
|
||||
_threshold = LOGID_GESTURE_DEFAULT_THRESHOLD;
|
||||
try {
|
||||
auto& threshold = root["threshold"];
|
||||
auto& threshold = root.lookup("threshold");
|
||||
if(threshold.getType() == libconfig::Setting::TypeInt) {
|
||||
_threshold = (int)threshold;
|
||||
if(_threshold <= 0) {
|
||||
@@ -76,7 +76,7 @@ std::shared_ptr<Gesture> Gesture::makeGesture(Device *device,
|
||||
}
|
||||
|
||||
try {
|
||||
auto& gesture_mode = setting["mode"];
|
||||
auto& gesture_mode = setting.lookup("mode");
|
||||
|
||||
if(gesture_mode.getType() != libconfig::Setting::TypeString) {
|
||||
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()
|
||||
{
|
||||
return _action;
|
||||
}
|
||||
}
|
@@ -66,7 +66,7 @@ IntervalGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||
Gesture::Config(device, setting)
|
||||
{
|
||||
try {
|
||||
auto& interval = setting["interval"];
|
||||
auto& interval = setting.lookup("interval");
|
||||
if(interval.getType() != libconfig::Setting::TypeInt) {
|
||||
logPrintf(WARN, "Line %d: interval must be an integer, skipping.",
|
||||
interval.getSourceLine());
|
||||
@@ -76,7 +76,7 @@ IntervalGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||
} catch(libconfig::SettingNotFoundException& e) {
|
||||
try {
|
||||
// pixels is an alias for interval
|
||||
auto& interval = setting["pixels"];
|
||||
auto& interval = setting.lookup("pixels");
|
||||
if(interval.getType() != libconfig::Setting::TypeInt) {
|
||||
logPrintf(WARN, "Line %d: pixels must be an integer, skipping.",
|
||||
interval.getSourceLine());
|
||||
@@ -93,4 +93,4 @@ IntervalGesture::Config::Config(Device *device, libconfig::Setting &setting) :
|
||||
int16_t IntervalGesture::Config::interval() const
|
||||
{
|
||||
return _interval;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user