Mercurial > repos > blastem
comparison bindings.c @ 1783:eda8df5bc74c
Minor cleanup
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 11 Mar 2019 00:04:48 -0700 |
parents | 326d1a601fb9 |
children | 34370330eaf3 |
comparison
equal
deleted
inserted
replaced
1782:b2bffd98063d | 1783:eda8df5bc74c |
---|---|
1 #include <string.h> | 1 #include <string.h> |
2 #include <stdlib.h> | |
2 #include "render.h" | 3 #include "render.h" |
3 #include "system.h" | 4 #include "system.h" |
4 #include "io.h" | 5 #include "io.h" |
5 #include "blastem.h" | 6 #include "blastem.h" |
6 #include "saves.h" | 7 #include "saves.h" |
555 | 556 |
556 int parse_binding_target(int device_num, char * target, tern_node * padbuttons, tern_node *mousebuttons, uint8_t * subtype_a, uint8_t * subtype_b) | 557 int parse_binding_target(int device_num, char * target, tern_node * padbuttons, tern_node *mousebuttons, uint8_t * subtype_a, uint8_t * subtype_b) |
557 { | 558 { |
558 const int gpadslen = strlen("gamepads."); | 559 const int gpadslen = strlen("gamepads."); |
559 const int mouselen = strlen("mouse."); | 560 const int mouselen = strlen("mouse."); |
560 if (!strncmp(target, "gamepads.", gpadslen)) { | 561 if (startswith(target, "gamepads.")) { |
561 int padnum = target[gpadslen] == 'n' ? device_num + 1 : target[gpadslen] - '0'; | 562 int padnum = target[gpadslen] == 'n' ? device_num + 1 : target[gpadslen] - '0'; |
562 if (padnum >= 1 && padnum <= 8) { | 563 if (padnum >= 1 && padnum <= 8) { |
563 int button = tern_find_int(padbuttons, target + gpadslen + 1, 0); | 564 int button = tern_find_int(padbuttons, target + gpadslen + 1, 0); |
564 if (button) { | 565 if (button) { |
565 *subtype_a = padnum; | 566 *subtype_a = padnum; |
573 } | 574 } |
574 } | 575 } |
575 } else { | 576 } else { |
576 warning("Gamepad mapping string '%s' refers to an invalid gamepad number %c\n", target, target[gpadslen]); | 577 warning("Gamepad mapping string '%s' refers to an invalid gamepad number %c\n", target, target[gpadslen]); |
577 } | 578 } |
578 } else if(!strncmp(target, "mouse.", mouselen)) { | 579 } else if(startswith(target, "mouse.")) { |
579 int mousenum = target[mouselen] == 'n' ? device_num + 1 : target[mouselen] - '0'; | 580 int mousenum = target[mouselen] == 'n' ? device_num + 1 : target[mouselen] - '0'; |
580 if (mousenum >= 1 && mousenum <= 8) { | 581 if (mousenum >= 1 && mousenum <= 8) { |
581 int button = tern_find_int(mousebuttons, target + mouselen + 1, 0); | 582 int button = tern_find_int(mousebuttons, target + mouselen + 1, 0); |
582 if (button) { | 583 if (button) { |
583 *subtype_a = mousenum; | 584 *subtype_a = mousenum; |
591 } | 592 } |
592 } | 593 } |
593 } else { | 594 } else { |
594 warning("Gamepad mapping string '%s' refers to an invalid mouse number %c\n", target, target[mouselen]); | 595 warning("Gamepad mapping string '%s' refers to an invalid mouse number %c\n", target, target[mouselen]); |
595 } | 596 } |
596 } else if(!strncmp(target, "ui.", strlen("ui."))) { | 597 } else if(startswith(target, "ui.")) { |
597 if (!strcmp(target + 3, "vdp_debug_mode")) { | 598 if (!strcmp(target + 3, "vdp_debug_mode")) { |
598 *subtype_a = UI_DEBUG_MODE_INC; | 599 *subtype_a = UI_DEBUG_MODE_INC; |
599 } else if(!strcmp(target + 3, "vdp_debug_pal")) { | 600 } else if(!strcmp(target + 3, "vdp_debug_pal")) { |
600 //legacy binding, ignore | 601 //legacy binding, ignore |
601 return 0; | 602 return 0; |
602 } else if(!strcmp(target + 3, "enter_debugger")) { | 603 } else if(!strcmp(target + 3, "enter_debugger")) { |
603 *subtype_a = UI_ENTER_DEBUGGER; | 604 *subtype_a = UI_ENTER_DEBUGGER; |
604 } else if(!strcmp(target + 3, "save_state")) { | 605 } else if(!strcmp(target + 3, "save_state")) { |
605 *subtype_a = UI_SAVE_STATE; | 606 *subtype_a = UI_SAVE_STATE; |
606 } else if(!strncmp(target + 3, "set_speed.", strlen("set_speed."))) { | 607 } else if(startswith(target + 3, "set_speed.")) { |
607 *subtype_a = UI_SET_SPEED; | 608 *subtype_a = UI_SET_SPEED; |
608 *subtype_b = atoi(target + 3 + strlen("set_speed.")); | 609 *subtype_b = atoi(target + 3 + strlen("set_speed.")); |
609 } else if(!strcmp(target + 3, "next_speed")) { | 610 } else if(!strcmp(target + 3, "next_speed")) { |
610 *subtype_a = UI_NEXT_SPEED; | 611 *subtype_a = UI_NEXT_SPEED; |
611 } else if(!strcmp(target + 3, "prev_speed")) { | 612 } else if(!strcmp(target + 3, "prev_speed")) { |