Exemplo n.º 1
0
void getPhaseAudioFile(char * filename, int index, unsigned int event)
{
  char * str = getModelAudioPath(filename);
  char * tmp = strcat_phasename(str, index);
  strcpy(tmp, suffixes[event]);
  strcat(tmp, SOUNDS_EXT);
}
Exemplo n.º 2
0
void getSwitchAudioFile(char * filename, swsrc_t index)
{
  char * str = getModelAudioPath(filename);

#if defined(PCBTARANIS)
  if (index <= SWSRC_LAST_SWITCH) {
    div_t swinfo = switchInfo(index);
    *str++ = 'S';
    *str++ = 'A' + swinfo.quot;
    const char * positions[] = { "-up", "-mid", "-down" };
    strcpy(str, positions[swinfo.rem]);
  }
  else {
    div_t swinfo = div(index - SWSRC_FIRST_MULTIPOS_SWITCH, XPOTS_MULTIPOS_COUNT);
    *str++ = 'S';
    *str++ = '1' + swinfo.quot;
    *str++ = '1' + swinfo.rem;
    *str = '\0';
  }
#else
  int len = STR_VSWITCHES[0];
  strncpy(str, &STR_VSWITCHES[1+(len*index)], len);
  str += len;
  *str = '\0';
#endif
  strcat(str, SOUNDS_EXT);
}
Exemplo n.º 3
0
void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event)
{
  char * str = getModelAudioPath(filename);
  int len = STR_VSWITCHES[0];
  strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH)], len);
  str[len] = '\0';
  strcat(str, suffixes[event]);
  strcat(str, SOUNDS_EXT);
}
Exemplo n.º 4
0
void getSwitchAudioFile(char * filename, int index)
{
  char * str = getModelAudioPath(filename);
  int len = STR_VSWITCHES[0];
  strncpy(str, &STR_VSWITCHES[1+len*(index+1)], len);
  str += len-1;
  if (*str == '\300') {
    strcpy(str, "-up");
    str += 3;
  }
  else if (*str == '-') {
    strcpy(str, "-mid");
    str += 4;
  }
  else if (*str == '\301') {
    strcpy(str, "-down");
    str += 5;
  }
  else {
    *(str+1) = 0;
  }
  strcat(str, SOUNDS_EXT);
}
Exemplo n.º 5
0
void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event)
{
  char * str = getModelAudioPath(filename);

#if defined(PCBTARANIS)
  *str++ = 'L';
  if (index >= 9) {
    div_t qr = div(index+1, 10);
    *str++ = '0' + qr.quot;
    *str++ = '0' + qr.rem;
  }
  else {
    *str++ = '1' + index;
  }
#else
  int len = STR_VSWITCHES[0];
  strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH)], len);
  str += len;
#endif

  strcpy(str, suffixes[event]);
  strcat(str, SOUNDS_EXT);
}
Exemplo n.º 6
0
void referenceModelAudioFiles()
{
  char path[AUDIO_FILENAME_MAXLEN+1];
  FILINFO fno;
  DIR dir;
  char *fn;   /* This function is assuming non-Unicode cfg. */
  TCHAR lfn[_MAX_LFN + 1];
  fno.lfname = lfn;
  fno.lfsize = sizeof(lfn);

  sdAvailablePhaseAudioFiles = 0;
  sdAvailableSwitchAudioFiles = 0;
  sdAvailableLogicalSwitchAudioFiles = 0;
  
  char * filename = getModelAudioPath(path);
  *(filename-1) = '\0';

  FRESULT res = f_opendir(&dir, path);        /* Open the directory */
  if (res == FR_OK) {
    for (;;) {
      res = f_readdir(&dir, &fno);                   /* Read a directory item */
      if (res != FR_OK || fno.fname[0] == 0) break;  /* Break on error or end of dir */
      fn = *fno.lfname ? fno.lfname : fno.fname;
      uint8_t len = strlen(fn);
      bool found = false;

      // Eliminates directories / non wav files
      if (len < 5 || strcasecmp(fn+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue;
      TRACE("referenceModelAudioFiles(): using file: %s", fn);

      // Phases Audio Files <phasename>-[on|off].wav
      for (int i=0; i<MAX_FLIGHT_MODES && !found; i++) {
        for (int event=0; event<2; event++) {
          getPhaseAudioFile(path, i, event);
          // TRACE("referenceModelAudioFiles(): searching for %s in %s", filename, fn);
          if (!strcasecmp(filename, fn)) {
            sdAvailablePhaseAudioFiles |= MASK_PHASE_AUDIO_FILE(i, event);
            found = true;
            TRACE("\tfound: %s", filename);
            break;
          }
        }
      }

      // Switches Audio Files <switchname>-[up|mid|down].wav
      for (int i=0; i<SWSRC_LAST_SWITCH+NUM_XPOTS*XPOTS_MULTIPOS_COUNT && !found; i++) {
        getSwitchAudioFile(path, i);
        // TRACE("referenceModelAudioFiles(): searching for %s in %s", filename, fn);
        if (!strcasecmp(filename, fn)) {
          sdAvailableSwitchAudioFiles |= MASK_SWITCH_AUDIO_FILE(i);
          found = true;
          TRACE("\tfound: %s", filename);
        }
      }

      // Logical Switches Audio Files <switchname>-[on|off].wav
      for (int i=0; i<NUM_LOGICAL_SWITCH && !found; i++) {
        for (int event=0; event<2; event++) {
          getLogicalSwitchAudioFile(path, i, event);
          // TRACE("referenceModelAudioFiles(): searching for %s in %s", filename, fn);
          if (!strcasecmp(filename, fn)) {
            sdAvailableLogicalSwitchAudioFiles |= MASK_LOGICAL_SWITCH_AUDIO_FILE(i, event);
            found = true;
            TRACE("\tfound: %s", filename);
            break;
          }
        }
      }
    }
    f_closedir(&dir);
  }
}