diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index bb4ccc35..7ef8adfe 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -23,6 +23,7 @@ #include "Graphics/MiddleEnd/Interface/SHRenderable.h" #include "Scene/SHSceneManager.h" #include "Math/Transform/SHTransformSystem.h" +#include "Input/SHInputManagerSystem.h" #include "Scenes/SBTestScene.h" #include "Math/Transform/SHTransformComponent.h" @@ -52,6 +53,7 @@ namespace Sandbox SHADE::SHSystemManager::CreateSystem(); SHADE::SHSystemManager::CreateSystem(); SHADE::SHGraphicsSystem* graphicsSystem = static_cast(SHADE::SHSystemManager::GetSystem()); + SHADE::SHSystemManager::CreateSystem(); // Create Routines SHADE::SHSystemManager::RegisterRoutine(); @@ -71,6 +73,8 @@ namespace Sandbox SHADE::SHComponentManager::CreateComponentSparseSet(); SHADE::SHComponentManager::CreateComponentSparseSet(); + + SHADE::SHSystemManager::RegisterRoutine(); // Set up graphics system and windows graphicsSystem->SetWindow(&window); diff --git a/SHADE_Engine/src/Input/SHInputManagerSystem.cpp b/SHADE_Engine/src/Input/SHInputManagerSystem.cpp index cbc49d7d..1beabe3f 100644 --- a/SHADE_Engine/src/Input/SHInputManagerSystem.cpp +++ b/SHADE_Engine/src/Input/SHInputManagerSystem.cpp @@ -35,6 +35,8 @@ namespace SHADE int SHInputManagerSystem::mouseScreenY = 0; int SHInputManagerSystem::mouseScreenXLast = 0; int SHInputManagerSystem::mouseScreenYLast = 0; + double SHInputManagerSystem::mouseVelocityX = 0; + double SHInputManagerSystem::mouseVelocityY = 0; int SHInputManagerSystem::mouseWheelVerticalDelta = 0; int SHInputManagerSystem::mouseWheelVerticalDeltaPoll = 0; @@ -126,6 +128,10 @@ namespace SHADE //Mouse Positioning///////////////////////////////////// //https://stackoverflow.com/a/6423739 + //Set last positioning + mouseScreenXLast = mouseScreenX; + mouseScreenYLast = mouseScreenY; + //Get cursor position, even when it is outside window POINT p; GetCursorPos(&p); diff --git a/SHADE_Engine/src/Input/SHInputManagerSystem.h b/SHADE_Engine/src/Input/SHInputManagerSystem.h index 6ee73ae9..77d8f8fd 100644 --- a/SHADE_Engine/src/Input/SHInputManagerSystem.h +++ b/SHADE_Engine/src/Input/SHInputManagerSystem.h @@ -420,6 +420,16 @@ namespace SHADE if (y) *y = mouseScreenY; } + //Get the mouse velocity + //Two output parameters for x and y velocitites + //In pixels per second for both + static inline void GetMouseVelocity(double* x = nullptr, + double* y = nullptr) noexcept + { + if (x) *x = mouseVelocityX; + if (y) *y = mouseVelocityY; + } + //Get the mouse wheel vertical delta static inline int GetMouseWheelVerticalDelta() noexcept { @@ -529,15 +539,26 @@ namespace SHADE //MOUSE VARIABLES/////////////////////////////////////////////////////////// //Present horizontal positioning of the mouse WRT the screen + //Increasing rightwards static int mouseScreenX; //Present vertical positioning of the mouse WRT the screen + //Increasing downwards static int mouseScreenY; //Horizontal positioning of the mouse WRT screen in last frame + //Increasing rightwards static int mouseScreenXLast; //Vertical positioning of the mouse WRT screen in the last frame + //Increasing downwards static int mouseScreenYLast; + //The velocity at which the mouse is being moved horizontally (px/s) + //Rightwards is positive + static double mouseVelocityX; + //The velocity at which the mouse is being moved vertically (px/s) + //Downwards is positive + static double mouseVelocityY; + //For polling mouse wheel events, not to be read static int mouseWheelVerticalDeltaPoll; //Mouse wheel vertical rotation speed. Positive is rotation AWAY from user