htc: skeleton constructors for htcmisc

This commit is contained in:
Michael Scire 2021-02-09 20:43:40 -08:00 committed by SciresM
parent b925344c3b
commit 1f03b11dbc
12 changed files with 310 additions and 6 deletions

View file

@ -351,6 +351,22 @@ namespace ams::htclow::ctrl {
this->DisconnectInternal();
}
void HtcctrlService::DisconnectInternal() {
/* Disconnect, if we need to. */
if (m_state_machine->IsDisconnectionNeeded()) {
/* Send a disconnect packet. */
m_send_buffer.AddPacket(m_packet_factory->MakeDisconnectPacket());
/* Signal our event. */
m_event.Signal();
/* Wait for us to be disconnected. */
while (!m_state_machine->IsDisconnected()) {
m_condvar.Wait(m_mutex);
}
}
}
void HtcctrlService::Resume() {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);

View file

@ -64,6 +64,13 @@ namespace ams::htclow::ctrl {
return !ctrl::IsDisconnected(m_state) && m_state != HtcctrlState_DriverConnected;
}
bool HtcctrlStateMachine::IsDisconnectionNeeded() {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);
return !ctrl::IsDisconnected(m_state) && m_state != HtcctrlState_Sleep && m_state != HtcctrlState_DriverConnected;
}
bool HtcctrlStateMachine::IsConnected() {
/* Lock ourselves. */
std::scoped_lock lk(m_mutex);

View file

@ -59,6 +59,7 @@ namespace ams::htclow::ctrl {
bool IsSleepingStatusChanged();
bool IsInformationNeeded();
bool IsDisconnectionNeeded();
bool IsConnected();
bool IsReadied();

View file

@ -16,9 +16,17 @@
#include <stratosphere.hpp>
#include "htclow_mux_channel_impl.hpp"
#include "../htclow_packet_factory.hpp"
#include "../htclow_default_channel_config.hpp"
namespace ams::htclow::mux {
SendBuffer::SendBuffer(impl::ChannelInternalType channel, PacketFactory *pf)
: m_channel(channel), m_packet_factory(pf), m_ring_buffer(), m_packet_list(),
m_version(ProtocolVersion), m_flow_control_enabled(true), m_max_packet_size(DefaultChannelConfig.max_packet_size)
{
/* ... */
}
SendBuffer::~SendBuffer() {
m_ring_buffer.Clear();
this->Clear();