Refactoring of Input Devices
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "InputDeviceGLFW.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace openVulkanoCpp::GLFW
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "InputProviderGLFW.hpp"
|
||||
#include "InputMappingGLFW.hpp"
|
||||
#include "Input/InputManager.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
static_assert(GLFW_JOYSTICK_LAST == 15); // if this fails, please update it and resize the controllers array accordingly as GLFW_JOYSTICK_LAST + 1
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "PlatformGLFW.hpp"
|
||||
#include "WindowGLFW.hpp"
|
||||
#include "Base/PlatformEnums.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include "Host/PlatformProducer.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "Base/IPlatform.hpp"
|
||||
#include "InputProviderGLFW.hpp"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace openVulkanoCpp
|
||||
{
|
||||
|
||||
26
openVulkanoCpp/Input/InputDeviceController.cpp
Normal file
26
openVulkanoCpp/Input/InputDeviceController.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "InputDeviceController.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
|
||||
namespace openVulkanoCpp::Input
|
||||
{
|
||||
void InputDeviceController::Init(const int index, const std::string& name)
|
||||
{
|
||||
InputDevice::Init(InputDeviceType::CONTROLLER, index, name);
|
||||
|
||||
pressedButtons = 0;
|
||||
lastPressedButtons = 0;
|
||||
for(float& axis : axes)
|
||||
{
|
||||
axis = 0;
|
||||
}
|
||||
|
||||
// TODO find controller type from name
|
||||
Logger::INPUT->info("Initialized controller: id: {0}, name: {1}", index, name);
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Base/Logger.hpp"
|
||||
#include "InputDevice.hpp"
|
||||
#include <cstring>
|
||||
|
||||
namespace openVulkanoCpp
|
||||
{
|
||||
namespace Input
|
||||
namespace openVulkanoCpp::Input
|
||||
{
|
||||
class ControllerType
|
||||
{
|
||||
@@ -40,20 +36,7 @@ namespace openVulkanoCpp
|
||||
protected:
|
||||
InputDeviceController() = default;
|
||||
|
||||
void Init(const int index, const std::string& name)
|
||||
{
|
||||
InputDevice::Init(InputDeviceType::CONTROLLER, index, name);
|
||||
|
||||
pressedButtons = 0;
|
||||
lastPressedButtons = 0;
|
||||
for(float& axis : axes)
|
||||
{
|
||||
axis = 0;
|
||||
}
|
||||
|
||||
// TODO find controller type from name
|
||||
Logger::INPUT->info("Initialized controller: id: {0}, name: {1}", index, name);
|
||||
}
|
||||
void Init(int index, const std::string& name);
|
||||
|
||||
void SetAxis(InputKey::Controller::Axis axisId, float value)
|
||||
{
|
||||
@@ -113,4 +96,3 @@ namespace openVulkanoCpp
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace openVulkanoCpp
|
||||
{
|
||||
namespace Input
|
||||
namespace openVulkanoCpp::Input
|
||||
{
|
||||
enum class InputDeviceType : uint8_t
|
||||
{
|
||||
UNKNOWN, KEYBOARD, MOUSE, CONTROLLER
|
||||
UNKNOWN, KEYBOARD, MOUSE, CONTROLLER, TOUCH
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user