nsEventStatus
AccessibleCaretEventHub::HandleEvent(WidgetEvent* aEvent)
{
  nsEventStatus status = nsEventStatus_eIgnore;

  if (!mInitialized) {
    return status;
  }

  MOZ_ASSERT(mRefCnt.get() > 1, "Expect caller holds us as well!");

  switch (aEvent->mClass) {
    case eMouseEventClass:
      status = HandleMouseEvent(aEvent->AsMouseEvent());
      break;

    case eTouchEventClass:
      status = HandleTouchEvent(aEvent->AsTouchEvent());
      break;

    case eKeyboardEventClass:
      status = HandleKeyboardEvent(aEvent->AsKeyboardEvent());
      break;

    default:
      break;
  }

  return status;
}
예제 #2
0
nsEventStatus
AccessibleCaretEventHub::HandleEvent(WidgetEvent* aEvent)
{
  nsEventStatus status = nsEventStatus_eIgnore;

  if (!mInitialized) {
    return status;
  }

  switch (aEvent->mClass) {
  case eMouseEventClass:
    status = HandleMouseEvent(aEvent->AsMouseEvent());
    break;

  case eWheelEventClass:
    status = HandleWheelEvent(aEvent->AsWheelEvent());
    break;

  case eTouchEventClass:
    status = HandleTouchEvent(aEvent->AsTouchEvent());
    break;

  case eKeyboardEventClass:
    status = HandleKeyboardEvent(aEvent->AsKeyboardEvent());
    break;

  default:
    break;
  }

  return status;
}
예제 #3
0
파일: Canvas.cpp 프로젝트: Gallaecio/0ad
void Canvas::OnMouse(wxMouseEvent& evt)
{
	// Capture on button-down, so we can respond even when the mouse
	// moves off the window
	if (!m_MouseCaptured && evt.ButtonDown())
	{
		m_MouseCaptured = true;
		CaptureMouse();
	}
	// Un-capture when all buttons are up
	else if (m_MouseCaptured && evt.ButtonUp() &&
		! (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_MIDDLE) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT))
		)
	{
		m_MouseCaptured = false;
		ReleaseMouse();
	}

	// Set focus when clicking
	if (evt.ButtonDown())
		SetFocus();

	// Reject motion events if the mouse has not actually moved
	if (evt.Moving() || evt.Dragging())
	{
		if (m_LastMousePos == evt.GetPosition())
			return;
		m_LastMousePos = evt.GetPosition();
	}

	HandleMouseEvent(evt);
}
예제 #4
0
static void
HandleMotionEvent(MirMotionEvent const motion, SDL_Window* sdl_window)
{
    int cord_index;
    for (cord_index = 0; cord_index < motion.pointer_count; cord_index++) {
        if (motion.pointer_coordinates[cord_index].tool_type == mir_motion_tool_type_finger) {
            HandleTouchEvent(motion, cord_index, sdl_window);
        }
        else {
            HandleMouseEvent(motion, cord_index, sdl_window);
        }
    }
}
예제 #5
0
파일: CCEGLView.cpp 프로젝트: Gamex/GameX
void EGLView::ProcessEventQueue()
{
    const pp::Size& size = g_instance->Size();
    // If the size of the global instance has changed then
    // we need to update our GL frame size accordingly
    if (size != _context->GetSize())
    {
        setFrameSize(size.width(), size.height());
    }

    pthread_mutex_lock(&_mutex);
    while (_event_queue.size())
    {
        pp::InputEvent event = _event_queue.front();
        _event_queue.pop();
        PP_InputEvent_Type type = event.GetType();
        switch (type)
        {
            case PP_INPUTEVENT_TYPE_KEYDOWN:
                CCLOG("got KEYDOWN");
                break;
            case PP_INPUTEVENT_TYPE_KEYUP:
                CCLOG("got KEYUP");
                break;
            case PP_INPUTEVENT_TYPE_CHAR:
                CCLOG("got KEYCHAR");
                break;
            case PP_INPUTEVENT_TYPE_MOUSEENTER:
                CCLOG("got MOUSEENTER");
                break;
            case PP_INPUTEVENT_TYPE_MOUSELEAVE:
                CCLOG("got MOUSELEAVE");
                break;
            case PP_INPUTEVENT_TYPE_MOUSEDOWN:
            case PP_INPUTEVENT_TYPE_MOUSEUP:
            case PP_INPUTEVENT_TYPE_MOUSEMOVE:
                {
                    const pp::MouseInputEvent* mevent =
                        reinterpret_cast<const pp::MouseInputEvent*>(&event);
                    HandleMouseEvent(mevent);
                    break;
                }
            default:
                CCLOG("unhandled event type: %d", type);
                break;
        }
    }
    pthread_mutex_unlock(&_mutex);
}
예제 #6
0
// Handle mouse events
//-----------------------------------------------------------------------------
CPUTEventHandledCode CPUT_DX11::CPUTHandleMouseEvent(int x, int y, int wheel, CPUTMouseState state)
{
    // dispatch event to GUI to handle GUI triggers (if any)
    CPUTEventHandledCode handleCode = CPUTGuiControllerDX11::GetController()->HandleMouseEvent(x,y,wheel,state);

    // dispatch event to users HandleMouseEvent() method if it wasn't consumed by the GUI
    if(CPUT_EVENT_HANDLED != handleCode)
    {
        HEAPCHECK;
        handleCode = HandleMouseEvent(x,y,wheel,state);
        HEAPCHECK;
    }

    return handleCode;
}
예제 #7
0
static void
HandleInput(MirInputEvent const* input_event, SDL_Window* window)
{
    switch (MIR_mir_input_event_get_type(input_event)) {
        case (mir_input_event_type_key):
            HandleKeyEvent(MIR_mir_input_event_get_keyboard_event(input_event), window);
            break;
        case (mir_input_event_type_pointer):
            HandleMouseEvent(MIR_mir_input_event_get_pointer_event(input_event), window);
            break;
        case (mir_input_event_type_touch):
            HandleTouchEvent(MIR_mir_input_event_get_touch_event(input_event),
                             MIR_mir_input_event_get_device_id(input_event),
                             window);
            break;
        default:
            break;
    }
}
예제 #8
0
void Input::PorcessEvents()
{
	SDL_Event event;

	// store the old keyboard for next frame
	StoreKeyboard();
	// Get the current state of the keyboard
	keyboard_ = SDL_GetKeyboardState( NULL );

	// reset the mouse
	mouse_.xMotion = 0;
	mouse_.yMotion = 0;

	if( keyboard_[SDL_SCANCODE_ESCAPE] )
	{
		askedToQuit_ = true;
	}

	while( SDL_PollEvent( &event ) )
	{
		// quit if there is a quit message or escape is pressed
		if( event.type == SDL_QUIT )
		{
			askedToQuit_ = true;
		}
		// update the mouse struct if it moved
		if( event.type == SDL_MOUSEMOTION )
		{
			HandleMouseEvent( event );
		}
		// toggle mouse lock with Left CTRL key
		if( event.type == SDL_KEYUP )
		{
			if( event.key.keysym.scancode == SDL_SCANCODE_LCTRL )
			{
				mouse_.locked = ((mouse_.locked == SDL_TRUE) ? SDL_FALSE : SDL_TRUE);
				SDL_SetRelativeMouseMode( mouse_.locked );
			}
		}
	}
}
예제 #9
0
void PicInputHandler::HandleInput() {
    sf::Event ev;

    while (app->pollEvent(ev)) {
        int dx = 0, dy = 0, op = OP_NONE;

        /* get input... */

        switch (ev.type) {
        case sf::Event::KeyPressed:
            switch (ev.key.code) {
            case sf::Keyboard::Escape:
                game->SetResolution(GR_ABORTED);
                break;
            case sf::Keyboard::P:
                game->SetPaused(!game->GetPaused());
                break;
            case sf::Keyboard::Num7:
            case sf::Keyboard::Y:
                dx = -1;
                dy = -1;
                break;
            case sf::Keyboard::Num9:
            case sf::Keyboard::U:
                dx = 1;
                dy = -1;
                break;
            case sf::Keyboard::Num1:
            case sf::Keyboard::B:
                dx = -1;
                dy = 1;
                break;
            case sf::Keyboard::Num3:
            case sf::Keyboard::N:
                dx = 1;
                dy = 1;
                break;
            case sf::Keyboard::Num4:
            case sf::Keyboard::H:
            case sf::Keyboard::A:
            case sf::Keyboard::Left:
                dx = -1;
                break;
            case sf::Keyboard::Num6:
            case sf::Keyboard::L:
            case sf::Keyboard::D:
            case sf::Keyboard::Right:
                dx = 1;
                break;
            case sf::Keyboard::Num8:
            case sf::Keyboard::K:
            case sf::Keyboard::W:
            case sf::Keyboard::Up:
                dy = -1;
                break;
            case sf::Keyboard::Num2:
            case sf::Keyboard::J:
            case sf::Keyboard::S:
            case sf::Keyboard::Down:
                dy = 1;
                break;
            case sf::Keyboard::Num0:
            case sf::Keyboard::Space:
                op = OP_HIT;
                break;
            case sf::Keyboard::Num5:
            case sf::Keyboard::RControl:
            case sf::Keyboard::LControl:
                op = OP_MARK;
                break;
            case sf::Keyboard::Z:
                op = OP_UNDO;
                break;
            default:
                break;
            }
            break;
        case sf::Event::MouseButtonPressed:
            op = HandleMouseEvent(ev.mouseButton.x, ev.mouseButton.y, ev.mouseButton.button, ev.type);
            break;
        case sf::Event::MouseButtonReleased:
            dragHelper.reset();
            break;
        case sf::Event::MouseMoved:
            op = HandleMouseEvent(ev.mouseMove.x, ev.mouseMove.y, dragHelper.getButton(), ev.type);
            break;
         case sf::Event::Closed:
            game->SetResolution(GR_ABORTED);
            break;
         default:
            break;
        }

        /* perform actual logic... */

        if (dx || dy) {
            game->TrySetLocationRel(dx, dy);
        }

        if (op != OP_NONE) {
            game->DoOp(op);
        }
    }
}