diff --git a/openVulkanoCpp/Input/InputManager.cpp b/openVulkanoCpp/Input/InputManager.cpp index 2c8ca5f..f9b68c6 100644 --- a/openVulkanoCpp/Input/InputManager.cpp +++ b/openVulkanoCpp/Input/InputManager.cpp @@ -61,7 +61,7 @@ namespace OpenVulkano::Input return value; } - bool InputManager::GetButton(InputAction* action) const + bool InputManager::GetButton(const InputAction* action) const { const std::vector& testDevices = action->GetDevices().empty() ? devices : action->GetDevices(); for (const InputDevice* device : testDevices) @@ -75,7 +75,7 @@ namespace OpenVulkano::Input return false; } - bool InputManager::GetButtonDown(InputAction* action) const + bool InputManager::GetButtonDown(const InputAction* action) const { const std::vector& testDevices = action->GetDevices().empty() ? devices : action->GetDevices(); for (const InputDevice* device : testDevices) @@ -92,6 +92,23 @@ namespace OpenVulkano::Input return false; } + bool InputManager::GetButtonUp(const InputAction* action) const + { + const std::vector& testDevices = action->GetDevices().empty() ? devices : action->GetDevices(); + for (const InputDevice* device : testDevices) + { + for (const KeyBinding binding : action->GetKeys()) + { + if (binding.key.GetInputDeviceType() != device->GetType()) + { + continue; + } + return device->GetButtonUp(binding.key); + } + } + return false; + } + bool InputManager::GetButton(InputKey key) const { for(const InputDevice* device : devices) @@ -102,6 +119,26 @@ namespace OpenVulkano::Input return false; } + bool InputManager::GetButtonUp(InputKey key) const + { + for(const InputDevice* device : devices) + { + if (key.GetInputDeviceType() != device->GetType()) continue; + return device->GetButtonUp(key); + } + return false; + } + + bool InputManager::GetButtonDown(InputKey key) const + { + for(const InputDevice* device : devices) + { + if (key.GetInputDeviceType() != device->GetType()) continue; + return device->GetButtonDown(key); + } + return false; + } + InputDevice* InputManager::GetDevice(InputDeviceType type) const { if (type == InputDeviceType::UNKNOWN) diff --git a/openVulkanoCpp/Input/InputManager.hpp b/openVulkanoCpp/Input/InputManager.hpp index 85a1673..a72ff72 100644 --- a/openVulkanoCpp/Input/InputManager.hpp +++ b/openVulkanoCpp/Input/InputManager.hpp @@ -35,16 +35,22 @@ namespace OpenVulkano::Input [[nodiscard]] InputAction* GetAction(const std::string& actionName); + [[nodiscard]] float GetAxis(const InputAction& action) const { return GetAxis(&action); } [[nodiscard]] float GetAxis(const InputAction* action) const; - [[nodiscard]] float GetAxis(InputKey key) const; - [[nodiscard]] bool GetButton(InputAction* action) const; - - [[nodiscard]] bool GetButtonDown(InputAction* action) const; - + [[nodiscard]] bool GetButton(const InputAction& action) const { return GetButton(&action); } + [[nodiscard]] bool GetButton(const InputAction* action) const; [[nodiscard]] bool GetButton(InputKey key) const; + [[nodiscard]] bool GetButtonUp(const InputAction& action) const { return GetButtonUp(&action); } + [[nodiscard]] bool GetButtonUp(const InputAction* action) const; + [[nodiscard]] bool GetButtonUp(InputKey key) const; + + [[nodiscard]] bool GetButtonDown(const InputAction& action) const { return GetButtonDown(&action); } + [[nodiscard]] bool GetButtonDown(const InputAction* action) const; + [[nodiscard]] bool GetButtonDown(InputKey key) const; + [[nodiscard]] InputDevice* GetDevice(InputDeviceType type) const; [[nodiscard]] std::vector GetDevices(InputDeviceType type) const;