Replace magic disconnect channel number with a constant

This commit is contained in:
Pokechu22 2019-11-10 12:55:29 -08:00
parent 5477409847
commit a23609562d
4 changed files with 6 additions and 3 deletions

View File

@ -63,6 +63,8 @@ enum class InitializeMode
// The Real Wii Remote sends report every ~5ms (200 Hz).
constexpr int UPDATE_FREQ = 200;
// Custom channel ID used in ControlChannel to indicate disconnects
constexpr int DOLPHIN_DISCONNET_CONTROL_CHANNEL = 99;
void Shutdown();
void Initialize(InitializeMode init_mode);

View File

@ -572,7 +572,7 @@ void Wiimote::SendDataReport()
void Wiimote::ControlChannel(const u16 channel_id, const void* data, u32 size)
{
// Check for custom communication
if (99 == channel_id)
if (channel_id == ::Wiimote::DOLPHIN_DISCONNET_CONTROL_CHANNEL)
{
// Wii Remote disconnected.
Reset();

View File

@ -143,7 +143,7 @@ void Wiimote::ClearReadQueue()
void Wiimote::ControlChannel(const u16 channel, const void* const data, const u32 size)
{
// Check for custom communication
if (channel == 99)
if (channel == ::Wiimote::DOLPHIN_DISCONNET_CONTROL_CHANNEL)
{
if (m_really_disconnect)
{

View File

@ -218,7 +218,8 @@ void WiimoteDevice::EventConnectionAccepted()
void WiimoteDevice::EventDisconnect()
{
// Send disconnect message to plugin
Wiimote::ControlChannel(m_connection_handle & 0xFF, 99, nullptr, 0);
Wiimote::ControlChannel(m_connection_handle & 0xFF, Wiimote::DOLPHIN_DISCONNET_CONTROL_CHANNEL,
nullptr, 0);
m_connection_state = ConnectionState::Inactive;