evdev-touchpad: Set some options using weston.ini
This patch adds 3 new options to weston.ini to allow
the user to change default constant_accel_factor,
min_accel_factor and max_accel_factor. If no options
are set, it falls back using defaults as it did before.
v2: create weston_config_section_get_double and use it
instead of manualy converting string to double.
v3: add default values in weston_config_get_double
instead of using conditionals.
v4: don't pass diagonal as pointer.
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 4e6cf7f..f98209c 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -337,6 +337,32 @@
WL_EXPORT
int
+weston_config_section_get_double(struct weston_config_section *section,
+ const char *key,
+ double *value, double default_value)
+{
+ struct weston_config_entry *entry;
+ char *end;
+
+ entry = config_section_get_entry(section, key);
+ if (entry == NULL) {
+ *value = default_value;
+ errno = ENOENT;
+ return -1;
+ }
+
+ *value = strtod(entry->value, &end);
+ if (*end != '\0') {
+ *value = default_value;
+ errno = EINVAL;
+ return -1;
+ }
+
+ return 0;
+}
+
+WL_EXPORT
+int
weston_config_section_get_string(struct weston_config_section *section,
const char *key,
char **value, const char *default_value)