summaryrefslogtreecommitdiffstats
path: root/src/hid_core/resources/touch_screen/gesture.cpp
blob: eaa0cc7d0b8ccd34714cfc5eafe44a8ef297f1ad (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#include "hid_core/resources/touch_screen/gesture.h"
#include "hid_core/resources/touch_screen/touch_screen_resource.h"

namespace Service::HID {

Gesture::Gesture(std::shared_ptr<TouchResource> resource) : touch_resource{resource} {}

Gesture::~Gesture() = default;

Result Gesture::Activate() {
    std::scoped_lock lock{mutex};

    // TODO: Result result = CreateThread();
    Result result = ResultSuccess;
    if (result.IsError()) {
        return result;
    }

    result = touch_resource->ActivateGesture();

    if (result.IsError()) {
        // TODO: StopThread();
    }

    return result;
}

Result Gesture::Activate(u64 aruid, u32 basic_gesture_id) {
    std::scoped_lock lock{mutex};
    return touch_resource->ActivateGesture(aruid, basic_gesture_id);
}

Result Gesture::Deactivate() {
    std::scoped_lock lock{mutex};
    const auto result = touch_resource->DeactivateGesture();

    if (result.IsError()) {
        return result;
    }

    // TODO: return StopThread();
    return ResultSuccess;
}

Result Gesture::IsActive(bool& out_is_active) const {
    out_is_active = touch_resource->IsGestureActive();
    return ResultSuccess;
}

} // namespace Service::HID