Add first draft for input handling for ImGuiOpenVulkano backend
This commit is contained in:
@@ -6,11 +6,19 @@
|
||||
|
||||
#include "ImGuiImplOpenVulkano.hpp"
|
||||
#include "Base/FrameMetadata.hpp"
|
||||
#include "Input/InputManager.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include <imgui.h>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
ImGuiImplOpenVulkano ImGuiImplOpenVulkano::INSTANCE{};
|
||||
|
||||
namespace {
|
||||
Input::InputAction pressed("ImGuiMousePressed");
|
||||
Input::InputAction positionX("ImGuiMousePositionX");
|
||||
Input::InputAction positionY("ImGuiMousePositionY");
|
||||
}
|
||||
|
||||
void ImGuiImplOpenVulkano::Init(OpenVulkano::IWindow* window)
|
||||
{
|
||||
@@ -29,6 +37,17 @@ namespace OpenVulkano
|
||||
|
||||
ImGuiViewport* mainViewport = ImGui::GetMainViewport();
|
||||
mainViewport->PlatformHandle = m_window;
|
||||
|
||||
pressed.BindKey(Input::InputKey::Mouse::BUTTON_1);
|
||||
pressed.BindKey(Input::InputKey::Touch::BUTTON_TAP);
|
||||
pressed.BindKey(Input::InputKey::Touch::BUTTON_PAN);
|
||||
|
||||
positionX.BindKey(Input::InputKey::Mouse::AXIS_X_ABS);
|
||||
positionX.BindKey(Input::InputKey::Touch::AXIS_TAP_X_ABS);
|
||||
positionX.BindKey(Input::InputKey::Touch::AXIS_PAN_X_ABS);
|
||||
positionY.BindKey(Input::InputKey::Mouse::AXIS_Y_ABS);
|
||||
positionY.BindKey(Input::InputKey::Touch::AXIS_TAP_Y_ABS);
|
||||
positionY.BindKey(Input::InputKey::Touch::AXIS_PAN_Y_ABS);
|
||||
}
|
||||
|
||||
void ImGuiImplOpenVulkano::NewFrame()
|
||||
@@ -54,6 +73,9 @@ namespace OpenVulkano
|
||||
io.DeltaTime = CURRENT_FRAME.frameTime;
|
||||
|
||||
//TODO handle inputs
|
||||
auto input = Input::InputManager::GetInstance();
|
||||
auto p = io.MousePos = { input->GetAxis(&positionX) / io.DisplayFramebufferScale.x, input->GetAxis(&positionY) / io.DisplayFramebufferScale.y };
|
||||
io.MouseDown[0] = input->GetButton(&pressed);
|
||||
}
|
||||
|
||||
void ImGuiImplOpenVulkano::Close()
|
||||
|
||||
Reference in New Issue
Block a user