From fd0dfe77e0c947e63026c944b94675018834351b Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 14 Jun 2017 21:59:30 -0700 Subject: Only complain about the first missing mapping for a given gamepad so a user does not get inundated with warning modals when their gamepad lacks a mapping entry --- io.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 8363e16..97f9d3d 100644 --- a/io.c +++ b/io.c @@ -1111,6 +1111,8 @@ typedef struct { tern_node *mousebuttons; } pad_button_state; + +static long map_warning_pad = -1; void process_pad_button(char *key, tern_val val, uint8_t valtype, void *data) { pad_button_state *state = data; @@ -1129,8 +1131,9 @@ void process_pad_button(char *key, tern_val val, uint8_t valtype, void *data) if (hostbutton < 0) { if (hostbutton == RENDER_INVALID_NAME) { warning("%s is not a valid gamepad input name\n", key); - } else if (hostbutton == RENDER_NOT_MAPPED) { - warning("No mapping exists for input %s on gamepad %d\n", key, hostpadnum); + } else if (hostbutton == RENDER_NOT_MAPPED && hostpadnum != map_warning_pad) { + warning("No SDL 2 mapping exists for input %s on gamepad %d\n", key, hostpadnum); + map_warning_pad = hostpadnum; } return; } @@ -1187,8 +1190,9 @@ void process_pad_axis(char *key, tern_val val, uint8_t valtype, void *data) if (axis < 0) { if (axis == RENDER_INVALID_NAME) { warning("%s is not a valid gamepad input name\n", key); - } else if (axis == RENDER_NOT_MAPPED) { - warning("No mapping exists for input %s on gamepad %d\n", key, hostpadnum); + } else if (axis == RENDER_NOT_MAPPED && hostpadnum != map_warning_pad) { + warning("No SDL 2 mapping exists for input %s on gamepad %d\n", key, hostpadnum); + map_warning_pad = hostpadnum; } goto done; } -- cgit v1.2.3