void CFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
{
  if (Core::IsRunning())
  {
    // Core is initialized and emulator is running
    if (UseDebugger)
    {
      bool was_stopped = CPU::IsStepping();
      CPU::EnableStepping(!was_stopped);
      // When the CPU stops it generates a IDM_UPDATE_DISASM_DIALOG which automatically refreshes
      // the UI, the UI only needs to be refreshed manually when unpausing.
      if (was_stopped)
      {
        g_pCodeWindow->Repopulate();
        UpdateGUI();
      }
    }
    else
    {
      DoPause();
    }
  }
  else
  {
    // Core is uninitialized, start the game
    BootGame("");
  }
}
Пример #2
0
void CStateMachinen::Update(CMonster& monster, eStateEvent evt)
{
	switch(monster.mStateParamter.stateCur)
	{
	case eMA_STAND:
		{
			DoStand(
				monster,
				evt);
			break;
		}
	case eMA_WALKAROUND:
		{
			DoWalkAround(
				monster,
				evt);
			break;
		}
	case eMA_PERSUIT:
		{
			DoPursuit(
				monster,
				evt);
			break;
		}
	case eMA_WALKAWAY:
	case eMA_RUNAWAY:
		{
			DoRunAway(
				monster,
				evt);
			break;
		}
	case eMA_ATTACK:
		{
			DoAttack(
				monster,
				evt);
			break;
		}
	case eMA_SCRIPT_RUN:
	case eMA_SCRIPT_WALK:
		{
			DoScriptMove(
				monster,
				evt);
			break;
		}
	case eMA_PAUSE:
		{
			DoPause(
				monster,
				evt);
			break;
		}
	}
}
Пример #3
0
void MediaWidget::Pauser::modifyPaused(unsigned const newPaused, MediaWidget &mw) {
	if (paused_) {
		if (!newPaused)
			mw.callWhenPaused(DoUnpause(mw));
	} else {
		if (newPaused)
			mw.callWhenPaused(DoPause(mw));
	}

	paused_ = newPaused;
}
void CFrame::DoRecordingSave()
{
  bool paused = (Core::GetState() == Core::CORE_PAUSE);

  if (!paused)
    DoPause();

  wxString path =
      wxFileSelector(_("Select The Recording File"), wxEmptyString, wxEmptyString, wxEmptyString,
                     _("Dolphin TAS Movies (*.dtm)") +
                         wxString::Format("|*.dtm|%s", wxGetTranslation(wxALL_FILES)),
                     wxFD_SAVE | wxFD_PREVIEW | wxFD_OVERWRITE_PROMPT, this);

  if (path.IsEmpty())
    return;

  Movie::SaveRecording(WxStrToStr(path));

  if (!paused)
    DoPause();
}
Пример #5
0
void CPUThread::Pause()
{
	if(!IsRunning()) return;

	SendDbgCommand(DID_PAUSE_THREAD, this);

	m_status = Paused;
	DoPause();
	Emu.CheckStatus();

	// ThreadBase::Stop(); // "Abort() called" exception
	SendDbgCommand(DID_PAUSED_THREAD, this);
}
Пример #6
0
void CPUThread::Pause()
{
	if(!IsRunning()) return;

	wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, this);

	m_status = Paused;
	DoPause();
	Emu.CheckStatus();

	ThreadBase::Stop(false);
	wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, this);
}
Пример #7
0
void SjPlayer::Pause(bool fadeToPause)
{
	if( !m_isInitialized ) {
		return;
	}

	// if the player is stopped or if we are already paused, there is nothing to do
	if( DoGetUrlOnAir().IsEmpty() || m_paused ) {
		return;
	}

	// real changing of the pause state in the implementation, this should also set the m_paused flag
	DoPause(fadeToPause);
}
Пример #8
0
void CPUThread::Pause()
{
	if(!IsRunning()) return;

#ifndef QT_UI
	wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, this);
#endif

	m_status = Paused;
	DoPause();
	Emu.CheckStatus();

	// ThreadBase::Stop(); // "Abort() called" exception
#ifndef QT_UI
	wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, this);
#endif
}
Пример #9
0
void
AnimationPlayer::Pause()
{
  DoPause();
  PostUpdate();
}
Пример #10
0
void
Animation::Pause()
{
  DoPause();
  PostUpdate();
}
Пример #11
0
void
Animation::Pause(ErrorResult& aRv)
{
  DoPause(aRv);
  PostUpdate();
}
Пример #12
0
void CFrame::OnKeyDown(wxKeyEvent& event)
{
	if(Core::GetState() != Core::CORE_UNINITIALIZED &&
			(RendererHasFocus() || g_TASInputDlg->HasFocus()))
	{
		int WiimoteId = -1;
		// Toggle fullscreen
		if (IsHotkey(event, HK_FULLSCREEN))
			DoFullscreen(!RendererIsFullscreen());
		// Send Debugger keys to CodeWindow
		else if (g_pCodeWindow && (event.GetKeyCode() >= WXK_F9 && event.GetKeyCode() <= WXK_F11))
 			event.Skip();
		// Pause and Unpause
		else if (IsHotkey(event, HK_PLAY_PAUSE))
			DoPause();
		// Stop
		else if (IsHotkey(event, HK_STOP))
			DoStop();
		// Screenshot hotkey
		else if (IsHotkey(event, HK_SCREENSHOT))
			Core::SaveScreenShot();
		// Wiimote connect and disconnect hotkeys
		else if (IsHotkey(event, HK_WIIMOTE1_CONNECT))
			WiimoteId = 0;
		else if (IsHotkey(event, HK_WIIMOTE2_CONNECT))
			WiimoteId = 1;
		else if (IsHotkey(event, HK_WIIMOTE3_CONNECT))
			WiimoteId = 2;
		else if (IsHotkey(event, HK_WIIMOTE4_CONNECT))
			WiimoteId = 3;
		// State save and state load hotkeys
		/*else if (event.GetKeyCode() >= WXK_F1 && event.GetKeyCode() <= WXK_F8)
		{
			int slot_number = event.GetKeyCode() - WXK_F1 + 1;
			if (event.GetModifiers() == wxMOD_NONE)
				State::Load(slot_number);
			else if (event.GetModifiers() == wxMOD_SHIFT)
				State::Save(slot_number);
			else
				event.Skip();
		}*/
		else if (event.GetKeyCode() == WXK_F11 && event.GetModifiers() == wxMOD_NONE)
			State::LoadLastSaved();
		else if (event.GetKeyCode() == WXK_F12)
		{
			if (event.GetModifiers() == wxMOD_NONE)
				State::UndoSaveState();
			else if (event.GetModifiers() == wxMOD_SHIFT)
				State::UndoLoadState();
			else
				event.Skip();
		}
		else
		{
			unsigned int i = NUM_HOTKEYS;
			if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain || g_TASInputDlg->HasFocus())
			{
				for (i = 0; i < NUM_HOTKEYS; i++)
				{
					if (IsHotkey(event, i))
					{
						int cmd = GetCmdForHotkey(i);
						if (cmd >= 0)
						{ 
							wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, cmd);
							wxMenuItem *item = GetMenuBar()->FindItem(cmd);
							if (item && item->IsCheckable())
							{
								item->wxMenuItemBase::Toggle();
								evt.SetInt(item->IsChecked());
							}
							GetEventHandler()->AddPendingEvent(evt);
							break;
						}
					}
				}
			}
			// On OS X, we claim all keyboard events while
			// emulation is running to avoid wxWidgets sounding
			// the system beep for unhandled key events when
			// receiving pad/wiimote keypresses which take an
			// entirely different path through the HID subsystem.
#ifndef __APPLE__
			// On other platforms, we leave the key event alone
			// so it can be passed on to the windowing system.
			if (i == NUM_HOTKEYS)
				event.Skip();
#endif
		}

		// Actually perform the wiimote connection or disconnection
		if (WiimoteId >= 0)
		{
			bool connect = !GetMenuBar()->IsChecked(IDM_CONNECT_WIIMOTE1 + WiimoteId);
			ConnectWiimote(WiimoteId, connect);
		}

		// Send the OSD hotkeys to the video backend
		if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7' && event.GetModifiers() == wxMOD_NONE)
		{
#ifdef _WIN32
			PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
#elif defined(HAVE_X11) && HAVE_X11
			X11Utils::SendKeyEvent(X11Utils::XDisplayFromHandle(GetHandle()), event.GetKeyCode());
#endif
		}
		// Send the freelook hotkeys to the video backend
		if ((event.GetKeyCode() == ')' || event.GetKeyCode() == '(' ||
					event.GetKeyCode() == '0' || event.GetKeyCode() == '9' ||
					event.GetKeyCode() == 'W' || event.GetKeyCode() == 'S' ||
					event.GetKeyCode() == 'A' || event.GetKeyCode() == 'D' ||
					event.GetKeyCode() == 'R')
				&& event.GetModifiers() == wxMOD_SHIFT)
		{
#ifdef _WIN32
			PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
#elif defined(HAVE_X11) && HAVE_X11
			X11Utils::SendKeyEvent(X11Utils::XDisplayFromHandle(GetHandle()), event.GetKeyCode());
#endif
		}
	}
	else
		event.Skip();
}
Пример #13
0
		void Pause()
		{
			DoPause();
		}
void PVAuthorEngineNodeUtility::Run()
{
    LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::Run: Enter"));

    if (iCmdQueue.empty())
        return;

    PVAENodeUtilCmd cmd = iCmdQueue[0];
    if (cmd.iNodes.empty())
    {
        LOG_ERR((0, "PVAuthorEngineNodeUtility::Run: Error - cmd.iNodes is empty"));
        CompleteUtilityCmd(cmd, PVMFFailure);
        return;
    }

    PVMFStatus status = PVMFFailure;
    LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::Run: cmd.iType=%d", cmd.iType));
    switch (cmd.iType)
    {
        case PVAENU_CMD_CONNECT:
            status = DoConnect(cmd);
            break;
        case PVAENU_CMD_DISCONNECT:
            status = DoDisconnect(cmd);
            break;
        case PVAENU_CMD_QUERY_UUID:
            status = DoQueryUuid(cmd);
            break;
        case PVAENU_CMD_QUERY_INTERFACE:
            status = DoQueryInterface(cmd);
            break;
        case PVAENU_CMD_INIT:
            status = DoInit(cmd);
            break;
        case PVAENU_CMD_PREPARE:
            status = DoPrepare(cmd);
            break;
        case PVAENU_CMD_START:
            status = DoStart(cmd);
            break;
        case PVAENU_CMD_PAUSE:
            status = DoPause(cmd);
            break;
        case PVAENU_CMD_STOP:
            status = DoStop(cmd);
            break;
        case PVAENU_CMD_FLUSH:
            status = DoFlush(cmd);
            break;
        case PVAENU_CMD_RESET:
            status = DoReset(cmd);
            break;
        default:
            status = PVMFFailure;
            break;
    }

    if (status != PVMFPending)
        CompleteUtilityCmd(cmd, status);

    LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::Run: Exit"));
}
Пример #15
0
static VOID
MainWndCommand(PMAIN_WND_INFO Info,
               WORD CmdId,
               HWND hControl)
{
    UNREFERENCED_PARAMETER(hControl);

    switch (CmdId)
    {
        case ID_PROP:
        {
            if (Info->SelectedItem != NO_ITEM_SELECTED)
            {
                Info->bDlgOpen = TRUE;
                OpenPropSheet(Info);
                Info->bDlgOpen = FALSE;
                SetMenuAndButtonStates(Info);
            }
        }
        break;

        case ID_REFRESH:
        {
            RefreshServiceList(Info);
            Info->SelectedItem = NO_ITEM_SELECTED;

            /* disable menus and buttons */
            SetMenuAndButtonStates(Info);

            /* clear the service in the status bar */
            SendMessage(Info->hStatus,
                        SB_SETTEXT,
                        1,
                        _T('\0'));
        }
        break;

        case ID_EXPORT:
        {
            ExportFile(Info);
            SetFocus(Info->hListView);
        }
        break;

        case ID_CREATE:
        {
            INT ret;

            ret = DialogBoxParam(hInstance,
                                 MAKEINTRESOURCE(IDD_DLG_CREATE),
                                 Info->hMainWnd,
                                 CreateDialogProc,
                                 (LPARAM)Info);
            if (ret == IDOK)
                RefreshServiceList(Info);

            SetFocus(Info->hListView);
        }
        break;

        case ID_DELETE:
        {
            if (Info->pCurrentService->ServiceStatusProcess.dwCurrentState != SERVICE_RUNNING)
            {
                DialogBoxParam(hInstance,
                               MAKEINTRESOURCE(IDD_DLG_DELETE),
                               Info->hMainWnd,
                               DeleteDialogProc,
                               (LPARAM)Info);
            }
            else
            {
                TCHAR Buf[60];
                LoadString(hInstance,
                           IDS_DELETE_STOP,
                           Buf,
                           sizeof(Buf) / sizeof(TCHAR));
                DisplayString(Buf);
            }

            SetFocus(Info->hListView);

        }
        break;

        case ID_START:
        {
            if (DoStart(Info, NULL))
            {
                UpdateServiceStatus(Info->pCurrentService);
                ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
                SetMenuAndButtonStates(Info);
                SetFocus(Info->hListView);
            }
        }
        break;

        case ID_STOP:
            if (DoStop(Info))
            {
                UpdateServiceStatus(Info->pCurrentService);
                ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
                SetMenuAndButtonStates(Info);
                SetFocus(Info->hListView);
            }
        break;

        case ID_PAUSE:
            DoPause(Info);
        break;

        case ID_RESUME:
            DoResume(Info);
        break;

        case ID_RESTART:
            if (DoStop(Info))
            {
                DoStart(Info, NULL);
                UpdateServiceStatus(Info->pCurrentService);
                ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
                SetMenuAndButtonStates(Info);
                SetFocus(Info->hListView);
            }
        break;

        case ID_HELP:
            MessageBox(NULL,
                       _T("Help is not yet implemented\n"),
                       _T("Note!"),
                       MB_OK | MB_ICONINFORMATION);
            SetFocus(Info->hListView);
        break;

        case ID_EXIT:
            PostMessage(Info->hMainWnd,
                        WM_CLOSE,
                        0,
                        0);
        break;

        case ID_VIEW_LARGE:
            SetListViewStyle(Info->hListView,
                             LVS_ICON);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_LARGE,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_SMALL:
            SetListViewStyle(Info->hListView,
                             LVS_SMALLICON);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_SMALL,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_LIST:
            SetListViewStyle(Info->hListView,
                             LVS_LIST);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_LIST,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_DETAILS:
            SetListViewStyle(Info->hListView,
                             LVS_REPORT);
            CheckMenuRadioItem(GetMenu(Info->hMainWnd),
                               ID_VIEW_LARGE,
                               ID_VIEW_DETAILS,
                               ID_VIEW_DETAILS,
                               MF_BYCOMMAND);
        break;

        case ID_VIEW_CUST:
        break;

        case ID_ABOUT:
            DialogBox(hInstance,
                      MAKEINTRESOURCE(IDD_ABOUTBOX),
                      Info->hMainWnd,
                      AboutDialogProc);
            SetFocus(Info->hListView);
        break;

    }
}
//--------------------------------------------------------------------------------
bool CSystemMonitorHandlerThread::DoCommand()
	{
	ASSERT(NUM_OF_CMDS == sizeof(g_pCommands) / sizeof(LPCTSTR));

	bool bRv = true;

	m_sCurCmd.MakeLower();
	m_sCurCmd.TrimLeft();
	m_sCurCmd.TrimRight();

	TRY
		{
		CString sTemp(m_sCurCmd.Left(4));

		if(sTemp == "hey")
			m_socket.Send("there\r\n\r\n", 6, CSmallSocket::WAITFORWOULDBLOCK);
		else
			{
			for(int i = 0; i < NUM_OF_CMDS; i++)
				{
				if(strncmp(sTemp, g_pCommands[i], 4) == 0)
					break;
				}

			if(i == CMDEXIT)
				{
				m_sCurCmd.Empty();
				m_sUser.Empty();
				m_sPass.Empty();
				return false;
				}

			if(i == CMDUSER)
				{
				if(m_sCurCmd.GetLength() > 5)
					DoUser(m_sCurCmd.Mid(5));
				m_sCurCmd.Empty();
				return true;
				}

			if(i == CMDPASS)
				{
				if(m_sCurCmd.GetLength() > 5)
					DoPass(m_sCurCmd.Mid(5));
				m_sCurCmd.Empty();
				return true;
				}

			if(! m_bLoggedIn)
				{
				m_sCurCmd.Empty();
				return true;
				}

			switch(i)
				{
				case CMDLOAD:
					if(m_sCurCmd.GetLength() > 5)
						DoLoad(m_sCurCmd.Mid(5));
					else
						{
						CSSConfigGeneral config;
						DoLoad(config.m_sLicenseFileDefault);
						}
					break;
				case CMDLIST:
					DoList();
					break;
				case CMDPAUSE:
					DoPause();
					break;
				case CMDCONT:
					DoContinue();
					break;
				case CMDREVOKE:
					DoRevoke();
					break;
				case CMDHELP:
					{
					for(int i = 0; i < NUM_OF_CMDS; i++)
						{
						CString sTemp;
						sTemp.Format("%s\r\n", g_pCommands[i]);
						m_socket.Send(sTemp, sTemp.GetLength(), CSmallSocket::WAITFORWOULDBLOCK);
						}
					}
					break;
				case CMDSERIAL:
					{
					CString sTemp;
					for(int i = 0; CPlatformInfo::GetProcessorSerialNumber(sTemp, i); i++)
						{
						sTemp += "\r\n";
						m_socket.Send(sTemp, sTemp.GetLength(), CSmallSocket::WAITFORWOULDBLOCK);
						}
					}
					break;

				case CMDDONGLE:
					DoDongle();
					break;

				case CMDCONFIG:
					DoConfigDump();
					break;

				default:
					m_socket.Send("what?\r\n\r\n", 6, CSmallSocket::WAITFORWOULDBLOCK);
					break;
				}
			}
		}
	CATCH_ALL(e)
		{
		}
	END_CATCH_ALL

	m_sCurCmd.Empty();
	return bRv;
	}
Пример #17
0
// Stop the emulation
void CFrame::DoStop()
{
  if (!Core::IsRunningAndStarted())
    return;
  if (m_confirmStop)
    return;

  // don't let this function run again until it finishes, or is aborted.
  m_confirmStop = true;

  m_bGameLoading = false;
  if (Core::GetState() != Core::CORE_UNINITIALIZED || m_RenderParent != nullptr)
  {
#if defined __WXGTK__
    wxMutexGuiLeave();
    std::lock_guard<std::recursive_mutex> lk(keystate_lock);
    wxMutexGuiEnter();
#endif
    // Ask for confirmation in case the user accidentally clicked Stop / Escape
    if (SConfig::GetInstance().bConfirmStop)
    {
      // Exit fullscreen to ensure it does not cover the stop dialog.
      DoFullscreen(false);

      // Pause the state during confirmation and restore it afterwards
      Core::EState state = Core::GetState();

      // Do not pause if netplay is running as CPU thread might be blocked
      // waiting on inputs
      bool should_pause = !NetPlayDialog::GetNetPlayClient();

      // If exclusive fullscreen is not enabled then we can pause the emulation
      // before we've exited fullscreen. If not then we need to exit fullscreen first.
      should_pause =
          should_pause && (!RendererIsFullscreen() || !g_Config.ExclusiveFullscreenEnabled() ||
                           SConfig::GetInstance().bRenderToMain);

      if (should_pause)
      {
        Core::SetState(Core::CORE_PAUSE);
      }

      wxMessageDialog m_StopDlg(
          this, !m_tried_graceful_shutdown ? _("Do you want to stop the current emulation?") :
                                             _("A shutdown is already in progress. Unsaved data "
                                               "may be lost if you stop the current emulation "
                                               "before it completes. Force stop?"),
          _("Please confirm..."), wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition);

      HotkeyManagerEmu::Enable(false);
      int Ret = m_StopDlg.ShowModal();
      HotkeyManagerEmu::Enable(true);
      if (Ret != wxID_YES)
      {
        if (should_pause)
          Core::SetState(state);

        m_confirmStop = false;
        return;
      }
    }

    const auto& stm = WII_IPC_HLE_Interface::GetDeviceByName("/dev/stm/eventhook");
    if (!m_tried_graceful_shutdown && stm &&
        std::static_pointer_cast<CWII_IPC_HLE_Device_stm_eventhook>(stm)->HasHookInstalled())
    {
      Core::DisplayMessage("Shutting down", 30000);
      // Unpause because gracefully shutting down needs the game to actually request a shutdown
      if (Core::GetState() == Core::CORE_PAUSE)
        DoPause();
      ProcessorInterface::PowerButton_Tap();
      m_confirmStop = false;
      m_tried_graceful_shutdown = true;
      return;
    }

    if (UseDebugger && g_pCodeWindow)
    {
      if (g_pCodeWindow->HasPanel<CWatchWindow>())
        g_pCodeWindow->GetPanel<CWatchWindow>()->SaveAll();
      PowerPC::watches.Clear();
      if (g_pCodeWindow->HasPanel<CBreakPointWindow>())
        g_pCodeWindow->GetPanel<CBreakPointWindow>()->SaveAll();
      PowerPC::breakpoints.Clear();
      PowerPC::memchecks.Clear();
      if (g_pCodeWindow->HasPanel<CBreakPointWindow>())
        g_pCodeWindow->GetPanel<CBreakPointWindow>()->NotifyUpdate();
      g_symbolDB.Clear();
      Host_NotifyMapLoaded();
    }

    // TODO: Show the author/description dialog here
    if (Movie::IsRecordingInput())
      DoRecordingSave();
    if (Movie::IsMovieActive())
      Movie::EndPlayInput(false);

    if (NetPlayDialog::GetNetPlayClient())
      NetPlayDialog::GetNetPlayClient()->Stop();

    Core::Stop();
    UpdateGUI();
  }
}