Пример #1
0
    void Gui::handleMouseInput()
    {
        while (!mInput->isMouseQueueEmpty())
         {
             MouseInput mouseInput = mInput->dequeueMouseInput();

             // Save the current mouse state. It will be needed if modal focus
             // changes or modal mouse input focus changes.
             mLastMouseX = mouseInput.getX();
             mLastMouseY = mouseInput.getY();

             switch (mouseInput.getType())
             {
               case MouseInput::PRESSED:
                   handleMousePressed(mouseInput);
                   break;
               case MouseInput::RELEASED:
                   handleMouseReleased(mouseInput);
                   break;
               case MouseInput::MOVED:
                   handleMouseMoved(mouseInput);
                   break;
               case MouseInput::WHEEL_MOVED_DOWN:
                   handleMouseWheelMovedDown(mouseInput);
                   break;
               case MouseInput::WHEEL_MOVED_UP:
                   handleMouseWheelMovedUp(mouseInput);
                   break;
               default:
                   throw GCN_EXCEPTION("Unknown mouse input type.");
                   break;
             }
         }
    }
Пример #2
0
void AGOSEngine::timerProc() {
	if (_videoLockOut & 0x80E9 || _videoLockOut & 2)
		return;

	_syncCount++;

	_videoLockOut |= 2;

	handleMouseMoved();

	if (!(_videoLockOut & 0x10)) {
		processVgaEvents();
		processVgaEvents();
		_cepeFlag = !_cepeFlag;
		if (!_cepeFlag)
			processVgaEvents();
	}

	if (_displayFlag) {
		displayScreen();
		_displayFlag = 0;
	}

	_videoLockOut &= ~2;
}
Пример #3
0
void AGOSEngine_Feeble::timerProc() {
	if (_videoLockOut & 0x80E9 || _videoLockOut & 2)
		return;

	_syncCount++;

	_videoLockOut |= 2;

	if (!(_videoLockOut & 0x10)) {
		_syncFlag2 = !_syncFlag2;
		if (!_syncFlag2) {
			processVgaEvents();
		} else {
			// Double speed on Oracle
			if (getGameType() == GType_FF && getBitFlag(99)) {
				processVgaEvents();
			} else if (_scrollCount == 0) {
				_videoLockOut &= ~2;
				return;
			}
		}

		if (getGameType() == GType_FF && _interactiveVideo) {
			// Controls Omni TV videos
			if (getBitFlag(42)) {
				stopInteractiveVideo();
			} else {
				_moviePlayer->nextFrame();
			}
		}

		animateSprites();
	}

	if (_displayFlag) {
		if (getGameType() == GType_FF && !(getFeatures() & GF_DEMO)) {
			if (!getBitFlag(78)) {
				oracleLogo();
			}
			if (getBitFlag(76)) {
				swapCharacterLogo();
			}
		}
		handleMouseMoved();
		displayScreen();
		_displayFlag = 0;
	}

	_videoLockOut &= ~2;
}
Пример #4
0
void AGOSEngine_PN::timerProc() {
	if (_videoLockOut & 0x80E9 || _videoLockOut & 2)
		return;

	_syncCount++;

	_videoLockOut |= 2;

	_sound->handleSoundQueue();
	handleMouseMoved();
	handleKeyboard();

	if (!(_videoLockOut & 0x10)) {
		if (_sampleWait) {
			_vgaCurSpriteId = 0xFFFF;
			vc15_sync();
			_sampleWait = false;
		}
		if (_sampleEnd) {
			_vgaCurSpriteId = 0xFFFE;
			vc15_sync();
			_sampleEnd = false;
		}

		processVgaEvents();
		processVgaEvents();
		_cepeFlag = !_cepeFlag;
		if (!_cepeFlag)
			processVgaEvents();
	}

	if (_displayFlag) {
		displayScreen();
		_displayFlag = 0;
	}

	_videoLockOut &= ~2;
}
Пример #5
0
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount) {
	if (isEnabled()) {
		_isDragging = true;
		handleMouseMoved(x, y, button);
	}
}
Пример #6
0
LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    BOOL bProcessed = FALSE;
	//CCLog("wParam:%d", wParam);
    switch (message)
    {
        case WM_MOUSEWHEEL:
#if(_MSC_VER >= 1600)
		// Don't process message generated by Windows Touch
		if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

		if (m_pDelegate)
		{
			POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
			ScreenToClient(m_hWnd, &point);
			DPoint pt(point.x, point.y);
			pt.x /= m_fFrameZoomFactor;
			pt.y /= m_fFrameZoomFactor;
			DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
			float zDelta = (short)HIWORD(wParam);
			if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
			{
				m_bCaptured = true;
				SetCapture(m_hWnd);

				CrossApp::CAEvent* event = new CrossApp::CAEvent();
				event->setEventType(CrossApp::EventType::middleMouseEvent);
				handleScrollWheel(pt.x, pt.y, 0, zDelta, event);
				event->release();
			}
		}
		break;

        case WM_MOUSEMOVE:
#if(_MSC_VER >= 1600)
            // Don't process message generated by Windows Touch
            if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */
            if (MK_LBUTTON == wParam && m_bCaptured)
            {
                POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
                DPoint pt(point.x, point.y);
                int id = 0;
                pt.x /= m_fFrameZoomFactor;
                pt.y /= m_fFrameZoomFactor;
                
                CrossApp::CAEvent* event = new CrossApp::CAEvent();
                event->setEventType(CrossApp::EventType::leftMouseEvent);
                handleTouchesMove(1, &id, &pt.x, &pt.y, event);
                event->release();
                
                event = new CrossApp::CAEvent();
                event->setEventType(CrossApp::EventType::movedMouseEvent);
                handleMouseMoved(pt.x, pt.y, event);
                event->release();
            }
            break;
            
	case WM_MBUTTONDOWN:
#if(_MSC_VER >= 1600)
		// Don't process message generated by Windows Touch
		if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

		if (m_pDelegate && MK_MBUTTON == wParam)
		{
			POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
			DPoint pt(point.x, point.y);
			pt.x /= m_fFrameZoomFactor;
			pt.y /= m_fFrameZoomFactor;
			DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
			if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
			{
				m_bCaptured = true;
				SetCapture(m_hWnd);
				int id = 0;

				CrossApp::CAEvent* event = new CrossApp::CAEvent();
				event->setEventType(CrossApp::EventType::middleMouseEvent);
				handleOtherMouseDown(1, &id, &pt.x, &pt.y, event);
				event->release();
			}
		}
		break;

	case WM_MBUTTONUP:
#if(_MSC_VER >= 1600)
		// Don't process message generated by Windows Touch
		if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

		if (m_pDelegate)
		{
			POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
			DPoint pt(point.x, point.y);
			pt.x /= m_fFrameZoomFactor;
			pt.y /= m_fFrameZoomFactor;
			DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
			if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
			{
				m_bCaptured = true;
				SetCapture(m_hWnd);
				int id = 0;

				CrossApp::CAEvent* event = new CrossApp::CAEvent();
				event->setEventType(CrossApp::EventType::middleMouseEvent);
				handleOtherMouseUp(1,&id, &pt.x, &pt.y, event);
				event->release();
			}
		}
		break;
            
    case WM_LBUTTONDOWN:
#if(_MSC_VER >= 1600)
        // Don't process message generated by Windows Touch
        if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */

        if (m_pDelegate && MK_LBUTTON == wParam)
        {
            POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
            DPoint pt(point.x, point.y);
            pt.x /= m_fFrameZoomFactor;
            pt.y /= m_fFrameZoomFactor;
            DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
            if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
            {
                m_bCaptured = true;
                SetCapture(m_hWnd);
                int id = 0;

				CrossApp::CAEvent* event = new CrossApp::CAEvent();
				event->setEventType(CrossApp::EventType::leftMouseEvent);
				handleTouchesBegin(1, &id, &pt.x, &pt.y, event);
				event->release();
            }
        }
        break;
            
        case WM_LBUTTONUP:
#if(_MSC_VER >= 1600)
            // Don't process message generated by Windows Touch
            if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */
            if (m_bCaptured)
            {
                POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
                DPoint pt(point.x, point.y);
                int id = 0;
                pt.x /= m_fFrameZoomFactor;
                pt.y /= m_fFrameZoomFactor;
                
                CrossApp::CAEvent* event = new CrossApp::CAEvent();
                event->setEventType(CrossApp::EventType::leftMouseEvent);
                handleTouchesEnd(1, &id, &pt.x, &pt.y, event);
                event->release();
                
                ReleaseCapture();
                m_bCaptured = false;
            }
            break;
            
        case WM_RBUTTONDOWN:
#if(_MSC_VER >= 1600)
            // Don't process message generated by Windows Touch
            if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */
            
            if (m_pDelegate && MK_RBUTTON == wParam)
            {
                POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
                DPoint pt(point.x, point.y);
                pt.x /= m_fFrameZoomFactor;
                pt.y /= m_fFrameZoomFactor;
                DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
                if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
                {
                    m_bCaptured = true;
                    SetCapture(m_hWnd);
                    int id = 0;
                    
                    CrossApp::CAEvent* event = new CrossApp::CAEvent();
                    event->setEventType(CrossApp::EventType::rightMouseEvent);
                    handleTouchesBegin(1, &id, &pt.x, &pt.y, event);
                    event->release();
                }
            }
            break;
            
        case WM_RBUTTONUP:
#if(_MSC_VER >= 1600)
            // Don't process message generated by Windows Touch
            if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break;
#endif /* #if(_MSC_VER >= 1600) */
            if (m_bCaptured)
            {
                POINT point = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
                DPoint pt(point.x, point.y);
                int id = 0;
                pt.x /= m_fFrameZoomFactor;
                pt.y /= m_fFrameZoomFactor;
                
                CrossApp::CAEvent* event = new CrossApp::CAEvent();
                event->setEventType(CrossApp::EventType::rightMouseEvent);
                handleTouchesEnd(1, &id, &pt.x, &pt.y, event);
                event->release();
                
                ReleaseCapture();
                m_bCaptured = false;
            }
            break;
            
#if(_MSC_VER >= 1600)
    case WM_TOUCH:
		{
            BOOL bHandled = FALSE;
            UINT cInputs = LOWORD(wParam);
            PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
            if (pInputs)
            {
                if (s_pfGetTouchInputInfoFunction((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT)))
                {
                    for (UINT i=0; i < cInputs; i++)
                    {
                        TOUCHINPUT ti = pInputs[i];
                        POINT input;
                        input.x = TOUCH_COORD_TO_PIXEL(ti.x);
                        input.y = TOUCH_COORD_TO_PIXEL(ti.y);
                        ScreenToClient(m_hWnd, &input);
                        DPoint pt(input.x, input.y);
                        DPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y);
                        if (m_obViewPortRect.equals(DRectZero) || m_obViewPortRect.containsPoint(tmp))
                        {
                            pt.x /= m_fFrameZoomFactor;
                            pt.y /= m_fFrameZoomFactor;

							CrossApp::CAEvent* event = new CrossApp::CAEvent();
							event->setEventType(CrossApp::EventType::leftMouseEvent);

                            if (ti.dwFlags & TOUCHEVENTF_DOWN)
                                handleTouchesBegin(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y, event);
                            else if (ti.dwFlags & TOUCHEVENTF_MOVE)
                                handleTouchesMove(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y, event);
                            else if (ti.dwFlags & TOUCHEVENTF_UP)
                                handleTouchesEnd(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y, event);

							event->release();
                         }
                     }
                     bHandled = TRUE;
                 }
                 delete [] pInputs;
             }
             if (bHandled)
             {
                 s_pfCloseTouchInputHandleFunction((HTOUCHINPUT)lParam);
             }
		}
      break;
#endif /* #if(_MSC_VER >= 1600) */
	case WM_SIZE:
	{
					static int oldWidth = 0, oldHeight = 0, windowState = 0;
					switch (wParam)
					{
					case SIZE_RESTORED:
					{
										  if (windowState == 2)
										  {
											  CCApplication::sharedApplication()->applicationWillEnterForeground();
											  
										  }
										  else if (windowState == 1)
										  {
											  this->setFrameSize(oldWidth, oldHeight);
											  CCApplication::sharedApplication()->applicationDidExitFullScreen();
										  }
										  windowState = 0;
					}
						break;
					case SIZE_MAXIMIZED:
					{
										   if (windowState == 2)
										   {
											   CCApplication::sharedApplication()->applicationWillEnterForeground();
										   }
										   else if (windowState == 0)
										   {
											   oldWidth = m_obScreenSize.width * 2;
											   oldHeight = m_obScreenSize.height * 2;
											   RECT rt;
											   SystemParametersInfo(SPI_GETWORKAREA, 0, &rt, 0);    // 获得工作区大小 
											   int w = (rt.right - rt.left) * 2;
											   int h = (rt.bottom - rt.top - 24) * 2;
											   this->setFrameSize(w, h);
											   CCApplication::sharedApplication()->applicationDidToggleFullScreen();
										   }
										   windowState = 1;
					}
						break;
					case SIZE_MINIMIZED:
					{
										   CCApplication::sharedApplication()->applicationDidEnterBackground();
										   windowState = 2;
					}
						break;
					}
	}
		break;
    case WM_KEYDOWN:
        switch (wParam)
        {
        case VK_F1:
            if (GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0)
                CAApplication::getApplication()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
            break;
        case VK_F2:
            if (GetKeyState(VK_LSHIFT) < 0 ||  GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0)
                CAApplication::getApplication()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeMenuClicked);
            break;
        case VK_ESCAPE:
			CAApplication::getApplication()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
            break;
        case VK_LEFT:
            CAIMEDispatcher::sharedDispatcher()->dispatchCursorMoveBackward();
            break;
        case VK_RIGHT:
            CAIMEDispatcher::sharedDispatcher()->dispatchCursorMoveForward();
            break;
		case VK_UP:
			CAIMEDispatcher::sharedDispatcher()->dispatchCursorMoveUp();
			break;
		case VK_DOWN:
			CAIMEDispatcher::sharedDispatcher()->dispatchCursorMoveDown();
			break;

        case 'C':
        case 'X':
            if (GetKeyState(VK_CONTROL) < 0)
                {
                    if (wParam == 'C')
                    {
                    CAIMEDispatcher::sharedDispatcher()->dispatchCopyToClipboard();
                    }
                    else
                    {
                    CAIMEDispatcher::sharedDispatcher()->dispatchCutToClipboard();
                    }
            }
            break;
        case 'V':
            if (GetKeyState(VK_CONTROL) < 0)
			{
				CAIMEDispatcher::sharedDispatcher()->dispatchPasteFromClipboard();
            }
            break;
        case 'A':
            if (GetKeyState(VK_CONTROL) < 0)
            {
                CAIMEDispatcher::sharedDispatcher()->dispatchSelectAll();
            }
            break;

        default:
            break;
        }

        if ( m_lpfnAccelerometerKeyHook!=NULL )
        {
            (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
        }
        break;
    case WM_KEYUP:
        if ( m_lpfnAccelerometerKeyHook!=NULL )
        {
            (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
        }
        break;
    case WM_CHAR:
        {
            if (wParam < 0x20)
            {
                if (VK_BACK == wParam)
                {
                    CAIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
                }
                else if (VK_RETURN == wParam)
                {
                    CAIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
                }
                else if (VK_TAB == wParam)
                {
                    // tab input
                }
                else if (VK_ESCAPE == wParam)
                {
                    // ESC input
                    //CCDirector::sharedDirector()->end();
                }
            }
            else if (wParam < 128)
            {
                // ascii char
                CAIMEDispatcher::sharedDispatcher()->dispatchInsertText((const char *)&wParam, 1);
            }
            else
            {
                char szUtf8[8] = {0};
                int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&wParam, 1, szUtf8, sizeof(szUtf8), NULL, NULL);
                CAIMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen);
            }
            if ( m_lpfnAccelerometerKeyHook!=NULL )
            {
                (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
            }
        }
        break;
    case WM_PAINT:
        PAINTSTRUCT ps;
        BeginPaint(m_hWnd, &ps);
        EndPaint(m_hWnd, &ps);
        break;

    case WM_CLOSE:
		CAApplication::getApplication()->end();
        break;

    case WM_DESTROY:
        destroyGL();
        PostQuitMessage(0);
        break;

    default:
        if (m_wndproc)
        {

            m_wndproc(message, wParam, lParam, &bProcessed);
            if (bProcessed) break;
        }
        return DefWindowProc(m_hWnd, message, wParam, lParam);
    }

    if (m_wndproc && !bProcessed)
    {
        m_wndproc(message, wParam, lParam, &bProcessed);
    }
    return 0;
}