void QNitpickerPlatformWindow::_process_key_event(Input::Event const &ev)
{
	const bool pressed = (ev.type() == Input::Event::PRESS);
	const int keycode = ev.code();

	if (pressed) {
		_last_keycode = keycode;
		_key_repeat_timer->start(KEY_REPEAT_DELAY_MS);
	} else
		_key_repeat_timer->stop();

	_keyboard_handler.processKeycode(keycode, pressed, false);
}
void QNitpickerPlatformWindow::_handle_input(unsigned int)
{
	for (int i = 0, num_ev = _input_session.flush(); i < num_ev; i++) {

		Input::Event *ev = &_ev_buf[i];

		bool const is_key_event = ev->type() == Input::Event::PRESS ||
					              ev->type() == Input::Event::RELEASE;

		bool const is_mouse_button_event =
			is_key_event && (ev->code() == Input::BTN_LEFT ||
					         ev->code() == Input::BTN_MIDDLE ||
					         ev->code() == Input::BTN_RIGHT);

		if (ev->type() == Input::Event::MOTION ||
			ev->type() == Input::Event::WHEEL ||
			is_mouse_button_event) {

			_process_mouse_event(ev);

		} else if (is_key_event && (ev->code() < 128)) {

			_process_key_event(ev);

		}
	}
}
void QNitpickerPlatformWindow::handle_events()
{
	/* handle resize events */

	if (_signal_receiver.pending()) {

		_signal_receiver.wait_for_signal();

		Framebuffer::Mode mode(_nitpicker_session.mode());

		if ((mode.width() != _current_mode.width()) ||
	    	(mode.height() != _current_mode.height()) ||
	    	(mode.format() != _current_mode.format())) {

			QRect geo(geometry());
			geo.setWidth(mode.width());
			geo.setHeight(mode.height());

			QWindowSystemInterface::handleGeometryChange(window(), geo);

			setGeometry(geo);
		}
	}

	/* handle input events */

	if (_input_session.is_pending()) {
		for (int i = 0, num_ev = _input_session.flush(); i < num_ev; i++) {

			Input::Event *ev = &_ev_buf[i];

			bool const is_key_event = ev->type() == Input::Event::PRESS ||
					                  ev->type() == Input::Event::RELEASE;

			bool const is_mouse_button_event =
				is_key_event && (ev->code() == Input::BTN_LEFT ||
					             ev->code() == Input::BTN_MIDDLE ||
					             ev->code() == Input::BTN_RIGHT);

			if (ev->type() == Input::Event::MOTION ||
				ev->type() == Input::Event::WHEEL ||
				is_mouse_button_event) {

				_process_mouse_event(ev);

			} else if (is_key_event && (ev->code() < 128)) {

				_process_key_event(ev);

			}
		}

	}

}
Beispiel #4
0
void QNitpickerInputHandler::readInputData()
{
//	qDebug() << "QNitpickerInputHandler::readInputData()";

	int i, num_ev;

	if (input->is_pending()) {
		for (i = 0, num_ev = input->flush(); i < num_ev; i++) {

			Input::Event *ev = &ev_buf[i];

			bool const is_key_event = ev->type() == Input::Event::PRESS
			                       || ev->type() == Input::Event::RELEASE;

			bool const is_mouse_button_event =
				is_key_event && (ev->code() == Input::BTN_LEFT
				              || ev->code() == Input::BTN_MIDDLE
				              || ev->code() == Input::BTN_RIGHT);

			if (ev->type() == Input::Event::MOTION
			 || ev->type() == Input::Event::WHEEL
			 || is_mouse_button_event) {

#ifndef QT_NO_QWS_MOUSE_NITPICKER
				mouse->processMouseEvent(ev);
#endif

			} else if (is_key_event && (ev->code() < 128)) {

#ifndef QT_NO_QWS_KEYBOARD_NITPICKER
				keyboard->processKeyEvent(ev);
#endif
			}
		}

	}

//	qDebug() << "QNitpickerInputHandler::readInputData() finished";
}
void QNitpickerPlatformWindow::_process_mouse_event(Input::Event const &ev)
{
	QPoint global_position(ev.ax(), ev.ay());
	QPoint local_position(global_position.x() - geometry().x(),
			              global_position.y() - geometry().y());

	switch (ev.type()) {

		case Input::Event::PRESS:

			/* make this window the focused window */
			requestActivateWindow();

			switch (ev.code()) {
				case Input::BTN_LEFT:
					_mouse_button_state |= Qt::LeftButton;
					break;
				case Input::BTN_RIGHT:
					_mouse_button_state |= Qt::RightButton;
					break;
				case Input::BTN_MIDDLE:
					_mouse_button_state |= Qt::MidButton;
					break;
				case Input::BTN_SIDE:
					_mouse_button_state |= Qt::XButton1;
					break;
				case Input::BTN_EXTRA:
					_mouse_button_state |= Qt::XButton2;
					break;
			}
			break;

		case Input::Event::RELEASE:

			switch (ev.code()) {
				case Input::BTN_LEFT:
					_mouse_button_state &= ~Qt::LeftButton;
					break;
				case Input::BTN_RIGHT:
					_mouse_button_state &= ~Qt::RightButton;
					break;
				case Input::BTN_MIDDLE:
					_mouse_button_state &= ~Qt::MidButton;
					break;
				case Input::BTN_SIDE:
					_mouse_button_state &= ~Qt::XButton1;
					break;
				case Input::BTN_EXTRA:
					_mouse_button_state &= ~Qt::XButton2;
					break;
			}
			break;

		case Input::Event::WHEEL:

			QWindowSystemInterface::handleWheelEvent(window(),
					                                 local_position,
					                                 local_position,
					                                 ev.ry() * 120,
					                                 Qt::Vertical);
			return;

		default:
			break;
	}

	QWindowSystemInterface::handleMouseEvent(window(),
			                                 local_position,
			                                 global_position,
			                                 _mouse_button_state);
}