17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-22 02:56:24 +02:00

feat(editor): scripted mouse and keys of a self-test are delivered between frames like real input events, so a press seen by ImGui starts a drag as it does by hand; while a script drives the input the real mouse and keyboard are ignored

This commit is contained in:
maj00r
2026-10-15 17:29:04 +02:00
parent 92aa39ce6e
commit 2a3d7f2e29
5 changed files with 73 additions and 22 deletions

View File

@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include <functional>
#include <optional>
#include <sstream>
#include <string>
@@ -20,16 +21,23 @@ class scripted_input
{
public:
bool dispatch(std::string const &Command, std::istringstream &Words);
void deliver();
void mouse_to(glm::dvec2 const &Screen);
std::optional<glm::dvec2> const &mouse() const
{
return m_mouse;
}
static bool driving()
{
return s_driving;
}
private:
void modifiers() const;
void queue(std::function<void()> Event);
std::optional<glm::dvec2> m_mouse;
int m_mods{0};
std::vector<std::function<void()>> m_events;
static inline bool s_driving{false};
};
class input_script
@@ -37,6 +45,10 @@ class input_script
public:
explicit input_script(char const *Variable) : m_variable{Variable} {}
void step();
void deliver()
{
m_input.deliver();
}
private:
char const *m_variable;