2021-02-09 14:16:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stratosphere.hpp>
|
|
|
|
#include "htc_htcmisc_impl.hpp"
|
|
|
|
|
|
|
|
namespace ams::htc::server {
|
|
|
|
|
|
|
|
class Observer {
|
|
|
|
private:
|
|
|
|
os::SystemEvent m_connect_event;
|
|
|
|
os::SystemEvent m_disconnect_event;
|
2021-02-10 04:43:40 +00:00
|
|
|
os::Event m_stop_event;
|
2021-02-09 14:16:43 +00:00
|
|
|
os::ThreadType m_observer_thread;
|
|
|
|
const HtcmiscImpl &m_misc_impl;
|
|
|
|
bool m_thread_running;
|
|
|
|
bool m_stopped;
|
|
|
|
bool m_connected;
|
|
|
|
bool m_is_service_available;
|
2021-02-10 04:43:40 +00:00
|
|
|
alignas(os::ThreadStackAlignment) u8 m_observer_thread_stack[os::MemoryPageSize];
|
2021-02-09 14:16:43 +00:00
|
|
|
public:
|
|
|
|
Observer(const HtcmiscImpl &misc_impl);
|
2021-02-10 04:43:40 +00:00
|
|
|
private:
|
|
|
|
static void ObserverThreadEntry(void *arg) { static_cast<Observer *>(arg)->ObserverThreadBody(); }
|
|
|
|
|
|
|
|
void ObserverThreadBody();
|
|
|
|
private:
|
|
|
|
Result Start();
|
|
|
|
|
|
|
|
void UpdateEvent();
|
2021-02-09 14:16:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|