Beispiel #1
0
void UI::onJoystickMotion (bool horizontal, int v)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onJoystickMotion(horizontal, v))
			return;
		if (window->isModal() || window->isFullscreen())
			break;
	}

	if (Config.getBindingsSpace() != BINDINGS_UI)
		return;

	if (_time - _lastJoystickMoveTime < 350 || horizontal) {
		_lastJoystickMovementValue = v;
		return;
	}

	// skip focus change if we go back to initial position
	if (v > 0 && v < _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	} else if (v < 0 && v > _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	}

	// now check whether our value is bigger than our movement delta
	const int delta = 2000;
	if (v < -delta) {
		focusPrev();
	} else if (v > delta) {
		focusNext();
	}

	_lastJoystickMoveTime = _time;
	_lastJoystickMovementValue = v;
}