mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 11:31:46 +02:00
WiimoteDevice: Make ConnectionState enum an enum class
Avoids polluting class scope and makes it strongly typed.
This commit is contained in:
parent
f564c28040
commit
38d155f993
@ -56,7 +56,7 @@ WiimoteDevice::WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd
|
|||||||
{
|
{
|
||||||
INFO_LOG(IOS_WIIMOTE, "Wiimote: #%i Constructed", number);
|
INFO_LOG(IOS_WIIMOTE, "Wiimote: #%i Constructed", number);
|
||||||
|
|
||||||
m_ConnectionState = (ready) ? CONN_READY : CONN_INACTIVE;
|
m_ConnectionState = ready ? ConnectionState::Ready : ConnectionState::Inactive;
|
||||||
m_ConnectionHandle = 0x100 + number;
|
m_ConnectionHandle = 0x100 + number;
|
||||||
memset(m_LinkKey, 0xA0 + number, HCI_KEY_SIZE);
|
memset(m_LinkKey, 0xA0 + number, HCI_KEY_SIZE);
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ void WiimoteDevice::DoState(PointerWrap& p)
|
|||||||
|
|
||||||
bool WiimoteDevice::LinkChannel()
|
bool WiimoteDevice::LinkChannel()
|
||||||
{
|
{
|
||||||
if (m_ConnectionState != CONN_LINKING)
|
if (m_ConnectionState != ConnectionState::Linking)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// try to connect L2CAP_PSM_HID_CNTL
|
// try to connect L2CAP_PSM_HID_CNTL
|
||||||
@ -178,7 +178,7 @@ bool WiimoteDevice::LinkChannel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "ConnectionState CONN_LINKING -> CONN_COMPLETE");
|
DEBUG_LOG(IOS_WIIMOTE, "ConnectionState CONN_LINKING -> CONN_COMPLETE");
|
||||||
m_ConnectionState = CONN_COMPLETE;
|
m_ConnectionState = ConnectionState::Complete;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -195,9 +195,9 @@ bool WiimoteDevice::LinkChannel()
|
|||||||
//
|
//
|
||||||
void WiimoteDevice::Activate(bool ready)
|
void WiimoteDevice::Activate(bool ready)
|
||||||
{
|
{
|
||||||
if (ready && (m_ConnectionState == CONN_INACTIVE))
|
if (ready && (m_ConnectionState == ConnectionState::Inactive))
|
||||||
{
|
{
|
||||||
m_ConnectionState = CONN_READY;
|
m_ConnectionState = ConnectionState::Ready;
|
||||||
}
|
}
|
||||||
else if (!ready)
|
else if (!ready)
|
||||||
{
|
{
|
||||||
@ -209,7 +209,7 @@ void WiimoteDevice::Activate(bool ready)
|
|||||||
void WiimoteDevice::EventConnectionAccepted()
|
void WiimoteDevice::EventConnectionAccepted()
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "ConnectionState %x -> CONN_LINKING", m_ConnectionState);
|
DEBUG_LOG(IOS_WIIMOTE, "ConnectionState %x -> CONN_LINKING", m_ConnectionState);
|
||||||
m_ConnectionState = CONN_LINKING;
|
m_ConnectionState = ConnectionState::Linking;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimoteDevice::EventDisconnect()
|
void WiimoteDevice::EventDisconnect()
|
||||||
@ -217,17 +217,14 @@ void WiimoteDevice::EventDisconnect()
|
|||||||
// Send disconnect message to plugin
|
// Send disconnect message to plugin
|
||||||
Wiimote::ControlChannel(m_ConnectionHandle & 0xFF, 99, nullptr, 0);
|
Wiimote::ControlChannel(m_ConnectionHandle & 0xFF, 99, nullptr, 0);
|
||||||
|
|
||||||
m_ConnectionState = CONN_INACTIVE;
|
m_ConnectionState = ConnectionState::Inactive;
|
||||||
// Clear channel flags
|
// Clear channel flags
|
||||||
ResetChannels();
|
ResetChannels();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WiimoteDevice::EventPagingChanged(u8 _pageMode)
|
bool WiimoteDevice::EventPagingChanged(u8 page_mode)
|
||||||
{
|
{
|
||||||
if ((m_ConnectionState == CONN_READY) && (_pageMode & HCI_PAGE_SCAN_ENABLE))
|
return (m_ConnectionState == ConnectionState::Ready) && (page_mode & HCI_PAGE_SCAN_ENABLE);
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimoteDevice::ResetChannels()
|
void WiimoteDevice::ResetChannels()
|
||||||
|
@ -30,8 +30,8 @@ public:
|
|||||||
// ugly Host handling....
|
// ugly Host handling....
|
||||||
// we really have to clean all this code
|
// we really have to clean all this code
|
||||||
|
|
||||||
bool IsConnected() const { return m_ConnectionState == CONN_COMPLETE; }
|
bool IsConnected() const { return m_ConnectionState == ConnectionState::Complete; }
|
||||||
bool IsInactive() const { return m_ConnectionState == CONN_INACTIVE; }
|
bool IsInactive() const { return m_ConnectionState == ConnectionState::Inactive; }
|
||||||
bool LinkChannel();
|
bool LinkChannel();
|
||||||
void ResetChannels();
|
void ResetChannels();
|
||||||
void Activate(bool ready);
|
void Activate(bool ready);
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
void EventConnectionAccepted();
|
void EventConnectionAccepted();
|
||||||
void EventDisconnect();
|
void EventDisconnect();
|
||||||
bool EventPagingChanged(u8 _pageMode);
|
bool EventPagingChanged(u8 page_mode);
|
||||||
|
|
||||||
const bdaddr_t& GetBD() const { return m_BD; }
|
const bdaddr_t& GetBD() const { return m_BD; }
|
||||||
const uint8_t* GetClass() const { return uclass; }
|
const uint8_t* GetClass() const { return uclass; }
|
||||||
@ -53,13 +53,14 @@ public:
|
|||||||
const u8* GetLinkKey() const { return m_LinkKey; }
|
const u8* GetLinkKey() const { return m_LinkKey; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum ConnectionState
|
enum class ConnectionState
|
||||||
{
|
{
|
||||||
CONN_INACTIVE = -1,
|
Inactive = -1,
|
||||||
CONN_READY,
|
Ready,
|
||||||
CONN_LINKING,
|
Linking,
|
||||||
CONN_COMPLETE
|
Complete
|
||||||
};
|
};
|
||||||
|
|
||||||
ConnectionState m_ConnectionState;
|
ConnectionState m_ConnectionState;
|
||||||
|
|
||||||
bool m_HIDControlChannel_Connected = false;
|
bool m_HIDControlChannel_Connected = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user