102 lines
3.8 KiB
C++
102 lines
3.8 KiB
C++
|
/************************************************************************************//*!
|
||
|
\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<float>(x), static_cast<float>(y), 0.0f);
|
||
|
}
|
||
|
int Input::MouseScrollDelta::get()
|
||
|
{
|
||
|
return SHInputManager::GetMouseWheelVerticalDelta();
|
||
|
}
|
||
|
|
||
|
/*---------------------------------------------------------------------------------*/
|
||
|
/* Usage Functions */
|
||
|
/*---------------------------------------------------------------------------------*/
|
||
|
bool Input::GetKey(KeyCode key)
|
||
|
{
|
||
|
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||
|
}
|
||
|
|
||
|
bool Input::GetKeyDown(KeyCode key)
|
||
|
{
|
||
|
return SHInputManager::GetKeyDown(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||
|
}
|
||
|
|
||
|
bool Input::GetKeyUp(KeyCode key)
|
||
|
{
|
||
|
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||
|
}
|
||
|
|
||
|
bool Input::GetMouseButton(MouseCode mouseButton)
|
||
|
{
|
||
|
return SHInputManager::GetKey(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
|
||
|
}
|
||
|
|
||
|
bool Input::GetMouseButtonDown(MouseCode mouseButton)
|
||
|
{
|
||
|
return SHInputManager::GetKeyDown(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
|
||
|
}
|
||
|
|
||
|
bool Input::GetMouseButtonUp(MouseCode mouseButton)
|
||
|
{
|
||
|
return SHInputManager::GetKeyUp(static_cast<SHInputManager::SH_KEYCODE>(mouseButton));
|
||
|
}
|
||
|
|
||
|
/*---------------------------------------------------------------------------------*/
|
||
|
/* Cursor Functions */
|
||
|
/*---------------------------------------------------------------------------------*/
|
||
|
void Input::SetMousePosition(Vector2 pos)
|
||
|
{
|
||
|
SHInputManager::SetMouseWindowPosition
|
||
|
(
|
||
|
static_cast<int>(pos.x),
|
||
|
static_cast<int>(pos.y)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/*---------------------------------------------------------------------------------*/
|
||
|
/* Time Functions */
|
||
|
/*---------------------------------------------------------------------------------*/
|
||
|
double Input::GetKeyHeldTime(KeyCode key)
|
||
|
{
|
||
|
return SHInputManager::GetKeyHeldTime(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||
|
}
|
||
|
|
||
|
double Input::GetKeyReleasedTime(KeyCode key)
|
||
|
{
|
||
|
return SHInputManager::GetKeyReleasedTime(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||
|
}
|
||
|
|
||
|
double Input::GetMouseHeldTime(MouseCode key)
|
||
|
{
|
||
|
return SHInputManager::GetKeyHeldTime(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||
|
}
|
||
|
|
||
|
double Input::GetMouseReleasedTime(MouseCode key)
|
||
|
{
|
||
|
return SHInputManager::GetKeyReleasedTime(static_cast<SHInputManager::SH_KEYCODE>(key));
|
||
|
}
|
||
|
|
||
|
}
|