rework API
This commit is contained in:
@@ -75,6 +75,23 @@ namespace OpenVulkano::Input
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InputManager::GetButtonDown(InputAction* action) const
|
||||
{
|
||||
const std::vector<InputDevice*>& 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->GetButtonDown(binding.key);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InputManager::GetButton(InputKey key) const
|
||||
{
|
||||
for(const InputDevice* device : devices)
|
||||
@@ -87,9 +104,13 @@ namespace OpenVulkano::Input
|
||||
|
||||
InputDevice* InputManager::GetDevice(InputDeviceType type) const
|
||||
{
|
||||
for (InputDevice* device: devices)
|
||||
if (type == InputDeviceType::UNKNOWN)
|
||||
{
|
||||
if (device->GetType() == type && type != InputDeviceType::UNKNOWN)
|
||||
return nullptr;
|
||||
}
|
||||
for (InputDevice* device : devices)
|
||||
{
|
||||
if (device->GetType() == type)
|
||||
{
|
||||
return device;
|
||||
}
|
||||
@@ -97,6 +118,24 @@ namespace OpenVulkano::Input
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<InputDevice*> InputManager::GetDevices(InputDeviceType type) const
|
||||
{
|
||||
if (type == InputDeviceType::UNKNOWN)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
std::vector<InputDevice*> devices;
|
||||
devices.reserve(this->devices.size());
|
||||
for (InputDevice* device : this->devices)
|
||||
{
|
||||
if (device->GetType() == type)
|
||||
{
|
||||
devices.push_back(device);
|
||||
}
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
||||
void InputManager::Tick()
|
||||
{
|
||||
for(InputDevice* device : devices)
|
||||
|
||||
Reference in New Issue
Block a user