Add methods IsAnyKeyDown on Mouse/Gamepad class
This commit is contained in:
@@ -31,6 +31,15 @@ void Gamepad::ResetState()
|
||||
_mappedPrevState.Clear();
|
||||
}
|
||||
|
||||
bool Gamepad::IsAnyKeyDown() const
|
||||
{
|
||||
// TODO: optimize with SIMD
|
||||
bool result = false;
|
||||
for (auto e : _state.Buttons)
|
||||
result |= e;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Gamepad::Update(EventQueue& queue)
|
||||
{
|
||||
// Copy state
|
||||
|
||||
@@ -164,6 +164,11 @@ public:
|
||||
return _mappedState.Buttons[static_cast<int32>(button)] && !_mappedPrevState.Buttons[static_cast<int32>(button)];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any gamepad button is currently pressed.
|
||||
/// </summary>
|
||||
API_PROPERTY() bool IsAnyKeyDown() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the gamepad button up state (true if was released during the current frame).
|
||||
/// </summary>
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Serialization/JsonTools.h"
|
||||
|
||||
#include "Engine/Debug/DebugLog.h"
|
||||
|
||||
struct AxisEvaluation
|
||||
{
|
||||
float RawValue;
|
||||
@@ -183,6 +185,15 @@ void Mouse::OnMouseDown(const Float2& position, const MouseButton button, Window
|
||||
e.MouseData.Position = position;
|
||||
}
|
||||
|
||||
bool Mouse::IsAnyKeyDown() const
|
||||
{
|
||||
// TODO: optimize with SIMD
|
||||
bool result = false;
|
||||
for (auto e : Mouse::_state.MouseButtons)
|
||||
result |= e;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Mouse::OnMouseUp(const Float2& position, const MouseButton button, Window* target)
|
||||
{
|
||||
Event& e = _queue.AddOne();
|
||||
|
||||
@@ -64,6 +64,11 @@ public:
|
||||
return _state.MousePosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any mouse key is currently pressed.
|
||||
/// </summary>
|
||||
API_PROPERTY() bool IsAnyKeyDown() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the delta position of the mouse in the screen-space coordinates.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user