Single instance

This commit is contained in:
2026-10-18 16:59:51 +02:00
parent 798708b3e7
commit 74503c27dd
19 changed files with 670 additions and 99 deletions

View File

@@ -2,7 +2,9 @@
#ifndef GKEYMAPPER_DAEMON_ACTION_H
#define GKEYMAPPER_DAEMON_ACTION_H
#include <array>
#include <string>
#include <vector>
#include "keymap.h"
#include "mapping.h"
@@ -18,6 +20,19 @@ public:
void run(const gkeymapper::Mapping& mapping);
// "keyhold": presses the keys of the mapping and keeps them down until the G
// key is released. Returns whether anything is being held; a sequence, an
// unusable target or a missing virtual keyboard fall back to a tap (false),
// so the caller does not have to special-case them. Releasing index 0..8 is
// done by end_hold(), all of them at once by release_held().
bool begin_hold(int index, const gkeymapper::Mapping& mapping);
void end_hold(int index);
// Let go of every held key. Called on device loss, on shutdown and before a
// new device is claimed: a virtual key that stayed down because its release
// report never arrived would look like a stuck key to the whole session.
void release_held();
// Replays one key press + release. Used by the media-key passthrough, which
// is not a mapping: the keyboard reports mute/volume/play only on the
// interface the daemon holds, so they are forwarded verbatim.
@@ -26,8 +41,15 @@ public:
private:
void run_command(const std::string& command);
// Parses mapping.target through the active layout. Logs and returns false on
// an invalid shortcut.
bool resolve_shortcut(const std::string& target,
std::vector<gkeymapper::ShortcutStep>& steps);
UinputKeyboard keyboard_;
gkeymapper::Keymap keymap_;
// Codes each G key (0 = G1) currently keeps down, empty when not holding.
std::array<std::vector<unsigned short>, gkeymapper::kNumKeys> held_{};
};
} // namespace gkeymapper::daemon