mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-01 15:28:21 -04:00
htc: skeleton constructors for htcmisc
This commit is contained in:
parent
b925344c3b
commit
1f03b11dbc
12 changed files with 310 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace ams::htclow::ctrl {
|
|||
bool IsSleepingStatusChanged();
|
||||
|
||||
bool IsInformationNeeded();
|
||||
bool IsDisconnectionNeeded();
|
||||
|
||||
bool IsConnected();
|
||||
bool IsReadied();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue