예제 #1
0
Vector2 Controller::MakeLookDisc(const Mathematics::Vector2 p_ScreenCentre) const
{
	Vector2 ret = m_States.MouseAndKeyboard().Position - p_ScreenCentre;
	ret = (ret.LengthSquared() > deadDist * deadDist) ? ret : Zero2();
	//ret += m_States.Gamepad().RightStick;

	return ret.IsAtOrigin() ? Zero2() : ret.Direction();
}
예제 #2
0
Vector2 Controller::MakeMoveDisc() const
{
	Vector2 ret = Zero2();
	ret(0) = MakeAxisFromKeys(KeyboardKey::A, KeyboardKey::D);
	ret(1) = MakeAxisFromKeys(KeyboardKey::S, KeyboardKey::W);
	ret += m_States.Gamepad().LeftStick;

	return ret.IsAtOrigin() ? Zero2() : ret.Direction();
}
예제 #3
0
void InputState::Update()
{
	Reset();
	m_System->Update();

	//buttons

	if (m_System->IsKeyDown(Keys::SPACE) || m_System->IsGamePadButtonDown(Xbox::A))
	{
		m_ActionPressed = true;
	}

	if (m_System->IsKeyDown(Keys::ENTER) || m_System->IsGamePadButtonDown(Xbox::X))
	{
		m_ConfirmPressed = true;
	}

	if (m_System->IsKeyDown(Keys::ESCAPE) || m_System->IsGamePadButtonDown(Xbox::Y))
	{
		m_DenyPressed = true;
	}

	if(m_System->IsKeyDown(Keys::F1))
	{
		m_FullscreenPressed = true;
	}
	
	//axes or discs

	Vector2 leftRaw;
	Vector2 rightRaw;

	if (m_System->GamepadIsConnected())
	{
		leftRaw(1) = -m_System->GetLeftAnalogX();
		leftRaw(2) = m_System->GetLeftAnalogY();
		rightRaw(1) = m_System->GetRightAnalogX();
		rightRaw(2) = m_System->GetRightAnalogY();

		m_LeftDisc = leftRaw - m_LeftDiscCentre;
		m_RightDisc = rightRaw - m_LeftDiscCentre;
	}
	else
	{
		if (m_System->IsKeyDown(Keys::A))
		{
			leftRaw += U();
		}

		if (m_System->IsKeyDown(Keys::D))
		{
			leftRaw += -U();
		}

		if (m_System->IsKeyDown(Keys::W))
		{
			leftRaw += V();
		}

		if (m_System->IsKeyDown(Keys::S))
		{
			leftRaw += -V();
		}

		if (m_System->IsKeyDown(Keys::LEFT))
		{
			rightRaw += -U();
		}

		if (m_System->IsKeyDown(Keys::RIGHT))
		{
			rightRaw += U();
		}

		if (m_System->IsKeyDown(Keys::UP))
		{
			rightRaw += V();
		}

		if (m_System->IsKeyDown(Keys::DOWN))
		{
			rightRaw += -V();
		}

		if (!EquivalentToZero(leftRaw.LengthSquared()))
		{
			m_LeftDisc = leftRaw.Direction();
		}

		if (!EquivalentToZero(rightRaw.LengthSquared()))
		{
			m_RightDisc = rightRaw.Direction();
		}
	}
}