summaryrefslogtreecommitdiffstats
path: root/src/hid_core/resources/controller_base.cpp
blob: df5f5c884f6b3b0a328ec6865bdbb488c0c58b6d (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
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "hid_core/resources/controller_base.h"

namespace Service::HID {

ControllerBase::ControllerBase(Core::HID::HIDCore& hid_core_) : hid_core(hid_core_) {}
ControllerBase::~ControllerBase() = default;

Result ControllerBase::Activate() {
    if (is_activated) {
        return ResultSuccess;
    }
    is_activated = true;
    OnInit();
    return ResultSuccess;
}

Result ControllerBase::Activate(u64 aruid) {
    return Activate();
}

void ControllerBase::DeactivateController() {
    if (is_activated) {
        OnRelease();
    }
    is_activated = false;
}

bool ControllerBase::IsControllerActivated() const {
    return is_activated;
}

void ControllerBase::SetAppletResource(std::shared_ptr<AppletResource> resource,
                                       std::recursive_mutex* resource_mutex) {
    applet_resource = resource;
    shared_mutex = resource_mutex;
}

} // namespace Service::HID