summaryrefslogtreecommitdiffhomepage
path: root/opentrack/shortcuts.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-05 23:32:43 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-05 23:32:43 +0100
commit86708a2311c1a3efd975798ff42d934eea0078ed (patch)
treefc13ca166c346fd30dbd01d712bb30d66d78feb4 /opentrack/shortcuts.h
parent578749c5b7f245aac08c4e514d2767dba059c4db (diff)
api/shortcuts: no longer keep shortcuts hardcoded
Diffstat (limited to 'opentrack/shortcuts.h')
-rw-r--r--opentrack/shortcuts.h34
1 files changed, 17 insertions, 17 deletions
diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h
index 8acc5ba5..4dec7c2c 100644
--- a/opentrack/shortcuts.h
+++ b/opentrack/shortcuts.h
@@ -8,6 +8,9 @@
#pragma once
#include <QObject>
+#include <tuple>
+#include <vector>
+#include <functional>
#ifdef BUILD_api
# include "opentrack-compat/export.hpp"
@@ -36,10 +39,10 @@ public:
Key
#endif
;
-
- K keyCenter;
- K keyToggle;
- K keyZero;
+
+ using fun = std::function<void(void)>;
+ using tt = std::tuple<K, fun>;
+ std::vector<tt> keys;
#ifdef _WIN32
KeybindingWorker::Token key_token;
#endif
@@ -56,32 +59,29 @@ public:
};
struct settings : opts {
- key_opts center, toggle, zero;
+ key_opts center, toggle, zero, start_tracking, stop_tracking, toggle_tracking;
main_settings s_main;
settings() :
opts("keyboard-shortcuts"),
center(b, "center"),
toggle(b, "toggle"),
- zero(b, "zero")
+ zero(b, "zero"),
+ start_tracking(b, "start-tracking"),
+ stop_tracking(b, "stop-tracking"),
+ toggle_tracking(b, "toggle-tracking")
{}
} s;
- Shortcuts()
+ Shortcuts() :
#ifdef _WIN32
- : key_token(KeybindingWorker::add_receiver([&](const Key& k) { receiver(k); }))
+ key_token([&](const Key& k) { receiver(k); })
#endif
- {
- reload();
- }
+ {}
- void reload();
+ void reload(const std::vector<std::tuple<Shortcuts::key_opts &, Shortcuts::fun> > &keys);
private:
- void bind_keyboard_shortcut(K &key, key_opts& k);
+ void bind_keyboard_shortcut(K &key, const key_opts& k);
#ifdef _WIN32
void receiver(const Key& k);
#endif
-signals:
- void center();
- void toggle();
- void zero();
};