Ejemplo n.º 1
0
	void D3D9RenderWindow::resize(unsigned int width, unsigned int height)
	{
		if (mHWnd && !mIsFullScreen)
		{
			unsigned int winWidth, winHeight;
			adjustWindow(width, height, &winWidth, &winHeight);
			SetWindowPos(mHWnd, 0, 0, 0, winWidth, winHeight,
				SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
		}
	}
Ejemplo n.º 2
0
	void D3D9RenderWindow::_finishSwitchingFullscreen()
	{		
		if(mIsFullScreen)
		{
			// Need to reset the region on the window sometimes, when the 
			// windowed mode was constrained by desktop 
			HRGN hRgn = CreateRectRgn(0,0,mWidth, mHeight);
			SetWindowRgn(mHWnd, hRgn, FALSE);
		}
		else
		{
			bool updateRect = false;

			// When switching back to windowed mode, need to reset window size 
			// after device has been restored
			// We may have had a resize event which polluted our desired sizes
			if (mWidth != mDesiredWidth ||
				mHeight != mDesiredHeight)
			{
				mWidth = mDesiredWidth;
				mHeight = mDesiredHeight;
				updateRect = true;
			}
			unsigned int winWidth, winHeight;
			adjustWindow(mWidth, mHeight, &winWidth, &winHeight);

			// deal with centreing when switching down to smaller resolution

			HMONITOR hMonitor = MonitorFromWindow(mHWnd, MONITOR_DEFAULTTONEAREST);
			MONITORINFO monitorInfo;
			memset(&monitorInfo, 0, sizeof(MONITORINFO));
			monitorInfo.cbSize = sizeof(MONITORINFO);
			GetMonitorInfo(hMonitor, &monitorInfo);

			LONG screenw = monitorInfo.rcWork.right  - monitorInfo.rcWork.left;
			LONG screenh = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;


			int left = screenw > winWidth ? ((screenw - winWidth) / 2) : 0;
			int top = screenh > winHeight ? ((screenh - winHeight) / 2) : 0;
			SetWindowPos(mHWnd, HWND_NOTOPMOST, left, top, winWidth, winHeight,
				SWP_DRAWFRAME | SWP_FRAMECHANGED | SWP_NOACTIVATE);

			if (updateRect)
			{
				// Notify viewports of resize
				ViewportList::iterator it = mViewportList.begin();
				while( it != mViewportList.end() )
					(*it++).second->_updateDimensions();			
			}
		}
		mSwitchingFullscreen = false;
	}
	void D3D9RenderWindow::_finishSwitchingFullscreen()
	{		
		if(mIsFullScreen)
		{
			// Need to reset the region on the window sometimes, when the 
			// windowed mode was constrained by desktop 
			HRGN hRgn = CreateRectRgn(0,0,mWidth, mHeight);
			SetWindowRgn(mHWnd, hRgn, FALSE);
		}
		else
		{			
			// When switching back to windowed mode, need to reset window size 
			// after device has been restored
			// We may have had a resize event which polluted our desired sizes
			if (mWidth != mDesiredWidth ||
				mHeight != mDesiredHeight)
			{
				mWidth = mDesiredWidth;
				mHeight = mDesiredHeight;				
			}
			unsigned int winWidth, winHeight;
			adjustWindow(mWidth, mHeight, &winWidth, &winHeight);

			// deal with centering when switching down to smaller resolution
			HMONITOR hMonitor = MonitorFromWindow(mHWnd, MONITOR_DEFAULTTONEAREST);
			MONITORINFO monitorInfo;
			memset(&monitorInfo, 0, sizeof(MONITORINFO));
			monitorInfo.cbSize = sizeof(MONITORINFO);
			GetMonitorInfo(hMonitor, &monitorInfo);

			LONG screenw = monitorInfo.rcWork.right  - monitorInfo.rcWork.left;
			LONG screenh = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;

            // When switching from a low fullscreen res to windowed mode in a high
            // res desktop need to release this low res constraint on the window
            // region otherwise we will not be able to make the window larger
            // than the low fullscreen res we were just at
            SetWindowRgn(mHWnd, NULL, TRUE);

			int left = screenw > winWidth ? ((screenw - winWidth) / 2) : 0;
			int top = screenh > winHeight ? ((screenh - winHeight) / 2) : 0;
			SetWindowPos(mHWnd, HWND_NOTOPMOST, left, top, winWidth, winHeight,
				SWP_DRAWFRAME | SWP_FRAMECHANGED | SWP_NOACTIVATE);

			updateWindowRect();
		}
		mSwitchingFullscreen = false;
	}
Ejemplo n.º 4
0
Player::Player( QWidget * parent, Qt::WFlags f) 
    : QMainWindow(parent, f)
{
    setupUi(this);
    path = QCoreApplication::applicationDirPath ();
    if (path.data()[path.size() - 1] != '/') path += "/";
    videoPlayer->mediaObject()->setTickInterval(1000);
    setUI();
    setActions();
    init();
    adjustWindow();
    videoPlayer->installEventFilter(this);
    videoPlayer->videoWidget()->installEventFilter(this);
    isFullScreen = false;
    //addButton->hide();
}
Ejemplo n.º 5
0
Jmplayer::Jmplayer( QWidget * parent, Qt::WFlags f) 
    : QMainWindow(parent, f)
{
    setupUi(this);    
    timer = new QTimer(this);
    ms = 0;
    fileIndex = 0;
    firstTime = true;
    running = false;    
    connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
    connect(timer, SIGNAL(timeout()), this, SLOT(setSliderValue()));
    connect(play_button, SIGNAL(clicked()), this, SLOT(pauseContinue()));
    connect(prev_button, SIGNAL(clicked()), this, SLOT(skipBackward()));
    connect(next_button, SIGNAL(clicked()), this, SLOT(skipForward()));
    connect(add_button, SIGNAL(clicked()), this, SLOT(loadFiles()));  
    connect(timeSlider, SIGNAL(sliderReleased()),this, SLOT(seekFile()));
    connect(volumeSlider, SIGNAL(valueChanged(int)),this, SLOT(changeVolume()));
    program = "/usr/bin/mplayer";
    myProcess = new QProcess(parent);  
    adjustWindow();
    initUi(); 
}
Ejemplo n.º 6
0
	void D3D9RenderWindow::create(const String& name, unsigned int width, unsigned int height,
		bool fullScreen, const NameValuePairList *miscParams)
	{
		HINSTANCE hInst = mInstance;
	
		HWND parentHWnd = 0;
		HWND externalHandle = 0;
		mFSAAType = D3DMULTISAMPLE_NONE;
		mFSAAQuality = 0;
		mFSAA = 0;
		mVSync = false;
		mVSyncInterval = 1;
		String title = name;
		unsigned int colourDepth = 32;
		int left = INT_MAX; // Defaults to screen center
		int top = INT_MAX;  // Defaults to screen center
		bool depthBuffer = true;
		String border = "";
		bool outerSize = false;
		mUseNVPerfHUD = false;
		size_t fsaaSamples = 0;
		String fsaaHint;
		bool enableDoubleClick = false;
		int monitorIndex = -1;	//Default by detecting the adapter from left / top position
		

		if(miscParams)
		{
			// Get variable-length params
			NameValuePairList::const_iterator opt;
			// left (x)
			opt = miscParams->find("left");
			if(opt != miscParams->end())
				left = StringConverter::parseInt(opt->second);
			// top (y)
			opt = miscParams->find("top");
			if(opt != miscParams->end())
				top = StringConverter::parseInt(opt->second);
			// Window title
			opt = miscParams->find("title");
			if(opt != miscParams->end())
				title = opt->second;
			// parentWindowHandle		-> parentHWnd
			opt = miscParams->find("parentWindowHandle");
			if(opt != miscParams->end())
				parentHWnd = (HWND)StringConverter::parseSizeT(opt->second);
			// externalWindowHandle		-> externalHandle
			opt = miscParams->find("externalWindowHandle");
			if(opt != miscParams->end())
				externalHandle = (HWND)StringConverter::parseSizeT(opt->second);
			// vsync	[parseBool]
			opt = miscParams->find("vsync");
			if(opt != miscParams->end())
				mVSync = StringConverter::parseBool(opt->second);
			// hidden	[parseBool]
			opt = miscParams->find("hidden");
			if(opt != miscParams->end())
				mHidden = StringConverter::parseBool(opt->second);
			// vsyncInterval	[parseUnsignedInt]
			opt = miscParams->find("vsyncInterval");
			if(opt != miscParams->end())
				mVSyncInterval = StringConverter::parseUnsignedInt(opt->second);
			// displayFrequency
			opt = miscParams->find("displayFrequency");
			if(opt != miscParams->end())
				mDisplayFrequency = StringConverter::parseUnsignedInt(opt->second);
			// colourDepth
			opt = miscParams->find("colourDepth");
			if(opt != miscParams->end())
				colourDepth = StringConverter::parseUnsignedInt(opt->second);
			// depthBuffer [parseBool]
			opt = miscParams->find("depthBuffer");
			if(opt != miscParams->end())
				depthBuffer = StringConverter::parseBool(opt->second);
			// FSAA settings
			opt = miscParams->find("FSAA");
			if(opt != miscParams->end())
			{
				mFSAA = StringConverter::parseUnsignedInt(opt->second);
			}
			opt = miscParams->find("FSAAHint");
			if(opt != miscParams->end())
			{
				mFSAAHint = opt->second;
			}

			// window border style
			opt = miscParams->find("border");
			if(opt != miscParams->end())
				border = opt->second;
			// set outer dimensions?
			opt = miscParams->find("outerDimensions");
			if(opt != miscParams->end())
				outerSize = StringConverter::parseBool(opt->second);
			// NV perf HUD?
			opt = miscParams->find("useNVPerfHUD");
			if(opt != miscParams->end())
				mUseNVPerfHUD = StringConverter::parseBool(opt->second);
			// sRGB?
			opt = miscParams->find("gamma");
			if(opt != miscParams->end())
				mHwGamma = StringConverter::parseBool(opt->second);
			// monitor index
			opt = miscParams->find("monitorIndex");
			if(opt != miscParams->end())
				monitorIndex = StringConverter::parseInt(opt->second);
			opt = miscParams->find("show");
			if(opt != miscParams->end())
				mHidden = !StringConverter::parseBool(opt->second);
			// enable double click messages
			opt = miscParams->find("enableDoubleClick");
			if(opt != miscParams->end())
				enableDoubleClick = StringConverter::parseBool(opt->second);

		}
		mIsFullScreen = fullScreen;

		// Destroy current window if any
		if( mHWnd )
			destroy();

		if (!externalHandle)
		{
			DWORD		dwStyleEx = 0;
			HMONITOR    hMonitor = NULL;		
			MONITORINFO monitorInfo;
			RECT		rc;

			// If we specified which adapter we want to use - find it's monitor.
			if (monitorIndex != -1)
			{
				IDirect3D9* direct3D9 = D3D9RenderSystem::getDirect3D9();

				for (uint i=0; i < direct3D9->GetAdapterCount(); ++i)
				{
					if (i == monitorIndex)
					{
						hMonitor = direct3D9->GetAdapterMonitor(i);
						break;
					}
				}				
			}

			// If we didn't specified the adapter index, or if it didn't find it
			if (hMonitor == NULL)
			{
				POINT windowAnchorPoint;

				// Fill in anchor point.
				windowAnchorPoint.x = left;
				windowAnchorPoint.y = top;


				// Get the nearest monitor to this window.
				hMonitor = MonitorFromPoint(windowAnchorPoint, MONITOR_DEFAULTTONEAREST);
			}

			// Get the target monitor info		
			memset(&monitorInfo, 0, sizeof(MONITORINFO));
			monitorInfo.cbSize = sizeof(MONITORINFO);
			GetMonitorInfo(hMonitor, &monitorInfo);

			// Update window style flags.
			mFullscreenWinStyle = WS_CLIPCHILDREN | WS_POPUP;
			mWindowedWinStyle   = WS_CLIPCHILDREN;

			if (!mHidden)
			{
				mFullscreenWinStyle |= WS_VISIBLE;
				mWindowedWinStyle |= WS_VISIBLE;
			}

			if (parentHWnd)
			{
				mWindowedWinStyle |= WS_CHILD;
			}
			else
			{
				if (border == "none")
					mWindowedWinStyle |= WS_POPUP;
				else if (border == "fixed")
					mWindowedWinStyle |= WS_OVERLAPPED | WS_BORDER | WS_CAPTION |
					WS_SYSMENU | WS_MINIMIZEBOX;
				else
					mWindowedWinStyle |= WS_OVERLAPPEDWINDOW;
			}
					
			unsigned int winWidth, winHeight;
			winWidth = width;
			winHeight = height;


			// No specified top left -> Center the window in the middle of the monitor
			if (left == INT_MAX || top == INT_MAX)
			{				
				int screenw = monitorInfo.rcWork.right  - monitorInfo.rcWork.left;
				int screenh = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;

				// clamp window dimensions to screen size
				int outerw = (winWidth < screenw)? winWidth : screenw;
				int outerh = (winHeight < screenh)? winHeight : screenh;

				if (left == INT_MAX)
					left = monitorInfo.rcWork.left + (screenw - outerw) / 2;
				else if (monitorIndex != -1)
					left += monitorInfo.rcWork.left;

				if (top == INT_MAX)
					top = monitorInfo.rcWork.top + (screenh - outerh) / 2;
				else if (monitorIndex != -1)
					top += monitorInfo.rcWork.top;
			}
			else if (monitorIndex != -1)
			{
				left += monitorInfo.rcWork.left;
				top += monitorInfo.rcWork.top;
			}

			mWidth = mDesiredWidth = width;
			mHeight = mDesiredHeight = height;
			mTop = top;
			mLeft = left;

			if (fullScreen)
			{
				dwStyleEx |= WS_EX_TOPMOST;				
				mTop = monitorInfo.rcMonitor.top;
				mLeft = monitorInfo.rcMonitor.left;		
			}
			else
			{				
                adjustWindow(width, height, &winWidth, &winHeight);

				if (!outerSize)
				{
					// Calculate window dimensions required
					// to get the requested client area
					SetRect(&rc, 0, 0, mWidth, mHeight);
					AdjustWindowRect(&rc, getWindowStyle(fullScreen), false);
					mWidth = rc.right - rc.left;
					mHeight = rc.bottom - rc.top;

					// Clamp window rect to the nearest display monitor.
					if (mLeft < monitorInfo.rcWork.left)
						mLeft = monitorInfo.rcWork.left;		

					if (mTop < monitorInfo.rcWork.top)					
						mTop = monitorInfo.rcWork.top;					
				
					if (static_cast<int>(winWidth) > monitorInfo.rcWork.right - mLeft)					
						winWidth = monitorInfo.rcWork.right - mLeft;	

					if (static_cast<int>(winHeight) > monitorInfo.rcWork.bottom - mTop)					
						winHeight = monitorInfo.rcWork.bottom - mTop;										
				}
			}
			
			UINT classStyle = 0;
			if (enableDoubleClick)
				classStyle |= CS_DBLCLKS;


			// Register the window class
			// NB allow 4 bytes of window data for D3D9RenderWindow pointer
			WNDCLASS wc = { classStyle, WindowEventUtilities::_WndProc, 0, 0, hInst,
				LoadIcon(0, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
				(HBRUSH)GetStockObject(BLACK_BRUSH), 0, "OgreD3D9Wnd" };
			RegisterClass(&wc);

			// Create our main window
			// Pass pointer to self
			mIsExternal = false;
			mHWnd = CreateWindowEx(dwStyleEx, "OgreD3D9Wnd", title.c_str(), getWindowStyle(fullScreen),
				mLeft, mTop, winWidth, winHeight, parentHWnd, 0, hInst, this);

			WindowEventUtilities::_addRenderWindow(this);
		}
		else
		{
			mHWnd = externalHandle;
			mIsExternal = true;
		}

		RECT rc;
		// top and left represent outer window coordinates
		GetWindowRect(mHWnd, &rc);
		mTop = rc.top;
		mLeft = rc.left;
		// width and height represent interior drawable area
		GetClientRect(mHWnd, &rc);
		mWidth = rc.right;
		mHeight = rc.bottom;

		mName = name;
		mDepthBufferPoolId = depthBuffer ? DepthBuffer::POOL_DEFAULT : DepthBuffer::POOL_NO_DEPTH;
		mDepthBuffer = 0;
		mColourDepth = colourDepth;

		LogManager::getSingleton().stream()
			<< "D3D9 : Created D3D9 Rendering Window '"
			<< mName << "' : " << mWidth << "x" << mHeight 
			<< ", " << mColourDepth << "bpp";
									
		mActive = true;
		mClosed = false;
		setHidden(mHidden);
	}
Ejemplo n.º 7
0
	void D3D9RenderWindow::setFullscreen(bool fullScreen, unsigned int width, unsigned int height)
	{
		if (fullScreen != mIsFullScreen || width != mWidth || height != mHeight)
		{
			if (fullScreen != mIsFullScreen)
				mSwitchingFullscreen = true;

			bool oldFullscreen = mIsFullScreen;
			mIsFullScreen = fullScreen;
			mWidth = mDesiredWidth = width;
			mHeight = mDesiredHeight = height;

			if (fullScreen)
			{
				// Get the nearest monitor to this window.
				HMONITOR hMonitor = MonitorFromWindow(mHWnd, MONITOR_DEFAULTTONEAREST);

				// Get monitor info	
				MONITORINFO monitorInfo;

				memset(&monitorInfo, 0, sizeof(MONITORINFO));
				monitorInfo.cbSize = sizeof(MONITORINFO);
				GetMonitorInfo(hMonitor, &monitorInfo);

				mTop = monitorInfo.rcMonitor.top;
				mLeft = monitorInfo.rcMonitor.left;				
				
				// need different ordering here

				if (oldFullscreen)
				{
					// was previously fullscreen, just changing the resolution
					SetWindowPos(mHWnd, HWND_TOPMOST, mLeft, mTop, width, height, SWP_NOACTIVATE);
				}
				else
				{
					SetWindowPos(mHWnd, HWND_TOPMOST, mLeft, mTop, width, height, SWP_NOACTIVATE);
					//MoveWindow(mHWnd, mLeft, mTop, mWidth, mHeight, FALSE);
					SetWindowLong(mHWnd, GWL_STYLE, getWindowStyle(mIsFullScreen));
					SetWindowPos(mHWnd, 0, 0,0, 0,0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
				}
			}
			else
			{
				// Calculate window dimensions required
				// to get the requested client area
				unsigned int winWidth, winHeight;
				winWidth = mWidth;
				winHeight = mHeight;
				
				adjustWindow(mWidth, mHeight, &winWidth, &winHeight);

				SetWindowLong(mHWnd, GWL_STYLE, getWindowStyle(mIsFullScreen));
				SetWindowPos(mHWnd, HWND_NOTOPMOST, 0, 0, winWidth, winHeight,
					SWP_DRAWFRAME | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOACTIVATE);
				// Note that we also set the position in the restoreLostDevice method
				// via _finishSwitchingFullScreen

				// Update the current rect.
				updateWindowRect();
			}
								
			// Have to release & trigger device reset
			// NB don't use windowMovedOrResized since Win32 doesn't know
			// about the size change yet				
			mDevice->invalidate(this);
			// Notify viewports of resize
			ViewportList::iterator it = mViewportList.begin();
			while( it != mViewportList.end() )
				(*it++).second->_updateDimensions();	
		}
	} 
Ejemplo n.º 8
0
quint8* KisMemoryWindow::getWriteChunkPtr(const KisChunkData &writeChunk)
{
    adjustWindow(writeChunk, &m_writeWindowEx, &m_readWindowEx);

    return m_writeWindowEx.calculatePointer(writeChunk);
}
Ejemplo n.º 9
0
void toggleFullscreen(WindowsDesc* winDesc)
{
	winDesc->fullScreen = !winDesc->fullScreen;
	adjustWindow(winDesc);
}
Ejemplo n.º 10
0
void openWindow(const char* app_name, WindowsDesc* winDesc)
{
	winDesc->fullscreenRect = { 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };

	// If user provided invalid or zero rect, get the rect from renderer
	if (getRectWidth(winDesc->windowedRect) <= 0 || getRectHeight(winDesc->windowedRect) <= 0)
	{
		getRecommendedResolution(&winDesc->windowedRect);
	}

	RECT clientRect = { (LONG)winDesc->windowedRect.left, (LONG)winDesc->windowedRect.top, (LONG)winDesc->windowedRect.right, (LONG)winDesc->windowedRect.bottom };
	AdjustWindowRect(&clientRect, WS_OVERLAPPEDWINDOW, FALSE);
	winDesc->windowedRect = { (int)clientRect.left, (int)clientRect.top, (int)clientRect.right, (int)clientRect.bottom };

	RectDesc& rect = winDesc->fullScreen ? winDesc->fullscreenRect : winDesc->windowedRect;

	WCHAR app[MAX_PATH];
	size_t charConverted = 0;
	mbstowcs_s(&charConverted, app, app_name, MAX_PATH);

	HWND hwnd = CreateWindowW(CONFETTI_WINDOW_CLASS,
		app,
		WS_OVERLAPPEDWINDOW | ((winDesc->visible) ? WS_VISIBLE : 0),
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		rect.right - rect.left,
		rect.bottom - rect.top,
		NULL,
		NULL,
		(HINSTANCE)GetModuleHandle(NULL),
		0
	);

	if (hwnd)
	{
		GetClientRect(hwnd, &clientRect);
		winDesc->windowedRect = { (int)clientRect.left, (int)clientRect.top, (int)clientRect.right, (int)clientRect.bottom };

		winDesc->handle = hwnd;
		gHWNDMap.insert({ hwnd, winDesc });

		if (winDesc->visible)
		{
			if (winDesc->maximized)
			{
				ShowWindow(hwnd, SW_MAXIMIZE);
			}
			else if (winDesc->minimized)
			{
				ShowWindow(hwnd, SW_MINIMIZE);
			}
			else if (winDesc->fullScreen)
			{
				adjustWindow(winDesc);
			}
		}

		LOGINFOF("Created window app %s", app_name);
	}
	else
	{
		LOGERRORF("Failed to create window app %s", app_name);
	}
}
Ejemplo n.º 11
0
// Window event handler - Use as less as possible
LRESULT CALLBACK WinProc(HWND _hwnd, UINT _id, WPARAM wParam, LPARAM lParam)
{
	WindowsDesc* gCurrentWindow = NULL;
	tinystl::unordered_hash_node<void*, WindowsDesc*>* pNode = gHWNDMap.find(_hwnd).node;
	if (pNode)
		gCurrentWindow = pNode->second;
	else
		return DefWindowProcW(_hwnd, _id, wParam, lParam);

	switch (_id)
	{
	case WM_ACTIVATE:
		if (LOWORD(wParam) == WA_INACTIVE)
		{
			captureMouse(_hwnd, false);
		}
		break;

	case WM_DISPLAYCHANGE:
	{
		if (gCurrentWindow)
		{
			if (gCurrentWindow->fullScreen)
			{
				adjustWindow(gCurrentWindow);
			}
			else
			{
				adjustWindow(gCurrentWindow);
			}
		}
		break;
	}

	case WM_SIZE:
		if (gCurrentWindow)
		{
			RectDesc rect = { 0 };
			if (gCurrentWindow->fullScreen)
			{
				gCurrentWindow->fullscreenRect = { 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };
				rect = gCurrentWindow->fullscreenRect;
			}
			else
			{
				if (IsIconic(_hwnd))
					return 0;

				RECT windowRect;
				GetClientRect(_hwnd, &windowRect);
				rect = { (int)windowRect.left, (int)windowRect.top, (int)windowRect.right, (int)windowRect.bottom };
				gCurrentWindow->windowedRect = rect;
			}

			WindowResizeEventData eventData = { rect, gCurrentWindow };
			PlatformEvents::onWindowResize(&eventData);
		}
		break;

	case WM_CLOSE:
	case WM_QUIT:
		gAppRunning = false;
		break;

	case WM_CHAR:
	{
		KeyboardCharEventData eventData;
		eventData.unicode = (unsigned)wParam;
		PlatformEvents::onKeyboardChar(&eventData);
		break;
	}
	case WM_MOUSEMOVE:
	{
		static int lastX = 0, lastY = 0;
		int x, y;
		x = GETX(lParam);
		y = GETY(lParam);

		MouseMoveEventData eventData;
		eventData.x = x;
		eventData.y = y;
		eventData.deltaX = x - lastX;
		eventData.deltaY = y - lastY;
		eventData.captured = isCaptured;
		PlatformEvents::onMouseMove(&eventData);

		lastX = x;
		lastY = y;
		break;
	}
	case WM_INPUT:
	{
		UINT dwSize;
		static BYTE lpb[128] = {};

		GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER));

		RAWINPUT* raw = (RAWINPUT*)lpb;

		if (raw->header.dwType == RIM_TYPEMOUSE)
		{
			static int lastX = 0, lastY = 0;

			int xPosRelative = raw->data.mouse.lLastX;
			int yPosRelative = raw->data.mouse.lLastY;

			RawMouseMoveEventData eventData;
			eventData.x = xPosRelative;
			eventData.y = yPosRelative;
			eventData.captured = isCaptured;
			PlatformEvents::onRawMouseMove(&eventData);

			lastX = xPosRelative;
			lastY = yPosRelative;
		}

		return 0;
	}
	case WM_LBUTTONDOWN:
	{
		MouseButtonEventData eventData;
		eventData.button = MOUSE_LEFT;
		eventData.pressed = true;
		eventData.x = GETX(lParam);
		eventData.y = GETY(lParam);
		if (PlatformEvents::wantsMouseCapture && !PlatformEvents::skipMouseCapture && !isCaptured)
		{
			captureMouse(_hwnd, true);
		}
		PlatformEvents::onMouseButton(&eventData);
		break;
	}
	case WM_LBUTTONUP:
	{
		MouseButtonEventData eventData;
		eventData.button = MOUSE_LEFT;
		eventData.pressed = false;
		eventData.x = GETX(lParam);
		eventData.y = GETY(lParam);
		PlatformEvents::onMouseButton(&eventData);
		break;
	}
	case WM_RBUTTONDOWN:
	{
		MouseButtonEventData eventData;
		eventData.button = MOUSE_RIGHT;
		eventData.pressed = true;
		eventData.x = GETX(lParam);
		eventData.y = GETY(lParam);
		PlatformEvents::onMouseButton(&eventData);
		break;
	}
	case WM_RBUTTONUP:
	{
		MouseButtonEventData eventData;
		eventData.button = MOUSE_RIGHT;
		eventData.pressed = false;
		eventData.x = GETX(lParam);
		eventData.y = GETY(lParam);
		PlatformEvents::onMouseButton(&eventData);
		break;
	}
	case WM_MBUTTONDOWN:
	{
		MouseButtonEventData eventData;
		eventData.button = MOUSE_MIDDLE;
		eventData.pressed = true;
		eventData.x = GETX(lParam);
		eventData.y = GETY(lParam);
		PlatformEvents::onMouseButton(&eventData);
		break;
	}
	case WM_MBUTTONUP:
	{
		MouseButtonEventData eventData;
		eventData.button = MOUSE_MIDDLE;
		eventData.pressed = false;
		eventData.x = GETX(lParam);
		eventData.y = GETY(lParam);
		PlatformEvents::onMouseButton(&eventData);
		break;
	}
	case WM_MOUSEWHEEL:
	{
		static int scroll;
		int s;

		scroll += GET_WHEEL_DELTA_WPARAM(wParam);
		s = scroll / WHEEL_DELTA;
		scroll %= WHEEL_DELTA;

		POINT point;
		point.x = GETX(lParam);
		point.y = GETY(lParam);
		ScreenToClient(_hwnd, &point);

		if (s != 0)
		{
			MouseWheelEventData eventData;
			eventData.scroll = s;
			eventData.x = point.x;
			eventData.y = point.y;
			PlatformEvents::onMouseWheel(&eventData);
		}
		break;
	}
	case WM_SYSKEYDOWN:
		if ((lParam & (1 << 29)) && (wParam == KEY_ENTER))
		{
			toggleFullscreen(gCurrentWindow);
		}
		updateKeyArray(_id, (unsigned)wParam);
		break;

	case WM_SYSKEYUP:
		updateKeyArray(_id, (unsigned)wParam);
		break;

	case WM_KEYUP:
		if (wParam == KEY_ESCAPE)
		{
			if (!isCaptured)
			{
				gAppRunning = false;
			}
			else
			{
				captureMouse(_hwnd, false);
			}
		}
		updateKeyArray(_id, (unsigned)wParam);
		break;

	case WM_KEYDOWN:
		updateKeyArray(_id, (unsigned)wParam);
		break;
	default:
		return DefWindowProcW(_hwnd, _id, wParam, lParam);
		break;
	}

	return 0;
}
Ejemplo n.º 12
0
//----------uartIntHandler0----------
void uartIntHandler(void){
    if (uartInt){
        uartInt = 0;
        
        if(theState == IDLE){
            switch (buff){
                case 'T':{ //RequestTemp
                    respondTemp(getTemp_DSP());		
                    break;
                }
//----------uartIntHandler1----------
                case 'H':{ //TurnHeatOn
                    // 0x7 is the maximum value.
                    respondHeat(adjustHeat(0x7), 'H');
                    break;
                }
                case 'K':{ //TurnHeatOff
                    // 0x0 is the minimum value.
                    respondHeat(adjustHeat(0x0), 'K');
                    break;
                }
                case 'W':{ //AdjustWindow
                    theState = ADJW;
                    break;
                }
                case 'V':{ //Ventilation
                    theState = ADJV;
                    break;
                }
                case 'F':{ //Watering
                    theState = ADJI;
                    break;
                }
                case 'S':{
                    theState = RESP_SOIL_HUM;
                    break;
                }
                default:{
                    // Do nothing - let the DevKit8000 timeout
                    break;
                }
            }
        }
//----------uartIntHandler2----------
        else if(theState == ADJW){
            if(buff-CONVERT_TO_ASCII == 1){
                respondWin(adjustWindow(0xFF));
            }
            else{
                respondWin(adjustWindow(0x00));
            }
            theState = IDLE;
        }
//----------uartIntHandler3----------
        else if(theState == ADJV){
            if(buff-CONVERT_TO_ASCII == 1){
                respondVent(adjustVentilation(0xFF));
            }
            else{
                respondVent(adjustVentilation(0x00));
            }
            theState = IDLE;
        }
        else if(theState == ADJI){
            if (!irrigationIndex){
                irrigationIndex = buff - CONVERT_TO_ASCII;
            }
            else{
                if (buff-CONVERT_TO_ASCII == 1){
                    respondIrri(adjustIrrigation(irrigationIndex - 1, 0xFF));
                }
                else if(buff - CONVERT_TO_ASCII == 0){
                    respondIrri(adjustIrrigation(irrigationIndex - 1, 0x00));
                }
                else{
                    respondIrri(-1); //Bad argument
                }
                irrigationIndex = 0;
                theState = IDLE;
            }
        }
        else if(theState == RESP_SOIL_HUM){
            uint8 temp = buff - CONVERT_TO_ASCII - 1; //incoming number is in ASCII 1-6, DSP works in 0-5.
            if (temp <= 5 && temp >= 0){
                respondSoilHum(temp, getSoilHum_DSP(temp));
                theState = IDLE;
            }
        }
        buff = 0;
        BlueLED_Write(LED_OFF);         // Turn off blue LED
    }
}
Ejemplo n.º 13
0
void ModelTreeDialog::showOptions(void)
{
	adjustWindow(m_optionsDelta);
	swapWindowText('>', '<');
	m_optionsShown = true;
}
Ejemplo n.º 14
0
void ModelTreeDialog::hideOptions(void)
{
	adjustWindow(-m_optionsDelta);
	swapWindowText('<', '>');
	m_optionsShown = false;
}