Merge branch 'main' into RenderingEditorVPIntegration

This commit is contained in:
Sri Sham Haran 2022-10-18 19:09:08 +08:00
commit da99a5559e
19 changed files with 581 additions and 55 deletions

View File

@ -0,0 +1,3 @@
Name: Cube.003
ID: 110152941
Type: 

View File

@ -0,0 +1,3 @@
Name: Cube.012
ID: 107348815
Type: 

View File

@ -0,0 +1,3 @@
Name: RaccoonPreTexturedVer1_Base9
ID: 91918845
Type: 

View File

@ -104,10 +104,10 @@ namespace Sandbox
//TODO: REMOVE AFTER PRESENTATION
//SHAssetManager::LoadDataTemp("../../Assets/racoon.gltf");
SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh");
//SHAssetManager::LoadDataTemp("../../Assets/Cube.012.shmesh");
//SHAssetManager::LoadDataTemp("../../Assets/RaccoonBag_Color_Ver4.dds");
//SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.dds");
SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.shtex");
//SHAssetManager::LoadDataTemp("../../Assets/RaccoonPreTexturedVer1_Base9.shtex");
//TODO: REMOVE AFTER PRESENTATION
@ -125,6 +125,8 @@ namespace Sandbox
SHSceneManager::InitSceneManager<SBTestScene>("TestScene");
SHFrameRateController::UpdateFRC();
SHAssetManager::Load();
}
void SBApplication::Update(void)
@ -159,6 +161,7 @@ namespace Sandbox
SHSceneManager::Exit();
SHSystemManager::Exit();
SHAssetManager::Unload();
}
}

View File

@ -9,6 +9,7 @@ namespace SHADE
{
bool compiled;
std::string name;
uint32_t numBytes;
uint32_t width;
uint32_t height;

View File

@ -16,7 +16,7 @@
#include <fstream>
void SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept
std::string SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept
{
std::string newPath{ path.string() };
newPath = newPath.substr(0, newPath.find_last_of('/') + 1);
@ -67,4 +67,6 @@ void SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPat
);
file.close();
return newPath;
}

View File

@ -21,6 +21,6 @@ namespace SHADE
{
private:
public:
static void CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept;
static std::string CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept;
};
}

View File

@ -142,8 +142,7 @@ namespace SHADE
SHLOG_ERROR("Unable to open SHMesh File: {}", path.string());
}
std::string name{ path.filename().string() };
name = name.substr(0, name.find_last_of('.'));
const std::string name{ path.stem().string() };
file.seekg(0);

View File

@ -29,8 +29,8 @@ namespace SHADE
static void LoadExternal(std::vector<SHMeshAsset>& meshes, AssetPath path) noexcept;
static void LoadSHMesh(SHMeshAsset& meshes, AssetPath path) noexcept;
public:
static void LoadMesh(std::vector<SHMeshAsset>& meshes, AssetPath path) noexcept;
static void LoadSHMesh(SHMeshAsset& meshes, AssetPath path) noexcept;
};
}

View File

@ -17,7 +17,7 @@
namespace SHADE
{
void SHTextureCompiler::CompileTextureBinary(SHTextureAsset const& asset, AssetPath path)
std::string SHTextureCompiler::CompileTextureBinary(SHTextureAsset const& asset, AssetPath path)
{
std::string newPath{ path.string() };
newPath = newPath.substr(0, newPath.find_last_of('.'));
@ -69,5 +69,7 @@ namespace SHADE
);
file.close();
return newPath;
}
}

View File

@ -19,6 +19,6 @@ namespace SHADE
{
struct SHTextureCompiler
{
static void CompileTextureBinary(SHTextureAsset const& asset, AssetPath path);
static std::string CompileTextureBinary(SHTextureAsset const& asset, AssetPath path);
};
}

View File

@ -93,6 +93,7 @@ namespace SHADE
std::memcpy(pixel, file.GetImageData()->m_mem, totalBytes);
//pixel = std::move(reinterpret_cast<SHTexture::PixelChannel const*>(file.GetDDSData()));
asset.name = path.stem().string();
asset.compiled = false;
asset.numBytes = static_cast<uint32_t>(totalBytes);
asset.width = file.GetWidth();

View File

@ -26,8 +26,8 @@ namespace SHADE
static void LoadTinyDDS(AssetPath path, SHTextureAsset& asset) noexcept;
static void LoadSHTexture(AssetPath path, SHTextureAsset& asset) noexcept;
public:
static void LoadImageAsset(AssetPath paths, SHTextureAsset& image);
static void LoadSHTexture(AssetPath path, SHTextureAsset& asset) noexcept;
};
}

View File

@ -40,7 +40,7 @@ typedef FMOD::Sound* SHSound;
#define ASSET_META_VER "1.0"
// Asset type enum
enum class AssetType : uint8_t
enum class AssetType : AssetTypeMeta
{
INVALID = 0,
AUDIO = 1,
@ -57,7 +57,12 @@ enum class AssetType : uint8_t
};
//Directory
#define ASSET_ROOT "./Assets/"
#ifdef _PUBLISH
#define ASSET_ROOT "Assets"
#else
#define ASSET_ROOT "../../Assets"
#endif
// ASSET EXTENSIONS
#define META_EXTENSION ".shmeta"

View File

@ -255,6 +255,26 @@ namespace SHADE
return result;
}
SHMeshAsset const* SHAssetManager::GetMesh(AssetID id) noexcept
{
if (meshCollection.find(id) == meshCollection.end())
{
return nullptr;
}
return &meshCollection[id];
}
SHTextureAsset const* SHAssetManager::GetTexture(AssetID id) noexcept
{
if (textureCollection.find(id) == textureCollection.end())
{
return nullptr;
}
return &textureCollection[id];
}
/****************************************************************************
* \param Path for meta data file
* \param Path for asset file
@ -307,12 +327,22 @@ namespace SHADE
for (auto const& mesh : meshes)
{
meshCollection.emplace(GenerateAssetID(AssetType::MESH), mesh);
auto id{ GenerateAssetID(AssetType::MESH) };
meshCollection.emplace(id, mesh);
AssetPath path;
if (!mesh.compiled)
{
SHMeshCompiler::CompileMeshBinary(mesh, asset.path);
path = SHMeshCompiler::CompileMeshBinary(mesh, asset.path);
}
assetCollection.emplace_back(
mesh.header.meshName,
id,
AssetType::MESH,
path,
0
);
}
}
@ -322,11 +352,20 @@ namespace SHADE
SHTextureLoader::LoadImageAsset(asset.path, image);
textureCollection.emplace(GenerateAssetID(AssetType::DDS), image);
if (!image.compiled)
{
SHTextureCompiler::CompileTextureBinary(image, asset.path);
auto id{ GenerateAssetID(AssetType::TEXTURE) };
textureCollection.emplace(id, image);
auto path{ SHTextureCompiler::CompileTextureBinary(image, asset.path) };
assetCollection.emplace_back(
image.name,
id,
AssetType::TEXTURE,
path,
0
);
}
}
@ -344,8 +383,24 @@ namespace SHADE
****************************************************************************/
void SHAssetManager::LoadAllData() noexcept
{
//TODO Remove when on demand loading is done
for (auto const& asset : assetCollection)
{
switch (asset.type)
{
case AssetType::MESH:
meshCollection.emplace(asset.id, SHMeshAsset());
SHMeshLoader::LoadSHMesh(meshCollection[asset.id], asset.path);
break;
case AssetType::TEXTURE:
textureCollection.emplace(asset.id, SHTextureAsset());
SHTextureLoader::LoadSHTexture(asset.path, textureCollection[asset.id]);
break;
default:
void;
}
}
}
@ -362,40 +417,51 @@ namespace SHADE
std::vector<AssetPath> metaFiles;
std::vector<AssetPath> AssetFiles;
//TODO: Write new function for file manager to loop through all files
SHFileSystem::StartupFillDirectories(ASSET_ROOT);
FolderPointer rootFolder = SHFileSystem::GetRoot();
for (auto const& meta : metaFiles)
for (auto const dir : std::filesystem::recursive_directory_iterator(ASSET_ROOT))
{
for (std::vector<AssetPath>::const_iterator it{ AssetFiles.cbegin() };
it != AssetFiles.cend();
++it)
if (dir.path().extension().string() == META_EXTENSION)
{
// Asset exists for meta file
std::string fileExtCheck{ it->filename().string() };
fileExtCheck += META_EXTENSION;
if (meta.filename().string() == fileExtCheck)
{
RegisterAsset(meta, *it);
AssetFiles.erase(it);
break;
}
auto meta{ SHAssetMetaHandler::RetrieveMetaData(dir.path()) };
assetCollection.push_back(meta);
assetRegistry.emplace(meta.id, meta);
}
}
//TODO: Write new function for file manager to loop through all files
//SHFileSystem::StartupFillDirectories(ASSET_ROOT);
//FolderPointer rootFolder = SHFileSystem::GetRoot();
//for (auto const& meta : metaFiles)
//{
// for (std::vector<AssetPath>::const_iterator it{ AssetFiles.cbegin() };
// it != AssetFiles.cend();
// ++it)
// {
// // Asset exists for meta file
// std::string fileExtCheck{ it->filename().string() };
// fileExtCheck += META_EXTENSION;
// if (meta.filename().string() == fileExtCheck)
// {
// RegisterAsset(meta, *it);
// AssetFiles.erase(it);
// break;
// }
// }
//}
//TODO: Handle if meta does not match all assets (if meta exist and asset doesnt, vice versa)
for (auto const& file : AssetFiles)
{
if (IsRecognised(file.extension().string().c_str()))
{
SHAssetMetaHandler::WriteMetaData(RegisterAssetNew(file));
}
else
{
std::cout << "Unsupported File Format: " << file.filename() << "\n";
}
}
//for (auto const& file : AssetFiles)
//{
// if (IsRecognised(file.extension().string().c_str()))
// {
// SHAssetMetaHandler::WriteMetaData(RegisterAssetNew(file));
// }
// else
// {
// std::cout << "Unsupported File Format: " << file.filename() << "\n";
// }
//}
}
AssetID SHAssetManager::RetrieveAsset(char const* path) noexcept

View File

@ -75,6 +75,8 @@ namespace SHADE
static std::vector<SHMeshAsset> GetAllMeshes() noexcept;
static std::vector<SHTextureAsset> GetAllTextures() noexcept;
static SHMeshAsset const* GetMesh(AssetID id) noexcept;
static SHTextureAsset const* GetTexture(AssetID id) noexcept;
private:
/****************************************************************************
* \brief Load resource data into memory

View File

@ -72,6 +72,13 @@ namespace SHADE
std::string line;
SHAsset meta;
// Get resource name
GetFieldValue(metaFile, line);
std::stringstream nameStream{ line };
AssetName name;
nameStream >> name;
meta.name = name;
// Get resource id
GetFieldValue(metaFile, line);
std::stringstream idStream{ line };
@ -88,6 +95,8 @@ namespace SHADE
metaFile.close();
meta.path = path.parent_path().string() + "/" + path.stem().string();
return meta;
}
@ -103,7 +112,7 @@ namespace SHADE
std::string path{ meta.path.string() };
path.append(META_EXTENSION);
std::ofstream metaFile{ path, std::ios_base::out };
std::ofstream metaFile{ path, std::ios_base::out | std::ios_base::trunc };
if (!metaFile.is_open())
{
@ -113,17 +122,17 @@ namespace SHADE
metaFile << "Name: " << meta.name << "\n";
metaFile << "ID: " << meta.id << "\n";
metaFile << "Type: " << static_cast<int>(meta.type) << std::endl;
metaFile << "Type: " << static_cast<AssetTypeMeta>(meta.type) << std::endl;
//TODO Add in information that is specific to types like mesh
switch(meta.type)
{
case AssetType::MESH:
break;
////TODO Add in information that is specific to types like mesh
//switch(meta.type)
//{
//case AssetType::MESH:
// break;
default:
break;
}
//default:
// break;
//}
metaFile.close();
}

View File

@ -0,0 +1,102 @@
/************************************************************************************//*!
\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));
}
}

View File

@ -0,0 +1,325 @@
/************************************************************************************//*!
\file Input.hxx
\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.
*//*************************************************************************************/
#pragma once
#include "Input/SHInputManager.h"
#include "Math/Vector2.hxx"
#include "Math/Vector3.hxx"
namespace SHADE
{
/// <summary>
/// Static class responsible for providing access to Input-related functionality.
/// </summary>
public ref class Input abstract sealed
{
public:
/*-----------------------------------------------------------------------------*/
/* Type Definitions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Represents the available supported keycodes that can be passed into the
/// key-based Input functions.
/// </summary>
enum class KeyCode : int
{
Space = static_cast<int>(SHInputManager::SH_KEYCODE::SPACE),
//Apostrophe = static_cast<int>(SHInputManager::SH_KEYCODE::APOSTROPHE),
Comma = static_cast<int>(SHInputManager::SH_KEYCODE::OEM_COMMA),
Minus = static_cast<int>(SHInputManager::SH_KEYCODE::OEM_MINUS),
Period = static_cast<int>(SHInputManager::SH_KEYCODE::OEM_PERIOD),
//Slash = static_cast<int>(SHInputManager::SH_KEYCODE::SLASH),
Key0 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_0),
Key1 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_1),
Key2 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_2),
Key3 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_3),
Key4 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_4),
Key5 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_5),
Key6 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_6),
Key7 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_7),
Key8 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_8),
Key9 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMBER_9),
//Semicolon = static_cast<int>(SHInputManager::SH_KEYCODE::SEMICOLON),
//Equal = static_cast<int>(SHInputManager::SH_KEYCODE::EQUAL),
A = static_cast<int>(SHInputManager::SH_KEYCODE::A),
B = static_cast<int>(SHInputManager::SH_KEYCODE::B),
C = static_cast<int>(SHInputManager::SH_KEYCODE::C),
D = static_cast<int>(SHInputManager::SH_KEYCODE::D),
E = static_cast<int>(SHInputManager::SH_KEYCODE::E),
F = static_cast<int>(SHInputManager::SH_KEYCODE::F),
G = static_cast<int>(SHInputManager::SH_KEYCODE::G),
H = static_cast<int>(SHInputManager::SH_KEYCODE::H),
I = static_cast<int>(SHInputManager::SH_KEYCODE::I),
J = static_cast<int>(SHInputManager::SH_KEYCODE::J),
K = static_cast<int>(SHInputManager::SH_KEYCODE::K),
L = static_cast<int>(SHInputManager::SH_KEYCODE::L),
M = static_cast<int>(SHInputManager::SH_KEYCODE::M),
N = static_cast<int>(SHInputManager::SH_KEYCODE::N),
O = static_cast<int>(SHInputManager::SH_KEYCODE::O),
P = static_cast<int>(SHInputManager::SH_KEYCODE::P),
Q = static_cast<int>(SHInputManager::SH_KEYCODE::Q),
R = static_cast<int>(SHInputManager::SH_KEYCODE::R),
S = static_cast<int>(SHInputManager::SH_KEYCODE::S),
T = static_cast<int>(SHInputManager::SH_KEYCODE::T),
U = static_cast<int>(SHInputManager::SH_KEYCODE::U),
V = static_cast<int>(SHInputManager::SH_KEYCODE::V),
W = static_cast<int>(SHInputManager::SH_KEYCODE::W),
X = static_cast<int>(SHInputManager::SH_KEYCODE::X),
Y = static_cast<int>(SHInputManager::SH_KEYCODE::Y),
Z = static_cast<int>(SHInputManager::SH_KEYCODE::Z),
//LeftBracket = static_cast<int>(SHInputManager::SH_KEYCODE::LEFTBRACKET),
//BackSlash = static_cast<int>(SHInputManager::SH_KEYCODE::BACKSLASH),
//RightBracket = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHTBRACKET),
//GraveAccent = static_cast<int>(SHInputManager::SH_KEYCODE::GRAVEACCENT),
//WORLD1 = static_cast<int>(SHInputManager::SH_KEYCODE::WORLD1),
//WORLD2 = static_cast<int>(SHInputManager::SH_KEYCODE::WORLD2),
/* Function keys */
Escape = static_cast<int>(SHInputManager::SH_KEYCODE::ESCAPE),
Enter = static_cast<int>(SHInputManager::SH_KEYCODE::ENTER),
Tab = static_cast<int>(SHInputManager::SH_KEYCODE::TAB),
Backspace = static_cast<int>(SHInputManager::SH_KEYCODE::BACKSPACE),
Insert = static_cast<int>(SHInputManager::SH_KEYCODE::INSERT),
Delete = static_cast<int>(SHInputManager::SH_KEYCODE::DEL),
Right = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_ARROW),
Left = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_ARROW),
Down = static_cast<int>(SHInputManager::SH_KEYCODE::DOWN_ARROW),
Up = static_cast<int>(SHInputManager::SH_KEYCODE::UP_ARROW),
PageUp = static_cast<int>(SHInputManager::SH_KEYCODE::PAGE_UP),
PageDown = static_cast<int>(SHInputManager::SH_KEYCODE::PAGE_DOWN),
Home = static_cast<int>(SHInputManager::SH_KEYCODE::HOME),
End = static_cast<int>(SHInputManager::SH_KEYCODE::END),
CapsLock = static_cast<int>(SHInputManager::SH_KEYCODE::CAPS_LOCK),
ScrollLock = static_cast<int>(SHInputManager::SH_KEYCODE::SCROLL_LOCK),
NumLock = static_cast<int>(SHInputManager::SH_KEYCODE::NUM_LOCK),
PrintScreen = static_cast<int>(SHInputManager::SH_KEYCODE::PRINT_SCREEN),
Pause = static_cast<int>(SHInputManager::SH_KEYCODE::PAUSE),
F1 = static_cast<int>(SHInputManager::SH_KEYCODE::F1),
F2 = static_cast<int>(SHInputManager::SH_KEYCODE::F2),
F3 = static_cast<int>(SHInputManager::SH_KEYCODE::F3),
F4 = static_cast<int>(SHInputManager::SH_KEYCODE::F4),
F5 = static_cast<int>(SHInputManager::SH_KEYCODE::F5),
F6 = static_cast<int>(SHInputManager::SH_KEYCODE::F6),
F7 = static_cast<int>(SHInputManager::SH_KEYCODE::F7),
F8 = static_cast<int>(SHInputManager::SH_KEYCODE::F8),
F9 = static_cast<int>(SHInputManager::SH_KEYCODE::F9),
F10 = static_cast<int>(SHInputManager::SH_KEYCODE::F10),
F11 = static_cast<int>(SHInputManager::SH_KEYCODE::F11),
F12 = static_cast<int>(SHInputManager::SH_KEYCODE::F12),
F13 = static_cast<int>(SHInputManager::SH_KEYCODE::F13),
F14 = static_cast<int>(SHInputManager::SH_KEYCODE::F14),
F15 = static_cast<int>(SHInputManager::SH_KEYCODE::F15),
F16 = static_cast<int>(SHInputManager::SH_KEYCODE::F16),
F17 = static_cast<int>(SHInputManager::SH_KEYCODE::F17),
F18 = static_cast<int>(SHInputManager::SH_KEYCODE::F18),
F19 = static_cast<int>(SHInputManager::SH_KEYCODE::F19),
F20 = static_cast<int>(SHInputManager::SH_KEYCODE::F20),
F21 = static_cast<int>(SHInputManager::SH_KEYCODE::F21),
F22 = static_cast<int>(SHInputManager::SH_KEYCODE::F22),
F23 = static_cast<int>(SHInputManager::SH_KEYCODE::F23),
F24 = static_cast<int>(SHInputManager::SH_KEYCODE::F24),
/* Keypad */
KeyPad0 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_0),
KeyPad1 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_1),
KeyPad2 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_2),
KeyPad3 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_3),
KeyPad4 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_4),
KeyPad5 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_5),
KeyPad6 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_6),
KeyPad7 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_7),
KeyPad8 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_8),
KeyPad9 = static_cast<int>(SHInputManager::SH_KEYCODE::NUMPAD_9),
//KeyPadDecimal = static_cast<int>(SHInputManager::SH_KEYCODE::KPDECIMAL),
//KeyPadDivide = static_cast<int>(SHInputManager::SH_KEYCODE::KPDIVIDE),
//KeyPadMultiply = static_cast<int>(SHInputManager::SH_KEYCODE::KPMULTIPLY),
//KeyPadSubtract = static_cast<int>(SHInputManager::SH_KEYCODE::KPSUBTRACT),
//KeyPadAdd = static_cast<int>(SHInputManager::SH_KEYCODE::KPADD),
//KeyPadEnter = static_cast<int>(SHInputManager::SH_KEYCODE::KPENTER),
//KeyPadEqual = static_cast<int>(SHInputManager::SH_KEYCODE::KEYPAD),
Shift = static_cast<int>(SHInputManager::SH_KEYCODE::SHIFT),
LeftControl = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_CTRL),
LeftAlt = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_ALT),
LeftSuper = static_cast<int>(SHInputManager::SH_KEYCODE::LEFT_WINDOWS),
RightShift = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_SHIFT),
RightControl = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_CTRL),
RightAlt = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_ALT),
RightSuper = static_cast<int>(SHInputManager::SH_KEYCODE::RIGHT_WINDOWS),
/* Gamepad */
JoystickA = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_A),
JoystickB = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_B),
JoystickX = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_X),
JoystickY = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_Y),
JoystickLeftBumper = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_LEFTSHOULDER),
JoystickRightBumper = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_RIGHTSHOULDER),
JoystickLeftTrigger = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_LEFTTRIGGER),
JoystickRightTrigger = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_RIGHTTRIGGER),
JoystickDPadUp = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_UP),
JoystickDPadDown = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_DOWN),
JoystickDPadLeft = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_LEFT),
JoystickDPadRight = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_DPAD_RIGHT),
JoystickMenu = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_MENU),
JoystickView = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_VIEW),
JoystickLeftStick = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_LEFT_THUMBSTICK_BUTTON),
JoystickRightStick = static_cast<int>(SHInputManager::SH_KEYCODE::GAMEPAD_RIGHT_THUMBSTICK_BUTTON),
/* Unity Gamepad Mappings */
JoystickButton0 = JoystickA,
JoystickButton1 = JoystickB,
JoystickButton2 = JoystickX,
JoystickButton3 = JoystickY,
JoystickButton4 = JoystickLeftBumper,
JoystickButton5 = JoystickRightBumper,
JoystickButton6 = JoystickView,
JoystickButton7 = JoystickMenu,
JoystickButton8 = JoystickLeftStick,
JoystickButton9 = JoystickRightStick
};
/// <summary>
/// Represents the available supported mouse keycodes that can be passed into the
/// mouse-button-based Input functions.
/// </summary>
enum class MouseCode : int
{
LeftButton = static_cast<int>(SHInputManager::SH_KEYCODE::LMB),
RightButton = static_cast<int>(SHInputManager::SH_KEYCODE::RMB),
MiddleButton = static_cast<int>(SHInputManager::SH_KEYCODE::MMB),
Button3 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB1),
Button4 = static_cast<int>(SHInputManager::SH_KEYCODE::XMB2)
};
/*-----------------------------------------------------------------------------*/
/* Properites */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Mouse position in screen coordinates relative to the top left of the window.
/// This value is a Vector3 for compatibility with functions that have Vector3
/// arguments. The z component of the Vector3 is always 0
/// </summary>
static property Vector3 MousePosition
{
Vector3 get();
}
/// <summary>
/// Amnount of vertical mouse scroll in this frame.
/// </summary>
static property int MouseScrollDelta
{
int get();
}
/*-----------------------------------------------------------------------------*/
/* Usage Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Checks if a specified key is being held down.
/// This will also be true if GetKeyDown() is true.
/// </summary>
/// <param name="key">KeyCode of the key to check.</param>
/// <returns>True while the user holds down the key specified.</returns>
static bool GetKey(KeyCode key);
/// <summary>
/// Checks if a specified key is pressed and was not pressed before.
/// </summary>
/// <param name="key">KeyCode of the key to check.</param>
/// <returns>
/// True during the frame the user starts pressing down the key specified.
/// </returns>
static bool GetKeyDown(KeyCode key);
/// <summary>
/// Checks if a specified key is no longer pressed pressed and was pressed
/// before.
/// </summary>
/// <param name="key">KeyCode of the key to check.</param>
/// <returns>
/// True during the frame the user releases the key identified by name.
/// </returns>
static bool GetKeyUp(KeyCode key);
/// <summary>
/// Checks if a specified mouse button is being held down.
/// This will also be true if GetMouseButtonDown() is true.
/// </summary>
/// <param name="mouseButton">MouseCode of the mouse button to check.</param>
/// <returns>True while the user holds down the mouse button specified.</returns>
static bool GetMouseButton(MouseCode mouseButton);
/// <summary>
/// Checks if a specified mouse button is pressed and was not pressed before.
/// </summary>
/// <param name="mouseButton">MouseCode of the mouse button to check.</param>
/// <returns>
/// True during the frame the user pressed the given mouse button.
/// </returns>
static bool GetMouseButtonDown(MouseCode mouseButton);
/// <summary>
/// Checks if a specified mouse button is no longer pressed and was pressed
/// before.
/// </summary>
/// <param name="mouseButton">MouseCode of the mouse button to check.</param>
/// <returns>
/// True during the frame the user releases the given mouse button.
/// </returns>
static bool GetMouseButtonUp(MouseCode mouseButton);
/*-----------------------------------------------------------------------------*/
/* Cursor Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Sets the position of the mouse cursor relative to the top left corner of the
/// window.
/// </summary>
/// <param name="pos">
/// Position of the mouse in window pixel coordinates to set.
/// </param>
static void SetMousePosition(Vector2 pos);
/*-----------------------------------------------------------------------------*/
/* Timing Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Retrieves the duration that the specified key has been held or was last held
/// for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetKeyHeldTime(KeyCode key);
/// <summary>
/// Retrieves the duration that the specified key has not been held or was last
/// not been held for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetKeyReleasedTime(KeyCode key);
/// <summary>
/// Retrieves the duration that the specified key has been held or was last held
/// for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetMouseHeldTime(MouseCode mouseButton);
/// <summary>
/// Retrieves the duration that the specified key has not been held or was last
/// not been held for.
/// </summary>
/// <param name="key">The key to check.</param>
/// <returns>Time in seconds that the key was held.</returns>
static double GetMouseReleasedTime(MouseCode mouseButton);
};
}