/************************************************************************************//*! \file Input.cxx \author Tng Kah Wei, kahwei.tng, 390009620 \par email: kahwei.tng\@digipen.edu \date Oct 16, 2022 \brief Contains the definition of the managed Input static class. Note: This file is written in C++17/CLI. Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or disclosure of this file or its contents without the prior written consent of DigiPen Institute of Technology is prohibited. *//*************************************************************************************/ #include "SHpch.h" #include "Input.hxx" #include "Utility/Convert.hxx" namespace SHADE { /*---------------------------------------------------------------------------------*/ /* Properties */ /*---------------------------------------------------------------------------------*/ Vector3 Input::MousePosition::get() { int x, y; SHInputManager::GetMouseWindowPosition(&x, &y); return Vector3(static_cast(x), static_cast(y), 0.0f); } int Input::MouseScrollDelta::get() { return SHInputManager::GetMouseWheelVerticalDelta(); } /*---------------------------------------------------------------------------------*/ /* Usage Functions */ /*---------------------------------------------------------------------------------*/ bool Input::GetKey(KeyCode key) { return SHInputManager::GetKey(static_cast(key)); } bool Input::GetKeyDown(KeyCode key) { return SHInputManager::GetKeyDown(static_cast(key)); } bool Input::GetKeyUp(KeyCode key) { return SHInputManager::GetKeyUp(static_cast(key)); } bool Input::GetMouseButton(MouseCode mouseButton) { return SHInputManager::GetKey(static_cast(mouseButton)); } bool Input::GetMouseButtonDown(MouseCode mouseButton) { return SHInputManager::GetKeyDown(static_cast(mouseButton)); } bool Input::GetMouseButtonUp(MouseCode mouseButton) { return SHInputManager::GetKeyUp(static_cast(mouseButton)); } /*---------------------------------------------------------------------------------*/ /* Cursor Functions */ /*---------------------------------------------------------------------------------*/ void Input::SetMousePosition(Vector2 pos) { SHInputManager::SetMouseWindowPosition ( static_cast(pos.x), static_cast(pos.y) ); } /*---------------------------------------------------------------------------------*/ /* Time Functions */ /*---------------------------------------------------------------------------------*/ double Input::GetKeyHeldTime(KeyCode key) { return SHInputManager::GetKeyHeldTime(static_cast(key)); } double Input::GetKeyReleasedTime(KeyCode key) { return SHInputManager::GetKeyReleasedTime(static_cast(key)); } double Input::GetMouseHeldTime(MouseCode key) { return SHInputManager::GetKeyHeldTime(static_cast(key)); } double Input::GetMouseReleasedTime(MouseCode key) { return SHInputManager::GetKeyReleasedTime(static_cast(key)); } Vector2 Input::GetMouseVelocity() { double velX, velY; SHInputManager::GetMouseVelocity(&velX, &velY); return Convert::ToCLI(SHVec2{ (float)velX,(float)velY }); } }