okay, now search for a '****.ctl' file in the current directory.
| 1399 | |
| 1400 | // okay, now search for a '****.ctl' file in the current directory. |
| 1401 | void lnxgameController::parse_ctl_file(int devnum, const char *ctlname) { |
| 1402 | // parse each file until we find a name match, no name match, just return |
| 1403 | char filename[_MAX_FNAME]; |
| 1404 | int i; |
| 1405 | |
| 1406 | if (ddio_FindFileStart("*.ctl", filename)) { |
| 1407 | do { |
| 1408 | InfFile file; |
| 1409 | bool found_name = false; |
| 1410 | |
| 1411 | if (file.Open(filename, "[controller settings]", CTLLex)) { |
| 1412 | // parse each line, setting the appropriate values, etc. |
| 1413 | while (file.ReadLine()) { |
| 1414 | int cmd; |
| 1415 | char operand[128]; |
| 1416 | |
| 1417 | while ((cmd = file.ParseLine(operand, INFFILE_LINELEN)) > INFFILE_ERROR) { |
| 1418 | // we want to assert that the name command comes before any other to verify |
| 1419 | // this is the file we really want to change. |
| 1420 | switch (cmd) { |
| 1421 | case CTLCMD_NAME: |
| 1422 | if (strcmp(ctlname, operand) != 0) |
| 1423 | goto cancel_file_parse; |
| 1424 | found_name = true; |
| 1425 | break; |
| 1426 | |
| 1427 | case CTLCMD_DEAD: // deadzone |
| 1428 | if (!found_name) |
| 1429 | goto cancel_file_parse; |
| 1430 | else { |
| 1431 | m_ControlList[devnum].deadzone = atof(operand); |
| 1432 | } |
| 1433 | break; |
| 1434 | |
| 1435 | case CTLCMD_AXIS: // allowable axis. |
| 1436 | // format of command is "+Z-R" |
| 1437 | // this would add a Z axis to the controller. -R would remove the Rudder. |
| 1438 | // you can do this for X,Y,Z,R,U,V. |
| 1439 | if (!found_name) |
| 1440 | goto cancel_file_parse; |
| 1441 | else { |
| 1442 | int slen = strlen(operand); |
| 1443 | for (i = 0; i <= slen; i += 2) { |
| 1444 | int axis_flag; |
| 1445 | if ((i + 1) <= slen) { |
| 1446 | char axis_cmd = tolower(operand[i + 1]); |
| 1447 | if (axis_cmd == 'x') |
| 1448 | axis_flag = CTF_X_AXIS; |
| 1449 | else if (axis_cmd == 'y') |
| 1450 | axis_flag = CTF_Y_AXIS; |
| 1451 | else if (axis_cmd == 'z') |
| 1452 | axis_flag = CTF_Z_AXIS; |
| 1453 | else if (axis_cmd == 'r') |
| 1454 | axis_flag = CTF_R_AXIS; |
| 1455 | else if (axis_cmd == 'u') |
| 1456 | axis_flag = CTF_U_AXIS; |
| 1457 | else if (axis_cmd == 'v') |
| 1458 | axis_flag = CTF_V_AXIS; |
nothing calls this directly
no test coverage detected