changeset 1400:6a0e3bb6981f

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
author Michael Pavone <pavone@retrodev.com>
date Wed, 14 Jun 2017 21:59:30 -0700
parents 19044d5e388c
children b56c8c51ca5d
files io.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/io.c	Wed Jun 14 21:17:35 2017 -0700
+++ b/io.c	Wed Jun 14 21:59:30 2017 -0700
@@ -1111,6 +1111,8 @@
 	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 @@
 		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 @@
 		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;
 		}