#include "CameraController.hpp" #include "Scene/Camera.hpp" #include "Input/InputDeviceMouse.hpp" #include "Input/InputDeviceController.hpp" #include "Input/InputManager.hpp" #include "Input/Touch/InputDeviceTouch.hpp" namespace OpenVulkano { CameraController::CameraController(Scene::Camera* camera) { m_inputManager = Input::InputManager::GetInstance(); m_camera = camera; m_actionCastRay = m_inputManager->GetAction("cast ray"); m_actionCastRay->BindKey(Input::InputKey::Mouse::BUTTON_1); m_actionCastRay->BindKey(Input::InputKey::Touch::AXIS_TAP_X); m_actionCastRay->BindKey(Input::InputKey::Touch::AXIS_TAP_Y); } void CameraController::Tick() { Input::InputDeviceMouse* mouse = static_cast(m_inputManager->GetDevice(Input::InputDeviceType::MOUSE)); Input::InputDeviceTouch* touch = static_cast(m_inputManager->GetDevice(Input::InputDeviceType::TOUCH)); if (m_camera->CanCastRay() && m_inputManager->GetButton(m_actionCastRay)) { if (mouse && mouse->GetButtonDown(Input::InputKey::Mouse::BUTTON_1)) { Math::Vector2i pos = mouse->GetMousePosition(); mouse->onLeftButtonClick.NotifyAll(pos); } // not sure about second condition here, but here should be something else if (touch && (touch->GetAxis(Input::InputKey::Touch::AXIS_TAP_X) != 0 || touch->GetAxis(Input::InputKey::Touch::AXIS_TAP_Y) != 0)) { Math::Vector2i pos = touch->GetTapPosition(); touch->OnTap.NotifyAll(pos); } } } }