当前位置: 首页>>代码示例>>C++>>正文


C++ MouseInput类代码示例

本文整理汇总了C++中MouseInput的典型用法代码示例。如果您正苦于以下问题:C++ MouseInput类的具体用法?C++ MouseInput怎么用?C++ MouseInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MouseInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

    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;
             }
         }
    }
开发者ID:doveiya,项目名称:isilme,代码行数:34,代码来源:gui.cpp

示例2: HandleKeyboard

//-------------------------------------------------------------------------------------------------
ALVR_RESULT HandleKeyboard(UINT_PTR ch)
{
    if(ch == 'E' || ch == 'e')
    {
        g_MouseInput.SetEmulation(!g_MouseInput.GetEmulation());
    }
    else if(ch == 'L' || ch == 'l')
    {
        g_bLateLatchRight = !g_bLateLatchRight;
    }
    else if(ch == 'A' || ch == 'a')
    {
        g_bRotate = !g_bRotate;
    }

    else if(ch == VK_UP)
    {
        ChangeDrawRepeat(true);
    }
    else if(ch == VK_DOWN)
    {
        ChangeDrawRepeat(false);
    }
    else
    {
        return ALVR_FALSE;
    }
    return ALVR_OK;
}
开发者ID:GPUOpen-LibrariesAndSDKs,项目名称:LiquidVR,代码行数:30,代码来源:SimpleLateLatch.cpp

示例3:

Qt3DCore::QBackendNode *MouseInputFunctor::create(Qt3DCore::QNode *frontend, const Qt3DCore::QBackendNodeFactory *factory) const
{
    MouseInput *input = m_handler->mouseInputManager()->getOrCreateResource(frontend->id());
    input->setFactory(factory);
    input->setInputHandler(m_handler);
    input->setPeer(frontend);
    return input;
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:8,代码来源:mouseinput.cpp

示例4: pushMotionInput

 void GLUTInput::pushMotionInput(int x, int y)
 {
     MouseInput mouseInput;
     mouseInput.setX(x);
     mouseInput.setY(y);
     mouseInput.setButton(MouseInput::EMPTY);
     mouseInput.setType(MouseInput::MOVED);
     mMouseInputQueue.push(mouseInput);
 }
开发者ID:weimingtom,项目名称:guichan_memory,代码行数:9,代码来源:glutinput.cpp

示例5: pushMouseWheelMovedDown

    void GenericInput::pushMouseWheelMovedDown(int x, int y)
    {
        MouseInput mouseInput;
        mouseInput.setX(x);
        mouseInput.setY(y);
        mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN);

        mMouseInputQueue.push(mouseInput);
    }
开发者ID:weimingtom,项目名称:guichan_cocos2dx,代码行数:9,代码来源:genericinput.cpp

示例6: pushMouseMoved

    void GenericInput::pushMouseMoved(int x, int y)
    {
        MouseInput mouseInput;
        mouseInput.setX(x);
        mouseInput.setY(y);
        mouseInput.setType(MouseInput::MOVED);

        mMouseInputQueue.push(mouseInput);
    }
开发者ID:weimingtom,项目名称:guichan_cocos2dx,代码行数:9,代码来源:genericinput.cpp

示例7: pushMouseButtonReleased

    void GenericInput::pushMouseButtonReleased(int x, int y, int button)
    {
        MouseInput mouseInput;
        mouseInput.setX(x);
        mouseInput.setY(y);
        mouseInput.setButton(button);
        mouseInput.setType(MouseInput::RELEASED);

        mMouseInputQueue.push(mouseInput);
    }
开发者ID:weimingtom,项目名称:guichan_cocos2dx,代码行数:10,代码来源:genericinput.cpp

示例8: GetTargetApzc

void
DragBlockState::DispatchEvent(const InputData& aEvent) const
{
  MouseInput mouseInput = aEvent.AsMouseInput();
  if (!mouseInput.TransformToLocal(mTransformToApzc)) {
    return;
  }

  GetTargetApzc()->HandleDragEvent(mouseInput, mDragMetrics);
}
开发者ID:leplatrem,项目名称:gecko-dev,代码行数:10,代码来源:InputBlockState.cpp

示例9: main

int main(int argc, char ** argv) {
	std::cout << "Starting Controller Mouse Emulator" << std::endl;

	float mouseSpeed = 15;
	float scrollSpeed = 25;

	MouseInput mouseInput;
	Gamepad gamepad;
	int dx, dy;
	int sy;

	while (true) {
		gamepad.update();

		dx = (int)(gamepad.getLThumbX() * mouseSpeed);
		dy = (int)(-gamepad.getLThumbY() * mouseSpeed);

		sy = (int)(gamepad.getRThumbY() * scrollSpeed);

		mouseInput.moveMouse(dx, dy);
		mouseInput.scrollWheel(sy);

		if (gamepad.aPressed())
			mouseInput.setLeftMouseDown(true);
		else if (gamepad.aReleased())
			mouseInput.setLeftMouseDown(false);

		if (gamepad.bPressed())
			mouseInput.setRightMouseDown(true);
		else if (gamepad.bReleased())
			mouseInput.setRightMouseDown(false);

		if (gamepad.rsPressed())
			mouseInput.setMiddleMouseDown(true);
		else if (gamepad.rsReleased())
			mouseInput.setMiddleMouseDown(false);

		if (gamepad.rbPressed() && mouseSpeed < MAX_MOUSE_SPEED) {
			mouseSpeed += SPEED_INCREMENT;
			std::cout << "Mouse speed: " << mouseSpeed << std::endl;
		}

		if (gamepad.lbPressed() && mouseSpeed > SPEED_INCREMENT) {
			mouseSpeed -= SPEED_INCREMENT;
			std::cout << "Mouse speed: " << mouseSpeed << std::endl;
		}

		gamepad.updateInput();

		Sleep(15);
	}

	return 0;
}
开发者ID:whupdup,项目名称:Controller-Mouse-Emulator,代码行数:54,代码来源:main.cpp

示例10: ConvertMouseEvent

static void ConvertMouseEvent( wxMouseEvent& event, MouseInput& input )
{
    uint32_t buttons = 0x0;

    buttons |= event.LeftIsDown() ? MouseButtons::Left : 0x0;
    buttons |= event.MiddleIsDown() ? MouseButtons::Middle : 0x0;
    buttons |= event.RightIsDown() ? MouseButtons::Right : 0x0;
    buttons |= event.Aux1IsDown() ? MouseButtons::Backward : 0x0;
    buttons |= event.Aux2IsDown() ? MouseButtons::Forward : 0x0;

    buttons |= event.AltDown() ? AcceleratorButtons::Alt : 0x0;
    buttons |= event.ControlDown() ? AcceleratorButtons::Ctrl : 0x0;
    buttons |= event.ShiftDown() ? AcceleratorButtons::Shift : 0x0;

    input.SetButtons( buttons );

    input.SetPosition( Point( event.GetX(), event.GetY() ) );
}
开发者ID:KETMGaming,项目名称:Helium,代码行数:18,代码来源:Input.cpp

示例11: handleMouseWheelMovedUp

    void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput)
    {
        WidgetPtr sourceWidget = GetMouseEventSource(mouseInput.getX(), mouseInput.getY());

        if (mFocusHandler->GetDraggedWidget() != NULL)
        {
            sourceWidget = mFocusHandler->GetDraggedWidget();
        }

        int sourceWidgetX, sourceWidgetY;
        sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);

        distributeMouseEvent(sourceWidget,
                             MouseEvent::WHEEL_MOVED_UP,
                             mouseInput.getButton(),
                             mouseInput.getX(),
                             mouseInput.getY());
    }
开发者ID:doveiya,项目名称:isilme,代码行数:18,代码来源:gui.cpp

示例12: simulateMouseClick

void SDLInput::simulateMouseClick(const int x, const int y,
                                  const MouseButton::Type button)
{
    MouseInput mouseInput;
    mouseInput.setX(x);
    mouseInput.setY(y);
    mouseInput.setReal(x, y);
    mouseInput.setButton(button);
    mouseInput.setType(MouseEventType::PRESSED);
    mouseInput.setTimeStamp(SDL_GetTicks());
    mMouseInputQueue.push(mouseInput);
    mouseInput.setType(MouseEventType::RELEASED);
    mouseInput.setTimeStamp(SDL_GetTicks());
    mMouseInputQueue.push(mouseInput);
}
开发者ID:KaneHart,项目名称:Elmlor-Client,代码行数:15,代码来源:sdlinput.cpp

示例13: handleMousePressed

    void Gui::handleMousePressed(const MouseInput& mouseInput)
    {
        WidgetPtr sourceWidget = GetMouseEventSource(mouseInput.getX(), mouseInput.getY());

        if (mFocusHandler->GetDraggedWidget())
        {
            sourceWidget = mFocusHandler->GetDraggedWidget();
        }

        int sourceWidgetX, sourceWidgetY;
        sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);

        if ((mFocusHandler->GetModalFocused() != NULL
            && sourceWidget->isModalFocused())
            || mFocusHandler->GetModalFocused() == NULL)
        {
            sourceWidget->requestFocus();
        }

        if (mouseInput.getTimeStamp() - mLastMousePressTimeStamp < 250
            && mLastMousePressButton == mouseInput.getButton())
        {
            mClickCount++;
        }
        else
        {
            mClickCount = 1;
        }

        distributeMouseEvent(sourceWidget,
                             MouseEvent::PRESSED,
                             mouseInput.getButton(),
                             mouseInput.getX(),
                             mouseInput.getY());

        mFocusHandler->SetLastWidgetPressed(sourceWidget);

        mFocusHandler->SetDraggedWidget(sourceWidget);
        mLastMouseDragButton = mouseInput.getButton();

        mLastMousePressButton = mouseInput.getButton();
        mLastMousePressTimeStamp = mouseInput.getTimeStamp();
    }
开发者ID:doveiya,项目名称:isilme,代码行数:43,代码来源:gui.cpp

示例14: mouseInputMotion

void mouseInputMotion(int x, int y)
{
	g_MouseInput.LastLocation.X = x;
	g_MouseInput.LastLocation.Y	= y;

	if (g_MouseInput.pCursorCallback != NULL)
		g_MouseInput.pCursorCallback(g_MouseInput.LastLocation);

	if (g_MouseInput.nSelectionState == SELECTION_ACTIVE)
		mouseInputCallSelection();
}
开发者ID:BillTheBest,项目名称:OpenNI,代码行数:11,代码来源:MouseInput.cpp

示例15: handleMouseReleased

    void Gui::handleMouseReleased(const MouseInput& mouseInput)
    {
        WidgetPtr sourceWidget = GetMouseEventSource(mouseInput.getX(), mouseInput.getY());

        if (mFocusHandler->GetDraggedWidget())
        {
            if (sourceWidget != mFocusHandler->GetLastWidgetPressed())
            {
                mFocusHandler->SetLastWidgetPressed(WidgetPtr());
            }
            
            sourceWidget = mFocusHandler->GetDraggedWidget();
        }

        int sourceWidgetX, sourceWidgetY;
        sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
        
        distributeMouseEvent(sourceWidget,
                             MouseEvent::RELEASED,
                             mouseInput.getButton(),
                             mouseInput.getX(),
                             mouseInput.getY());

        if (mouseInput.getButton() == mLastMousePressButton            
            && mFocusHandler->GetLastWidgetPressed() == sourceWidget)
        {
            distributeMouseEvent(sourceWidget,
                                 MouseEvent::CLICKED,
                                 mouseInput.getButton(),
                                 mouseInput.getX(),
                                 mouseInput.getY());
            
            mFocusHandler->SetLastWidgetPressed(WidgetPtr());
        }
        else
        {
            mLastMousePressButton = 0;
            mClickCount = 0;
        }

        if (mFocusHandler->GetDraggedWidget())
        {
            mFocusHandler->SetDraggedWidget(WidgetPtr());
        }
    }
开发者ID:doveiya,项目名称:isilme,代码行数:45,代码来源:gui.cpp


注:本文中的MouseInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。