comparison io.c @ 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 08116cb5ffaa
children 4e5797b3935a
comparison
equal deleted inserted replaced
1399:19044d5e388c 1400:6a0e3bb6981f
1109 int padnum; 1109 int padnum;
1110 tern_node *padbuttons; 1110 tern_node *padbuttons;
1111 tern_node *mousebuttons; 1111 tern_node *mousebuttons;
1112 } pad_button_state; 1112 } pad_button_state;
1113 1113
1114
1115 static long map_warning_pad = -1;
1114 void process_pad_button(char *key, tern_val val, uint8_t valtype, void *data) 1116 void process_pad_button(char *key, tern_val val, uint8_t valtype, void *data)
1115 { 1117 {
1116 pad_button_state *state = data; 1118 pad_button_state *state = data;
1117 int hostpadnum = state->padnum; 1119 int hostpadnum = state->padnum;
1118 int ui_func, padnum, button; 1120 int ui_func, padnum, button;
1127 //key is not a valid base 10 integer 1129 //key is not a valid base 10 integer
1128 hostbutton = render_translate_input_name(hostpadnum, key, 0); 1130 hostbutton = render_translate_input_name(hostpadnum, key, 0);
1129 if (hostbutton < 0) { 1131 if (hostbutton < 0) {
1130 if (hostbutton == RENDER_INVALID_NAME) { 1132 if (hostbutton == RENDER_INVALID_NAME) {
1131 warning("%s is not a valid gamepad input name\n", key); 1133 warning("%s is not a valid gamepad input name\n", key);
1132 } else if (hostbutton == RENDER_NOT_MAPPED) { 1134 } else if (hostbutton == RENDER_NOT_MAPPED && hostpadnum != map_warning_pad) {
1133 warning("No mapping exists for input %s on gamepad %d\n", key, hostpadnum); 1135 warning("No SDL 2 mapping exists for input %s on gamepad %d\n", key, hostpadnum);
1136 map_warning_pad = hostpadnum;
1134 } 1137 }
1135 return; 1138 return;
1136 } 1139 }
1137 if (hostbutton & RENDER_DPAD_BIT) { 1140 if (hostbutton & RENDER_DPAD_BIT) {
1138 if (bindtype == BIND_GAMEPAD1) { 1141 if (bindtype == BIND_GAMEPAD1) {
1185 //key is not a valid base 10 integer 1188 //key is not a valid base 10 integer
1186 axis = render_translate_input_name(hostpadnum, key, 1); 1189 axis = render_translate_input_name(hostpadnum, key, 1);
1187 if (axis < 0) { 1190 if (axis < 0) {
1188 if (axis == RENDER_INVALID_NAME) { 1191 if (axis == RENDER_INVALID_NAME) {
1189 warning("%s is not a valid gamepad input name\n", key); 1192 warning("%s is not a valid gamepad input name\n", key);
1190 } else if (axis == RENDER_NOT_MAPPED) { 1193 } else if (axis == RENDER_NOT_MAPPED && hostpadnum != map_warning_pad) {
1191 warning("No mapping exists for input %s on gamepad %d\n", key, hostpadnum); 1194 warning("No SDL 2 mapping exists for input %s on gamepad %d\n", key, hostpadnum);
1195 map_warning_pad = hostpadnum;
1192 } 1196 }
1193 goto done; 1197 goto done;
1194 } 1198 }
1195 if (axis & RENDER_DPAD_BIT) { 1199 if (axis & RENDER_DPAD_BIT) {
1196 if (bindtype == BIND_GAMEPAD1) { 1200 if (bindtype == BIND_GAMEPAD1) {