mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 22:49:00 +01:00
WiimoteDevice: Move channel state booleans into a struct
These were essentially duplicated for both channels, when they could be implemented in terms of a struct, which allows for simplifying the reset case.
This commit is contained in:
parent
94fd8505d6
commit
647da59679
@ -96,14 +96,14 @@ void WiimoteDevice::DoState(PointerWrap& p)
|
|||||||
|
|
||||||
p.Do(m_ConnectionState);
|
p.Do(m_ConnectionState);
|
||||||
|
|
||||||
p.Do(m_HIDControlChannel_Connected);
|
p.Do(m_hid_control_channel.connected);
|
||||||
p.Do(m_HIDControlChannel_ConnectedWait);
|
p.Do(m_hid_control_channel.connected_wait);
|
||||||
p.Do(m_HIDControlChannel_Config);
|
p.Do(m_hid_control_channel.config);
|
||||||
p.Do(m_HIDControlChannel_ConfigWait);
|
p.Do(m_hid_control_channel.config_wait);
|
||||||
p.Do(m_HIDInterruptChannel_Connected);
|
p.Do(m_hid_interrupt_channel.connected);
|
||||||
p.Do(m_HIDInterruptChannel_ConnectedWait);
|
p.Do(m_hid_interrupt_channel.connected_wait);
|
||||||
p.Do(m_HIDInterruptChannel_Config);
|
p.Do(m_hid_interrupt_channel.config);
|
||||||
p.Do(m_HIDInterruptChannel_ConfigWait);
|
p.Do(m_hid_interrupt_channel.config_wait);
|
||||||
|
|
||||||
p.Do(m_BD);
|
p.Do(m_BD);
|
||||||
p.Do(m_ConnectionHandle);
|
p.Do(m_ConnectionHandle);
|
||||||
@ -134,45 +134,45 @@ bool WiimoteDevice::LinkChannel()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// try to connect L2CAP_PSM_HID_CNTL
|
// try to connect L2CAP_PSM_HID_CNTL
|
||||||
if (!m_HIDControlChannel_Connected)
|
if (!m_hid_control_channel.connected)
|
||||||
{
|
{
|
||||||
if (m_HIDControlChannel_ConnectedWait)
|
if (m_hid_control_channel.connected_wait)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_HIDControlChannel_ConnectedWait = true;
|
m_hid_control_channel.connected_wait = true;
|
||||||
SendConnectionRequest(0x0040, L2CAP_PSM_HID_CNTL);
|
SendConnectionRequest(0x0040, L2CAP_PSM_HID_CNTL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to config L2CAP_PSM_HID_CNTL
|
// try to config L2CAP_PSM_HID_CNTL
|
||||||
if (!m_HIDControlChannel_Config)
|
if (!m_hid_control_channel.config)
|
||||||
{
|
{
|
||||||
if (m_HIDControlChannel_ConfigWait)
|
if (m_hid_control_channel.config_wait)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_HIDControlChannel_ConfigWait = true;
|
m_hid_control_channel.config_wait = true;
|
||||||
SendConfigurationRequest(0x0040);
|
SendConfigurationRequest(0x0040);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to connect L2CAP_PSM_HID_INTR
|
// try to connect L2CAP_PSM_HID_INTR
|
||||||
if (!m_HIDInterruptChannel_Connected)
|
if (!m_hid_interrupt_channel.connected)
|
||||||
{
|
{
|
||||||
if (m_HIDInterruptChannel_ConnectedWait)
|
if (m_hid_interrupt_channel.connected_wait)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_HIDInterruptChannel_ConnectedWait = true;
|
m_hid_interrupt_channel.connected_wait = true;
|
||||||
SendConnectionRequest(0x0041, L2CAP_PSM_HID_INTR);
|
SendConnectionRequest(0x0041, L2CAP_PSM_HID_INTR);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to config L2CAP_PSM_HID_INTR
|
// try to config L2CAP_PSM_HID_INTR
|
||||||
if (!m_HIDInterruptChannel_Config)
|
if (!m_hid_interrupt_channel.config)
|
||||||
{
|
{
|
||||||
if (m_HIDInterruptChannel_ConfigWait)
|
if (m_hid_interrupt_channel.config_wait)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_HIDInterruptChannel_ConfigWait = true;
|
m_hid_interrupt_channel.config_wait = true;
|
||||||
SendConfigurationRequest(0x0041);
|
SendConfigurationRequest(0x0041);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -230,14 +230,8 @@ bool WiimoteDevice::EventPagingChanged(u8 page_mode) const
|
|||||||
void WiimoteDevice::ResetChannels()
|
void WiimoteDevice::ResetChannels()
|
||||||
{
|
{
|
||||||
// reset connection process
|
// reset connection process
|
||||||
m_HIDControlChannel_Connected = false;
|
m_hid_control_channel = {};
|
||||||
m_HIDControlChannel_Config = false;
|
m_hid_interrupt_channel = {};
|
||||||
m_HIDInterruptChannel_Connected = false;
|
|
||||||
m_HIDInterruptChannel_Config = false;
|
|
||||||
m_HIDControlChannel_ConnectedWait = false;
|
|
||||||
m_HIDControlChannel_ConfigWait = false;
|
|
||||||
m_HIDInterruptChannel_ConnectedWait = false;
|
|
||||||
m_HIDInterruptChannel_ConfigWait = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -422,9 +416,9 @@ void WiimoteDevice::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size)
|
|||||||
|
|
||||||
// update state machine
|
// update state machine
|
||||||
if (rChannel.PSM == L2CAP_PSM_HID_CNTL)
|
if (rChannel.PSM == L2CAP_PSM_HID_CNTL)
|
||||||
m_HIDControlChannel_Connected = true;
|
m_hid_control_channel.connected = true;
|
||||||
else if (rChannel.PSM == L2CAP_PSM_HID_INTR)
|
else if (rChannel.PSM == L2CAP_PSM_HID_INTR)
|
||||||
m_HIDInterruptChannel_Connected = true;
|
m_hid_interrupt_channel.connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimoteDevice::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size)
|
void WiimoteDevice::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size)
|
||||||
@ -498,9 +492,9 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size)
|
|||||||
|
|
||||||
// update state machine
|
// update state machine
|
||||||
if (rChannel.PSM == L2CAP_PSM_HID_CNTL)
|
if (rChannel.PSM == L2CAP_PSM_HID_CNTL)
|
||||||
m_HIDControlChannel_Connected = true;
|
m_hid_control_channel.connected = true;
|
||||||
else if (rChannel.PSM == L2CAP_PSM_HID_INTR)
|
else if (rChannel.PSM == L2CAP_PSM_HID_INTR)
|
||||||
m_HIDInterruptChannel_Connected = true;
|
m_hid_interrupt_channel.connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimoteDevice::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size)
|
void WiimoteDevice::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size)
|
||||||
@ -518,9 +512,9 @@ void WiimoteDevice::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Siz
|
|||||||
SChannel& rChannel = m_Channel[rsp->scid];
|
SChannel& rChannel = m_Channel[rsp->scid];
|
||||||
|
|
||||||
if (rChannel.PSM == L2CAP_PSM_HID_CNTL)
|
if (rChannel.PSM == L2CAP_PSM_HID_CNTL)
|
||||||
m_HIDControlChannel_Config = true;
|
m_hid_control_channel.config = true;
|
||||||
else if (rChannel.PSM == L2CAP_PSM_HID_INTR)
|
else if (rChannel.PSM == L2CAP_PSM_HID_INTR)
|
||||||
m_HIDInterruptChannel_Config = true;
|
m_hid_interrupt_channel.config = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimoteDevice::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size)
|
void WiimoteDevice::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size)
|
||||||
|
@ -61,16 +61,18 @@ private:
|
|||||||
Complete
|
Complete
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct HIDChannelState
|
||||||
|
{
|
||||||
|
bool connected = false;
|
||||||
|
bool connected_wait = false;
|
||||||
|
bool config = false;
|
||||||
|
bool config_wait = false;
|
||||||
|
};
|
||||||
|
|
||||||
ConnectionState m_ConnectionState;
|
ConnectionState m_ConnectionState;
|
||||||
|
|
||||||
bool m_HIDControlChannel_Connected = false;
|
HIDChannelState m_hid_control_channel;
|
||||||
bool m_HIDControlChannel_ConnectedWait = false;
|
HIDChannelState m_hid_interrupt_channel;
|
||||||
bool m_HIDControlChannel_Config = false;
|
|
||||||
bool m_HIDControlChannel_ConfigWait = false;
|
|
||||||
bool m_HIDInterruptChannel_Connected = false;
|
|
||||||
bool m_HIDInterruptChannel_ConnectedWait = false;
|
|
||||||
bool m_HIDInterruptChannel_Config = false;
|
|
||||||
bool m_HIDInterruptChannel_ConfigWait = false;
|
|
||||||
|
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
bdaddr_t m_BD;
|
bdaddr_t m_BD;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user