comparison controller_info.c @ 1608:419a0a133b5c

Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
author Michael Pavone <pavone@retrodev.com>
date Fri, 03 Aug 2018 19:32:21 -0700
parents 68b05322d971
children 84ef1eb2c96a
comparison
equal deleted inserted replaced
1607:0174759e559f 1608:419a0a133b5c
259 } else { 259 } else {
260 return label_source(info)[axis - SDL_CONTROLLER_AXIS_TRIGGERLEFT + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER + 1]; 260 return label_source(info)[axis - SDL_CONTROLLER_AXIS_TRIGGERLEFT + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER + 1];
261 } 261 }
262 } 262 }
263 263
264 char *make_controller_type_key(controller_info *info)
265 {
266 const char *subtype;
267 if (info->subtype == SUBTYPE_UNKNOWN) {
268 switch(info->type)
269 {
270 case TYPE_XBOX:
271 subtype = subtype_names[SUBTYPE_X360];
272 break;
273 case TYPE_PSX:
274 subtype = subtype_names[SUBTYPE_PS4];
275 break;
276 case TYPE_NINTENDO:
277 subtype = subtype_names[SUBTYPE_SWITCH];
278 break;
279 default:
280 subtype = "unknown";
281 }
282 } else {
283 subtype = subtype_names[info->subtype];
284 }
285 const char *variant = variant_names[info->variant];
286 const char *parts[] = {subtype, "_", variant};
287 char *ret = alloc_concat_m(3, parts);
288 for (char *cur = ret; *cur; cur++)
289 {
290 if (*cur == ' ')
291 {
292 *cur = '_';
293 }
294 }
295 return ret;
296 }
297