Minor fixes to input manager
- Pass binding names into functions by const reference instead of by value - Fixed oversight of not being able to modify or read mouse Y positive multiplier for a binding
This commit is contained in:
parent
d25253118f
commit
9a5dc52d77
|
@ -575,7 +575,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
//Only get of largest magnitude
|
//Only get of largest magnitude
|
||||||
double SHInputManager::GetBindingAxis(std::string bindingName, size_t cNum) noexcept
|
double SHInputManager::GetBindingAxis(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
//Over keycodes, prioritise positive
|
//Over keycodes, prioritise positive
|
||||||
for (SH_KEYCODE k : bindings[bindingName].positiveKeyCodes)
|
for (SH_KEYCODE k : bindings[bindingName].positiveKeyCodes)
|
||||||
|
@ -606,7 +606,7 @@ namespace SHADE
|
||||||
return largestMagnitude;
|
return largestMagnitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManager::GetBindingPositiveButton(std::string bindingName, size_t cNum) noexcept
|
bool SHInputManager::GetBindingPositiveButton(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return false;
|
if (cNum >= XUSER_MAX_COUNT) return false;
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManager::GetBindingNegativeButton(std::string bindingName, size_t cNum) noexcept
|
bool SHInputManager::GetBindingNegativeButton(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return false;
|
if (cNum >= XUSER_MAX_COUNT) return false;
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManager::GetBindingPositiveButtonDown(std::string bindingName, size_t cNum) noexcept
|
bool SHInputManager::GetBindingPositiveButtonDown(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return false;
|
if (cNum >= XUSER_MAX_COUNT) return false;
|
||||||
|
|
||||||
|
@ -663,7 +663,7 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManager::GetBindingNegativeButtonDown(std::string bindingName, size_t cNum) noexcept
|
bool SHInputManager::GetBindingNegativeButtonDown(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return false;
|
if (cNum >= XUSER_MAX_COUNT) return false;
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManager::GetBindingPositiveButtonUp(std::string bindingName, size_t cNum) noexcept
|
bool SHInputManager::GetBindingPositiveButtonUp(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return false;
|
if (cNum >= XUSER_MAX_COUNT) return false;
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHInputManager::GetBindingNegativeButtonUp(std::string bindingName, size_t cNum) noexcept
|
bool SHInputManager::GetBindingNegativeButtonUp(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return false;
|
if (cNum >= XUSER_MAX_COUNT) return false;
|
||||||
|
|
||||||
|
@ -721,7 +721,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fetches longest hold time
|
//Fetches longest hold time
|
||||||
double SHInputManager::GetBindingPositiveHeldTime(std::string bindingName, size_t cNum) noexcept
|
double SHInputManager::GetBindingPositiveHeldTime(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ namespace SHADE
|
||||||
return maxHeldTime;
|
return maxHeldTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
double SHInputManager::GetBindingNegativeHeldTime(std::string bindingName, size_t cNum) noexcept
|
double SHInputManager::GetBindingNegativeHeldTime(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
||||||
|
|
||||||
|
@ -764,7 +764,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fetches shortest release time
|
//Fetches shortest release time
|
||||||
double SHInputManager::GetBindingPositiveReleasedTime(std::string bindingName, size_t cNum) noexcept
|
double SHInputManager::GetBindingPositiveReleasedTime(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ namespace SHADE
|
||||||
return minReleaseTime;
|
return minReleaseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
double SHInputManager::GetBindingNegativeReleasedTime(std::string bindingName, size_t cNum) noexcept
|
double SHInputManager::GetBindingNegativeReleasedTime(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ namespace SHADE
|
||||||
|
|
||||||
//Only for mouse movement
|
//Only for mouse movement
|
||||||
//Get largest delta
|
//Get largest delta
|
||||||
double SHInputManager::GetBindingMouseVelocity(std::string bindingName, size_t cNum) noexcept
|
double SHInputManager::GetBindingMouseVelocity(std::string const& bindingName, size_t cNum) noexcept
|
||||||
{
|
{
|
||||||
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
if (cNum >= XUSER_MAX_COUNT) return 0.0;
|
||||||
|
|
||||||
|
|
|
@ -319,8 +319,8 @@ namespace SHADE
|
||||||
std::set<SH_CONTROLLERCODE> negativeControllerCodes;
|
std::set<SH_CONTROLLERCODE> negativeControllerCodes;
|
||||||
|
|
||||||
//Mouse movement mapped to axes?
|
//Mouse movement mapped to axes?
|
||||||
double mouseXPositiveMultiplier;
|
double mouseXPositiveMultiplier = 0.0f;
|
||||||
double mouseYPositiveMultiplier;
|
double mouseYPositiveMultiplier = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -484,7 +484,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Input state accessors (KB & M) */
|
/* Input state accessors (Controller) */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
//How many controller inputs of any kind are being used now
|
//How many controller inputs of any kind are being used now
|
||||||
|
@ -622,14 +622,14 @@ namespace SHADE
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
//Add a new binding to the map
|
//Add a new binding to the map
|
||||||
static inline void BindingsAdd(std::string newBindingName) noexcept
|
static inline void BindingsAdd(std::string const& newBindingName) noexcept
|
||||||
{
|
{
|
||||||
bindings.insert({ newBindingName, SHLogicalBindingData() });
|
bindings.insert({ newBindingName, SHLogicalBindingData() });
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove a binding from the map
|
//Remove a binding from the map
|
||||||
//Returns 1 if found and removed, 0 if not found
|
//Returns 1 if found and removed, 0 if not found
|
||||||
static inline size_t BindingsRemove(std::string targetBindingName) noexcept
|
static inline size_t BindingsRemove(std::string const& targetBindingName) noexcept
|
||||||
{
|
{
|
||||||
return bindings.erase(targetBindingName);
|
return bindings.erase(targetBindingName);
|
||||||
}
|
}
|
||||||
|
@ -647,13 +647,13 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check positive keycodes to binding
|
//Check positive keycodes to binding
|
||||||
static inline std::set<SH_KEYCODE> const& BindingsGetPositiveKeyCodes(std::string bindingName) noexcept
|
static inline std::set<SH_KEYCODE> const& BindingsGetPositiveKeyCodes(std::string const& bindingName) noexcept
|
||||||
{
|
{
|
||||||
return bindings[bindingName].positiveKeyCodes;
|
return bindings[bindingName].positiveKeyCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add positive SH_KEYCODE to binding
|
//Add positive SH_KEYCODE to binding
|
||||||
static inline void BindingsAddPositiveKeyCode(std::string targetBindingName,
|
static inline void BindingsAddPositiveKeyCode(std::string const& targetBindingName,
|
||||||
SH_KEYCODE toAdd) noexcept
|
SH_KEYCODE toAdd) noexcept
|
||||||
{
|
{
|
||||||
bindings[targetBindingName].positiveKeyCodes.insert(toAdd);
|
bindings[targetBindingName].positiveKeyCodes.insert(toAdd);
|
||||||
|
@ -661,20 +661,20 @@ namespace SHADE
|
||||||
|
|
||||||
//Remove positive SH_KEYCODE from binding
|
//Remove positive SH_KEYCODE from binding
|
||||||
//If toRemove found and removed, returns 1. Otherwise, 0.
|
//If toRemove found and removed, returns 1. Otherwise, 0.
|
||||||
static inline size_t BindingsRemovePositiveKeyCode(std::string targetBindingName,
|
static inline size_t BindingsRemovePositiveKeyCode(std::string const& targetBindingName,
|
||||||
SH_KEYCODE toRemove) noexcept
|
SH_KEYCODE toRemove) noexcept
|
||||||
{
|
{
|
||||||
return bindings[targetBindingName].positiveKeyCodes.erase(toRemove);
|
return bindings[targetBindingName].positiveKeyCodes.erase(toRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check negative keycodes to binding
|
//Check negative keycodes to binding
|
||||||
static inline std::set<SH_KEYCODE> const& BindingsGetNegativeKeyCodes(std::string bindingName) noexcept
|
static inline std::set<SH_KEYCODE> const& BindingsGetNegativeKeyCodes(std::string const& bindingName) noexcept
|
||||||
{
|
{
|
||||||
return bindings[bindingName].negativeKeyCodes;
|
return bindings[bindingName].negativeKeyCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add negative SH_KEYCODE to binding
|
//Add negative SH_KEYCODE to binding
|
||||||
static inline void BindingsAddNegativeKeyCode(std::string targetBindingName,
|
static inline void BindingsAddNegativeKeyCode(std::string const& targetBindingName,
|
||||||
SH_KEYCODE toAdd) noexcept
|
SH_KEYCODE toAdd) noexcept
|
||||||
{
|
{
|
||||||
bindings[targetBindingName].negativeKeyCodes.insert(toAdd);
|
bindings[targetBindingName].negativeKeyCodes.insert(toAdd);
|
||||||
|
@ -682,20 +682,20 @@ namespace SHADE
|
||||||
|
|
||||||
//Remove negative SH_KEYCODE from binding
|
//Remove negative SH_KEYCODE from binding
|
||||||
//If toRemove found and removed, returns 1. Otherwise, 0.
|
//If toRemove found and removed, returns 1. Otherwise, 0.
|
||||||
static inline size_t BindingsRemoveNegativeKeyCode(std::string targetBindingName,
|
static inline size_t BindingsRemoveNegativeKeyCode(std::string const& targetBindingName,
|
||||||
SH_KEYCODE toRemove) noexcept
|
SH_KEYCODE toRemove) noexcept
|
||||||
{
|
{
|
||||||
return bindings[targetBindingName].negativeKeyCodes.erase(toRemove);
|
return bindings[targetBindingName].negativeKeyCodes.erase(toRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check positive controllercodes to binding
|
//Check positive controllercodes to binding
|
||||||
static inline std::set<SH_CONTROLLERCODE> const& BindingsGetPositiveControllerCodes(std::string bindingName) noexcept
|
static inline std::set<SH_CONTROLLERCODE> const& BindingsGetPositiveControllerCodes(std::string const& bindingName) noexcept
|
||||||
{
|
{
|
||||||
return bindings[bindingName].positiveControllerCodes;
|
return bindings[bindingName].positiveControllerCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add positive SH_CONTROLLERCODE to binding
|
//Add positive SH_CONTROLLERCODE to binding
|
||||||
static inline void BindingsAddPositiveControllerCode(std::string targetBindingName,
|
static inline void BindingsAddPositiveControllerCode(std::string const& targetBindingName,
|
||||||
SH_CONTROLLERCODE toAdd) noexcept
|
SH_CONTROLLERCODE toAdd) noexcept
|
||||||
{
|
{
|
||||||
bindings[targetBindingName].positiveControllerCodes.insert(toAdd);
|
bindings[targetBindingName].positiveControllerCodes.insert(toAdd);
|
||||||
|
@ -703,20 +703,20 @@ namespace SHADE
|
||||||
|
|
||||||
//Remove positive SH_CONTROLLERCODE from binding
|
//Remove positive SH_CONTROLLERCODE from binding
|
||||||
//If toRemove found and removed, returns 1. Otherwise, 0.
|
//If toRemove found and removed, returns 1. Otherwise, 0.
|
||||||
static inline size_t BindingsRemovePositiveControllerCode(std::string targetBindingName,
|
static inline size_t BindingsRemovePositiveControllerCode(std::string const& targetBindingName,
|
||||||
SH_CONTROLLERCODE toRemove) noexcept
|
SH_CONTROLLERCODE toRemove) noexcept
|
||||||
{
|
{
|
||||||
return bindings[targetBindingName].positiveControllerCodes.erase(toRemove);
|
return bindings[targetBindingName].positiveControllerCodes.erase(toRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check negative controllercodes to binding
|
//Check negative controllercodes to binding
|
||||||
static inline std::set<SH_CONTROLLERCODE> const& BindingsGetNegativeControllerCodes(std::string bindingName) noexcept
|
static inline std::set<SH_CONTROLLERCODE> const& BindingsGetNegativeControllerCodes(std::string const& bindingName) noexcept
|
||||||
{
|
{
|
||||||
return bindings[bindingName].negativeControllerCodes;
|
return bindings[bindingName].negativeControllerCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add negative SH_CONTROLLERCODE to binding
|
//Add negative SH_CONTROLLERCODE to binding
|
||||||
static inline void BindingsAddNegativeControllerCode(std::string targetBindingName,
|
static inline void BindingsAddNegativeControllerCode(std::string const& targetBindingName,
|
||||||
SH_CONTROLLERCODE toAdd) noexcept
|
SH_CONTROLLERCODE toAdd) noexcept
|
||||||
{
|
{
|
||||||
bindings[targetBindingName].negativeControllerCodes.insert(toAdd);
|
bindings[targetBindingName].negativeControllerCodes.insert(toAdd);
|
||||||
|
@ -724,7 +724,7 @@ namespace SHADE
|
||||||
|
|
||||||
//Remove negative SH_CONTROLLERCODE from binding
|
//Remove negative SH_CONTROLLERCODE from binding
|
||||||
//If toRemove found and removed, returns 1. Otherwise, 0.
|
//If toRemove found and removed, returns 1. Otherwise, 0.
|
||||||
static inline size_t BindingsRemoveNegativeControllerCode(std::string targetBindingName,
|
static inline size_t BindingsRemoveNegativeControllerCode(std::string const& targetBindingName,
|
||||||
SH_CONTROLLERCODE toRemove) noexcept
|
SH_CONTROLLERCODE toRemove) noexcept
|
||||||
{
|
{
|
||||||
return bindings[targetBindingName].negativeControllerCodes.erase(toRemove);
|
return bindings[targetBindingName].negativeControllerCodes.erase(toRemove);
|
||||||
|
@ -732,57 +732,57 @@ namespace SHADE
|
||||||
|
|
||||||
//Mouse movement bindings
|
//Mouse movement bindings
|
||||||
|
|
||||||
static inline double const BindingsGetMouseXPositiveMultiplier(std::string bindingName) noexcept
|
static inline double const BindingsGetMouseXPositiveMultiplier(std::string const& bindingName) noexcept
|
||||||
{
|
{
|
||||||
return bindings[bindingName].mouseXPositiveMultiplier;
|
return bindings[bindingName].mouseXPositiveMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void BindingsSetMouseXPositiveMultiplier(std::string bindingName, double newValue) noexcept
|
static inline void BindingsSetMouseXPositiveMultiplier(std::string const& bindingName, double newValue) noexcept
|
||||||
{
|
{
|
||||||
bindings[bindingName].mouseXPositiveMultiplier = newValue;
|
bindings[bindingName].mouseXPositiveMultiplier = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double const BindingsGetMouseYPositiveMultiplier(std::string bindingName) noexcept
|
static inline double const BindingsGetMouseYPositiveMultiplier(std::string const& bindingName) noexcept
|
||||||
{
|
{
|
||||||
return bindings[bindingName].mouseXPositiveMultiplier;
|
return bindings[bindingName].mouseYPositiveMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void BindingsSetMouseYPositiveMultiplier(std::string bindingName, double newValue) noexcept
|
static inline void BindingsSetMouseYPositiveMultiplier(std::string const& bindingName, double newValue) noexcept
|
||||||
{
|
{
|
||||||
bindings[bindingName].mouseXPositiveMultiplier = newValue;
|
bindings[bindingName].mouseYPositiveMultiplier = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the axis value of binding, between -1 and 1
|
//Get the axis value of binding, between -1 and 1
|
||||||
static double GetBindingAxis(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static double GetBindingAxis(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
|
|
||||||
//Whether binding is being held or not
|
//Whether binding is being held or not
|
||||||
//Does not work for mouse movement
|
//Does not work for mouse movement
|
||||||
static bool GetBindingPositiveButton(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static bool GetBindingPositiveButton(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
static bool GetBindingNegativeButton(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static bool GetBindingNegativeButton(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
|
|
||||||
//Whether binding is pressed down IN THIS FRAME ONLY
|
//Whether binding is pressed down IN THIS FRAME ONLY
|
||||||
//Does not work for mouse movement
|
//Does not work for mouse movement
|
||||||
static bool GetBindingPositiveButtonDown(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static bool GetBindingPositiveButtonDown(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
static bool GetBindingNegativeButtonDown(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static bool GetBindingNegativeButtonDown(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
|
|
||||||
//Whether binding is released IN THIS FRAME ONLY
|
//Whether binding is released IN THIS FRAME ONLY
|
||||||
//Does not work for mouse movement
|
//Does not work for mouse movement
|
||||||
static bool GetBindingPositiveButtonUp(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static bool GetBindingPositiveButtonUp(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
static bool GetBindingNegativeButtonUp(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static bool GetBindingNegativeButtonUp(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
|
|
||||||
//Binding times
|
//Binding times
|
||||||
|
|
||||||
//Does not work for mouse movement
|
//Does not work for mouse movement
|
||||||
static double GetBindingPositiveHeldTime(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static double GetBindingPositiveHeldTime(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
static double GetBindingNegativeHeldTime(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static double GetBindingNegativeHeldTime(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
|
|
||||||
//Does not work for mouse movement
|
//Does not work for mouse movement
|
||||||
static double GetBindingPositiveReleasedTime(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static double GetBindingPositiveReleasedTime(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
static double GetBindingNegativeReleasedTime(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static double GetBindingNegativeReleasedTime(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
|
|
||||||
//Binding mouse velocity
|
//Binding mouse velocity
|
||||||
//Only for mouse movement
|
//Only for mouse movement
|
||||||
static double GetBindingMouseVelocity(std::string bindingName, size_t controllerNumber = 0) noexcept;
|
static double GetBindingMouseVelocity(std::string const& bindingName, size_t controllerNumber = 0) noexcept;
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Other Functions */
|
/* Other Functions */
|
||||||
|
|
Loading…
Reference in New Issue