summaryrefslogtreecommitdiffhomepage
path: root/opentrack-logic/work.cpp
blob: 820112bf53fea2d6e3cea6cb4beaeb17385f8593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "work.hpp"


Work::Work(Mappings& m, SelectedLibraries& libs, WId handle) :
    libs(libs),
    tracker(std::make_shared<Tracker>(m, libs)),
    sc(std::make_shared<Shortcuts>()),
    handle(handle),
    keys {
        key_tuple(s.key_center, [&](bool) -> void { tracker->center(); }, true),
        key_tuple(s.key_toggle, [&](bool) -> void { tracker->toggle_enabled(); }, true),
        key_tuple(s.key_zero, [&](bool) -> void { tracker->zero(); }, true),
        key_tuple(s.key_toggle_press, [&](bool x) -> void { tracker->set_toggle(!x); }, false),
        key_tuple(s.key_zero_press, [&](bool x) -> void { tracker->set_zero(x); }, false),
        }
{
    reload_shortcuts();
    tracker->start();
}

void Work::reload_shortcuts()
{
    sc->reload(keys);
}

Work::~Work()
{
    sc = nullptr;
    // order matters, otherwise use-after-free -sh
    tracker = nullptr;
    libs = SelectedLibraries();
}