summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-07-18 10:59:50 +0200
committerDavid Härdeman <david@hardeman.nu>2015-07-18 10:59:50 +0200
commit48bd20a7b4d183edf2e19e17a3b7dc1d307ea8c1 (patch)
treea882729fc41a09c92e7641b6fbd33889bbdb1bad
parentf9bfa7645d2301fbf9de5510ad9cf4c98d8cfcea (diff)
Move rows and cols in keymap files to the description section
-rw-r--r--keymaps/default/test.layout4
-rw-r--r--keymaps/default/test2.layout4
-rw-r--r--rcm-server-keymap.c72
3 files changed, 42 insertions, 38 deletions
diff --git a/keymaps/default/test.layout b/keymaps/default/test.layout
index fabc573..3a7efa1 100644
--- a/keymaps/default/test.layout
+++ b/keymaps/default/test.layout
@@ -1,6 +1,8 @@
[Description]
Name=Samsung AA59-00581A
Description=Samsung AA59-00581A LCD/LED TV Remote Control
+Rows=8
+Cols=3
[Keymap]
Map=nec:0x01018:KEY_POWER
@@ -8,8 +10,6 @@ Map=nec:0x01017:KEY_OK
Map=nec:0x01019:KEY_TV
[Layout]
-Rows=8
-Cols=3
Button=KEY_POWER
Button=KEY_POWER
Button=KEY_POWER
diff --git a/keymaps/default/test2.layout b/keymaps/default/test2.layout
index c1ff8dc..16bfa23 100644
--- a/keymaps/default/test2.layout
+++ b/keymaps/default/test2.layout
@@ -1,6 +1,8 @@
[Description]
Name=Foobar 2000
Description=Foobar TV/AVR Universal Remote
+Rows=8
+Cols=3
[Keymap]
Map=nec:0xf00f0000:KEY_NUMERIC_0
@@ -20,8 +22,6 @@ Map=nec:0xf00f0013:KEY_LEFT
Map=nec:0xf00f0014:KEY_RIGHT
[Layout]
-Rows=8
-Cols=3
Button=KEY_NUMERIC_1
Button=KEY_NUMERIC_2
Button=KEY_NUMERIC_3
diff --git a/rcm-server-keymap.c b/rcm-server-keymap.c
index d2a01c8..b33e262 100644
--- a/rcm-server-keymap.c
+++ b/rcm-server-keymap.c
@@ -155,19 +155,46 @@ keymap_parse(FILE *fp, char **line, size_t *buf_size, struct keymap *keymap,
/* FIXME: eat RHS whitespace for p */
switch (current_section) {
case INI_SECTION_DESCRIPTION:
- if (!keymap)
- continue;
+ if (!strcasecmp(p, "Rows")) {
+ if (rows >= 0) {
+ fprintf(stderr, "Multiple rows specifications\n");
+ return -EINVAL;
+ }
+
+ r = strtol_strict(tmp, &rows);
+ if (r < 0) {
+ fprintf(stderr, "Invalid rows specification\n");
+ return -EINVAL;
+ }
+
+ } else if (!strcasecmp(p, "Cols")) {
+ if (cols >= 0) {
+ fprintf(stderr, "Multiple cols specifications\n");
+ return -EINVAL;
+ }
+
+ r = strtol_strict(tmp, &cols);
+ if (r < 0) {
+ fprintf(stderr, "Invalid cols specification\n");
+ return -EINVAL;
+ }
+
+ } else if (!strcasecmp(p, "Name")) {
+ if (keymap) {
+ keymap->name = strdup(tmp);
+ if (!keymap->name)
+ return -ENOMEM;
+ }
- if (!strcasecmp(p, "Name")) {
- keymap->name = strdup(tmp);
- if (!keymap->name)
- return -ENOMEM;
} else if (!strcasecmp(p, "Description")) {
- keymap->description = strdup(tmp);
- if (!keymap->description)
- return -ENOMEM;
+ if (keymap) {
+ keymap->description = strdup(tmp);
+ if (!keymap->description)
+ return -ENOMEM;
+ }
}
break;
+
case INI_SECTION_KEYMAP:
if (!strcasecmp(p, "Map")) {
char *protocol;
@@ -214,32 +241,9 @@ keymap_parse(FILE *fp, char **line, size_t *buf_size, struct keymap *keymap,
}
break;
- case INI_SECTION_LAYOUT:
- if (!strcasecmp(p, "Rows")) {
- if (rows >= 0) {
- fprintf(stderr, "Multiple rows specifications\n");
- return -EINVAL;
- }
-
- r = strtol_strict(tmp, &rows);
- if (r < 0) {
- fprintf(stderr, "Invalid rows specification\n");
- return -EINVAL;
- }
-
- } else if (!strcasecmp(p, "Cols")) {
- if (cols >= 0) {
- fprintf(stderr, "Multiple cols specifications\n");
- return -EINVAL;
- }
- r = strtol_strict(tmp, &cols);
- if (r < 0) {
- fprintf(stderr, "Invalid cols specification\n");
- return -EINVAL;
- }
-
- } else if (!strcasecmp(p, "Button")) {
+ case INI_SECTION_LAYOUT:
+ if (!strcasecmp(p, "Button")) {
if (keymap) {
if (!strcasecmp(tmp, "Blank"))
keymap->layout[layout_count] = NULL;