diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-08-28 11:20:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-28 11:20:29 +0200 |
| commit | 81bf4eccba449bfe2b6adfb51260108aec710d4f (patch) | |
| tree | 215c5b536cbcf1df9888081aadd3de16eb4b3ebe /hyprtester/plugin/src/main.cpp | |
| parent | 378e130f1426648d8d734049800128f9882805bf (diff) | |
input: Add fully configurable trackpad gestures (#11490)
Adds configurable trackpad gestures
Diffstat (limited to 'hyprtester/plugin/src/main.cpp')
| -rw-r--r-- | hyprtester/plugin/src/main.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/hyprtester/plugin/src/main.cpp b/hyprtester/plugin/src/main.cpp index 7eeb2eea..03035918 100644 --- a/hyprtester/plugin/src/main.cpp +++ b/hyprtester/plugin/src/main.cpp @@ -9,11 +9,14 @@ #include <src/layout/IHyprLayout.hpp> #include <src/managers/LayoutManager.hpp> #include <src/managers/input/InputManager.hpp> +#include <src/managers/input/trackpad/TrackpadGestures.hpp> #include <src/Compositor.hpp> #undef private #include <hyprutils/utils/ScopeGuard.hpp> +#include <hyprutils/string/VarList.hpp> using namespace Hyprutils::Utils; +using namespace Hyprutils::String; #include "globals.hpp" @@ -88,6 +91,41 @@ class CTestKeyboard : public IKeyboard { bool m_isVirtual; }; +static SDispatchResult pressAlt(std::string in) { + g_pInputManager->m_lastMods = in == "1" ? HL_MODIFIER_ALT : 0; + + return {.success = true}; +} + +static SDispatchResult simulateGesture(std::string in) { + CVarList data(in); + + uint32_t fingers = 3; + try { + fingers = std::stoul(data[1]); + } catch (...) { return {.success = false}; } + + if (data[0] == "down") { + g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{}); + g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {0, 300}}); + g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{}); + } else if (data[0] == "up") { + g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{}); + g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {0, -300}}); + g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{}); + } else if (data[0] == "left") { + g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{}); + g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {-300, 0}}); + g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{}); + } else { + g_pTrackpadGestures->gestureBegin(IPointer::SSwipeBeginEvent{}); + g_pTrackpadGestures->gestureUpdate(IPointer::SSwipeUpdateEvent{.fingers = fingers, .delta = {300, 0}}); + g_pTrackpadGestures->gestureEnd(IPointer::SSwipeEndEvent{}); + } + + return {.success = true}; +} + static SDispatchResult vkb(std::string in) { auto tkb0 = CTestKeyboard::create(false); auto tkb1 = CTestKeyboard::create(false); @@ -141,6 +179,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:test", ::test); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:snapmove", ::snapMove); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:vkb", ::vkb); + HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:alt", ::pressAlt); + HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:gesture", ::simulateGesture); return {"hyprtestplugin", "hyprtestplugin", "Vaxry", "1.0"}; } |
