comparison io.c @ 1005:580a806aef6a

Allow overriding speed 0. May be useful for people that want to use vsync
author Michael Pavone <pavone@retrodev.com>
date Sun, 01 May 2016 15:57:43 -0700
parents e28f365605da
children 7267bc1ab547
comparison
equal deleted inserted replaced
1004:fc000f245cc8 1005:580a806aef6a
600 curstr[len] = cur->el; 600 curstr[len] = cur->el;
601 curstr[len+1] = 0; 601 curstr[len+1] = 0;
602 if (cur->el) { 602 if (cur->el) {
603 process_speeds(cur->straight.next, curstr); 603 process_speeds(cur->straight.next, curstr);
604 } else { 604 } else {
605 int speed_index = atoi(curstr); 605 char *end;
606 if (speed_index < 1) { 606 long speed_index = strtol(curstr, &end, 10);
607 if (!strcmp(curstr, "0")) { 607 if (speed_index < 0 || end == curstr || *end) {
608 warning("Speed index 0 cannot be set to a custom value\n"); 608 warning("%s is not a valid speed index", curstr);
609 } else {
610 warning("%s is not a valid speed index", curstr);
611 }
612 } else { 609 } else {
613 if (speed_index >= num_speeds) { 610 if (speed_index >= num_speeds) {
614 speeds = realloc(speeds, sizeof(uint32_t) * (speed_index+1)); 611 speeds = realloc(speeds, sizeof(uint32_t) * (speed_index+1));
615 for(; num_speeds < speed_index + 1; num_speeds++) { 612 for(; num_speeds < speed_index + 1; num_speeds++) {
616 speeds[num_speeds] = 0; 613 speeds[num_speeds] = 0;
617 } 614 }
618 } 615 }
619 speeds[speed_index] = atoi(cur->straight.value.ptrval); 616 speeds[speed_index] = atoi(cur->straight.value.ptrval);
617 if (speeds[speed_index] < 1) {
618 warning("%s is not a valid speed percentage, setting speed %d to 100", cur->straight.value.ptrval, speed_index);
619 speeds[speed_index] = 100;
620 }
620 } 621 }
621 } 622 }
622 process_speeds(cur->left, prefix); 623 process_speeds(cur->left, prefix);
623 process_speeds(cur->right, prefix); 624 process_speeds(cur->right, prefix);
624 if (curstr && len) { 625 if (curstr && len) {
1057 } 1058 }
1058 } 1059 }
1059 } 1060 }
1060 map_bindings(ports, mice[mouse].buttons, MAX_MOUSE_BUTTONS); 1061 map_bindings(ports, mice[mouse].buttons, MAX_MOUSE_BUTTONS);
1061 } 1062 }
1063 //not really related to the intention of this function, but the best place to do this currently
1064 if (speeds[0] != 100) {
1065 set_speed_percent(genesis, speeds[0]);
1066 }
1062 } 1067 }
1063 1068
1064 #define TH 0x40 1069 #define TH 0x40
1065 #define TR 0x20 1070 #define TR 0x20
1066 #define TH_TIMEOUT 56000 1071 #define TH_TIMEOUT 56000