diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-04-29 09:21:10 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-04-29 09:21:23 +0200 |
commit | 3a7011ff73cce39ecacb4c5651c1a2dbda8eb10e (patch) | |
tree | 84d21d48998aaacbad9cb27b7e5edf29b0dd1396 /opentrack/work.hpp | |
parent | 69cc802722c8264c0fd8b138a298d4820c11f1d8 (diff) |
api, main: implement new keybindings
The following keybindings are now implemented:
- restart tracking. if not started, starts.
- toggle (keep position) while key held
- zero (keep zero) while key held
The latter two options only work for Windows as libqxt doesn't support
them.
Closes #291
Diffstat (limited to 'opentrack/work.hpp')
-rwxr-xr-x[-rw-r--r--] | opentrack/work.hpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/opentrack/work.hpp b/opentrack/work.hpp index 4188b937..3b65ba52 100644..100755 --- a/opentrack/work.hpp +++ b/opentrack/work.hpp @@ -27,9 +27,9 @@ struct Work mem<Tracker> tracker; mem<Shortcuts> sc; WId handle; - using fn = std::function<void(void)>; - using tt = std::tuple<key_opts&, fn>; - std::vector<std::tuple<key_opts&, fn>> keys; + using fn = std::function<void(bool)>; + using tt = std::tuple<key_opts&, fn, bool>; + std::vector<tt> keys; Work(main_settings& s, Mappings& m, SelectedLibraries& libs, WId handle) : s(s), libs(libs), @@ -37,13 +37,15 @@ struct Work sc(std::make_shared<Shortcuts>()), handle(handle), keys { - tt(s.key_center, [&]() -> void { tracker->center(); }), - tt(s.key_toggle, [&]() -> void { tracker->toggle_enabled(); }), - tt(s.key_zero, [&]() -> void { tracker->zero(); }), + tt(s.key_center, [&](bool) -> void { tracker->center(); }, true), + tt(s.key_toggle, [&](bool) -> void { tracker->toggle_enabled(); }, true), + tt(s.key_zero, [&](bool) -> void { tracker->zero(); }, true), + tt(s.key_toggle_press, [&](bool x) -> void { tracker->set_toggle(!x); }, false), + tt(s.key_zero_press, [&](bool x) -> void { tracker->set_zero(x); }, false), } { reload_shortcuts(); - tracker->start(); + tracker->start(); } void reload_shortcuts() |