Ejemplo n.º 1
0
	void InputManager::PostMouseEvent(int32_t xPosition, int32_t yPosition)
	{
		PostMouseEvent(Trigger(CURSOR_MOVED));
	}
Ejemplo n.º 2
0
void GLView::OnMouseMove (int shift, int button, int x, int y) {
    PostMouseEvent (_tx("gls_mouseMove"), button, x, y);
}
Ejemplo n.º 3
0
	void InputManager::PostMouseEvent(const RAWMOUSE &rawMouse)
    {
		EDEventManager::EventManager *eventManager = EDEventManager::EventManager::GetInstance();

		// Check for mouse for movement.
		if (rawMouse.lLastX != 0 || rawMouse.lLastY != 0)
		{
			PostMouseEvent(Trigger(POSITION_CHANGED));

			// Update the mouse mickeys.
			if (!(rawMouse.usFlags & MOUSE_MOVE_ABSOLUTE))
			{
				mouseState.xMickeys += rawMouse.lLastX;
				mouseState.yMickeys += rawMouse.lLastY;
			}
		}

		// Check for wheel movement.
		if (rawMouse.usButtonFlags & RI_MOUSE_WHEEL)
		{
			PostMouseEvent(Trigger(WHEEL_MOVED), (void *) rawMouse.usButtonData);
			mouseState.wheelDelta += (int16_t) rawMouse.usButtonData;
		}

		if (rawMouse.usButtonFlags & RI_MOUSE_HORIZONTAL_WHEEL)
		{
			PostMouseEvent(Trigger(H_WHEEL_MOVED), (void *) rawMouse.usButtonData);
			mouseState.hWheelDelta += (int16_t) rawMouse.usButtonData;
		}

		uint16_t vKeys[5] = { VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_XBUTTON1, VK_XBUTTON2 };

		// For each button, check the up and down flags and build events appropriately.
		for (int buttonNo = 0; buttonNo < 5; buttonNo++)
		{
			int buttonData = (rawMouse.usButtonFlags >> (buttonNo * 2)) & 0x03;

			// If this is a button up event...
			if (buttonData & 0x02)
			{
				// Data we need: button number, event type.
				Trigger trigger(vKeys[buttonNo], INPUT_RELEASED);

				for (list<EventMessage>::iterator message = mouseTriggers[trigger].begin(); message != mouseTriggers[trigger].end(); message++)
				{
					// If this event was being triggered persistently, remove it.
					if (firingEvents.find(std::string(message->eventName)) != firingEvents.end())
					{
						firingEvents.erase(std::string(message->eventName));
						eventManager->DeletePersistentEvent(message->eventName);
					}
					// Otherwise, if the mode matches, post the event.
					else if (message->IsValidMode(inputMode))
					{
						eventManager->PostEvent(message->eventName, nullptr, EDEventManager::EM_PRIORITY_ABOVE_NORMAL, EDEventManager::EM_FLAG_IMMEDIATE);
					}
				}

				// Mark this button as being up.
				mouseState.isPressed[buttonNo] = false;
			}

			// If it's a key down message...
			else if (buttonData & 0x01)
			{
				// For each possible key message (excludes KEY_RELEASED), see if there are events that should be triggered.
				for (int state = INPUT_PRESSED; state <= INPUT_HELD; state++)
				{
					// Data we need: button, event type.
					Trigger trigger(vKeys[buttonNo], (ButtonState) state);

					// If the button is already down, ignore KEY_PRESSED and KEY_HELD triggers.
					if ((state == INPUT_PRESSED || state == INPUT_HELD) && mouseState.isPressed[buttonNo])
						continue;

					for (list<EventMessage>::iterator message = mouseTriggers[trigger].begin(); message != mouseTriggers[trigger].end(); message++)
					{
						// Is this the right input mode for this event? If not, skip this message.
						if (!message->IsValidMode(inputMode))
							continue;

						// For pressed and repeated events, send out a one-time event.
						// For held keys, initiate persistent event and add it to the list of firing events.
						switch (trigger.buttonState)
						{
						case INPUT_PRESSED:
						case INPUT_REPEATED:
							eventManager->PostEvent(message->eventName, nullptr, EDEventManager::EM_PRIORITY_ABOVE_NORMAL, EDEventManager::EM_FLAG_IMMEDIATE);
							break;
						case INPUT_HELD:
							eventManager->PostEvent(message->eventName, nullptr, EDEventManager::EM_PRIORITY_ABOVE_NORMAL, EDEventManager::EM_FLAG_PERSISTENT);
							firingEvents.insert(std::string(message->eventName));
							break;
						}
					}
				}

				// Mark this button as being down.
				mouseState.isPressed[buttonNo] = true;
			}
		}
	}