Implemented Input Functions via C# #358

Merged
mushgunAX merged 5 commits from SP3-10-input-management into main 2023-02-23 14:00:26 +08:00
2 changed files with 18 additions and 3 deletions
Showing only changes of commit 0e572d7f89 - Show all commits

View File

@ -24,6 +24,7 @@ namespace SHADE
/* Static defines */
/*------------------------------------------------------------------------*/
bool SHInputManager::mouseCentering = false;
bool SHInputManager::controllerInUse = false;
std::map<std::string, SHInputManager::SHLogicalBindingData> SHInputManager::bindings;
@ -806,16 +807,15 @@ namespace SHADE
//Mouse Centering
if (GetKey(SH_KEYCODE::Q))
if (mouseCentering)
{
uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth();
uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight();
SetMouseWindowPosition(width / 2, height / 2);
//This four lines help a lot
//These four lines help a lot
POINT p;
GetCursorPos(&p);
mouseVelocityX -= static_cast<double>(p.x - mouseScreenX) / dt;
mouseVelocityY -= static_cast<double>(p.y - mouseScreenY) / dt;
}

View File

@ -1074,6 +1074,18 @@ namespace SHADE
SetCursorPos(p.x, p.y);
}
//Call to set the flag to start mouse centering every frame
static inline void SetMouseCentering(bool state) noexcept
{
mouseCentering = state;
}
//Get the flag whether mouse centering is on or not
static inline bool GetMouseCentering() noexcept
{
return mouseCentering;
}
private:
/*------------------------------------------------------------------------*/
/* Constants */
@ -1097,6 +1109,9 @@ namespace SHADE
/* Data Members */
/*------------------------------------------------------------------------*/
//Whether mouse centering will be called every frame or not
static bool mouseCentering;
//If the last input is from controller(s) or KB/M
//True if from controller(s), False if from KB/M
//Useful for switching control hints between controllers and KB/M