Exemple #1
0
int main(int argc, char *argv[])
{
  Q_INIT_RESOURCE(companion);
  QApplication app(argc, argv);
  app.setApplicationName("OpenTX Simulator");
  app.setOrganizationName("OpenTX");
  app.setOrganizationDomain("open-tx.org");

#ifdef __APPLE__
  app.setStyle(new MyProxyStyle);
#endif

  QString dir;
  if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";

  /* QTranslator companionTranslator;
  companionTranslator.load(":/companion_" + locale);
  QTranslator qtTranslator;
  qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  app.installTranslator(&companionTranslator);
  app.installTranslator(&qtTranslator);
*/

  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
  uint32_t sdlFlags = 0;
  #ifdef JOYSTICKS
    sdlFlags |= SDL_INIT_JOYSTICK;
  #endif
  #ifdef SIMU_AUDIO
    sdlFlags |= SDL_INIT_AUDIO;
  #endif
  if (SDL_Init(sdlFlags) < 0) {
    fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError());
  }
#endif

  SimulatorDialog *dialog;
  QString eepromFileName;
  QDir eedir;
  QFile file;

  registerSimulators();
  registerOpenTxFirmwares();

  eedir = QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
  if (!eedir.exists("OpenTX")) {
    eedir.mkdir("OpenTX");
  }
  eedir.cd("OpenTX");

  QStringList firmwareIds;
  int currentIdx = 0;
  foreach(SimulatorFactory *factory, registered_simulators) {
    firmwareIds << factory->name();
    if (factory->name() == g.lastSimulator()) {
      currentIdx = firmwareIds.size() - 1;
    }
  }
Exemple #2
0
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(companion);
    QApplication app(argc, argv);
    app.setApplicationName("OpenTX Simulator");
    app.setOrganizationName("OpenTX");
    app.setOrganizationDomain("open-tx.org");

#ifdef __APPLE__
    app.setStyle(new MyProxyStyle);
#endif

    QString dir;
    if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";

    /* QTranslator companionTranslator;
    companionTranslator.load(":/companion_" + locale);
    QTranslator qtTranslator;
    qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app.installTranslator(&companionTranslator);
    app.installTranslator(&qtTranslator);
    */

    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
    uint32_t sdlFlags = 0;
#ifdef JOYSTICKS
    sdlFlags |= SDL_INIT_JOYSTICK;
#endif
#ifdef SIMU_AUDIO
    sdlFlags |= SDL_INIT_AUDIO;
#endif
    SDL_Init(sdlFlags);
#endif

    RegisterEepromInterfaces();
    registerOpenTxFirmwares();

    SimulatorDialog *dialog;
    const char * eepromFileName;
    QString fileName;
    QByteArray path;
    QDir eedir;
    QFile file;

    QMessageBox msgBox;
    msgBox.setWindowTitle("Radio type");
    msgBox.setText("Which radio type do you want to simulate?");
    msgBox.setIcon(QMessageBox::Question);
    QAbstractButton *taranisButton = msgBox.addButton("Taranis", QMessageBox::ActionRole);
    QAbstractButton *sky9xButton = msgBox.addButton("9X-Sky9X", QMessageBox::ActionRole);
    QAbstractButton *gruvinButton = msgBox.addButton("9X-Gruvin9X", QMessageBox::ActionRole);
    QAbstractButton *proButton = msgBox.addButton("9XR-Pro", QMessageBox::ActionRole);
    msgBox.addButton("9X-M128", QMessageBox::ActionRole);
    QPushButton *exitButton = msgBox.addButton(QMessageBox::Close);

    eedir = QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
    if (!eedir.exists("OpenTX")) {
        eedir.mkdir("OpenTX");
    }
    eedir.cd("OpenTX");

    msgBox.exec();

    if (msgBox.clickedButton() == exitButton)
        return 0;
    else if (msgBox.clickedButton() == taranisButton) {
        current_firmware_variant = GetFirmware("opentx-taranis-haptic-en");
        fileName = eedir.filePath("eeprom-taranis.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialogTaranis();
    }
    else if (msgBox.clickedButton() == sky9xButton) {
        current_firmware_variant = GetFirmware("opentx-sky9x-heli-templates-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-bluetooth-en");
        fileName = eedir.filePath("eeprom-sky9x.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }
    else if (msgBox.clickedButton() == gruvinButton) {
        current_firmware_variant = GetFirmware("opentx-gruvin9x-heli-templates-sdcard-voice-DSM2PPM-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-ttsen-en");
        fileName = eedir.filePath("eeprom-gruvin9x.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }
    else if (msgBox.clickedButton() == proButton) {
        current_firmware_variant = GetFirmware("opentx-9xrpro-heli-templates-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-en");
        fileName = eedir.filePath("eeprom-9xrpro.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }
    else {
        current_firmware_variant = GetFirmware("opentx-9x128-frsky-heli-templates-audio-voice-haptic-DSM2-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-thrtrace-en");
        fileName = eedir.filePath("eeprom-9x128.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }

    dialog->show();
    dialog->start(eepromFileName);

    int result = app.exec();

    delete dialog;

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
    SDL_Quit();
#endif

    return result;
}
Exemple #3
0
int main(int argc, char *argv[])
{
  Q_INIT_RESOURCE(companion);
  QApplication app(argc, argv);
  app.setApplicationName("OpenTX Companion");
  app.setOrganizationName("OpenTX");
  app.setOrganizationDomain("open-tx.org");
  app.setAttribute(Qt::AA_DontShowIconsInMenus, false);

#ifdef __APPLE__
  app.setStyle(new MyProxyStyle);
#endif

  QTranslator companionTranslator;
  companionTranslator.load(":/companion_" + g.locale());
  QTranslator qtTranslator;
  qtTranslator.load((QString)"qt_" + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  app.installTranslator(&companionTranslator);
  app.installTranslator(&qtTranslator);

  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
  uint32_t sdlFlags = 0;
  #ifdef JOYSTICKS
    sdlFlags |= SDL_INIT_JOYSTICK;
  #endif
  #ifdef SIMU_AUDIO
    sdlFlags |= SDL_INIT_AUDIO;
  #endif
  if (SDL_Init(sdlFlags) < 0) {
    fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError());
  }
#endif

  RegisterEepromInterfaces();
  registerOpenTxFirmwares();

  if (g.profile[g.id()].fwType().isEmpty()){
    g.profile[g.id()].fwType(default_firmware_variant->getId());
    g.profile[g.id()].fwName("");
  }

  QString splashScreen;
  if ( g.profile[g.id()].fwType().contains("taranis"))     splashScreen = ":/images/splasht.png";
  else if ( g.profile[g.id()].fwType().contains("9xrpro")) splashScreen = ":/images/splashp.png";
  else if ( g.profile[g.id()].fwType().contains("9xr"))    splashScreen = ":/images/splashr.png";
  else  splashScreen = ":/images/splash.png";

  QPixmap pixmap = QPixmap(splashScreen);
  QSplashScreen *splash = new QSplashScreen(pixmap);

  current_firmware_variant = GetFirmware(g.profile[g.id()].fwType());

  MainWindow *mainWin = new MainWindow();
  if (g.showSplash()) {
    splash->show();
    QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close()));
    QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show()));
  }
  else {
    mainWin->show();
  }

  int result = app.exec();

  delete splash;
  delete mainWin;

  UnregisterFirmwares();
  UnregisterEepromInterfaces();

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
  SDL_Quit();
#endif

  return result;
}