コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: panmaneecnc/qGRBL
void MainWindow::on_btnStopGFile_clicked()
{
    if(m_eCurrentState == stSendingGFile || m_eCurrentState == stCheckingGFile)
    {
        gfile.close();
        m_eCurrentState = stIdle;
        UpdateUIState();
    }
    ui->btnToolChangeAccept->setEnabled(false);
}
コード例 #2
0
ファイル: MainWindow.cpp プロジェクト: panmaneecnc/qGRBL
void MainWindow::on_btnCheckGFile_clicked()
{
    if(gfile.isOpen()) gfile.close();
    gfile.setFileName(ui->leGFileName->text());
    if(!gfile.open(QFile::ReadOnly)) return;
    m_eCurrentState = stCheckingGFile;
    UpdateUIState();
    grbl.SendAsyncCommand("$C");
    GFileSendChunk();
}
コード例 #3
0
LRESULT TapeReaderView::OnIQFeedConnected( UINT, WPARAM, LPARAM, BOOL& bHandled ) {

  m_stateUI = UI_NOSYMBOL;
  UpdateUIState();

  m_edtSymbol.SetFocus();

  bHandled = true;
  return 1;
}
コード例 #4
0
LRESULT TapeReaderView::OnIQFeedDisconnected( UINT, WPARAM, LPARAM, BOOL& bHandled ) {
  // this message never arrives

  m_stateUI = UI_DISCONNECTED;
  UpdateUIState();

  DestroyWindow();

  bHandled = true;
  return 1;
}
コード例 #5
0
ファイル: MainWindow.cpp プロジェクト: panmaneecnc/qGRBL
void MainWindow::on_btnReset_pressed()
{
    if(m_eCurrentState == stSendingGFile || m_eCurrentState == stCheckingGFile)
    {
        gfile.close();
        m_eCurrentState = stIdle;
        UpdateUIState();
    }
    grbl.SendReset();
    ui->btnToolChangeAccept->setEnabled(false);
}
コード例 #6
0
void TapeReaderView::StopData( void ) {
  if ( UI_STARTED == m_stateUI ) {
    std::string sSend = _T( "r" );
    sSend += m_sSymbol;
    sSend += _T( "\n" );

    m_pIQFeed->Send( sSend );

    m_stateUI = UI_SYMBOLENTRY;
    UpdateUIState();
  }
}
コード例 #7
0
ファイル: MainWindow.cpp プロジェクト: panmaneecnc/qGRBL
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    m_eCurrentState = stIdle;

    _ManualControlCreate();

    connect(&grbl, SIGNAL(QueuedCommandDone()), this, SLOT(QueuedCommandDone()));
    connect(&grbl, SIGNAL(CommandError(QString)), this, SLOT(CommandError(QString)));
    connect(&grbl, SIGNAL(CommandSent(QString)), this, SLOT(CommandSent(QString)));
    connect(&grbl, SIGNAL(ResponseLineReceieved(QString)), this, SLOT(ResponseLineReceieved(QString)));

    connect(ui->btnXm, SIGNAL(pressed()), this, SLOT(JoggingBtnPressed()));
    connect(ui->btnXp, SIGNAL(pressed()), this, SLOT(JoggingBtnPressed()));
    connect(ui->btnYm, SIGNAL(pressed()), this, SLOT(JoggingBtnPressed()));
    connect(ui->btnYp, SIGNAL(pressed()), this, SLOT(JoggingBtnPressed()));
    connect(ui->btnZm, SIGNAL(pressed()), this, SLOT(JoggingBtnPressed()));
    connect(ui->btnZp, SIGNAL(pressed()), this, SLOT(JoggingBtnPressed()));
    connect(ui->btnHome, SIGNAL(pressed()), this, SLOT(JoggingBtnPressed()));
    connect(ui->menuCommunication, SIGNAL(triggered(QAction*)), this, SLOT(CommPortSelected(QAction*)));
    connect(ui->menuCommunication, SIGNAL(aboutToShow()), this, SLOT(EnumerateCommPorts()));

    connect(&grbl, SIGNAL(ToolChangeRequest()), this, SLOT(ToolChangeRequest()));
    connect(&grbl, SIGNAL(SetZProbe()), this, SLOT(SetZProbe()));
    connect(ui->leGFileName, SIGNAL(textChanged(QString)), this, SLOT(UpdateUIState()));

    UpdateUIState();
    startTimer(100);

#if(SIMULATOR_DEBUG)
    m_CurrentCommPort = "/dev/ttyFAKE";
    grbl.OpenPort(m_CurrentCommPort, 115200);
#endif

}
コード例 #8
0
ファイル: MainWindow.cpp プロジェクト: panmaneecnc/qGRBL
void MainWindow::QueuedCommandDone()
{
    switch(m_eCurrentState)
    {
    case stCheckingGFile: /* Just falling through to next state */
    case stSendingGFile:
        if(!GFileSendChunk())
        {
            m_eCurrentState = stIdle;
            UpdateUIState();
        }
        break;

    default:
        break;
    }
}
コード例 #9
0
LRESULT TapeReaderView::OnEnChangeEdtsymbol(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
  // TODO:  If this is a RICHEDIT control, the control will not
  // send this notification unless you override the CDialogImpl<TapeReaderView>::OnInitDialog()
  // function and call CRichEditCtrl().SetEventMask()
  // with the ENM_CHANGE flag ORed into the mask.

  // TODO:  Add your control notification handler code here
  if ( 0 == m_edtSymbol.GetWindowTextLengthA() ) {
    m_stateUI = UI_NOSYMBOL;
  }
  else {
    m_stateUI = UI_SYMBOLENTRY;
  }
  UpdateUIState();

  return 0;
}
コード例 #10
0
ファイル: EmuThread.cpp プロジェクト: thesourcehim/ppsspp
void EmuThread_Stop()
{
	// Already stopped?
	{
		std::lock_guard<std::mutex> guard(emuThreadLock);
		if (emuThread == NULL || emuThreadReady == THREAD_END)
			return;
	}

	UpdateUIState(UISTATE_EXIT);
	Core_Stop();
	Core_WaitInactive(800);
	if (WAIT_TIMEOUT == WaitForSingleObject(emuThread, 800))
	{
		_dbg_assert_msg_(COMMON, false, "Wait for EmuThread timed out.");
	}
	{
		std::lock_guard<std::mutex> guard(emuThreadLock);
		CloseHandle(emuThread);
		emuThread = 0;
	}
	PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0);
}
コード例 #11
0
ファイル: EmuThread.cpp プロジェクト: AnwariJr/ppsspp
void EmuThread_Stop()
{
	// Already stopped?
	{
		lock_guard guard(emuThreadLock);
		if (emuThread == NULL || emuThreadReady == THREAD_END)
			return;
	}

	UpdateUIState(UISTATE_EXIT);
	Core_Stop();
	Core_WaitInactive(800);
	if (WAIT_TIMEOUT == WaitForSingleObject(emuThread, 800))
	{
		_dbg_assert_msg_(COMMON, false, "Wait for EmuThread timed out.");
	}
	{
		lock_guard guard(emuThreadLock);
		CloseHandle(emuThread);
		emuThread = 0;
	}
	host->UpdateUI();
}
コード例 #12
0
ファイル: main.cpp プロジェクト: NickABoen/Awe
void CALLBACK OnGUIEvent(UINT eventID, INT controlID, CDXUTControl* control, void* userContext)
{
    switch (controlID) {
        case UI_TOGGLEFULLSCREEN:
            DXUTToggleFullScreen(); break;
        case UI_TOGGLEWARP:
            DXUTToggleWARP(); break;
        case UI_CHANGEDEVICE:
            gD3DSettingsDlg.SetActive(!gD3DSettingsDlg.IsActive()); break;
        case UI_LIGHTINGONLY:
            gUIConstants.lightingOnly = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;
        case UI_FACENORMALS:
            gUIConstants.faceNormals = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;        
        case UI_VISUALIZELIGHTCOUNT:
            gUIConstants.visualizeLightCount = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;            
        case UI_VISUALIZEPERSAMPLESHADING:
            gUIConstants.visualizePerSampleShading = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;            
        case UI_SELECTEDSCENE:
            DestroyScene(); break;
        case UI_LIGHTS:
            gApp->SetActiveLights(DXUTGetD3D11Device(), 1 << gLightsSlider->GetValue()); break;
        case UI_CULLTECHNIQUE:
            gUIConstants.lightCullTechnique = static_cast<unsigned int>(PtrToUlong(gCullTechniqueCombo->GetSelectedData())); break;

        // These controls all imply changing parameters to the App constructor
        // (i.e. recreating resources and such), so we'll just clean up the app here and let it be
        // lazily recreated next render.
        case UI_MSAA:
            DestroyApp(); break;

        default:
            break;
    }

    UpdateUIState();
}
コード例 #13
0
ファイル: EmuScreen.cpp プロジェクト: Alwayssnarky/ppsspp
void EmuScreen::update(InputState &input) {
	if (!booted_)
		bootGame(gamePath_);

	UIScreen::update(input);

	// Simply forcibily update to the current screen size every frame. Doesn't cost much.
	// If bounds is set to be smaller than the actual pixel resolution of the display, respect that.
	// TODO: Should be able to use g_dpi_scale here instead. Might want to store the dpi scale in the UI context too.
	const Bounds &bounds = screenManager()->getUIContext()->GetBounds();
	PSP_CoreParameter().pixelWidth = pixel_xres * bounds.w / dp_xres;
	PSP_CoreParameter().pixelHeight = pixel_yres * bounds.h / dp_yres;

	UpdateUIState(UISTATE_INGAME);

	if (errorMessage_.size()) {
		// Special handling for ZIP files. It's not very robust to check an error message but meh,
		// at least it's pre-translation.
		if (errorMessage_.find("ZIP") != std::string::npos) {
			screenManager()->push(new InstallZipScreen(gamePath_));
			errorMessage_ = "";
			quit_ = true;
			return;
		}
		I18NCategory *g = GetI18NCategory("Error");
		std::string errLoadingFile = g->T("Error loading file", "Could not load game");

		errLoadingFile.append(" ");
		errLoadingFile.append(g->T(errorMessage_.c_str()));

		screenManager()->push(new PromptScreen(errLoadingFile, "OK", ""));
		errorMessage_ = "";
		quit_ = true;
		return;
	}

	if (invalid_)
		return;

	// Virtual keys.
	__CtrlSetRapidFire(virtKeys[VIRTKEY_RAPID_FIRE - VIRTKEY_FIRST]);

	// Apply tilt to left stick
	// TODO: Make into an axis
#ifdef MOBILE_DEVICE
	/*
	if (g_Config.bAccelerometerToAnalogHoriz) {
		// Get the "base" coordinate system which is setup by the calibration system
		float base_x = g_Config.fTiltBaseX;
		float base_y = g_Config.fTiltBaseY;

		//convert the current input into base coordinates and normalize
		//TODO: check if all phones give values between [-50, 50]. I'm not sure how iOS works.
		float normalized_input_x = (input.acc.y - base_x) / 50.0 ;
		float normalized_input_y = (input.acc.x - base_y) / 50.0 ;

		//TODO: need a better name for computed x and y.
		float delta_x =  tiltInputCurve(normalized_input_x * 2.0 * (g_Config.iTiltSensitivityX)) ;

		//if the invert is enabled, invert the motion
		if (g_Config.bInvertTiltX) {
			delta_x *= -1;
		}

		float delta_y =  tiltInputCurve(normalized_input_y * 2.0 * (g_Config.iTiltSensitivityY)) ;
		
		if (g_Config.bInvertTiltY) {
			delta_y *= -1;
		}

		//clamp the delta between [-1, 1]
		leftstick_x += clamp1(delta_x);
		__CtrlSetAnalogX(clamp1(leftstick_x), CTRL_STICK_LEFT);

		
		leftstick_y += clamp1(delta_y);
		__CtrlSetAnalogY(clamp1(leftstick_y), CTRL_STICK_LEFT);
	}
	*/
#endif

	// Make sure fpsLimit starts at 0
	if (PSP_CoreParameter().fpsLimit != 0 && PSP_CoreParameter().fpsLimit != 1) {
		PSP_CoreParameter().fpsLimit = 0;
	}

	// This is here to support the iOS on screen back button.
	if (pauseTrigger_) {
		pauseTrigger_ = false;
		screenManager()->push(new GamePauseScreen(gamePath_));
	}
}
コード例 #14
0
ファイル: EmuThread.cpp プロジェクト: thesourcehim/ppsspp
unsigned int WINAPI TheThread(void *)
{
	_InterlockedExchange(&emuThreadReady, THREAD_INIT);

	setCurrentThreadName("Emu");  // And graphics...

	host = new WindowsHost(MainWindow::GetHInstance(), MainWindow::GetHWND(), MainWindow::GetDisplayHWND());
	host->SetWindowTitle(nullptr);

	// Convert the command-line arguments to Unicode, then to proper UTF-8 
	// (the benefit being that we don't have to pollute the UI project with win32 ifdefs and lots of Convert<whatever>To<whatever>).
	// This avoids issues with PPSSPP inadvertently destroying paths with Unicode glyphs 
	// (using the ANSI args resulted in Japanese/Chinese glyphs being turned into question marks, at least for me..).
	// -TheDax
	std::vector<std::wstring> wideArgs = GetWideCmdLine();
	std::vector<std::string> argsUTF8;
	for (auto& string : wideArgs) {
		argsUTF8.push_back(ConvertWStringToUTF8(string));
	}

	std::vector<const char *> args;

	for (auto& string : argsUTF8) {
		args.push_back(string.c_str());
	}

	bool performingRestart = NativeIsRestarting();
	NativeInit(static_cast<int>(args.size()), &args[0], "1234", "1234", nullptr);

	host->UpdateUI();

	GraphicsContext *graphicsContext = nullptr;

	std::string error_string;
	if (!host->InitGraphics(&error_string, &graphicsContext)) {
		// Before anything: are we restarting right now?
		if (performingRestart) {
			// Okay, switching graphics didn't work out.  Probably a driver bug - fallback to restart.
			// This happens on NVIDIA when switching OpenGL -> Vulkan.
			g_Config.Save();
			W32Util::ExitAndRestart();
		}

		I18NCategory *err = GetI18NCategory("Error");
		Reporting::ReportMessage("Graphics init error: %s", error_string.c_str());

		const char *defaultErrorVulkan = "Failed initializing graphics. Try upgrading your graphics drivers.\n\nWould you like to try switching to OpenGL?\n\nError message:";
		const char *defaultErrorOpenGL = "Failed initializing graphics. Try upgrading your graphics drivers.\n\nWould you like to try switching to DirectX 9?\n\nError message:";
		const char *defaultErrorDirect3D9 = "Failed initializing graphics. Try upgrading your graphics drivers and directx 9 runtime.\n\nWould you like to try switching to OpenGL?\n\nError message:";
		const char *genericError;
		int nextBackend = GPU_BACKEND_DIRECT3D9;
		switch (g_Config.iGPUBackend) {
		case GPU_BACKEND_DIRECT3D9:
			nextBackend = GPU_BACKEND_OPENGL;
			genericError = err->T("GenericDirect3D9Error", defaultErrorDirect3D9);
			break;
		case GPU_BACKEND_VULKAN:
			nextBackend = GPU_BACKEND_OPENGL;
			genericError = err->T("GenericVulkanError", defaultErrorVulkan);
			break;
		case GPU_BACKEND_OPENGL:
		default:
			nextBackend = GPU_BACKEND_DIRECT3D9;
			genericError = err->T("GenericOpenGLError", defaultErrorOpenGL);
			break;
		}
		std::string full_error = StringFromFormat("%s\n\n%s", genericError, error_string.c_str());
		std::wstring title = ConvertUTF8ToWString(err->T("GenericGraphicsError", "Graphics Error"));
		bool yes = IDYES == MessageBox(0, ConvertUTF8ToWString(full_error).c_str(), title.c_str(), MB_ICONERROR | MB_YESNO);
		ERROR_LOG(BOOT, full_error.c_str());

		if (yes) {
			// Change the config to the alternative and restart.
			g_Config.iGPUBackend = nextBackend;
			g_Config.Save();

			W32Util::ExitAndRestart();
		}

		// No safe way out without graphics.
		ExitProcess(1);
	}

	NativeInitGraphics(graphicsContext);
	NativeResized();

	INFO_LOG(BOOT, "Done.");
	_dbg_update_();

	if (coreState == CORE_POWERDOWN) {
		INFO_LOG(BOOT, "Exit before core loop.");
		goto shutdown;
	}

	_InterlockedExchange(&emuThreadReady, THREAD_CORE_LOOP);

	if (g_Config.bBrowse)
		PostMessage(MainWindow::GetHWND(), WM_COMMAND, ID_FILE_LOAD, 0);

	Core_EnableStepping(FALSE);

	while (GetUIState() != UISTATE_EXIT)
	{
		// We're here again, so the game quit.  Restart Core_Run() which controls the UI.
		// This way they can load a new game.
		if (!Core_IsActive())
			UpdateUIState(UISTATE_MENU);

		Core_Run(graphicsContext);
	}

shutdown:
	_InterlockedExchange(&emuThreadReady, THREAD_SHUTDOWN);

	NativeShutdownGraphics();

	// NativeShutdown deletes the graphics context through host->ShutdownGraphics().
	NativeShutdown();
	
	_InterlockedExchange(&emuThreadReady, THREAD_END);

	return 0;
}
コード例 #15
0
ファイル: main.cpp プロジェクト: NickABoen/Awe
void InitUI()
{
    // Setup default UI state
    // NOTE: All of these are made directly available in the shader constant buffer
    // This is convenient for development purposes.

#pragma region set UIConstants
    gUIConstants.lightingOnly = 0;
    gUIConstants.faceNormals = 0;
    gUIConstants.visualizeLightCount = 0;
    gUIConstants.visualizePerSampleShading = 0;
    gUIConstants.lightCullTechnique = CULL_QUAD_DEFERRED_LIGHTING;
#pragma endregion

    gD3DSettingsDlg.Init(&gDialogResourceManager);

    for (int i = 0; i < HUD_NUM; ++i) {
        gHUD[i].Init(&gDialogResourceManager);
        gHUD[i].SetCallback(OnGUIEvent);
    }

    int width = 200;

#pragma region Generate Hud
    // Generic HUD
    {
        CDXUTDialog* HUD = &gHUD[HUD_GENERIC];
        int y = 0;

        HUD->AddButton(UI_TOGGLEFULLSCREEN, L"Toggle full screen", 0, y, width, 23);
        y += 26;

        // Warp doesn't support DX11 yet
        //HUD->AddButton(UI_TOGGLEWARP, L"Toggle WARP (F3)", 0, y, width, 23, VK_F3);
        //y += 26;

        HUD->AddButton(UI_CHANGEDEVICE, L"Change device (F2)", 0, y, width, 23, VK_F2);
        y += 26;

#pragma region Add MSAA select Combo Box Items
        HUD->AddComboBox(UI_MSAA, 0, y, width, 23, 0, false, &gMSAACombo);
        y += 26;
        gMSAACombo->AddItem(L"No MSAA", ULongToPtr(1));
        gMSAACombo->AddItem(L"2x MSAA", ULongToPtr(2));
        gMSAACombo->AddItem(L"4x MSAA", ULongToPtr(4));
        gMSAACombo->AddItem(L"8x MSAA", ULongToPtr(8));
#pragma endregion

#pragma region Add Scene/mesh select Combo Box items
        HUD->AddComboBox(UI_SELECTEDSCENE, 0, y, width, 23, 0, false, &gSceneSelectCombo);
        y += 26;
		gSceneSelectCombo->AddItem(L"Cube World (AWE)", ULongToPtr(CUBE_WORLD));
        gSceneSelectCombo->AddItem(L"Power Plant", ULongToPtr(POWER_PLANT_SCENE));
        gSceneSelectCombo->AddItem(L"Sponza", ULongToPtr(SPONZA_SCENE));
		gSceneSelectCombo->AddItem(L"Multi Object Scene", ULongToPtr(MULTI_SCENE));
		gSceneSelectCombo->AddItem(L"CUBES", ULongToPtr(CUBES));
#pragma endregion

#pragma region Add Options Checkboxes and sliders
        HUD->AddCheckBox(UI_ANIMATELIGHT, L"Animate Lights", 0, y, width, 23, false, VK_SPACE, false, &gAnimateLightCheck);
        y += 26;

        HUD->AddCheckBox(UI_LIGHTINGONLY, L"Lighting Only", 0, y, width, 23, gUIConstants.lightingOnly != 0);
        y += 26;

        HUD->AddCheckBox(UI_FACENORMALS, L"Face Normals", 0, y, width, 23, gUIConstants.faceNormals != 0);
        y += 26;

        HUD->AddCheckBox(UI_VISUALIZELIGHTCOUNT, L"Visualize Light Count", 0, y, width, 23, gUIConstants.visualizeLightCount != 0);
        y += 26;

        HUD->AddCheckBox(UI_VISUALIZEPERSAMPLESHADING, L"Visualize Shading Freq.", 0, y, width, 23, gUIConstants.visualizePerSampleShading != 0);
        y += 26;

        HUD->AddStatic(UI_LIGHTSTEXT, L"Lights:", 0, y, width, 23);
        y += 26;
        HUD->AddSlider(UI_LIGHTS, 0, y, width, 23, 0, MAX_LIGHTS_POWER, MAX_LIGHTS_POWER, false, &gLightsSlider);
        y += 26;
#pragma endregion

#pragma region Add Lighting method select Combo box items
        HUD->AddComboBox(UI_CULLTECHNIQUE, 0, y, width, 23, 0, false, &gCullTechniqueCombo);
        y += 26;
        gCullTechniqueCombo->AddItem(L"No Cull Forward", ULongToPtr(CULL_FORWARD_NONE));
        gCullTechniqueCombo->AddItem(L"No Cull Pre-Z", ULongToPtr(CULL_FORWARD_PREZ_NONE));
        gCullTechniqueCombo->AddItem(L"No Cull Deferred", ULongToPtr(CULL_DEFERRED_NONE));
        gCullTechniqueCombo->AddItem(L"Quad", ULongToPtr(CULL_QUAD));
        gCullTechniqueCombo->AddItem(L"Quad Deferred Light", ULongToPtr(CULL_QUAD_DEFERRED_LIGHTING));
        gCullTechniqueCombo->AddItem(L"Compute Shader Tile", ULongToPtr(CULL_COMPUTE_SHADER_TILE));
        gCullTechniqueCombo->SetSelectedByData(ULongToPtr(gUIConstants.lightCullTechnique));
#pragma endregion

        HUD->SetSize(width, y);
    }

    // Expert HUD
    {
        CDXUTDialog* HUD = &gHUD[HUD_EXPERT];
        int y = 0;
    
        HUD->SetSize(width, y);

        // Initially hidden
        HUD->SetVisible(false);
    }
#pragma endregion

    UpdateUIState();
}
コード例 #16
0
LRESULT TapeReaderView::OnIQFeedUpdate( UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) {

  ou::tf::IQFUpdateMessage* msg = reinterpret_cast<ou::tf::IQFUpdateMessage*>( lParam );

  if ( 'N' == *msg->FieldBegin( ou::tf::IQFUpdateMessage::QPLast ) ) {  // field has "Not Found" in numeric field
    CWindow::MessageBoxA( "Symbol Not Found", "Error", MB_OK );
    m_stateUI = UI_SYMBOLENTRY;
    UpdateUIState();
  }
  else {
    std::string sSymbol( 
      msg->FieldBegin( ou::tf::IQFUpdateMessage::QPSymbol ),
      msg->FieldEnd( ou::tf::IQFUpdateMessage::QPSymbol ) );
    if ( sSymbol == m_sSymbol ) {
      std::string sLastTradeTime( 
        msg->FieldBegin(ou::tf:: IQFUpdateMessage::QPLastTradeTime ),
        msg->FieldEnd( ou::tf::IQFUpdateMessage::QPLastTradeTime ) );
      if ( 9 == sLastTradeTime.length() ) {
        std::string sBid( msg->FieldBegin( ou::tf::IQFUpdateMessage::QPBid ), msg->FieldEnd( ou::tf::IQFUpdateMessage::QPBid ) );
        std::string sBidVol( msg->FieldBegin( ou::tf::IQFUpdateMessage::QPBidSize ), msg->FieldEnd( ou::tf::IQFUpdateMessage::QPBidSize ) );
        std::string sTick( msg->FieldBegin( ou::tf::IQFUpdateMessage::QPLast ), msg->FieldEnd( ou::tf::IQFUpdateMessage::QPLast ) );
        std::string sTickVol( msg->FieldBegin( ou::tf::IQFUpdateMessage::QPLastVol ), msg->FieldEnd( ou::tf::IQFUpdateMessage::QPLastVol ) );
        std::string sAsk( msg->FieldBegin( ou::tf::IQFUpdateMessage::QPAsk ), msg->FieldEnd( ou::tf::IQFUpdateMessage::QPAsk ) );
        std::string sAskVol( msg->FieldBegin( ou::tf::IQFUpdateMessage::QPAskSize ), msg->FieldEnd( ou::tf::IQFUpdateMessage::QPAskSize ) );
//            sPrice.assign( msg->FieldBegin( IQFUpdateMessage::QPExtTradeLast ), msg->FieldEnd( IQFUpdateMessage::QPExtTradeLast ) );
//            sSize.assign( msg->FieldBegin( IQFUpdateMessage::QPLastVol ), msg->FieldEnd( IQFUpdateMessage::QPLastVol ) );

        int cntPerPage = m_lvTape.GetCountPerPage();
        if ( 0 < cntPerPage ) {

          int ix;
          while ( cntPerPage <= (ix = m_lvTape.GetItemCount() ) ) {
            m_lvTape.DeleteItem( ix - 1 );
          }

          m_lvTape.InsertItem( 0, sLastTradeTime.c_str() );
          m_lvTape.SetItemText( 0, COLHDR_COL_Bid, sBid.c_str() );
          m_lvTape.SetItemText( 0, COLHDR_COL_BidVol, sBidVol.c_str() );
          m_lvTape.SetItemText( 0, COLHDR_COL_Tck, sTick.c_str() );
          m_lvTape.SetItemText( 0, COLHDR_COL_TckVol, sTickVol.c_str() );
          m_lvTape.SetItemText( 0, COLHDR_COL_Ask, sAsk.c_str() );
          m_lvTape.SetItemText( 0, COLHDR_COL_AskVol, sAskVol.c_str() );

          structRowItems ri;
          ri.vTime = sLastTradeTime;
          ri.vBid = msg->Double( ou::tf::IQFUpdateMessage::QPBid );
//          ri.vBidVol = msg->Integer( IQFUpdateMessage::QPBidSize );
          ri.vTick = msg->Double( ou::tf::IQFUpdateMessage::QPLast );
//          ri.vTickVol = msg->Integer( IQFUpdateMessage::QPLastVol );
          ri.vAsk = msg->Double( ou::tf::IQFUpdateMessage::QPAsk );
//          ri.vAskVol = msg->Integer( IQFUpdateMessage::QPAskSize );
          
          COLORREF cBack = ou::Colour::Beige;
          // set colours so green range for higher buy/sell, new high buy/sell
          // set colours so red range for lower buy/sell, new log buy/sell

          if ( m_bRunning ) {
            if ( 't' == sLastTradeTime[8] ) {  // treat as trade
              double dblMid = ( ri.vBid + ri.vAsk ) / 2.0;
              ri.vBate = "Trade";
              if ( ri.vTick > dblMid ) {
                cBack = ou::Colour::LightGreen;
                ri.vBate = "Buy";
              }
              else {
                cBack = ou::Colour::LightPink;
                ri.vBate = "Sell";
              }
              if ( ri.vTick > m_dblMaxTick ) {
                cBack = ou::Colour::Blue;
              }
              if ( ri.vTick < m_dblMinTick ) {
                cBack = ou::Colour::Orange;
              }
            }
            else {  // process bid/ask stuff
              if ( ( ri.vBid > m_prvValues.vBid ) && ( ri.vAsk < m_prvValues.vAsk ) ) {
                // new inside bid and new inside ask
                cBack = ou::Colour::Gray;
                ri.vBate = "Best Bid/Ask";
              }
              else {
                if ( ( ri.vBid > m_prvValues.vBid ) || ( ri.vAsk < m_prvValues.vAsk ) ) {
                  if ( ri.vBid > m_prvValues.vBid ) {
                    cBack = ou::Colour::Yellow;
                    ri.vBate = "Best Bid";
                  }
                  else {
                    cBack = ou::Colour::White;
                    ri.vBate = "Best Ask";
                  }
                }
                else {  // regular bid or regular ask change
                  if ( 'b' == sLastTradeTime[8] ) {
                    ri.vBate = "Bid";
                    cBack = ou::Colour::LightYellow;
                  }
                  if ( 'a' == sLastTradeTime[8] ) {
                    ri.vBate = "Ask";
                    cBack = ou::Colour::Snow;
                  }
                }
              }
            }
            m_lvTape.SetItemText( 0, COLHDR_COL_BATE, ri.vBate.c_str() );
          }
          else {
            m_bRunning = true;
            m_dblMinTick = m_dblMaxTick = ri.vTick;
          }
          m_prvValues = ri;
          m_dblMinTick = std::min<double>( m_dblMinTick, ri.vTick );
          m_dblMaxTick = std::max<double>( m_dblMaxTick, ri.vTick );

          m_prvValues = ri;
        }
      }
    }
  }

  linebuffer_t* p = reinterpret_cast<linebuffer_t*>( wParam );
  m_pIQFeed->UpdateDone( p, msg );

  bHandled = true;
  return 1;
}
コード例 #17
0
ファイル: EmuThread.cpp プロジェクト: AnwariJr/ppsspp
unsigned int WINAPI TheThread(void *)
{
	_InterlockedExchange(&emuThreadReady, THREAD_INIT);

	setCurrentThreadName("Emu");  // And graphics...

	// Native overwrites host. Can't allow that.

	Host *oldHost = host;

	// Convert the command-line arguments to Unicode, then to proper UTF-8 
	// (the benefit being that we don't have to pollute the UI project with win32 ifdefs and lots of Convert<whatever>To<whatever>).
	// This avoids issues with PPSSPP inadvertently destroying paths with Unicode glyphs 
	// (using the ANSI args resulted in Japanese/Chinese glyphs being turned into question marks, at least for me..).
	// -TheDax
	std::vector<std::wstring> wideArgs = GetWideCmdLine();
	std::vector<std::string> argsUTF8;
	for (auto& string : wideArgs) {
		argsUTF8.push_back(ConvertWStringToUTF8(string));
	}

	std::vector<const char *> args;

	for (auto& string : argsUTF8) {
		args.push_back(string.c_str());
	}

	NativeInit(static_cast<int>(args.size()), &args[0], "1234", "1234", "1234");

	Host *nativeHost = host;
	host = oldHost;

	host->UpdateUI();
	
	//Check Colour depth
	HDC dc = GetDC(NULL);
	u32 colour_depth = GetDeviceCaps(dc, BITSPIXEL);
	ReleaseDC(NULL, dc);
	if (colour_depth != 32){
		MessageBox(0, L"Please switch your display to 32-bit colour mode", L"OpenGL Error", MB_OK);
		ExitProcess(1);
	}

	std::string error_string;
	if (!host->InitGraphics(&error_string)) {
		Reporting::ReportMessage("Graphics init error: %s", error_string.c_str());
		std::string full_error = StringFromFormat( "Failed initializing OpenGL. Try upgrading your graphics drivers.\n\nError message:\n\n%s", error_string.c_str());
		MessageBox(0, ConvertUTF8ToWString(full_error).c_str(), L"OpenGL Error", MB_OK | MB_ICONERROR);
		ERROR_LOG(BOOT, full_error.c_str());

		// No safe way out without OpenGL.
		ExitProcess(1);
	}

	NativeInitGraphics();
	NativeResized();

	INFO_LOG(BOOT, "Done.");
	_dbg_update_();

	if (coreState == CORE_POWERDOWN) {
		INFO_LOG(BOOT, "Exit before core loop.");
		goto shutdown;
	}

	_InterlockedExchange(&emuThreadReady, THREAD_CORE_LOOP);

	if (g_Config.bBrowse)
		PostMessage(MainWindow::GetHWND(), WM_COMMAND, ID_FILE_LOAD, 0);

	Core_EnableStepping(FALSE);

	while (GetUIState() != UISTATE_EXIT)
	{
		// We're here again, so the game quit.  Restart Core_Run() which controls the UI.
		// This way they can load a new game.
		if (!Core_IsActive())
			UpdateUIState(UISTATE_MENU);

		Core_Run();
	}

shutdown:
	_InterlockedExchange(&emuThreadReady, THREAD_SHUTDOWN);

	NativeShutdownGraphics();

	host->ShutdownSound();
	host = nativeHost;
	NativeShutdown();
	host = oldHost;
	host->ShutdownGraphics();
	
	_InterlockedExchange(&emuThreadReady, THREAD_END);

	return 0;
}
コード例 #18
0
ファイル: EmuThread.cpp プロジェクト: rifters/ppsspp
unsigned int WINAPI TheThread(void *)
{
    _InterlockedExchange(&emuThreadReady, THREAD_INIT);

    setCurrentThreadName("EmuThread");

    // Native overwrites host. Can't allow that.

    Host *oldHost = host;
    UpdateScreenScale();

    NativeInit(__argc, (const char **)__argv, "1234", "1234", "1234");
    Host *nativeHost = host;
    host = oldHost;

    host->UpdateUI();

    //Check Colour depth
    HDC dc = GetDC(NULL);
    u32 colour_depth = GetDeviceCaps(dc, BITSPIXEL);
    ReleaseDC(NULL, dc);
    if (colour_depth != 32) {
        MessageBoxA(0, "Please switch your display to 32-bit colour mode", "OpenGL Error", MB_OK);
        ExitProcess(1);
    }

    std::string error_string;
    if (!host->InitGL(&error_string)) {
        Reporting::ReportMessage("OpenGL init error: %s", error_string.c_str());
        std::string full_error = StringFromFormat( "Failed initializing OpenGL. Try upgrading your graphics drivers.\n\nError message:\n\n%s", error_string.c_str());
        MessageBoxA(0, full_error.c_str(), "OpenGL Error", MB_OK | MB_ICONERROR);
        ERROR_LOG(BOOT, full_error.c_str());

        // No safe way out without OpenGL.
        ExitProcess(1);
    }

    NativeInitGraphics();

    INFO_LOG(BOOT, "Done.");
    _dbg_update_();

    if (coreState == CORE_POWERDOWN) {
        INFO_LOG(BOOT, "Exit before core loop.");
        goto shutdown;
    }

    _InterlockedExchange(&emuThreadReady, THREAD_CORE_LOOP);

    if (g_Config.bBrowse)
        PostMessage(MainWindow::GetHWND(), WM_COMMAND, ID_FILE_LOAD, 0);

    Core_EnableStepping(FALSE);

    while (globalUIState != UISTATE_EXIT)
    {
        // We're here again, so the game quit.  Restart Core_Run() which controls the UI.
        // This way they can load a new game.
        if (!Core_IsActive())
            UpdateUIState(UISTATE_MENU);

        Core_Run();
    }

shutdown:
    _InterlockedExchange(&emuThreadReady, THREAD_SHUTDOWN);

    NativeShutdownGraphics();

    host->ShutdownSound();
    host = nativeHost;
    NativeShutdown();
    host = oldHost;
    host->ShutdownGL();

    _InterlockedExchange(&emuThreadReady, THREAD_END);

    return 0;
}
コード例 #19
0
ファイル: EmuScreen.cpp プロジェクト: ANR2ME/ppsspp
void EmuScreen::sendMessage(const char *message, const char *value) {
	// External commands, like from the Windows UI.
	if (!strcmp(message, "pause")) {
		screenManager()->push(new GamePauseScreen(gamePath_));
	} else if (!strcmp(message, "stop")) {
		// We will push MainScreen in update().
		PSP_Shutdown();
		bootPending_ = false;
		invalid_ = true;
		host->UpdateDisassembly();
	} else if (!strcmp(message, "reset")) {
		PSP_Shutdown();
		bootPending_ = true;
		invalid_ = true;
		host->UpdateDisassembly();

		std::string resetError;
		if (!PSP_InitStart(PSP_CoreParameter(), &resetError)) {
			ELOG("Error resetting: %s", resetError.c_str());
			screenManager()->switchScreen(new MainScreen());
			System_SendMessage("event", "failstartgame");
			return;
		}
	} else if (!strcmp(message, "boot")) {
		const char *ext = strrchr(value, '.');
		if (!strcmp(ext, ".ppst")) {
			SaveState::Load(value, &AfterStateLoad);
		} else {
			PSP_Shutdown();
			bootPending_ = true;
			bootGame(value);
		}
	} else if (!strcmp(message, "control mapping")) {
		UpdateUIState(UISTATE_MENU);
		screenManager()->push(new ControlMappingScreen());
	} else if (!strcmp(message, "settings")) {
		UpdateUIState(UISTATE_MENU);
		screenManager()->push(new GameSettingsScreen(gamePath_));
	} else if (!strcmp(message, "gpu resized") || !strcmp(message, "gpu clear cache")) {
		if (gpu) {
			gpu->ClearCacheNextFrame();
			gpu->Resized();
		}
		Reporting::UpdateConfig();
		RecreateViews();
	} else if (!strcmp(message, "gpu dump next frame")) {
		if (gpu) gpu->DumpNextFrame();
	} else if (!strcmp(message, "clear jit")) {
		if (MIPSComp::jit) {
			MIPSComp::jit->ClearCache();
		}
		if (PSP_IsInited()) {
			currentMIPS->UpdateCore(g_Config.bJit ? CPU_JIT : CPU_INTERPRETER);
		}
	} else if (!strcmp(message, "window minimized")) {
		if (!strcmp(value, "true")) {
			gstate_c.skipDrawReason |= SKIPDRAW_WINDOW_MINIMIZED;
		} else {
			gstate_c.skipDrawReason &= ~SKIPDRAW_WINDOW_MINIMIZED;
		}
	}
}
コード例 #20
0
ファイル: MainWindow.cpp プロジェクト: hrydgard/ppsspp
	LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)	{
		switch (message) {
		case WM_CREATE:
			if (!DoesVersionMatchWindows(6, 0, 0, 0, true)) {
				// Remove the D3D11 choice on versions below XP
				RemoveMenu(GetMenu(hWnd), ID_OPTIONS_DIRECT3D11, MF_BYCOMMAND);
			}
			break;
			
		case WM_GETMINMAXINFO:
			{
				MINMAXINFO *minmax = reinterpret_cast<MINMAXINFO *>(lParam);
				RECT rc = { 0 };
				bool portrait = g_Config.IsPortrait();
				rc.right = portrait ? 272 : 480;
				rc.bottom = portrait ? 480 : 272;
				AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, TRUE);
				minmax->ptMinTrackSize.x = rc.right - rc.left;
				minmax->ptMinTrackSize.y = rc.bottom - rc.top;
			}
			return 0;

		case WM_ACTIVATE:
			{
				bool pause = true;
				if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
					WindowsRawInput::GainFocus();
					if (!IsIconic(GetHWND())) {
						InputDevice::GainFocus();
					}
					g_activeWindow = WINDOW_MAINWINDOW;
					pause = false;
				}
				if (!noFocusPause && g_Config.bPauseOnLostFocus && GetUIState() == UISTATE_INGAME) {
					if (pause != Core_IsStepping()) {	// != is xor for bools
						if (disasmWindow[0])
							SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0);
						else
							Core_EnableStepping(pause);
					}
				}

				if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
					NativeMessageReceived("got_focus", "");
					hasFocus = true;
					trapMouse = true;
				}
				if (wParam == WA_INACTIVE) {
					NativeMessageReceived("lost_focus", "");
					WindowsRawInput::LoseFocus();
					InputDevice::LoseFocus();
					hasFocus = false;
					trapMouse = false;
				}
			}
			break;

		case WM_ERASEBKGND:
			// This window is always covered by DisplayWindow. No reason to erase.
			return 1;

		case WM_MOVE:
			SavePosition();
			break;

		case WM_ENTERSIZEMOVE:
			inResizeMove = true;
			break;

		case WM_EXITSIZEMOVE:
			inResizeMove = false;
			HandleSizeChange(SIZE_RESTORED);
			break;

		case WM_SIZE:
			switch (wParam) {
			case SIZE_RESTORED:
			case SIZE_MAXIMIZED:
				if (g_IgnoreWM_SIZE) {
					return DefWindowProc(hWnd, message, wParam, lParam);
				} else if (!inResizeMove) {
					HandleSizeChange(wParam);
				}
				if (hasFocus) {
					InputDevice::GainFocus();
				}
				break;

			case SIZE_MINIMIZED:
				Core_NotifyWindowHidden(true);
				if (!g_Config.bPauseWhenMinimized) {
					NativeMessageReceived("window minimized", "true");
				}
				InputDevice::LoseFocus();
				break;
			default:
				break;
			}
			break;

    case WM_TIMER:
			// Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode.
			switch (wParam) {
			case TIMER_CURSORUPDATE:
				CorrectCursor();
				return 0;

			case TIMER_CURSORMOVEUPDATE:
				hideCursor = true;
				KillTimer(hWnd, TIMER_CURSORMOVEUPDATE);
				return 0;
			}
			break;

		// For some reason, need to catch this here rather than in DisplayProc.
		case WM_MOUSEWHEEL:
			{
				int wheelDelta = (short)(wParam >> 16);
				KeyInput key;
				key.deviceId = DEVICE_ID_MOUSE;

				if (wheelDelta < 0) {
					key.keyCode = NKCODE_EXT_MOUSEWHEEL_DOWN;
					wheelDelta = -wheelDelta;
				} else {
					key.keyCode = NKCODE_EXT_MOUSEWHEEL_UP;
				}
				// There's no separate keyup event for mousewheel events, let's pass them both together.
				// This also means it really won't work great for key mapping :( Need to build a 1 frame delay or something.
				key.flags = KEY_DOWN | KEY_UP | KEY_HASWHEELDELTA | (wheelDelta << 16);
				NativeKey(key);
			}
			break;

		case WM_COMMAND:
			{
				if (!MainThread_Ready())
					return DefWindowProc(hWnd, message, wParam, lParam);

				MainWindowMenu_Process(hWnd, wParam);
			}
			break;

		case WM_USER_TOGGLE_FULLSCREEN:
			ToggleFullscreen(hwndMain, wParam ? true : false);
			break;

		case WM_INPUT:
			return WindowsRawInput::Process(hWnd, wParam, lParam);

		// TODO: Could do something useful with WM_INPUT_DEVICE_CHANGE?

		// Not sure why we are actually getting WM_CHAR even though we use RawInput, but alright..
		case WM_CHAR:
			return WindowsRawInput::ProcessChar(hWnd, wParam, lParam);

		case WM_DEVICECHANGE:
#ifndef _M_ARM
			DinputDevice::CheckDevices();
#endif
			return DefWindowProc(hWnd, message, wParam, lParam);

		case WM_VERYSLEEPY_MSG:
			switch (wParam) {
			case VERYSLEEPY_WPARAM_SUPPORTED:
				return TRUE;

			case VERYSLEEPY_WPARAM_GETADDRINFO:
				{
					VerySleepy_AddrInfo *info = (VerySleepy_AddrInfo *)lParam;
					const u8 *ptr = (const u8 *)info->addr;
					std::string name;

					if (MIPSComp::jit && MIPSComp::jit->DescribeCodePtr(ptr, name)) {
						swprintf_s(info->name, L"Jit::%S", name.c_str());
						return TRUE;
					}
					if (gpu && gpu->DescribeCodePtr(ptr, name)) {
						swprintf_s(info->name, L"GPU::%S", name.c_str());
						return TRUE;
					}
				}
				return FALSE;

			default:
				return FALSE;
			}
			break;

		case WM_DROPFILES:
			{
				if (!MainThread_Ready())
					return DefWindowProc(hWnd, message, wParam, lParam);

				HDROP hdrop = (HDROP)wParam;
				int count = DragQueryFile(hdrop,0xFFFFFFFF,0,0);
				if (count != 1) {
					MessageBox(hwndMain,L"You can only load one file at a time",L"Error",MB_ICONINFORMATION);
				}
				else
				{
					TCHAR filename[512];
					if (DragQueryFile(hdrop, 0, filename, 512) != 0) {
						const std::string utf8_filename = ReplaceAll(ConvertWStringToUTF8(filename), "\\", "/");
						NativeMessageReceived("boot", utf8_filename.c_str());
						Core_EnableStepping(false);
					}
				}
			}
			break;

		case WM_CLOSE:
			InputDevice::StopPolling();
			WindowsRawInput::Shutdown();
			return DefWindowProc(hWnd,message,wParam,lParam);

		case WM_DESTROY:
			KillTimer(hWnd, TIMER_CURSORUPDATE);
			KillTimer(hWnd, TIMER_CURSORMOVEUPDATE);
			PostQuitMessage(0);
			break;

		case WM_USER + 1:
			if (disasmWindow[0])
				disasmWindow[0]->NotifyMapLoaded();
			if (memoryWindow[0])
				memoryWindow[0]->NotifyMapLoaded();

			if (disasmWindow[0])
				disasmWindow[0]->UpdateDialog();

			SetForegroundWindow(hwndMain);
			break;

		case WM_USER_SAVESTATE_FINISH:
			SetCursor(LoadCursor(0, IDC_ARROW));
			break;

		case WM_USER_UPDATE_UI:
			TranslateMenus(hwndMain, menu);
			// Update checked status immediately for accelerators.
			UpdateMenus();
			break;

		case WM_USER_WINDOW_TITLE_CHANGED:
			UpdateWindowTitle();
			break;

		case WM_USER_BROWSE_BOOT_DONE:
			BrowseAndBootDone();
			break;

		case WM_USER_BROWSE_BG_DONE:
			BrowseBackgroundDone();
			break;

		case WM_USER_RESTART_EMUTHREAD:
			NativeSetRestarting();
			InputDevice::StopPolling();
			MainThread_Stop();
			coreState = CORE_POWERUP;
			UpdateUIState(UISTATE_MENU);
			MainThread_Start(g_Config.iGPUBackend == (int)GPUBackend::OPENGL);
			InputDevice::BeginPolling();
			break;

		case WM_MENUSELECT:
			// Called when a menu is opened. Also when an item is selected, but meh.
			UpdateMenus(true);
			WindowsRawInput::NotifyMenu();
			trapMouse = false;
			break;

		case WM_EXITMENULOOP:
			// Called when menu is closed.
			trapMouse = true;
			break;

		// Turn off the screensaver.
		// Note that if there's a screensaver password, this simple method
		// doesn't work on Vista or higher.
		case WM_SYSCOMMAND:
			{
				switch (wParam) {
				case SC_SCREENSAVE:  
					return 0;
				case SC_MONITORPOWER:
					return 0;      
				}
				return DefWindowProc(hWnd, message, wParam, lParam);
			}

		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		return 0;
	}