Ejemplo n.º 1
0
bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
	if (ev.jbutton.button == JOY_BUT_LMOUSE) {
		event.type = Common::EVENT_LBUTTONUP;
		processMouseEvent(event, _km.x, _km.y);
	} else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
		event.type = Common::EVENT_RBUTTONUP;
		processMouseEvent(event, _km.x, _km.y);
	} else {
		event.type = Common::EVENT_KEYUP;
		switch (ev.jbutton.button) {
		case JOY_BUT_ESCAPE:
			event.kbd.keycode = Common::KEYCODE_ESCAPE;
			event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod)ev.key.keysym.mod, 0);
			break;
		case JOY_BUT_PERIOD:
			event.kbd.keycode = Common::KEYCODE_PERIOD;
			event.kbd.ascii = mapKey(SDLK_PERIOD, (SDLMod)ev.key.keysym.mod, 0);
			break;
		case JOY_BUT_SPACE:
			event.kbd.keycode = Common::KEYCODE_SPACE;
			event.kbd.ascii = mapKey(SDLK_SPACE, (SDLMod)ev.key.keysym.mod, 0);
			break;
		case JOY_BUT_F5:
			event.kbd.keycode = Common::KEYCODE_F5;
			event.kbd.ascii = mapKey(SDLK_F5, (SDLMod)ev.key.keysym.mod, 0);
			break;
		}
	}
	return true;
}
Ejemplo n.º 2
0
bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {

	event.kbd.flags = 0;

	switch (ev.jbutton.button) {
	case BTN_CROSS: // Left mouse button
		event.type = Common::EVENT_LBUTTONUP;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BTN_CIRCLE: // Right mouse button
		event.type = Common::EVENT_RBUTTONUP;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BTN_TRIANGLE: // Game menu
		event.type = Common::EVENT_KEYUP;
		event.kbd.keycode = Common::KEYCODE_F5;
		event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0);
		break;
	case BTN_SELECT: // Virtual keyboard
		// Handled in key down
		break;
	case BTN_SQUARE: // Escape
		event.type = Common::EVENT_KEYUP;
		event.kbd.keycode = Common::KEYCODE_ESCAPE;
		event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0);
		break;
	}
	return true;
}
Ejemplo n.º 3
0
/**
 * Before calling the original SDL implementation, this method loads in
 * queued events.
 *
 * @param event The ScummVM event
 */
bool WebOSSdlEventSource::pollEvent(Common::Event &event) {
	uint32 curTime = g_system->getMillis();

	// Event-dependent nitializations for when SDL runs its first poll.
	if (_firstPoll) {
		// Set the initial dimensions
		calculateDimensions();

		// Having a mouse pointer on screen when not in Touchpad mode is poor
		// interface design, because the user won't know whether to tap buttons
		// or drag the pointer to them.  On the first poll, set the appropriate
		// pointer visibility.
		g_system->showMouse(_touchpadMode);
		_firstPoll = false;
	}

	// Run down the priority list for queued events. The built-in
	// event queue runs events on the next poll, which causes many
	// WebOS devices (and a few game engines) to ignore certain inputs.
	// Allowing keys and clicks to stay "down" longer is enough to register
	// the press.
	if (_queuedEscapeUpTime != 0 && curTime >= _queuedEscapeUpTime) {
		event.type = Common::EVENT_KEYUP;
		event.kbd.flags = 0;
		event.kbd.keycode = Common::KEYCODE_ESCAPE;
		event.kbd.ascii = Common::ASCII_ESCAPE;
		_queuedEscapeUpTime = 0;
		return true;
	} else if (_queuedSpaceUpTime != 0 && curTime >= _queuedSpaceUpTime) {
		event.type = Common::EVENT_KEYUP;
		event.kbd.flags = 0;
		event.kbd.keycode = Common::KEYCODE_SPACE;
		event.kbd.ascii = Common::ASCII_SPACE;
		_queuedSpaceUpTime = 0;
		return true;
	} else if (_queuedRUpTime != 0 && curTime >= _queuedRUpTime) {
		event.type = Common::EVENT_RBUTTONUP;
		processMouseEvent(event, _curX, _curY);
		_queuedRUpTime = 0;
		return true;
	} else if (_queuedDragTime != 0 && curTime >= _queuedDragTime) {
		event.type = Common::EVENT_LBUTTONDOWN;
		_dragging = true;
		processMouseEvent(event, _curX, _curY);
		_queuedDragTime = 0;
		return true;
	}

	return SdlEventSource::pollEvent(event);
}
Ejemplo n.º 4
0
bool AndroidSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
	if (ev.button.button == SDL_BUTTON_LEFT)
		event.type = Common::EVENT_LBUTTONDOWN;
	else if (ev.button.button == SDL_BUTTON_RIGHT)
		event.type = Common::EVENT_RBUTTONDOWN;
#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
	else if (ev.button.button == SDL_BUTTON_WHEELUP)
		event.type = Common::EVENT_WHEELUP;
	else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
		event.type = Common::EVENT_WHEELDOWN;
#endif
#if defined(SDL_BUTTON_MIDDLE)
	else if (ev.button.button == SDL_BUTTON_MIDDLE) {
		event.type = Common::EVENT_MBUTTONDOWN;

		static int show_onscreen = 0;
		if (show_onscreen == 0) {
			SDL_ANDROID_SetScreenKeyboardShown(0);
			show_onscreen++;
		} else if (show_onscreen==1) {
			SDL_ANDROID_SetScreenKeyboardShown(1);
			show_onscreen++;
		}
		if (show_onscreen == 2)
			show_onscreen = 0;
	}
#endif
	else
		return false;

	processMouseEvent(event, ev.button.x, ev.button.y);

	return true;
}
Ejemplo n.º 5
0
bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
	if (ev.button.button == SDL_BUTTON_LEFT) {
		if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */
			event.type = Common::EVENT_RBUTTONUP;
		else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */
			event.type = Common::EVENT_LBUTTONUP;
		else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */
			event.type = Common::EVENT_RBUTTONUP;
		else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */
			event.type = Common::EVENT_MOUSEMOVE;
		else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */
			event.type = Common::EVENT_MOUSEMOVE;
		else
			event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */
	} else if (ev.button.button == SDL_BUTTON_RIGHT)
		event.type = Common::EVENT_RBUTTONUP;
#if defined(SDL_BUTTON_MIDDLE)
	else if (ev.button.button == SDL_BUTTON_MIDDLE)
		event.type = Common::EVENT_MBUTTONUP;
#endif
	else
		return false;

	processMouseEvent(event, ev.button.x, ev.button.y);

	return true;
}
Ejemplo n.º 6
0
/**
 * Handles mouse button release.
 *
 * @param ev    The SDL event
 * @param event The ScummVM event.
 * @return True if event was processed, false if not.
 */
bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev,
		Common::Event &event) {
	// Only react if the finger hasn't been virtually lifted already
	if (_fingerDown[ev.button.which]) {
		// No matter what, if it's the first finger that's lifted when
		// we're dragging, just lift the mouse button.
		if (ev.button.which == 0 && _dragging) {
			event.type = Common::EVENT_LBUTTONUP;
			processMouseEvent(event, _curX, _curY);
			_dragging = false;
		} else {
			// If it was the first finger and the click hasn't been
			// canceled, it's a click.
			if (ev.button.which == 0 && _doClick &&
					!_fingerDown[1] && !_fingerDown[2]) {
				event.type = Common::EVENT_LBUTTONUP;
				processMouseEvent(event, _curX, _curY);
				g_system->getEventManager()->pushEvent(event);
				event.type = Common::EVENT_LBUTTONDOWN;
				if (_queuedDragTime > 0)
					_queuedDragTime = 0;
			} else if (ev.button.which == 1 &&
					_fingerDown[0] && _fingerDown[1] && !_fingerDown[2]) {
				// If the first finger's down and the second taps, it's a
				// right mouse click.
				event.type = Common::EVENT_RBUTTONDOWN;
				processMouseEvent(event, _curX, _curY);
				_queuedRUpTime = g_system->getMillis() + QUEUED_RUP_DELAY;
			} else if (ev.button.which == 2 &&
					_fingerDown[0] && _fingerDown[1]) {
				// If two fingers are down and a third taps, it's a middle
				// click -- but lift the second finger so it doesn't register
				// as a right click.
				event.type = Common::EVENT_MBUTTONUP;
				processMouseEvent(event, _curX, _curY);
				g_system->getEventManager()->pushEvent(event);
				event.type = Common::EVENT_MBUTTONDOWN;
				_fingerDown[1] = false;
			}
		}
		// Officially lift the finger that was raised.
		_fingerDown[ev.button.which] = false;
	}
	return true;
}
Ejemplo n.º 7
0
bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
	event.type = Common::EVENT_MOUSEMOVE;

	// update KbdMouse
	_km.x = ev.motion.x * MULTIPLIER;
	_km.y = ev.motion.y * MULTIPLIER;

	return processMouseEvent(event, ev.motion.x, ev.motion.y);
}
Ejemplo n.º 8
0
/**
 * Handles mouse button press.
 *
 * @param ev    The SDL event
 * @param event The ScummVM event.
 * @return True if event was processed, false if not.
 */
bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev,
		Common::Event &event) {
	_dragDiffX[ev.button.which] = 0;
	_dragDiffY[ev.button.which] = 0;
	_fingerDown[ev.button.which] = true;
	_screenDownTime[ev.button.which] = g_system->getMillis();

	if (ev.button.which == 0) {
		// Do a click when the finger lifts unless we leave the range
		_doClick = true;
		// Queue up dragging if auto-drag mode is on
		if (_autoDragMode)
			_queuedDragTime = g_system->getMillis() + QUEUED_DRAG_DELAY;
		// Turn drag mode on instantly for a double-tap
		else if (g_system->getMillis() - _dragStartTime < DOUBLETAP_LIMIT) {
			_dragging = true;
			event.type = Common::EVENT_LBUTTONDOWN;
			processMouseEvent(event, _curX, _curY);
		}
		// If we're not in touchpad mode, move the cursor to the tap
		if (!_touchpadMode) {
			_curX = MIN(_screenX, MAX(0, 0 + ev.motion.x));
			_curY = MIN(_screenY, MAX(0, 0 + ev.motion.y));
			// If we're already clicking, hold it until after the move.
			if (event.type == Common::EVENT_LBUTTONDOWN) {
				processMouseEvent(event, _curX, _curY);
				g_system->getEventManager()->pushEvent(event);
			}
			// Move the mouse
			event.type = Common::EVENT_MOUSEMOVE;
			processMouseEvent(event, _curX, _curY);
		}
		// Watch for a double-tap-triggered drag
		_dragStartTime = g_system->getMillis();
	} else if (ev.button.which == 1) {
		// Kill any queued drag event if a second finger goes down
		if (_queuedDragTime > 0)
			_queuedDragTime = 0;
		_doClick = false;
	}
	return true;
}
Ejemplo n.º 9
0
bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {

	event.kbd.flags = 0;

	switch (ev.jbutton.button) {
	case BTN_CROSS: // Left mouse button
		event.type = Common::EVENT_LBUTTONDOWN;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BTN_CIRCLE: // Right mouse button
		event.type = Common::EVENT_RBUTTONDOWN;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BTN_TRIANGLE: // Game menu
		event.type = Common::EVENT_KEYDOWN;
		event.kbd.keycode = Common::KEYCODE_F5;
		event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0);
		break;
	case BTN_SELECT: // Virtual keyboard
#ifdef ENABLE_VKEYBD
		event.type = Common::EVENT_VIRTUAL_KEYBOARD;
#endif
		break;
	case BTN_SQUARE: // Escape
		event.type = Common::EVENT_KEYDOWN;
		event.kbd.keycode = Common::KEYCODE_ESCAPE;
		event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0);
		break;
	case BTN_L1: // Predictive input dialog
		event.type = Common::EVENT_PREDICTIVE_DIALOG;
		break;
	case BTN_START: // ScummVM in game menu
		event.type = Common::EVENT_MAINMENU;
		break;
	}
	return true;
}
Ejemplo n.º 10
0
bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
	if (ev.button.button == SDL_BUTTON_LEFT)
		event.type = Common::EVENT_LBUTTONUP;
	else if (ev.button.button == SDL_BUTTON_RIGHT)
		event.type = Common::EVENT_RBUTTONUP;
#if defined(SDL_BUTTON_MIDDLE)
	else if (ev.button.button == SDL_BUTTON_MIDDLE)
		event.type = Common::EVENT_MBUTTONUP;
#endif
	else
		return false;
	processMouseEvent(event, ev.button.x, ev.button.y);

	return true;
}
Ejemplo n.º 11
0
bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
	int axis = ev.jaxis.value;
	if ( axis > JOY_DEADZONE) {
		axis -= JOY_DEADZONE;
		event.type = Common::EVENT_MOUSEMOVE;
	} else if ( axis < -JOY_DEADZONE ) {
		axis += JOY_DEADZONE;
		event.type = Common::EVENT_MOUSEMOVE;
	} else
		axis = 0;

	if ( ev.jaxis.axis == JOY_XAXIS) {
#ifdef JOY_ANALOG
		_km.x_vel = axis / 2000;
		_km.x_down_count = 0;
#else
		if (axis != 0) {
			_km.x_vel = (axis > 0) ? 1:-1;
			_km.x_down_count = 1;
		} else {
			_km.x_vel = 0;
			_km.x_down_count = 0;
		}
#endif

	} else if (ev.jaxis.axis == JOY_YAXIS) {
#ifndef JOY_INVERT_Y
		axis = -axis;
#endif
#ifdef JOY_ANALOG
		_km.y_vel = -axis / 2000;
		_km.y_down_count = 0;
#else
		if (axis != 0) {
			_km.y_vel = (-axis > 0) ? 1: -1;
			_km.y_down_count = 1;
		} else {
			_km.y_vel = 0;
			_km.y_down_count = 0;
		}
#endif
	}

	processMouseEvent(event, _km.x, _km.y);

	return true;
}
Ejemplo n.º 12
0
    //---------------------------------------------------------------------
	bool EventDispatcher::dispatchEvent(InputEvent* e) 
	{
		bool ret = false;
		if (e->isEventBetween(MouseEvent::ME_FIRST_EVENT, MouseEvent::ME_LAST_EVENT))	// i am open to suggestions for a better way to do this
																						// maybe a method e->isEvent(InputEvent::MouseEvent) ??
		{
			MouseEvent* me = static_cast<MouseEvent*> (e);
			ret = processMouseEvent(me);
		}
		else if (e->isEventBetween(KeyEvent::KE_FIRST_EVENT, KeyEvent::KE_LAST_EVENT))
		{
			KeyEvent* ke = static_cast<KeyEvent*> (e);
			ret = processKeyEvent(ke);

		}
		return ret;
	}
Ejemplo n.º 13
0
void RecordedCamera::manageEvent(core::objectmodel::Event* e)
{
    if(p_activated.getValue())
    {
        //Dispatch event
        if (sofa::core::objectmodel::MouseEvent::checkEventType(e))
        {
            sofa::core::objectmodel::MouseEvent* me = static_cast<sofa::core::objectmodel::MouseEvent*>(e);
            processMouseEvent(me);
        }
    }
    else
    {
        isMoving = false;
        currentMode = NONE_MODE;
    }
}
Ejemplo n.º 14
0
bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
	if (ev.button.button == SDL_BUTTON_LEFT)
		event.type = Common::EVENT_LBUTTONUP;
	else if (ev.button.button == SDL_BUTTON_RIGHT)
		event.type = Common::EVENT_RBUTTONUP;
#if defined(SDL_BUTTON_MIDDLE)
	else if (ev.button.button == SDL_BUTTON_MIDDLE)
		event.type = Common::EVENT_MBUTTONUP;
#endif
	else
		return false;

	// update KbdMouse
	_km.x = ev.button.x * MULTIPLIER;
	_km.y = ev.button.y * MULTIPLIER;

	return processMouseEvent(event, ev.button.x, ev.button.y);
}
Ejemplo n.º 15
0
bool HelpWindow::eventFilter(QObject *watched, QEvent *event)
{
	// We are filtering mouse event on help content widget's viewport
	if (watched == m_helpContentWidget->viewport()) {
		if (event->type() != QEvent::MouseButtonRelease) {
			return false;
		}
		return processMouseEvent(dynamic_cast<QMouseEvent *>(event));
	}

	// We are filtering mouse event on help content widget
	if (watched == m_helpContentWidget) {
		if (event->type() != QEvent::KeyPress) {
			return false;
		}
		return processKeyEvent(dynamic_cast<QKeyEvent *>(event));
	}

	return false;
}
	//-----------------------------------------------------------------------
	void CoherentUIView::injectMouseUp(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
	{
		processMouseEvent(arg, id, CoherentUIInputConvertor::MouseUp);
	}
	//-----------------------------------------------------------------------
	void CoherentUIView::injectMouseMove(const OIS::MouseEvent& arg)
	{
		processMouseEvent(arg, OIS::MB_Button7, CoherentUIInputConvertor::MoveOrWheel);
	}
Ejemplo n.º 18
0
bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
	if (false) {}

	//  Motorol A1200/E6/A1600 remapkey by Lubomyr
#ifdef MOTOEZX
	// Quit on MOD+Camera Key on A1200
	if (ev.key.keysym.sym == SDLK_e) {
		event.type = Common::EVENT_QUIT;
		return true;
	}
	// '1' Bypass security protection - MOD+Call key
	if (ev.key.keysym.sym == SDLK_f) {
		ev.key.keysym.sym = SDLK_1;
	}
	// F5 Game Menu - Call key
	else if (ev.key.keysym.sym == SDLK_SPACE) {
		ev.key.keysym.sym = SDLK_F5;
	}
	// VirtualKeyboard - Camera key
	else if (ev.key.keysym.sym == SDLK_PAUSE) {
		ev.key.keysym.sym = SDLK_F7;
	}
	// Enter - mod+fire key
	else if (ev.key.keysym.sym == SDLK_b) {
		ev.key.keysym.sym = SDLK_RETURN;
	}
	// '3' - mod+up key
	else if (ev.key.keysym.sym == SDLK_j) {
		ev.key.keysym.sym = SDLK_3;
	}
	// '6' - mod+up key
	else if (ev.key.keysym.sym == SDLK_i) {
		ev.key.keysym.sym = SDLK_6;
	}
	// 'y' - mod+right key
	else if (ev.key.keysym.sym == SDLK_g) {
		ev.key.keysym.sym = SDLK_y;
	}
	// 'n' - mod+right key
	else if (ev.key.keysym.sym == SDLK_h) {
		ev.key.keysym.sym = SDLK_n;
	}
	//  mod+vol'+' -> volume'+'
	else if (ev.key.keysym.sym == SDLK_c) {
		ev.key.keysym.sym = SDLK_RIGHTBRACKET;
	}
	//  mod+vol'-' -> volume'-'
	else if (ev.key.keysym.sym == SDLK_d) {
		ev.key.keysym.sym = SDLK_LEFTBRACKET;
	}
#endif

#ifdef MOTOMAGX
	// Quit on Clr
	if (ev.key.keysym.sym == SDLK_BACKSPACE) {
		event.type = Common::EVENT_QUIT;
		return true;
	}
	// Game Menu - Left Soft key
	else if (ev.key.keysym.sym == SDLK_F9) {
		ev.key.keysym.sym = SDLK_F5;
	}
	// VirtualKeyboard - Right Soft key
	else if (ev.key.keysym.sym == SDLK_F11) {
		ev.key.keysym.sym = SDLK_F7;
	}
#endif

// Joystick to Mouse
	else if (ev.key.keysym.sym == SDLK_LEFT) {
		if (ev.type == SDL_KEYDOWN) {
			_km.x_vel = -1;
			_km.x_down_count = 1;
		} else {
			_km.x_vel = 0;
			_km.x_down_count = 0;
		}

		event.type = Common::EVENT_MOUSEMOVE;
		processMouseEvent(event, _km.x, _km.y);
		return true;
	} else if (ev.key.keysym.sym == SDLK_RIGHT) {
		if (ev.type == SDL_KEYDOWN) {
			_km.x_vel = 1;
			_km.x_down_count = 1;
		} else {
			_km.x_vel = 0;
			_km.x_down_count = 0;
		}

		event.type = Common::EVENT_MOUSEMOVE;
		processMouseEvent(event, _km.x, _km.y);

		return true;
	} else if (ev.key.keysym.sym == SDLK_DOWN) {
		if (ev.type == SDL_KEYDOWN) {
			_km.y_vel = 1;
			_km.y_down_count = 1;
		} else {
			_km.y_vel = 0;
			_km.y_down_count = 0;
		}

		event.type = Common::EVENT_MOUSEMOVE;
		processMouseEvent(event, _km.x, _km.y);

		return true;
	} else if (ev.key.keysym.sym == SDLK_UP) {
		if (ev.type == SDL_KEYDOWN) {
			_km.y_vel = -1;
			_km.y_down_count = 1;
		} else {
			_km.y_vel = 0;
			_km.y_down_count = 0;
		}

		event.type = Common::EVENT_MOUSEMOVE;
		processMouseEvent(event, _km.x, _km.y);

		return true;
	} else if (ev.key.keysym.sym == SDLK_RETURN) {
		// Joystick center to pressing Left Mouse
		if (ev.key.type == SDL_KEYDOWN) {
			event.type = Common::EVENT_LBUTTONDOWN;
		} else {
			event.type = Common::EVENT_LBUTTONUP;
		}

		processMouseEvent(event, _km.x, _km.y);

		return true;
	} else if (ev.key.keysym.sym == SDLK_PLUS) {
		// Volume Up to pressing Right Mouse
		if (ev.key.type == SDL_KEYDOWN ) {
			event.type = Common::EVENT_RBUTTONDOWN;
		} else {
			event.type = Common::EVENT_RBUTTONUP;
		}
		processMouseEvent(event, _km.x, _km.y);

		return true;
	} else if (ev.key.keysym.sym == SDLK_MINUS) {
		// Volume Down to pressing Left Mouse
		if (ev.key.type == SDL_KEYDOWN) {
			event.type = Common::EVENT_LBUTTONDOWN;
		} else {
			event.type = Common::EVENT_LBUTTONUP;
		}

		processMouseEvent(event, _km.x, _km.y);

		return true;
	} else {
		// Let the events fall through if we didn't change them, this may not be the best way to
		// set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though.
		// and yes i have an huge terminal size so i dont wrap soon enough.
		event.type = Common::EVENT_KEYDOWN;
		event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
		event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
	}

	return false;
}
Ejemplo n.º 19
0
bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {

	Model model = Model(((OSystem_SDL_Maemo *)g_system)->getModel());
	debug(10, "Model: %s %u %s %s", model.hwId, model.modelType, model.hwAlias, model.hasHwKeyboard ? "true" : "false");

	// List of special N810 keys:
	// SDLK_F4 -> menu
	// SDLK_F5 -> home
	// SDLK_F6 -> fullscreen
	// SDLK_F7 -> zoom +
	// SDLK_F8 -> zoom -

#ifdef ENABLE_KEYMAPPER
	if (ev.type == SDL_KEYDOWN || ev.type == SDL_KEYUP) {
		const KeymapEntry *entry;
		for (entry = keymapEntries; entry->sym != SDLK_LAST; ++entry) {
			if (ev.key.keysym.sym == entry->sym) {
				SDLModToOSystemKeyFlags(SDL_GetModState(), event);
				event.type = ev.type == SDL_KEYDOWN ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
				event.kbd.keycode = entry->keycode;
				event.kbd.ascii = entry->ascii;
				return true;
			}
		}
	}
#else
	switch (ev.type) {
		case SDL_KEYDOWN:{
			if (ev.key.keysym.sym == SDLK_F4
			    || (model.modelType == kModelTypeN900
			        && ev.key.keysym.sym == SDLK_m
			        && (ev.key.keysym.mod & KMOD_CTRL)
			        && (ev.key.keysym.mod & KMOD_SHIFT))) {
				event.type = Common::EVENT_MAINMENU;
				debug(9, "remapping to main menu");
				return true;
			} else if (ev.key.keysym.sym == SDLK_F6) {
				if (!model.hasHwKeyboard) {
					event.type = Common::EVENT_KEYDOWN;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 down (virtual keyboard)");
					return true;
				} else {
					// handled in keyup
				}
			} else if (ev.key.keysym.sym == SDLK_F7) {
				event.type = Common::EVENT_RBUTTONDOWN;
				processMouseEvent(event, _km.x, _km.y);
				 debug(9, "remapping to right click down");
				return true;
			} else if (ev.key.keysym.sym == SDLK_F8) {
				if (ev.key.keysym.mod & KMOD_CTRL) {
					event.type = Common::EVENT_KEYDOWN;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 down (virtual keyboard)");
					return true;
				} else {
					// handled in keyup
					return true;
				}
			}
			break;
		}
		case SDL_KEYUP: {
			if (ev.key.keysym.sym == SDLK_F4
			    || (model.modelType == kModelTypeN900
			        && ev.key.keysym.sym == SDLK_m
			        && (ev.key.keysym.mod & KMOD_CTRL)
			        && (ev.key.keysym.mod & KMOD_SHIFT))) {
				event.type = Common::EVENT_MAINMENU;
				return true;
			} else if (ev.key.keysym.sym == SDLK_F6) {
				if (!model.hasHwKeyboard) {
					event.type = Common::EVENT_KEYUP;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 down (virtual keyboard)");
					return true;
				} else {
					bool currentState = ((OSystem_SDL *)g_system)->getGraphicsManager()->getFeatureState(OSystem::kFeatureFullscreenMode);
					g_system->beginGFXTransaction();
					((OSystem_SDL *)g_system)->getGraphicsManager()->setFeatureState(OSystem::kFeatureFullscreenMode, !currentState);
					g_system->endGFXTransaction();
					debug(9, "remapping to full screen toggle");
					return true;
				}
			} else if (ev.key.keysym.sym == SDLK_F7) {
				event.type = Common::EVENT_RBUTTONUP;
				processMouseEvent(event, _km.x, _km.y);
					debug(9, "remapping to right click up");
				return true;
			} else if (ev.key.keysym.sym == SDLK_F8) {
				if (ev.key.keysym.mod & KMOD_CTRL) {
					event.type = Common::EVENT_KEYUP;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 up (virtual keyboard)");
					return true;
				} else {
					toggleClickMode();
					debug(9, "remapping to click toggle");
					return true;
				}
			}
			break;
		}
	}
#endif
	// Invoke parent implementation of this method
	return SdlEventSource::remapKey(ev, event);
}
Ejemplo n.º 20
0
bool WINCESdlEventSource::pollEvent(Common::Event &event) {
	SDL_Event ev;
	ev.type = SDL_NOEVENT;
	DWORD currentTime;
	bool keyEvent = false;
	bool freeLookActive = _graphicsMan->getFreeLookState();
	int deltaX, deltaY;

	memset(&event, 0, sizeof(Common::Event));

	handleKbdMouse();

	// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
	int screenID = _graphicsMan->getScreenChangeID();
	if (screenID != _lastScreenID) {
		_lastScreenID = screenID;
		event.type = Common::EVENT_SCREEN_CHANGED;
		return true;
	}

	CEDevice::wakeUp();

	currentTime = GetTickCount();

	while (SDL_PollEvent(&ev)) {
		switch (ev.type) {
		case SDL_KEYDOWN:
			debug(1, "Key down %X %s", ev.key.keysym.sym, SDL_GetKeyName((SDLKey)ev.key.keysym.sym));
			// KMOD_RESERVED is used if the key has been injected by an external buffer
			if (ev.key.keysym.mod != KMOD_RESERVED && !GUI::Actions::Instance()->mappingActive()) {
				keyEvent = true;
				_graphicsMan->_lastKeyPressed = ev.key.keysym.sym;
				_graphicsMan->_keyRepeatTime = currentTime;
				_graphicsMan->_keyRepeat = 0;

				if (!GUI_Actions::Instance()->mappingActive() && GUI_Actions::Instance()->performMapped(ev.key.keysym.sym, true))
					return true;
			}

			if (GUI_Actions::Instance()->mappingActive())
				event.kbd.flags = 0xFF;
			else if (ev.key.keysym.sym == SDLK_PAUSE) {
				_graphicsMan->_lastKeyPressed = 0;
				event.type = Common::EVENT_PREDICTIVE_DIALOG;
				return true;
			}
			event.type = Common::EVENT_KEYDOWN;
			if (!GUI::Actions::Instance()->mappingActive())
				event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
			else
				event.kbd.keycode = (Common::KeyCode)mapKeyCE(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode, GUI::Actions::Instance()->mappingActive());
			event.kbd.ascii = mapKeyCE(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode, GUI::Actions::Instance()->mappingActive());

			if (ev.key.keysym.mod == KMOD_RESERVED && ev.key.keysym.unicode == KMOD_SHIFT) {
				event.kbd.ascii ^= 0x20;
				event.kbd.flags = Common::KBD_SHIFT;
			}

			return true;

		case SDL_KEYUP:
			debug(1, "Key up %X %s", ev.key.keysym.sym, SDL_GetKeyName((SDLKey)ev.key.keysym.sym));
			// KMOD_RESERVED is used if the key has been injected by an external buffer
			if (ev.key.keysym.mod != KMOD_RESERVED && !GUI::Actions::Instance()->mappingActive()) {
				keyEvent = true;
				_graphicsMan->_lastKeyPressed = 0;

				if (!GUI_Actions::Instance()->mappingActive() && GUI_Actions::Instance()->performMapped(ev.key.keysym.sym, false))
					return true;
			}

			if (GUI_Actions::Instance()->mappingActive())
				event.kbd.flags = 0xFF;
			else if (ev.key.keysym.sym == SDLK_PAUSE) {
				_graphicsMan->_lastKeyPressed = 0;
				return false;   // chew up the show agi dialog key up event
			}

			event.type = Common::EVENT_KEYUP;
			if (!GUI::Actions::Instance()->mappingActive())
				event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
			else
				event.kbd.keycode = (Common::KeyCode)mapKeyCE(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode, GUI::Actions::Instance()->mappingActive());
			event.kbd.ascii = mapKeyCE(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode, GUI::Actions::Instance()->mappingActive());

			if (ev.key.keysym.mod == KMOD_RESERVED && ev.key.keysym.unicode == KMOD_SHIFT) {
				event.kbd.ascii ^= 0x20;
				event.kbd.flags = Common::KBD_SHIFT;
			}

			return true;

		case SDL_MOUSEMOTION:
			event.type = Common::EVENT_MOUSEMOVE;
			processMouseEvent(event, ev.motion.x, ev.motion.y);
			_graphicsMan->setMousePos(event.mouse.x, event.mouse.y);

			return true;

		case SDL_MOUSEBUTTONDOWN:
			if (ev.button.button == SDL_BUTTON_LEFT)
				event.type = Common::EVENT_LBUTTONDOWN;
			else if (ev.button.button == SDL_BUTTON_RIGHT)
				event.type = Common::EVENT_RBUTTONDOWN;
			else
				break;
			processMouseEvent(event, ev.button.x, ev.button.y);


			if (event.mouse.x > _tapX)
				deltaX = event.mouse.x - _tapX;
			else
				deltaX = _tapX - event.mouse.x;
			if (event.mouse.y > _tapY)
				deltaY = event.mouse.y - _tapY;
			else
				deltaY = _tapY - event.mouse.y;
			_closeClick = (deltaX <= 5 && deltaY <= 5);

			if (!_isSmartphone) {
				// handle double-taps
				if (_tapTime) {     // second tap
					if (_closeClick && (GetTickCount() - _tapTime < 1000)) {
						if (event.mouse.y <= 20 &&
						        _graphicsMan->_panelInitialized &&
						        !_graphicsMan->_noDoubleTapPT) {
							// top of screen (show panel)
							_graphicsMan->swap_panel_visibility();
						} else if (!_graphicsMan->_noDoubleTapRMB) {
							// right click
							event.type = Common::EVENT_RBUTTONDOWN;
							_rbutton = true;
						}
					}
					_tapTime = 0;
				} else {
					_tapTime = GetTickCount();
					_tapX = event.mouse.x;
					_tapY = event.mouse.y;
				}
			}

			if (freeLookActive && !_closeClick) {
				_rbutton = false;
				_tapTime = 0;
				_tapX = event.mouse.x;
				_tapY = event.mouse.y;
				event.type = Common::EVENT_MOUSEMOVE;
				_graphicsMan->setMousePos(event.mouse.x, event.mouse.y);
			}


			if (_graphicsMan->_toolbarHandler.action(event.mouse.x, event.mouse.y, true)) {
				if (!_graphicsMan->_toolbarHandler.drawn()) {
					_graphicsMan->_toolbarHighDrawn = false;
					_graphicsMan->internUpdateScreen();
				}
				if (_graphicsMan->_newOrientation != _graphicsMan->_orientationLandscape) {
					_graphicsMan->_orientationLandscape = _graphicsMan->_newOrientation;
					_graphicsMan->_toolbarHighDrawn = false;
					ConfMan.setInt("landscape", _graphicsMan->_orientationLandscape);
					ConfMan.flushToDisk();
					_graphicsMan->hotswapGFXMode();
				}
				return false;
			}

			return true;

		case SDL_MOUSEBUTTONUP:
			if (ev.button.button == SDL_BUTTON_LEFT)
				event.type = Common::EVENT_LBUTTONUP;
			else if (ev.button.button == SDL_BUTTON_RIGHT)
				event.type = Common::EVENT_RBUTTONUP;
			else
				break;

			if (_rbutton) {
				event.type = Common::EVENT_RBUTTONUP;
				_rbutton = false;
			}

			processMouseEvent(event, ev.button.x, ev.button.y);

			if (freeLookActive && !_closeClick) {
				_tapX = event.mouse.x;
				_tapY = event.mouse.y;
				event.type = Common::EVENT_MOUSEMOVE;
				_graphicsMan->setMousePos(event.mouse.x, event.mouse.y);
			}

			if (_graphicsMan->_toolbarHandler.action(event.mouse.x, event.mouse.y, false)) {
				if (!_graphicsMan->_toolbarHandler.drawn()) {
					_graphicsMan->_toolbarHighDrawn = false;
					_graphicsMan->internUpdateScreen();
				}
				return false;

			}
			return true;

		case SDL_VIDEOEXPOSE:
			_graphicsMan->notifyVideoExpose();
			break;

		case SDL_QUIT:
			event.type = Common::EVENT_QUIT;
			return true;

		case SDL_ACTIVEEVENT:
			if (ev.active.state & SDL_APPMOUSEFOCUS)
				debug(2, "%s mouse focus.", ev.active.gain ? "Got" : "Lost");
			if (ev.active.state & SDL_APPINPUTFOCUS)
				debug(2, "%s input focus.", ev.active.gain ? "Got" : "Lost");
			if (ev.active.state & SDL_APPACTIVE)
				debug(2, "%s total focus.", ev.active.gain ? "Got" : "Lost");
			if (ev.active.state & SDL_APPINPUTFOCUS) {
				_graphicsMan->_hasfocus = ev.active.gain;
				SDL_PauseAudio(!_graphicsMan->_hasfocus);
				if (_graphicsMan->_hasfocus)
					_graphicsMan->notifyVideoExpose();
			}
			break;
		}
	}

	// Simulate repeated key for backend
	if (!keyEvent && _graphicsMan->_lastKeyPressed && (int)currentTime > _graphicsMan->_keyRepeatTime + _graphicsMan->_keyRepeatTrigger) {
		_graphicsMan->_keyRepeatTime = currentTime;
		_graphicsMan->_keyRepeat++;
		GUI_Actions::Instance()->performMapped(_graphicsMan->_lastKeyPressed, true);
	}

	return false;
}
Ejemplo n.º 21
0
bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {

	if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) {
		switch (ev.key.keysym.sym) {
		case SDLK_LEFT:
			event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
			processMouseEvent(event, _km.x, _km.y);
			return true;
			break;
		case SDLK_RIGHT:
			event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP;
			processMouseEvent(event, _km.x, _km.y);
			return true;
			break;
#if defined(SDL_BUTTON_MIDDLE)
		case SDLK_UP:
			event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_MBUTTONDOWN : Common::EVENT_MBUTTONUP;
			processMouseEvent(event, _km.x, _km.y);
			return true;
			break;
#endif
		default:
		  break;
		}
	}

	if (ev.type == SDL_KEYDOWN) {
		switch (ev.key.keysym.sym) {
		case SDLK_HOME:
			event.type = Common::EVENT_LBUTTONDOWN;
			processMouseEvent(event, _km.x, _km.y);
			return true;
			break;
		case SDLK_END:
			event.type = Common::EVENT_RBUTTONDOWN;
			processMouseEvent(event, _km.x, _km.y);
			return true;
			break;
		case SDLK_PAGEDOWN:
			event.type = Common::EVENT_MAINMENU;
			return true;
			break;
		case SDLK_PAGEUP:
			OP::ToggleTapMode();
			if (OP::tapmodeLevel == TAPMODE_LEFT) {
				g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click"));
			} else if (OP::tapmodeLevel == TAPMODE_RIGHT) {
				g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click"));
			} else if (OP::tapmodeLevel == TAPMODE_HOVER) {
				g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)"));
			} else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) {
				g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (DPad Clicks)"));
			}
			break;
		case SDLK_RSHIFT:
			BUTTON_STATE_L = true;
			break;
		case SDLK_RCTRL:
			break;
		default:
			return false;
			break;
		}
		return false;
	} else {
		switch (ev.key.keysym.sym) {
		case SDLK_HOME:
			event.type = Common::EVENT_LBUTTONUP;
			processMouseEvent(event, _km.x, _km.y);
			return true;
			break;
		case SDLK_END:
			event.type = Common::EVENT_RBUTTONUP;
			processMouseEvent(event, _km.x, _km.y);
			return true;
			break;
		case SDLK_PAGEDOWN:
			event.type = Common::EVENT_MAINMENU;
			return true;
			break;
		case SDLK_PAGEUP:
			break;
		case SDLK_RSHIFT:
			BUTTON_STATE_L = false;
			break;
		case SDLK_RCTRL:
			break;
		default:
			return false;
			break;
		}
		return false;
	}
	return false;
}
Ejemplo n.º 22
0
bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {

	Model model = Model(((OSystem_SDL_Maemo *)g_system)->getModel());
	debug(10, "Model: %s %u %s %s", model.hwId, model.modelType, model.hwAlias, model.hwKeyboard ? "true" : "false");

	// List of special N810 keys:
	// SDLK_F4 -> menu
	// SDLK_F5 -> home
	// SDLK_F6 -> fullscreen
	// SDLK_F7 -> zoom +
	// SDLK_F8 -> zoom -

	switch (ev.type) {
		case SDL_KEYDOWN:{
			if (ev.key.keysym.sym == SDLK_F4
			    || (model.modelType == kModelTypeN900
			        && ev.key.keysym.sym == SDLK_m
			        && (ev.key.keysym.mod & KMOD_CTRL)
			        && (ev.key.keysym.mod & KMOD_SHIFT))) {
				event.type = Common::EVENT_MAINMENU;
				debug(9, "remapping to main menu");
				return true;
			} else if (ev.key.keysym.sym == SDLK_F6) {
				if (!model.hwKeyboard) {
					event.type = Common::EVENT_KEYDOWN;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 down (virtual keyboard)");
					return true;
				} else {
					// handled in keyup
				}
			} else if (ev.key.keysym.sym == SDLK_F7) {
				event.type = Common::EVENT_RBUTTONDOWN;
				processMouseEvent(event, _km.x, _km.y);
				 debug(9, "remapping to right click down");
				return true;
			} else if (ev.key.keysym.sym == SDLK_F8) {
				if (ev.key.keysym.mod & KMOD_CTRL) {
					event.type = Common::EVENT_KEYDOWN;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 down (virtual keyboard)");
					return true;
				} else {
					// handled in keyup
					return true;
				}
			}
			break;
		}
		case SDL_KEYUP: {
			if (ev.key.keysym.sym == SDLK_F4
			    || (model.modelType == kModelTypeN900
			        && ev.key.keysym.sym == SDLK_m
			        && (ev.key.keysym.mod & KMOD_CTRL)
			        && (ev.key.keysym.mod & KMOD_SHIFT))) {
				event.type = Common::EVENT_MAINMENU;
				return true;
			} else if (ev.key.keysym.sym == SDLK_F6) {
				if (!model.hwKeyboard) {
					event.type = Common::EVENT_KEYUP;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 down (virtual keyboard)");
					return true;
				} else {
					bool currentState = ((OSystem_SDL *)g_system)->getGraphicsManager()->getFeatureState(OSystem::kFeatureFullscreenMode);
					g_system->beginGFXTransaction();
					((OSystem_SDL *)g_system)->getGraphicsManager()->setFeatureState(OSystem::kFeatureFullscreenMode, !currentState);
					g_system->endGFXTransaction();
					debug(9, "remapping to full screen toggle");
					return true;
				}
			} else if (ev.key.keysym.sym == SDLK_F7) {
				event.type = Common::EVENT_RBUTTONUP;
				processMouseEvent(event, _km.x, _km.y);
					debug(9, "remapping to right click up");
				return true;
			} else if (ev.key.keysym.sym == SDLK_F8) {
				if (ev.key.keysym.mod & KMOD_CTRL) {
					event.type = Common::EVENT_KEYUP;
					event.kbd.keycode = Common::KEYCODE_F7;
					event.kbd.ascii = Common::ASCII_F7;
					event.kbd.flags = 0;
					debug(9, "remapping to F7 up (virtual keyboard)");
					return true;
				} else {
					_clickEnabled = !_clickEnabled;
					((SurfaceSdlGraphicsManager*) _graphicsManager)->displayMessageOnOSD(
					  _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled"));
					debug(9, "remapping to click toggle");
					return true;
				}
			}
			break;
		}
	}
	// Invoke parent implementation of this method
	return SdlEventSource::remapKey(ev, event);
}
Ejemplo n.º 23
0
bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
	event.type = Common::EVENT_MOUSEMOVE;
	processMouseEvent(event, ev.motion.x, ev.motion.y, ev.motion.xrel, ev.motion.yrel); // ResidualVM xrel,yrel

	return true;
}
Ejemplo n.º 24
0
bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
	event.type = Common::EVENT_MOUSEMOVE;
	processMouseEvent(event, ev.motion.x, ev.motion.y);

	return true;
}
Ejemplo n.º 25
0
bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {

	_stickBtn[ev.jbutton.button] = 1;
	event.kbd.flags = 0;

	switch (ev.jbutton.button) {
	case BUTTON_UP:
	case BUTTON_UPLEFT:
	case BUTTON_LEFT:
	case BUTTON_DOWNLEFT:
	case BUTTON_DOWN:
	case BUTTON_DOWNRIGHT:
	case BUTTON_RIGHT:
	case BUTTON_UPRIGHT:
		moveStick();
		event.type = Common::EVENT_MOUSEMOVE;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BUTTON_B:
	case BUTTON_CLICK:
		event.type = Common::EVENT_LBUTTONDOWN;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BUTTON_X:
		event.type = Common::EVENT_RBUTTONDOWN;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BUTTON_L:
		BUTTON_STATE_L = true;
		break;
	case BUTTON_R:
		event.type = Common::EVENT_KEYDOWN;
		if (BUTTON_STATE_L == true) {
#ifdef ENABLE_VKEYBD
			event.kbd.keycode = Common::KEYCODE_F7;
			event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0);
#else
			event.kbd.keycode = Common::KEYCODE_0;
			event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
#endif
		} else {
			event.kbd.keycode = Common::KEYCODE_RETURN;
			event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
		}
		break;
	case BUTTON_SELECT:
	case BUTTON_HOME:
		event.type = Common::EVENT_KEYDOWN;
		if (BUTTON_STATE_L == true) {
			event.type = Common::EVENT_QUIT;
		} else {
			event.kbd.keycode = Common::KEYCODE_ESCAPE;
			event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
		}
		break;
	case BUTTON_A:
		event.type = Common::EVENT_KEYDOWN;
		if (BUTTON_STATE_L == true) {
			event.type = Common::EVENT_PREDICTIVE_DIALOG;
		} else {
		event.kbd.keycode = Common::KEYCODE_PERIOD;
		event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
		}
		break;
	case BUTTON_Y:
		event.type = Common::EVENT_KEYDOWN;
		if (BUTTON_STATE_L == true) {
			GPH::ToggleTapMode();
			if (GPH::tapmodeLevel == TAPMODE_LEFT) {
				g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click"));
			} else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
				g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click"));
			} else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
				g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)"));
			}
		} else {
			event.kbd.keycode = Common::KEYCODE_SPACE;
			event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
		}
		break;
	case BUTTON_MENU:
	case BUTTON_HELP:
		event.type = Common::EVENT_KEYDOWN;
		if (BUTTON_STATE_L == true) {
			event.type = Common::EVENT_MAINMENU;
		} else {
			event.kbd.keycode = Common::KEYCODE_F5;
			event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
		}
		break;
	case BUTTON_VOLUP:
		WIZ_HW::mixerMoveVolume(2);
		if (WIZ_HW::volumeLevel == 100) {
			g_system->displayMessageOnOSD(_("Maximum Volume"));
		} else {
			g_system->displayMessageOnOSD(_("Increasing Volume"));
		}
		break;
	case BUTTON_VOLDOWN:
		WIZ_HW::mixerMoveVolume(1);
		if (WIZ_HW::volumeLevel == 0) {
			g_system->displayMessageOnOSD(_("Minimal Volume"));
		} else {
			g_system->displayMessageOnOSD(_("Decreasing Volume"));
		}
		break;
	case BUTTON_HOLD:
		event.type = Common::EVENT_QUIT;
		break;
	case BUTTON_HELP2:
		GPH::ToggleTapMode();
		if (GPH::tapmodeLevel == TAPMODE_LEFT) {
			g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click"));
		} else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
			g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click"));
		} else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
			g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)"));
		}
		break;
	}
	return true;
}
Ejemplo n.º 26
0
bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {

	_stickBtn[ev.jbutton.button] = 0;
	event.kbd.flags = 0;

	switch (ev.jbutton.button) {
	case BUTTON_UP:
	case BUTTON_UPLEFT:
	case BUTTON_LEFT:
	case BUTTON_DOWNLEFT:
	case BUTTON_DOWN:
	case BUTTON_DOWNRIGHT:
	case BUTTON_RIGHT:
	case BUTTON_UPRIGHT:
		moveStick();
		event.type = Common::EVENT_MOUSEMOVE;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BUTTON_B:
	case BUTTON_CLICK:
		event.type = Common::EVENT_LBUTTONUP;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BUTTON_X:
		event.type = Common::EVENT_RBUTTONUP;
		processMouseEvent(event, _km.x, _km.y);
		break;
	case BUTTON_L:
		BUTTON_STATE_L = false;
		break;
	case BUTTON_SELECT:
	case BUTTON_HOME:
		event.type = Common::EVENT_KEYUP;
		event.kbd.keycode = Common::KEYCODE_ESCAPE;
		event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
		break;
	case BUTTON_A:
		event.type = Common::EVENT_KEYUP;
		event.kbd.keycode = Common::KEYCODE_PERIOD;
		event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
		break;
	case BUTTON_Y:
		event.type = Common::EVENT_KEYUP;
		event.kbd.keycode = Common::KEYCODE_SPACE;
		event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
		break;
	case BUTTON_MENU:
	case BUTTON_HELP:
		event.type = Common::EVENT_KEYUP;
		if (BUTTON_STATE_L == true) {
			event.type = Common::EVENT_MAINMENU;
		} else {
			event.kbd.keycode = Common::KEYCODE_F5;
			event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
		}
		break;
	case BUTTON_R:
		event.type = Common::EVENT_KEYUP;
		if (BUTTON_STATE_L == true) {
#ifdef ENABLE_VKEYBD
			event.kbd.keycode = Common::KEYCODE_F7;
			event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0);
#else
			event.kbd.keycode = Common::KEYCODE_0;
			event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
#endif
		} else {
			event.kbd.keycode = Common::KEYCODE_RETURN;
			event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
		}
		break;
	case BUTTON_VOLUP:
		break;
	case BUTTON_VOLDOWN:
		break;
	case BUTTON_HOLD:
		break;
	case BUTTON_HELP2:
		break;
	}
	return true;
}
Ejemplo n.º 27
0
bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
	switch (ev.type) {
	case SDL_KEYDOWN:
		return handleKeyDown(ev, event);
	case SDL_KEYUP:
		return handleKeyUp(ev, event);
	case SDL_MOUSEMOTION:
		return handleMouseMotion(ev, event);
	case SDL_MOUSEBUTTONDOWN:
		return handleMouseButtonDown(ev, event);
	case SDL_MOUSEBUTTONUP:
		return handleMouseButtonUp(ev, event);
	case SDL_JOYBUTTONDOWN:
		return handleJoyButtonDown(ev, event);
	case SDL_JOYBUTTONUP:
		return handleJoyButtonUp(ev, event);
	case SDL_JOYAXISMOTION:
		return handleJoyAxisMotion(ev, event);

#if SDL_VERSION_ATLEAST(2, 0, 0)
	case SDL_MOUSEWHEEL: {
		Sint32 yDir = ev.wheel.y;
#if SDL_VERSION_ATLEAST(2, 0, 4)
		if (ev.wheel.direction == SDL_MOUSEWHEEL_FLIPPED) {
			yDir *= -1;
		}
#endif
		// HACK: It seems we want the mouse coordinates supplied
		// with a mouse wheel event. However, SDL2 does not supply
		// these, thus we use whatever we got last time. It seems
		// these are always stored in _km.x, _km.y.
		processMouseEvent(event, _km.x, _km.y);
		if (yDir < 0) {
			event.type = Common::EVENT_WHEELDOWN;
			return true;
		} else if (yDir > 0) {
			event.type = Common::EVENT_WHEELUP;
			return true;
		} else {
			return false;
		}
		}

	case SDL_TEXTINPUT: {
		// When we get a TEXTINPUT event it means we got some user input for
		// which no KEYDOWN exists. SDL 1.2 introduces a "fake" key down+up
		// in such cases. We will do the same to mimic it's behavior.
		event.type = Common::EVENT_KEYDOWN;

		event.kbd = Common::KeyState(Common::KEYCODE_INVALID, convUTF8ToUTF32(ev.text.text), 0);

		SDLModToOSystemKeyFlags(SDL_GetModState(), event);
		// Set the scroll lock sticky flag
		if (_scrollLock)
			event.kbd.flags |= Common::KBD_SCRL;

		// Fake a key up when we have a proper ascii value.
		_queuedFakeKeyUp = (event.kbd.ascii != 0);
		_fakeKeyUp = event;
		_fakeKeyUp.type = Common::EVENT_KEYUP;

		return _queuedFakeKeyUp;
		}

	case SDL_WINDOWEVENT:
		switch (ev.window.event) {
		case SDL_WINDOWEVENT_EXPOSED:
			if (_graphicsManager)
				_graphicsManager->notifyVideoExpose();
			return false;

		case SDL_WINDOWEVENT_RESIZED:
			return handleResizeEvent(event, ev.window.data1, ev.window.data2);

		default:
			return false;
		}
#else
	case SDL_VIDEOEXPOSE:
		if (_graphicsManager)
			_graphicsManager->notifyVideoExpose();
		return false;

	case SDL_VIDEORESIZE:
		return handleResizeEvent(event, ev.resize.w, ev.resize.h);
#endif

	case SDL_QUIT:
		event.type = Common::EVENT_QUIT;
		return true;

	}

	return false;
}
Ejemplo n.º 28
0
bool PSP2EventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {

	event.kbd.flags = 0;

	switch (ev.jbutton.button) {
// Dpad
	case BTN_LEFT: // Left (+R_trigger: Up+Left)
		if (!_km.modifier) {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP4;
			event.kbd.ascii = mapKey(SDLK_KP4, (SDLMod) ev.key.keysym.mod, 0);
		} else {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP7;
			event.kbd.ascii = mapKey(SDLK_KP7, (SDLMod) ev.key.keysym.mod, 0);
		}
		break;
	case BTN_RIGHT: // Right (+R_trigger: Down+Right)
		if (!_km.modifier) {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP6;
			event.kbd.ascii = mapKey(SDLK_KP6, (SDLMod) ev.key.keysym.mod, 0);
		} else {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP3;
			event.kbd.ascii = mapKey(SDLK_KP3, (SDLMod) ev.key.keysym.mod, 0);
		}
		break;
	case BTN_UP: // Up (+R_trigger: Up+Right)
		if (!_km.modifier) {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP8;
			event.kbd.ascii = mapKey(SDLK_KP8, (SDLMod) ev.key.keysym.mod, 0);
		} else {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP9;
			event.kbd.ascii = mapKey(SDLK_KP9, (SDLMod) ev.key.keysym.mod, 0);
		}
		break;
	case BTN_DOWN: // Down (+R_trigger: Down+Left)
		if (!_km.modifier) {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP2;
			event.kbd.ascii = mapKey(SDLK_KP2, (SDLMod) ev.key.keysym.mod, 0);
		} else {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_KP1;
			event.kbd.ascii = mapKey(SDLK_KP1, (SDLMod) ev.key.keysym.mod, 0);
		}
		break;
// Buttons
	case BTN_CROSS: // Left mouse button
		event.type = Common::EVENT_LBUTTONDOWN;
		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
		break;
	case BTN_CIRCLE: // Right mouse button
		event.type = Common::EVENT_RBUTTONDOWN;
		processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
		break;
	case BTN_TRIANGLE: // Escape (+R_trigger: Return)
		if (!_km.modifier) {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_ESCAPE;
			event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0);
		} else {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_RETURN;
			event.kbd.ascii = mapKey(SDLK_RETURN, (SDLMod) ev.key.keysym.mod, 0);
		}
		break;
	case BTN_SQUARE: // Period (+R_trigger: Space)
		if (!_km.modifier) {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_PERIOD;
			event.kbd.ascii = mapKey(SDLK_PERIOD, (SDLMod) ev.key.keysym.mod, 0);
		} else {
			event.type = Common::EVENT_KEYDOWN;
			event.kbd.keycode = Common::KEYCODE_SPACE;
			event.kbd.ascii = mapKey(SDLK_SPACE, (SDLMod) ev.key.keysym.mod, 0);
		}
		break;
	case BTN_L1: // Game menu
		event.type = Common::EVENT_KEYDOWN;
		event.kbd.keycode = Common::KEYCODE_F5;
		event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0);
		break;
	case BTN_R1: // Modifier + Shift
		_km.modifier=true; // slow mouse
		event.type = Common::EVENT_KEYDOWN;
		event.kbd.keycode = Common::KEYCODE_INVALID;
		event.kbd.ascii = 0;
		event.kbd.flags = Common::KBD_SHIFT;
		break;
	case BTN_START: // ScummVM in game menu
		event.type = Common::EVENT_MAINMENU;
		break;
	case BTN_SELECT: // Virtual keyboard (+R_trigger: Predictive Input Dialog)
		if (!_km.modifier) {
#ifdef ENABLE_VKEYBD
			event.type = Common::EVENT_VIRTUAL_KEYBOARD;
#endif
		} else {
			event.type = Common::EVENT_PREDICTIVE_DIALOG;
		}
		break;
	}
	return true;
}
Ejemplo n.º 29
0
bool SdlEventSource::handleKbdMouse(Common::Event &event) {
	// returns true if an event is generated
	// Skip recording of these events
	uint32 curTime = g_system->getMillis(true);

	if (curTime >= _km.last_time + _km.delay_time) {

		int16 oldKmX = _km.x;
		int16 oldKmY = _km.y;

		_km.last_time = curTime;
		if (_km.x_down_count == 1) {
			_km.x_down_time = curTime;
			_km.x_down_count = 2;
		}
		if (_km.y_down_count == 1) {
			_km.y_down_time = curTime;
			_km.y_down_count = 2;
		}

		if (_km.x_vel || _km.y_vel) {
			if (_km.x_down_count) {
				if (curTime > _km.x_down_time + 300) {
					if (_km.x_vel > 0)
						_km.x_vel += MULTIPLIER;
					else
						_km.x_vel -= MULTIPLIER;
				} else if (curTime > _km.x_down_time + 200) {
					if (_km.x_vel > 0)
						_km.x_vel = 5 * MULTIPLIER;
					else
						_km.x_vel = -5 * MULTIPLIER;
				}
			}
			if (_km.y_down_count) {
				if (curTime > _km.y_down_time + 300) {
					if (_km.y_vel > 0)
						_km.y_vel += MULTIPLIER;
					else
						_km.y_vel -= MULTIPLIER;
				} else if (curTime > _km.y_down_time + 200) {
					if (_km.y_vel > 0)
						_km.y_vel = 5 * MULTIPLIER;
					else
						_km.y_vel = -5 * MULTIPLIER;
				}
			}

			int16 speedFactor = 25;

			if (g_system->hasFeature(OSystem::kFeatureKbdMouseSpeed)) {
				switch (ConfMan.getInt("kbdmouse_speed")) {
				// 0.25 keyboard pointer speed
				case 0:
					speedFactor = 100;
					break;
				// 0.5 speed
				case 1:
					speedFactor = 50;
					break;
				// 0.75 speed
				case 2:
					speedFactor = 33;
					break;
				// 1.0 speed
				case 3:
					speedFactor = 25;
					break;
				// 1.25 speed
				case 4:
					speedFactor = 20;
					break;
				// 1.5 speed
				case 5:
					speedFactor = 17;
					break;
				// 1.75 speed
				case 6:
					speedFactor = 14;
					break;
				// 2.0 speed
				case 7:
					speedFactor = 12;
					break;
				default:
					speedFactor = 25;
				}
			}

			// - The modifier key makes the mouse movement slower
			// - The extra factor "delay/speedFactor" ensures velocities 
			// are independent of the kbdMouse update rate
			// - all velocities were originally chosen
			// at a delay of 25, so that is the reference used here
			// - note: operator order is important to avoid overflow
			if (_km.modifier) {
				_km.x += ((_km.x_vel / 10) * ((int16)_km.delay_time)) / speedFactor;
				_km.y += ((_km.y_vel / 10) * ((int16)_km.delay_time)) / speedFactor;
			} else {
				_km.x += (_km.x_vel * ((int16)_km.delay_time)) / speedFactor;
				_km.y += (_km.y_vel * ((int16)_km.delay_time)) / speedFactor;
			}

			if (_km.x < 0) {
				_km.x = 0;
				_km.x_vel = -1 * MULTIPLIER;
				_km.x_down_count = 1;
			} else if (_km.x > _km.x_max * MULTIPLIER) {
				_km.x = _km.x_max * MULTIPLIER;
				_km.x_vel = 1 * MULTIPLIER;
				_km.x_down_count = 1;
			}

			if (_km.y < 0) {
				_km.y = 0;
				_km.y_vel = -1 * MULTIPLIER;
				_km.y_down_count = 1;
			} else if (_km.y > _km.y_max * MULTIPLIER) {
				_km.y = _km.y_max * MULTIPLIER;
				_km.y_vel = 1 * MULTIPLIER;
				_km.y_down_count = 1;
			}

			if (_graphicsManager) {
				_graphicsManager->getWindow()->warpMouseInWindow((Uint16)(_km.x / MULTIPLIER), (Uint16)(_km.y / MULTIPLIER));
			}

			if (_km.x != oldKmX || _km.y != oldKmY) {
				event.type = Common::EVENT_MOUSEMOVE;
				return processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
			}
		}
	}
	return false;
}
Ejemplo n.º 30
0
bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
	switch (ev.type) {
	case SDL_KEYDOWN:
		return handleKeyDown(ev, event);
	case SDL_KEYUP:
		return handleKeyUp(ev, event);
	case SDL_MOUSEMOTION:
		return handleMouseMotion(ev, event);
	case SDL_MOUSEBUTTONDOWN:
		return handleMouseButtonDown(ev, event);
	case SDL_MOUSEBUTTONUP:
		return handleMouseButtonUp(ev, event);
	case SDL_JOYBUTTONDOWN:
		return handleJoyButtonDown(ev, event);
	case SDL_JOYBUTTONUP:
		return handleJoyButtonUp(ev, event);
	case SDL_JOYAXISMOTION:
		return handleJoyAxisMotion(ev, event);

#if SDL_VERSION_ATLEAST(2, 0, 0)
	case SDL_MOUSEWHEEL: {
		Sint32 yDir = ev.wheel.y;
		// HACK: It seems we want the mouse coordinates supplied
		// with a mouse wheel event. However, SDL2 does not supply
		// these, thus we use whatever we got last time. It seems
		// these are always stored in _km.x, _km.y.
		if (!processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER)) {
			return false;
		}
		if (yDir < 0) {
			event.type = Common::EVENT_WHEELDOWN;
			return true;
		} else if (yDir > 0) {
			event.type = Common::EVENT_WHEELUP;
			return true;
		} else {
			return false;
		}
		}

	case SDL_TEXTINPUT: {
		// When we get a TEXTINPUT event it means we got some user input for
		// which no KEYDOWN exists. SDL 1.2 introduces a "fake" key down+up
		// in such cases. We will do the same to mimic it's behavior.
		event.type = Common::EVENT_KEYDOWN;

		event.kbd = Common::KeyState(Common::KEYCODE_INVALID, convUTF8ToUTF32(ev.text.text), 0);

		SDLModToOSystemKeyFlags(SDL_GetModState(), event);
		// Set the scroll lock sticky flag
		if (_scrollLock)
			event.kbd.flags |= Common::KBD_SCRL;

		// Fake a key up when we have a proper ascii value.
		_queuedFakeKeyUp = (event.kbd.ascii != 0);
		_fakeKeyUp = event;
		_fakeKeyUp.type = Common::EVENT_KEYUP;

		return _queuedFakeKeyUp;
		}

	case SDL_WINDOWEVENT:
		switch (ev.window.event) {
		case SDL_WINDOWEVENT_EXPOSED:
			if (_graphicsManager)
				_graphicsManager->notifyVideoExpose();
			return false;

		// SDL2 documentation indicate that SDL_WINDOWEVENT_SIZE_CHANGED is sent either as a result
		// of the size being changed by an external event (for example the user resizing the window
		// or going fullscreen) or a call to the SDL API (for example SDL_SetWindowSize). On the
		// other hand SDL_WINDOWEVENT_RESIZED is only sent for resize resulting from an external event,
		// and is always preceded by a SDL_WINDOWEVENT_SIZE_CHANGED event.
		// We need to handle the programmatic resize as well so that the graphics manager always know
		// the current size. See comments in SdlWindow::createOrUpdateWindow for details of one case
		// where we need to call SDL_SetWindowSize and we need the resulting event to be processed.
		// However if the documentation is correct we can ignore SDL_WINDOWEVENT_RESIZED since when we
		// get one we should always get a SDL_WINDOWEVENT_SIZE_CHANGED as well.
		case SDL_WINDOWEVENT_SIZE_CHANGED:
		//case SDL_WINDOWEVENT_RESIZED:
			return handleResizeEvent(event, ev.window.data1, ev.window.data2);

		default:
			return false;
		}
#else
	case SDL_VIDEOEXPOSE:
		if (_graphicsManager)
			_graphicsManager->notifyVideoExpose();
		return false;

	case SDL_VIDEORESIZE:
		return handleResizeEvent(event, ev.resize.w, ev.resize.h);
#endif

	case SDL_QUIT:
		event.type = Common::EVENT_QUIT;
		return true;

	}

	return false;
}