KonvergoWindow::KonvergoWindow(QWindow* parent) : QQuickWindow(parent), m_debugLayer(false), m_lastScale(1.0)
{
    // NSWindowCollectionBehaviorFullScreenPrimary is only set on OSX if Qt::WindowFullscreenButtonHint is set on the window.
    setFlags(flags() | Qt::WindowFullscreenButtonHint);

    m_infoTimer = new QTimer(this);
    m_infoTimer->setInterval(1000);

    installEventFilter(new EventFilter(this));

    connect(m_infoTimer, &QTimer::timeout, this, &KonvergoWindow::updateDebugInfo);

    InputComponent::Get().registerHostCommand("close", this, "close");
    InputComponent::Get().registerHostCommand("toggleDebug", this, "toggleDebug");
    InputComponent::Get().registerHostCommand("reload", this, "reloadWeb");
    InputComponent::Get().registerHostCommand("fullscreen", this, "toggleFullscreen");

#ifdef TARGET_RPI
    // On RPI, we use dispmanx layering - the video is on a layer below Konvergo,
    // and during playback the Konvergo window is partially transparent. The OSD
    // will be visible on top of the video as part of the Konvergo window.
    setColor(QColor("transparent"));
#else
    setColor(QColor("#111111"));
#endif

    loadGeometry();
    notifyScale(size());

    connect(SettingsComponent::Get().getSection(SETTINGS_SECTION_MAIN), &SettingsSection::valuesUpdated,
            this, &KonvergoWindow::updateMainSectionSettings);

    connect(this, &KonvergoWindow::visibilityChanged,
            this, &KonvergoWindow::onVisibilityChanged);

    connect(this, &KonvergoWindow::enableVideoWindowSignal,
            this, &KonvergoWindow::enableVideoWindow, Qt::QueuedConnection);

    connect(&PlayerComponent::Get(), &PlayerComponent::windowVisible,
            this, &KonvergoWindow::playerWindowVisible);

    connect(&PlayerComponent::Get(), &PlayerComponent::playbackStarting,
            this, &KonvergoWindow::playerPlaybackStarting);

    // this is using old syntax because ... reasons. QQuickCloseEvent is not public class
    connect(this, SIGNAL(closing(QQuickCloseEvent*)), this, SLOT(closingWindow()));

    connect(qApp, &QCoreApplication::aboutToQuit, this, &KonvergoWindow::closingWindow);

#ifdef KONVERGO_OPENELEC
    setVisibility(QWindow::FullScreen);
#else
    updateFullscreenState(false);
#endif

    emit enableVideoWindowSignal();
}
Пример #2
0
void KonvergoWindow::updateMainSectionSettings(const QVariantMap& values)
{
  // update mouse visibility if needed
  if (values.find("disablemouse") != values.end())
  {
    SystemComponent::Get().setCursorVisibility(!SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "disablemouse").toBool());
  }

  if (values.find("fullscreen") == values.end())
    return;

  updateFullscreenState();
}
Пример #3
0
void Utility::inputEvent(uint16_t code) {
  //forward key-press event
  //(in case window is currently active and capturing a new button / axis assignment)
  winInputCapture->inputEvent(code);

  //if escape key is pressed on *any* keyboard; release the mouse if it is acquired
  for(unsigned i = 0; i < keyboard<>::count; i++) {
    if(code == keyboard<>::index(i, keyboard<>::escape) && inputManager.state(code) && input.acquired()) {
      input.unacquire();
      return;  //do not trigger other UI actions that may be bound to escape key
    }
  }

  if(winMain->window->isActiveWindow()) {
    bool resizeWindow = false;

    if(isButtonDown(code, inputUiGeneral.loadCartridge)) {
      string filename = selectCartridge();
      if(filename.length() > 0) loadCartridge(filename);
    }

    if(isButtonDown(code, inputUiGeneral.pauseEmulation)) {
      application.pause = !application.pause;
    }

    if(isButtonDown(code, inputUiGeneral.resetSystem)) {
      modifySystemState(Reset);
    }

    if(isButtonDown(code, inputUiGeneral.powerCycleSystem)) {
      modifySystemState(PowerCycle);
    }

    if(isButtonDown(code, inputUiGeneral.lowerSpeed)) {
      config.system.speed--;
      updateEmulationSpeed();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.raiseSpeed)) {
      config.system.speed++;
      updateEmulationSpeed();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleCheatSystem)) {
      if(cheat.enabled() == false) {
        cheat.enable();
        showMessage("Cheat system enabled.");
      } else {
        cheat.disable();
        showMessage("Cheat system disabled.");
      }
    }

    if(isButtonDown(code, inputUiGeneral.toggleFullscreen)) {
      config.video.isFullscreen = !config.video.isFullscreen;
      updateFullscreenState();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleMenu)) {
      winMain->window->menuBar()->setVisible(!winMain->window->menuBar()->isVisibleTo(winMain->window));
      resizeWindow = true;
    }

    if(isButtonDown(code, inputUiGeneral.toggleStatus)) {
      winMain->window->statusBar()->setVisible(!winMain->window->statusBar()->isVisibleTo(winMain->window));
      resizeWindow = true;
    }

    //prevent calling twice when toggleMenu == toggleStatus
    if(resizeWindow == true) {
      resizeMainWindow();
    }

    if(isButtonDown(code, inputUiGeneral.exitEmulator)) {
      application.terminate = true;
    }
  }
}
Пример #4
0
void KonvergoWindow::onScreenCountChanged(int newCount)
{
  updateFullscreenState();
}
Пример #5
0
KonvergoWindow::KonvergoWindow(QWindow* parent) : QQuickWindow(parent), m_debugLayer(false), m_lastScale(1.0)
{
  // NSWindowCollectionBehaviorFullScreenPrimary is only set on OSX if Qt::WindowFullscreenButtonHint is set on the window.
  setFlags(flags() | Qt::WindowFullscreenButtonHint);

  m_infoTimer = new QTimer(this);
  m_infoTimer->setInterval(1000);

  installEventFilter(new EventFilter(this));

  connect(m_infoTimer, &QTimer::timeout, this, &KonvergoWindow::updateDebugInfo);

  InputComponent::Get().registerHostCommand("close", this, "close");
  InputComponent::Get().registerHostCommand("toggleDebug", this, "toggleDebug");
  InputComponent::Get().registerHostCommand("reload", this, "reloadWeb");
  InputComponent::Get().registerHostCommand("fullscreen", this, "toggleFullscreen");

#ifdef TARGET_RPI
  // On RPI, we use dispmanx layering - the video is on a layer below Konvergo,
  // and during playback the Konvergo window is partially transparent. The OSD
  // will be visible on top of the video as part of the Konvergo window.
  setColor(QColor("transparent"));
#else
  setColor(QColor("#111111"));
#endif

  loadGeometry();
  m_lastScale = CalculateScale(size());

  connect(SettingsComponent::Get().getSection(SETTINGS_SECTION_MAIN), &SettingsSection::valuesUpdated,
          this, &KonvergoWindow::updateMainSectionSettings);

  connect(this, &KonvergoWindow::visibilityChanged,
          this, &KonvergoWindow::onVisibilityChanged);

  connect(this, &KonvergoWindow::enableVideoWindowSignal,
          this, &KonvergoWindow::enableVideoWindow, Qt::QueuedConnection);

//  connect(QGuiApplication::desktop(), &QDesktopWidget::screenCountChanged,
//              this, &KonvergoWindow::onScreenCountChanged);

  connect(&PlayerComponent::Get(), &PlayerComponent::windowVisible,
          this, &KonvergoWindow::playerWindowVisible);

  connect(&PlayerComponent::Get(), &PlayerComponent::playbackStarting,
          this, &KonvergoWindow::playerPlaybackStarting);

  // this is using old syntax because ... reasons. QQuickCloseEvent is not public class
  connect(this, SIGNAL(closing(QQuickCloseEvent*)), this, SLOT(closingWindow()));

  connect(qApp, &QCoreApplication::aboutToQuit, this, &KonvergoWindow::saveGeometry);

  if (!SystemComponent::Get().isOpenELEC())
  {
    // this is such a hack. But I could not get it to enter into fullscreen
    // mode if I didn't trigger this after a while.
    //
    QTimer::singleShot(500, [=]() {
        updateFullscreenState();
    });
  }
  else
  {
    setWindowState(Qt::WindowFullScreen);
  }

  emit enableVideoWindowSignal();
}
Пример #6
0
void Utility::toggleFullscreen() {
  config().video.isFullscreen = !config().video.isFullscreen;
  updateFullscreenState();
  resizeMainWindow();
  mainWindow->syncUi();
}
Пример #7
0
void Utility::inputEvent(uint16_t code) {
  //forward key-press event
  //(in case window is currently active and capturing a new button / axis assignment)
  winInputCapture->inputEvent(code);

  for(unsigned i = 0; i < keyboard<>::count; i++) {
    if(code == keyboard<>::index(i, keyboard<>::escape) && inputManager.state(code)) {
      if(mainWindow->window->isActiveWindow() && input.acquired()) {
        //release mouse capture
        input.unacquire();
        return;  //do not trigger other UI actions that may be bound to escape key
      } else if(settingsWindow->window->isActiveWindow()) {
        settingsWindow->window->hide();
        return;
      } else if(toolsWindow->window->isActiveWindow()) {
        toolsWindow->window->hide();
        return;
      }
    }
  }

  if(mainWindow->window->isActiveWindow()) {
    bool resizeWindow = false;

    if(isButtonDown(code, inputUiGeneral.loadCartridge)) {
      string filename = selectCartridge();
      if(filename.length() > 0) loadCartridge(filename);
    }

    if(isButtonDown(code, inputUiGeneral.pauseEmulation)) {
      application.pause = !application.pause;
      if(application.pause) audio.clear();
    }

    if(isButtonDown(code, inputUiGeneral.resetSystem)) {
      modifySystemState(Reset);
    }

    if(isButtonDown(code, inputUiGeneral.powerCycleSystem)) {
      modifySystemState(PowerCycle);
    }

    if(isButtonDown(code, inputUiGeneral.saveScreenshot)) {
      //tell SNES::Interface to save a screenshot at the next video_refresh() event
      interface.saveScreenshot = true;
    }

    if(isButtonDown(code, inputUiGeneral.showStateManager)) {
      toolsWindow->showStateManager();
    }

    if(isButtonDown(code, inputUiGeneral.quickLoad1)) utility.quickLoad(0);
    if(isButtonDown(code, inputUiGeneral.quickLoad2)) utility.quickLoad(1);
    if(isButtonDown(code, inputUiGeneral.quickLoad3)) utility.quickLoad(2);
    if(isButtonDown(code, inputUiGeneral.quickSave1)) utility.quickSave(0);
    if(isButtonDown(code, inputUiGeneral.quickSave2)) utility.quickSave(1);
    if(isButtonDown(code, inputUiGeneral.quickSave3)) utility.quickSave(2);

    if(isButtonDown(code, inputUiGeneral.lowerSpeed)) {
      config.system.speed--;
      updateEmulationSpeed();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.raiseSpeed)) {
      config.system.speed++;
      updateEmulationSpeed();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleCheatSystem)) {
      if(SNES::cheat.enabled() == false) {
        SNES::cheat.enable();
        showMessage("Cheat system enabled.");
      } else {
        SNES::cheat.disable();
        showMessage("Cheat system disabled.");
      }
    }

    if(isButtonDown(code, inputUiGeneral.toggleFullscreen)) {
      config.video.isFullscreen = !config.video.isFullscreen;
      updateFullscreenState();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleMenu)) {
      mainWindow->window->menuBar()->setVisible(!mainWindow->window->menuBar()->isVisibleTo(mainWindow->window));
      resizeWindow = true;
    }

    if(isButtonDown(code, inputUiGeneral.toggleStatus)) {
      mainWindow->window->statusBar()->setVisible(!mainWindow->window->statusBar()->isVisibleTo(mainWindow->window));
      resizeWindow = true;
    }

    //prevent calling twice when toggleMenu == toggleStatus
    if(resizeWindow == true) {
      resizeMainWindow();
    }

    if(isButtonDown(code, inputUiGeneral.exitEmulator)) {
      application.terminate = true;
    }
  }
}