void InputProcessor::Enable(bool enable)
		{
			if (IsEnabled() == enable)
				return;

			Keyboard *keyboard = m_gameApp->GetKeyboard();
			Mouse *mouse = m_gameApp->GetMouse();
			Touchscreen *touchscreen = m_gameApp->GetTouchscreen();

			if (enable)
			{
				if (keyboard != NULL)
					keyboard->RegisterListener(this);
				if (mouse != NULL)
					mouse->RegisterListener(this);
				if (touchscreen != NULL)
					touchscreen->RegisterListener(this);
			}
			else
			{
				if (keyboard != NULL)
					keyboard->UnregisterListener(this);
				if (mouse != NULL)
					mouse->UnregisterListener(this);
				if (touchscreen != NULL)
					touchscreen->UnregisterListener(this);
			}

			m_enabled = enable;
		}
Example #2
0
bool HelpPopup::handleTouchscreen(Touchscreen &ts) {
	if (ts.pressed()) {
		dismiss();
		ts.setHandled();
	}
	return true;
}
Example #3
0
bool ContextMenu::handleTouchscreen(Touchscreen &ts) {
	if (ts.inRect(box)) {
		int i = std::max(0, std::min(static_cast<int>(options.size()) - 1,
				(ts.getY() - (box.y + 4)) / (gmenu2x.font->getLineSpacing() + 2)));
		if (ts.released()) {
			options[i]->action();
			dismiss();
		} else if (ts.pressed()) {
			selected = i;
		}
	} else {
		if (ts.released()) {
			dismiss();
		}
	}
	return true;
}