diff options
author | Mattias Andrée <maandree@kth.se> | 2022-07-27 18:07:52 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-07-27 18:07:52 +0200 |
commit | 99e4682b4c4b7c2f3e06ea53e690ef7f1bba1250 (patch) | |
tree | 071148b5032a08b713851495a9540aba27b66bac | |
parent | Add support for prefix-prefixed numerical values for reverse name-lookup (for future internal use) (diff) | |
download | libgamepad-99e4682b4c4b7c2f3e06ea53e690ef7f1bba1250.tar.gz libgamepad-99e4682b4c4b7c2f3e06ea53e690ef7f1bba1250.tar.bz2 libgamepad-99e4682b4c4b7c2f3e06ea53e690ef7f1bba1250.tar.xz |
Minor code improvement
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | libgamepad_get_absolute_axis_by_name.c | 12 | ||||
-rw-r--r-- | libgamepad_get_button_by_name.c | 12 | ||||
-rw-r--r-- | libgamepad_get_relative_axis_by_name.c | 12 |
3 files changed, 15 insertions, 21 deletions
diff --git a/libgamepad_get_absolute_axis_by_name.c b/libgamepad_get_absolute_axis_by_name.c index 69b8d6f..683dc94 100644 --- a/libgamepad_get_absolute_axis_by_name.c +++ b/libgamepad_get_absolute_axis_by_name.c @@ -21,16 +21,14 @@ libgamepad_get_absolute_axis_by_name(const char *name) } errno = saved_errno; return (int16_t)code; - } else { - if (!strncasecmp(name, "ABS_#", 5)) { - if (isdigit(name[5])) { - name = &name[5]; - goto numerical; - } + } else if (!strncasecmp(name, "ABS_#", 5)) { + if (isdigit(name[5])) { + name = &name[5]; + goto numerical; } for (code = 0; code < ELEMSOF(libgamepad_absolute_axis_names__); code++) if (!strcasecmp(name, libgamepad_absolute_axis_names__[code])) return (int16_t)code; - return -1; } + return -1; } diff --git a/libgamepad_get_button_by_name.c b/libgamepad_get_button_by_name.c index 63af9d8..b44726c 100644 --- a/libgamepad_get_button_by_name.c +++ b/libgamepad_get_button_by_name.c @@ -37,12 +37,10 @@ libgamepad_get_button_by_name(const char *name) } errno = saved_errno; return (int16_t)code; - } else { - if (!strncasecmp(name, "KEY_#", 5) || !strncasecmp(name, "BTN_#", 5)) { - if (isdigit(name[5])) { - name = &name[5]; - goto numerical; - } + } else if (!strncasecmp(name, "KEY_#", 5) || !strncasecmp(name, "BTN_#", 5)) { + if (isdigit(name[5])) { + name = &name[5]; + goto numerical; } for (code = 0; code < ELEMSOF(libgamepad_button_names__); code++) if (!strcasecmp(name, libgamepad_button_names__[code])) @@ -52,6 +50,6 @@ libgamepad_get_button_by_name(const char *name) return (int16_t)NAME; LIST_ALIASES(X) #undef X - return -1; } + return -1; } diff --git a/libgamepad_get_relative_axis_by_name.c b/libgamepad_get_relative_axis_by_name.c index 34b9827..f82ba0a 100644 --- a/libgamepad_get_relative_axis_by_name.c +++ b/libgamepad_get_relative_axis_by_name.c @@ -21,16 +21,14 @@ libgamepad_get_relative_axis_by_name(const char *name) } errno = saved_errno; return (int16_t)code; - } else { - if (!strncasecmp(name, "REL_#", 5)) { - if (isdigit(name[5])) { - name = &name[5]; - goto numerical; - } + } else if (!strncasecmp(name, "REL_#", 5)) { + if (isdigit(name[5])) { + name = &name[5]; + goto numerical; } for (code = 0; code < ELEMSOF(libgamepad_relative_axis_names__); code++) if (!strcasecmp(name, libgamepad_relative_axis_names__[code])) return (int16_t)code; - return -1; } + return -1; } |