WiimoteDevice: Amend variable naming for non-class member variables

This file is quite out of sync when it comes to our naming conventions,
this brings it back in line with it.
This commit is contained in:
Lioncash
2018-06-10 13:22:11 -04:00
parent 70417c8d16
commit eaace415d3
2 changed files with 302 additions and 302 deletions

View File

@ -28,25 +28,25 @@ namespace IOS::HLE
class CBigEndianBuffer class CBigEndianBuffer
{ {
public: public:
explicit CBigEndianBuffer(u8* pBuffer) : m_pBuffer(pBuffer) {} explicit CBigEndianBuffer(u8* buffer) : m_buffer(buffer) {}
u8 Read8(u32 offset) const { return m_pBuffer[offset]; } u8 Read8(u32 offset) const { return m_buffer[offset]; }
u16 Read16(u32 offset) const { return Common::swap16(&m_pBuffer[offset]); } u16 Read16(u32 offset) const { return Common::swap16(&m_buffer[offset]); }
u32 Read32(u32 offset) const { return Common::swap32(&m_pBuffer[offset]); } u32 Read32(u32 offset) const { return Common::swap32(&m_buffer[offset]); }
void Write8(u32 offset, u8 data) { m_pBuffer[offset] = data; } void Write8(u32 offset, u8 data) { m_buffer[offset] = data; }
void Write16(u32 offset, u16 data) void Write16(u32 offset, u16 data)
{ {
const u16 swapped = Common::swap16(data); const u16 swapped = Common::swap16(data);
std::memcpy(&m_pBuffer[offset], &swapped, sizeof(u16)); std::memcpy(&m_buffer[offset], &swapped, sizeof(u16));
} }
void Write32(u32 offset, u32 data) void Write32(u32 offset, u32 data)
{ {
const u32 swapped = Common::swap32(data); const u32 swapped = Common::swap32(data);
std::memcpy(&m_pBuffer[offset], &swapped, sizeof(u32)); std::memcpy(&m_buffer[offset], &swapped, sizeof(u32));
} }
u8* GetPointer(u32 offset) { return &m_pBuffer[offset]; } u8* GetPointer(u32 offset) { return &m_buffer[offset]; }
private: private:
u8* m_pBuffer; u8* m_buffer;
}; };
WiimoteDevice::WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd, bool ready) WiimoteDevice::WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd, bool ready)
@ -246,33 +246,33 @@ void WiimoteDevice::ResetChannels()
// //
// This function receives L2CAP commands from the CPU // This function receives L2CAP commands from the CPU
void WiimoteDevice::ExecuteL2capCmd(u8* _pData, u32 _Size) void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
{ {
// parse the command // parse the command
l2cap_hdr_t* pHeader = (l2cap_hdr_t*)_pData; l2cap_hdr_t* header = (l2cap_hdr_t*)ptr;
u8* pData = _pData + sizeof(l2cap_hdr_t); u8* data = ptr + sizeof(l2cap_hdr_t);
u32 DataSize = _Size - sizeof(l2cap_hdr_t); const u32 data_size = size - sizeof(l2cap_hdr_t);
DEBUG_LOG(IOS_WIIMOTE, " CID 0x%04x, Len 0x%x, DataSize 0x%x", pHeader->dcid, pHeader->length, DEBUG_LOG(IOS_WIIMOTE, " CID 0x%04x, Len 0x%x, DataSize 0x%x", header->dcid, header->length,
DataSize); data_size);
if (pHeader->length != DataSize) if (header->length != data_size)
{ {
INFO_LOG(IOS_WIIMOTE, "Faulty packet. It is dropped."); INFO_LOG(IOS_WIIMOTE, "Faulty packet. It is dropped.");
return; return;
} }
switch (pHeader->dcid) switch (header->dcid)
{ {
case L2CAP_SIGNAL_CID: case L2CAP_SIGNAL_CID:
SignalChannel(pData, DataSize); SignalChannel(data, data_size);
break; break;
default: default:
{ {
DEBUG_ASSERT_MSG(IOS_WIIMOTE, DoesChannelExist(pHeader->dcid), DEBUG_ASSERT_MSG(IOS_WIIMOTE, DoesChannelExist(header->dcid),
"L2CAP: SendACLPacket to unknown channel %i", pHeader->dcid); "L2CAP: SendACLPacket to unknown channel %i", header->dcid);
const auto itr = m_Channel.find(pHeader->dcid); const auto itr = m_Channel.find(header->dcid);
const int number = m_ConnectionHandle & 0xFF; const int number = m_ConnectionHandle & 0xFF;
if (itr != m_Channel.end()) if (itr != m_Channel.end())
@ -281,12 +281,12 @@ void WiimoteDevice::ExecuteL2capCmd(u8* _pData, u32 _Size)
switch (channel.PSM) switch (channel.PSM)
{ {
case L2CAP_PSM_SDP: case L2CAP_PSM_SDP:
HandleSDP(pHeader->dcid, pData, DataSize); HandleSDP(header->dcid, data, data_size);
break; break;
case L2CAP_PSM_HID_CNTL: case L2CAP_PSM_HID_CNTL:
if (number < MAX_BBMOTES) if (number < MAX_BBMOTES)
Wiimote::ControlChannel(number, pHeader->dcid, pData, DataSize); Wiimote::ControlChannel(number, header->dcid, data, data_size);
break; break;
case L2CAP_PSM_HID_INTR: case L2CAP_PSM_HID_INTR:
@ -294,17 +294,17 @@ void WiimoteDevice::ExecuteL2capCmd(u8* _pData, u32 _Size)
if (number < MAX_BBMOTES) if (number < MAX_BBMOTES)
{ {
DEBUG_LOG(WIIMOTE, "Wiimote_InterruptChannel"); DEBUG_LOG(WIIMOTE, "Wiimote_InterruptChannel");
DEBUG_LOG(WIIMOTE, " Channel ID: %04x", pHeader->dcid); DEBUG_LOG(WIIMOTE, " Channel ID: %04x", header->dcid);
const std::string temp = ArrayToString(pData, DataSize); const std::string temp = ArrayToString(data, data_size);
DEBUG_LOG(WIIMOTE, " Data: %s", temp.c_str()); DEBUG_LOG(WIIMOTE, " Data: %s", temp.c_str());
Wiimote::InterruptChannel(number, pHeader->dcid, pData, DataSize); Wiimote::InterruptChannel(number, header->dcid, data, data_size);
} }
} }
break; break;
default: default:
ERROR_LOG(IOS_WIIMOTE, "Channel 0x04%x has unknown PSM %x", pHeader->dcid, channel.PSM); ERROR_LOG(IOS_WIIMOTE, "Channel 0x04%x has unknown PSM %x", header->dcid, channel.PSM);
break; break;
} }
} }
@ -313,13 +313,13 @@ void WiimoteDevice::ExecuteL2capCmd(u8* _pData, u32 _Size)
} }
} }
void WiimoteDevice::SignalChannel(u8* _pData, u32 _Size) void WiimoteDevice::SignalChannel(u8* data, u32 size)
{ {
while (_Size >= sizeof(l2cap_cmd_hdr_t)) while (size >= sizeof(l2cap_cmd_hdr_t))
{ {
l2cap_cmd_hdr_t* cmd_hdr = (l2cap_cmd_hdr_t*)_pData; l2cap_cmd_hdr_t* cmd_hdr = (l2cap_cmd_hdr_t*)data;
_pData += sizeof(l2cap_cmd_hdr_t); data += sizeof(l2cap_cmd_hdr_t);
_Size = _Size - sizeof(l2cap_cmd_hdr_t) - cmd_hdr->length; size = size - sizeof(l2cap_cmd_hdr_t) - cmd_hdr->length;
switch (cmd_hdr->code) switch (cmd_hdr->code)
{ {
@ -329,23 +329,23 @@ void WiimoteDevice::SignalChannel(u8* _pData, u32 _Size)
break; break;
case L2CAP_CONNECT_REQ: case L2CAP_CONNECT_REQ:
ReceiveConnectionReq(cmd_hdr->ident, _pData, cmd_hdr->length); ReceiveConnectionReq(cmd_hdr->ident, data, cmd_hdr->length);
break; break;
case L2CAP_CONNECT_RSP: case L2CAP_CONNECT_RSP:
ReceiveConnectionResponse(cmd_hdr->ident, _pData, cmd_hdr->length); ReceiveConnectionResponse(cmd_hdr->ident, data, cmd_hdr->length);
break; break;
case L2CAP_CONFIG_REQ: case L2CAP_CONFIG_REQ:
ReceiveConfigurationReq(cmd_hdr->ident, _pData, cmd_hdr->length); ReceiveConfigurationReq(cmd_hdr->ident, data, cmd_hdr->length);
break; break;
case L2CAP_CONFIG_RSP: case L2CAP_CONFIG_RSP:
ReceiveConfigurationResponse(cmd_hdr->ident, _pData, cmd_hdr->length); ReceiveConfigurationResponse(cmd_hdr->ident, data, cmd_hdr->length);
break; break;
case L2CAP_DISCONNECT_REQ: case L2CAP_DISCONNECT_REQ:
ReceiveDisconnectionReq(cmd_hdr->ident, _pData, cmd_hdr->length); ReceiveDisconnectionReq(cmd_hdr->ident, data, cmd_hdr->length);
break; break;
default: default:
@ -353,7 +353,7 @@ void WiimoteDevice::SignalChannel(u8* _pData, u32 _Size)
return; return;
} }
_pData += cmd_hdr->length; data += cmd_hdr->length;
} }
} }
@ -368,38 +368,38 @@ void WiimoteDevice::SignalChannel(u8* _pData, u32 _Size)
// //
// //
void WiimoteDevice::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size) void WiimoteDevice::ReceiveConnectionReq(u8 ident, u8* data, u32 size)
{ {
l2cap_con_req_cp* pCommandConnectionReq = (l2cap_con_req_cp*)_pData; l2cap_con_req_cp* command_connection_req = (l2cap_con_req_cp*)data;
// create the channel // create the channel
SChannel& rChannel = m_Channel[pCommandConnectionReq->scid]; SChannel& channel = m_Channel[command_connection_req->scid];
rChannel.PSM = pCommandConnectionReq->psm; channel.PSM = command_connection_req->psm;
rChannel.SCID = pCommandConnectionReq->scid; channel.SCID = command_connection_req->scid;
rChannel.DCID = pCommandConnectionReq->scid; channel.DCID = command_connection_req->scid;
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionRequest"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionRequest");
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
DEBUG_LOG(IOS_WIIMOTE, " PSM: 0x%04x", rChannel.PSM); DEBUG_LOG(IOS_WIIMOTE, " PSM: 0x%04x", channel.PSM);
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rChannel.SCID); DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", channel.SCID);
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", rChannel.DCID); DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", channel.DCID);
// response // response
l2cap_con_rsp_cp Rsp; l2cap_con_rsp_cp rsp;
Rsp.scid = rChannel.SCID; rsp.scid = channel.SCID;
Rsp.dcid = rChannel.DCID; rsp.dcid = channel.DCID;
Rsp.result = L2CAP_SUCCESS; rsp.result = L2CAP_SUCCESS;
Rsp.status = L2CAP_NO_INFO; rsp.status = L2CAP_NO_INFO;
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConnectionResponse"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConnectionResponse");
SendCommandToACL(_Ident, L2CAP_CONNECT_RSP, sizeof(l2cap_con_rsp_cp), (u8*)&Rsp); SendCommandToACL(ident, L2CAP_CONNECT_RSP, sizeof(l2cap_con_rsp_cp), (u8*)&rsp);
} }
void WiimoteDevice::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size) void WiimoteDevice::ReceiveConnectionResponse(u8 ident, u8* data, u32 size)
{ {
l2cap_con_rsp_cp* rsp = (l2cap_con_rsp_cp*)_pData; l2cap_con_rsp_cp* rsp = (l2cap_con_rsp_cp*)data;
DEBUG_ASSERT(_Size == sizeof(l2cap_con_rsp_cp)); DEBUG_ASSERT(size == sizeof(l2cap_con_rsp_cp));
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionResponse"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionResponse");
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", rsp->dcid); DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", rsp->dcid);
@ -411,95 +411,95 @@ void WiimoteDevice::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size)
DEBUG_ASSERT(rsp->status == L2CAP_NO_INFO); DEBUG_ASSERT(rsp->status == L2CAP_NO_INFO);
DEBUG_ASSERT(DoesChannelExist(rsp->scid)); DEBUG_ASSERT(DoesChannelExist(rsp->scid));
SChannel& rChannel = m_Channel[rsp->scid]; SChannel& channel = m_Channel[rsp->scid];
rChannel.DCID = rsp->dcid; channel.DCID = rsp->dcid;
// update state machine // update state machine
if (rChannel.PSM == L2CAP_PSM_HID_CNTL) if (channel.PSM == L2CAP_PSM_HID_CNTL)
m_hid_control_channel.connected = true; m_hid_control_channel.connected = true;
else if (rChannel.PSM == L2CAP_PSM_HID_INTR) else if (channel.PSM == L2CAP_PSM_HID_INTR)
m_hid_interrupt_channel.connected = true; m_hid_interrupt_channel.connected = true;
} }
void WiimoteDevice::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size) void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 size)
{ {
u32 Offset = 0; u32 offset = 0;
l2cap_cfg_req_cp* pCommandConfigReq = (l2cap_cfg_req_cp*)_pData; l2cap_cfg_req_cp* command_config_req = (l2cap_cfg_req_cp*)data;
// Flags being 1 means that the options are sent in multi-packets // Flags being 1 means that the options are sent in multi-packets
DEBUG_ASSERT(pCommandConfigReq->flags == 0x00); DEBUG_ASSERT(command_config_req->flags == 0x00);
DEBUG_ASSERT(DoesChannelExist(pCommandConfigReq->dcid)); DEBUG_ASSERT(DoesChannelExist(command_config_req->dcid));
SChannel& rChannel = m_Channel[pCommandConfigReq->dcid]; SChannel& channel = m_Channel[command_config_req->dcid];
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest");
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", pCommandConfigReq->dcid); DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", command_config_req->dcid);
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", pCommandConfigReq->flags); DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", command_config_req->flags);
Offset += sizeof(l2cap_cfg_req_cp); offset += sizeof(l2cap_cfg_req_cp);
u8 TempBuffer[1024]; u8 temp_buffer[1024];
u32 RespLen = 0; u32 resp_len = 0;
l2cap_cfg_rsp_cp* Rsp = (l2cap_cfg_rsp_cp*)TempBuffer; l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)temp_buffer;
Rsp->scid = rChannel.DCID; rsp->scid = channel.DCID;
Rsp->flags = 0x00; rsp->flags = 0x00;
Rsp->result = L2CAP_SUCCESS; rsp->result = L2CAP_SUCCESS;
RespLen += sizeof(l2cap_cfg_rsp_cp); resp_len += sizeof(l2cap_cfg_rsp_cp);
// read configuration options // read configuration options
while (Offset < _Size) while (offset < size)
{ {
l2cap_cfg_opt_t* pOptions = (l2cap_cfg_opt_t*)&_pData[Offset]; l2cap_cfg_opt_t* options = (l2cap_cfg_opt_t*)&data[offset];
Offset += sizeof(l2cap_cfg_opt_t); offset += sizeof(l2cap_cfg_opt_t);
switch (pOptions->type) switch (options->type)
{ {
case L2CAP_OPT_MTU: case L2CAP_OPT_MTU:
{ {
DEBUG_ASSERT(pOptions->length == L2CAP_OPT_MTU_SIZE); DEBUG_ASSERT(options->length == L2CAP_OPT_MTU_SIZE);
l2cap_cfg_opt_val_t* pMTU = (l2cap_cfg_opt_val_t*)&_pData[Offset]; l2cap_cfg_opt_val_t* mtu = (l2cap_cfg_opt_val_t*)&data[offset];
rChannel.MTU = pMTU->mtu; channel.MTU = mtu->mtu;
DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", pMTU->mtu); DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", mtu->mtu);
} }
break; break;
case L2CAP_OPT_FLUSH_TIMO: case L2CAP_OPT_FLUSH_TIMO:
{ {
DEBUG_ASSERT(pOptions->length == L2CAP_OPT_FLUSH_TIMO_SIZE); DEBUG_ASSERT(options->length == L2CAP_OPT_FLUSH_TIMO_SIZE);
l2cap_cfg_opt_val_t* pFlushTimeOut = (l2cap_cfg_opt_val_t*)&_pData[Offset]; l2cap_cfg_opt_val_t* flush_time_out = (l2cap_cfg_opt_val_t*)&data[offset];
rChannel.FlushTimeOut = pFlushTimeOut->flush_timo; channel.FlushTimeOut = flush_time_out->flush_timo;
DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", pFlushTimeOut->flush_timo); DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", flush_time_out->flush_timo);
} }
break; break;
default: default:
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown Option: 0x%02x", pOptions->type); DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown Option: 0x%02x", options->type);
break; break;
} }
Offset += pOptions->length; offset += options->length;
u32 OptionSize = sizeof(l2cap_cfg_opt_t) + pOptions->length; const u32 option_size = sizeof(l2cap_cfg_opt_t) + options->length;
memcpy(&TempBuffer[RespLen], pOptions, OptionSize); memcpy(&temp_buffer[resp_len], options, option_size);
RespLen += OptionSize; resp_len += option_size;
} }
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationResponse"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationResponse");
SendCommandToACL(_Ident, L2CAP_CONFIG_RSP, RespLen, TempBuffer); SendCommandToACL(ident, L2CAP_CONFIG_RSP, resp_len, temp_buffer);
// update state machine // update state machine
if (rChannel.PSM == L2CAP_PSM_HID_CNTL) if (channel.PSM == L2CAP_PSM_HID_CNTL)
m_hid_control_channel.connected = true; m_hid_control_channel.connected = true;
else if (rChannel.PSM == L2CAP_PSM_HID_INTR) else if (channel.PSM == L2CAP_PSM_HID_INTR)
m_hid_interrupt_channel.connected = true; m_hid_interrupt_channel.connected = true;
} }
void WiimoteDevice::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size) void WiimoteDevice::ReceiveConfigurationResponse(u8 ident, u8* data, u32 size)
{ {
l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)_pData; l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)data;
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse");
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid); DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid);
@ -509,30 +509,30 @@ void WiimoteDevice::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Siz
DEBUG_ASSERT(rsp->result == L2CAP_SUCCESS); DEBUG_ASSERT(rsp->result == L2CAP_SUCCESS);
// update state machine // update state machine
SChannel& rChannel = m_Channel[rsp->scid]; const SChannel& channel = m_Channel[rsp->scid];
if (rChannel.PSM == L2CAP_PSM_HID_CNTL) if (channel.PSM == L2CAP_PSM_HID_CNTL)
m_hid_control_channel.config = true; m_hid_control_channel.config = true;
else if (rChannel.PSM == L2CAP_PSM_HID_INTR) else if (channel.PSM == L2CAP_PSM_HID_INTR)
m_hid_interrupt_channel.config = true; m_hid_interrupt_channel.config = true;
} }
void WiimoteDevice::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size) void WiimoteDevice::ReceiveDisconnectionReq(u8 ident, u8* data, u32 size)
{ {
l2cap_discon_req_cp* pCommandDisconnectionReq = (l2cap_discon_req_cp*)_pData; l2cap_discon_req_cp* command_disconnection_req = (l2cap_discon_req_cp*)data;
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq");
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", pCommandDisconnectionReq->dcid); DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", command_disconnection_req->dcid);
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", pCommandDisconnectionReq->scid); DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", command_disconnection_req->scid);
// response // response
l2cap_discon_req_cp Rsp; l2cap_discon_req_cp rsp;
Rsp.dcid = pCommandDisconnectionReq->dcid; rsp.dcid = command_disconnection_req->dcid;
Rsp.scid = pCommandDisconnectionReq->scid; rsp.scid = command_disconnection_req->scid;
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendDisconnectionResponse"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendDisconnectionResponse");
SendCommandToACL(_Ident, L2CAP_DISCONNECT_RSP, sizeof(l2cap_discon_req_cp), (u8*)&Rsp); SendCommandToACL(ident, L2CAP_DISCONNECT_RSP, sizeof(l2cap_discon_req_cp), (u8*)&rsp);
} }
// //
@ -550,9 +550,9 @@ void WiimoteDevice::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size)
void WiimoteDevice::SendConnectionRequest(u16 scid, u16 psm) void WiimoteDevice::SendConnectionRequest(u16 scid, u16 psm)
{ {
// create the channel // create the channel
SChannel& rChannel = m_Channel[scid]; SChannel& channel = m_Channel[scid];
rChannel.PSM = psm; channel.PSM = psm;
rChannel.SCID = scid; channel.SCID = scid;
l2cap_con_req_cp cr; l2cap_con_req_cp cr;
cr.psm = psm; cr.psm = psm;
@ -569,11 +569,11 @@ void WiimoteDevice::SendConnectionRequest(u16 scid, u16 psm)
void WiimoteDevice::SendDisconnectRequest(u16 scid) void WiimoteDevice::SendDisconnectRequest(u16 scid)
{ {
// create the channel // create the channel
SChannel& rChannel = m_Channel[scid]; const SChannel& channel = m_Channel[scid];
l2cap_discon_req_cp cr; l2cap_discon_req_cp cr;
cr.dcid = rChannel.DCID; cr.dcid = channel.DCID;
cr.scid = rChannel.SCID; cr.scid = channel.SCID;
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendDisconnectionRequest"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendDisconnectionRequest");
DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr.dcid); DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr.dcid);
@ -583,56 +583,56 @@ void WiimoteDevice::SendDisconnectRequest(u16 scid)
(u8*)&cr); (u8*)&cr);
} }
void WiimoteDevice::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut) void WiimoteDevice::SendConfigurationRequest(u16 scid, u16 mtu, u16 flush_time_out)
{ {
DEBUG_ASSERT(DoesChannelExist(scid)); DEBUG_ASSERT(DoesChannelExist(scid));
SChannel& rChannel = m_Channel[scid]; const SChannel& channel = m_Channel[scid];
u8 Buffer[1024]; u8 buffer[1024];
int Offset = 0; int offset = 0;
l2cap_cfg_req_cp* cr = (l2cap_cfg_req_cp*)&Buffer[Offset]; l2cap_cfg_req_cp* cr = (l2cap_cfg_req_cp*)&buffer[offset];
cr->dcid = rChannel.DCID; cr->dcid = channel.DCID;
cr->flags = 0; cr->flags = 0;
Offset += sizeof(l2cap_cfg_req_cp); offset += sizeof(l2cap_cfg_req_cp);
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationRequest"); DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationRequest");
DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr->dcid); DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr->dcid);
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", cr->flags); DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", cr->flags);
l2cap_cfg_opt_t* pOptions; l2cap_cfg_opt_t* options;
// (shuffle2) currently we end up not appending options. this is because we don't // (shuffle2) currently we end up not appending options. this is because we don't
// negotiate after trying to set MTU = 0 fails (stack will respond with // negotiate after trying to set MTU = 0 fails (stack will respond with
// "configuration failed" msg...). This is still fine, we'll just use whatever the // "configuration failed" msg...). This is still fine, we'll just use whatever the
// Bluetooth stack defaults to. // Bluetooth stack defaults to.
if (MTU || rChannel.MTU) if (mtu || channel.MTU)
{ {
if (MTU == 0) if (mtu == 0)
MTU = rChannel.MTU; mtu = channel.MTU;
pOptions = (l2cap_cfg_opt_t*)&Buffer[Offset]; options = (l2cap_cfg_opt_t*)&buffer[offset];
Offset += sizeof(l2cap_cfg_opt_t); offset += sizeof(l2cap_cfg_opt_t);
pOptions->type = L2CAP_OPT_MTU; options->type = L2CAP_OPT_MTU;
pOptions->length = L2CAP_OPT_MTU_SIZE; options->length = L2CAP_OPT_MTU_SIZE;
*(u16*)&Buffer[Offset] = MTU; *(u16*)&buffer[offset] = mtu;
Offset += L2CAP_OPT_MTU_SIZE; offset += L2CAP_OPT_MTU_SIZE;
DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", MTU); DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", mtu);
} }
if (FlushTimeOut || rChannel.FlushTimeOut) if (flush_time_out || channel.FlushTimeOut)
{ {
if (FlushTimeOut == 0) if (flush_time_out == 0)
FlushTimeOut = rChannel.FlushTimeOut; flush_time_out = channel.FlushTimeOut;
pOptions = (l2cap_cfg_opt_t*)&Buffer[Offset]; options = (l2cap_cfg_opt_t*)&buffer[offset];
Offset += sizeof(l2cap_cfg_opt_t); offset += sizeof(l2cap_cfg_opt_t);
pOptions->type = L2CAP_OPT_FLUSH_TIMO; options->type = L2CAP_OPT_FLUSH_TIMO;
pOptions->length = L2CAP_OPT_FLUSH_TIMO_SIZE; options->length = L2CAP_OPT_FLUSH_TIMO_SIZE;
*(u16*)&Buffer[Offset] = FlushTimeOut; *(u16*)&buffer[offset] = flush_time_out;
Offset += L2CAP_OPT_FLUSH_TIMO_SIZE; offset += L2CAP_OPT_FLUSH_TIMO_SIZE;
DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", FlushTimeOut); DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", flush_time_out);
} }
SendCommandToACL(L2CAP_CONFIG_REQ, L2CAP_CONFIG_REQ, Offset, Buffer); SendCommandToACL(L2CAP_CONFIG_REQ, L2CAP_CONFIG_REQ, offset, buffer);
} }
// //
@ -652,13 +652,13 @@ void WiimoteDevice::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut
#define SDP_SEQ8 0x35 #define SDP_SEQ8 0x35
#define SDP_SEQ16 0x36 #define SDP_SEQ16 0x36
void WiimoteDevice::SDPSendServiceSearchResponse(u16 cid, u16 TransactionID, void WiimoteDevice::SDPSendServiceSearchResponse(u16 cid, u16 transaction_id,
u8* pServiceSearchPattern, u8* service_search_pattern,
u16 MaximumServiceRecordCount) u16 maximum_service_record_count)
{ {
// verify block... we handle search pattern for HID service only // verify block... we handle search pattern for HID service only
{ {
CBigEndianBuffer buffer(pServiceSearchPattern); CBigEndianBuffer buffer(service_search_pattern);
DEBUG_ASSERT(buffer.Read8(0) == SDP_SEQ8); // data sequence DEBUG_ASSERT(buffer.Read8(0) == SDP_SEQ8); // data sequence
DEBUG_ASSERT(buffer.Read8(1) == 0x03); // sequence size DEBUG_ASSERT(buffer.Read8(1) == 0x03); // sequence size
@ -667,135 +667,135 @@ void WiimoteDevice::SDPSendServiceSearchResponse(u16 cid, u16 TransactionID,
DEBUG_ASSERT(buffer.Read16(3) == 0x1124); DEBUG_ASSERT(buffer.Read16(3) == 0x1124);
} }
u8 DataFrame[1000]; u8 data_frame[1000];
CBigEndianBuffer buffer(DataFrame); CBigEndianBuffer buffer(data_frame);
int Offset = 0; int offset = 0;
l2cap_hdr_t* pHeader = (l2cap_hdr_t*)&DataFrame[Offset]; l2cap_hdr_t* header = (l2cap_hdr_t*)&data_frame[offset];
Offset += sizeof(l2cap_hdr_t); offset += sizeof(l2cap_hdr_t);
pHeader->dcid = cid; header->dcid = cid;
buffer.Write8(Offset, 0x03); buffer.Write8(offset, 0x03);
Offset++; offset++;
buffer.Write16(Offset, TransactionID); buffer.Write16(offset, transaction_id);
Offset += 2; // Transaction ID offset += 2; // Transaction ID
buffer.Write16(Offset, 0x0009); buffer.Write16(offset, 0x0009);
Offset += 2; // Param length offset += 2; // Param length
buffer.Write16(Offset, 0x0001); buffer.Write16(offset, 0x0001);
Offset += 2; // TotalServiceRecordCount offset += 2; // TotalServiceRecordCount
buffer.Write16(Offset, 0x0001); buffer.Write16(offset, 0x0001);
Offset += 2; // CurrentServiceRecordCount offset += 2; // CurrentServiceRecordCount
buffer.Write32(Offset, 0x10000); buffer.Write32(offset, 0x10000);
Offset += 4; // ServiceRecordHandleList[4] offset += 4; // ServiceRecordHandleList[4]
buffer.Write8(Offset, 0x00); buffer.Write8(offset, 0x00);
Offset++; // No continuation state; offset++; // No continuation state;
pHeader->length = (u16)(Offset - sizeof(l2cap_hdr_t)); header->length = (u16)(offset - sizeof(l2cap_hdr_t));
m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); m_pHost->SendACLPacket(GetConnectionHandle(), data_frame, header->length + sizeof(l2cap_hdr_t));
} }
static u32 ParseCont(u8* pCont) static u32 ParseCont(u8* cont)
{ {
u32 attribOffset = 0; u32 attrib_offset = 0;
CBigEndianBuffer attribList(pCont); CBigEndianBuffer attrib_list(cont);
u8 typeID = attribList.Read8(attribOffset); const u8 type_id = attrib_list.Read8(attrib_offset);
attribOffset++; attrib_offset++;
if (typeID == 0x02) if (type_id == 0x02)
{ {
return attribList.Read16(attribOffset); return attrib_list.Read16(attrib_offset);
} }
else if (typeID == 0x00) else if (type_id == 0x00)
{ {
return 0x00; return 0x00;
} }
ERROR_LOG(IOS_WIIMOTE, "ParseCont: wrong cont: %i", typeID); ERROR_LOG(IOS_WIIMOTE, "ParseCont: wrong cont: %i", type_id);
PanicAlert("ParseCont: wrong cont: %i", typeID); PanicAlert("ParseCont: wrong cont: %i", type_id);
return 0; return 0;
} }
static int ParseAttribList(u8* pAttribIDList, u16& _startID, u16& _endID) static int ParseAttribList(u8* attrib_id_list, u16& start_id, u16& end_id)
{ {
u32 attribOffset = 0; u32 attrib_offset = 0;
CBigEndianBuffer attribList(pAttribIDList); CBigEndianBuffer attrib_list(attrib_id_list);
u8 sequence = attribList.Read8(attribOffset); const u8 sequence = attrib_list.Read8(attrib_offset);
attribOffset++; attrib_offset++;
u8 seqSize = attribList.Read8(attribOffset); const u8 seq_size = attrib_list.Read8(attrib_offset);
attribOffset++; attrib_offset++;
u8 typeID = attribList.Read8(attribOffset); const u8 type_id = attrib_list.Read8(attrib_offset);
attribOffset++; attrib_offset++;
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG)
{ {
DEBUG_ASSERT(sequence == SDP_SEQ8); DEBUG_ASSERT(sequence == SDP_SEQ8);
(void)seqSize; (void)seq_size;
} }
if (typeID == SDP_UINT32) if (type_id == SDP_UINT32)
{ {
_startID = attribList.Read16(attribOffset); start_id = attrib_list.Read16(attrib_offset);
attribOffset += 2; attrib_offset += 2;
_endID = attribList.Read16(attribOffset); end_id = attrib_list.Read16(attrib_offset);
attribOffset += 2; attrib_offset += 2;
} }
else else
{ {
_startID = attribList.Read16(attribOffset); start_id = attrib_list.Read16(attrib_offset);
attribOffset += 2; attrib_offset += 2;
_endID = _startID; end_id = start_id;
WARN_LOG(IOS_WIIMOTE, "Read just a single attrib - not tested"); WARN_LOG(IOS_WIIMOTE, "Read just a single attrib - not tested");
PanicAlert("Read just a single attrib - not tested"); PanicAlert("Read just a single attrib - not tested");
} }
return attribOffset; return attrib_offset;
} }
void WiimoteDevice::SDPSendServiceAttributeResponse(u16 cid, u16 TransactionID, u32 ServiceHandle, void WiimoteDevice::SDPSendServiceAttributeResponse(u16 cid, u16 transaction_id, u32 service_handle,
u16 startAttrID, u16 endAttrID, u16 start_attr_id, u16 end_attr_id,
u16 MaximumAttributeByteCount, u16 maximum_attribute_byte_count,
u8* pContinuationState) u8* continuation_state)
{ {
if (ServiceHandle != 0x10000) if (service_handle != 0x10000)
{ {
ERROR_LOG(IOS_WIIMOTE, "Unknown service handle %x", ServiceHandle); ERROR_LOG(IOS_WIIMOTE, "Unknown service handle %x", service_handle);
PanicAlert("Unknown service handle %x", ServiceHandle); PanicAlert("Unknown service handle %x", service_handle);
} }
u32 contState = ParseCont(pContinuationState); const u32 cont_state = ParseCont(continuation_state);
u32 packetSize = 0; u32 packet_size = 0;
const u8* pPacket = GetAttribPacket(ServiceHandle, contState, packetSize); const u8* packet = GetAttribPacket(service_handle, cont_state, packet_size);
// generate package // generate package
u8 DataFrame[1000]; u8 data_frame[1000];
CBigEndianBuffer buffer(DataFrame); CBigEndianBuffer buffer(data_frame);
int Offset = 0; int offset = 0;
l2cap_hdr_t* pHeader = (l2cap_hdr_t*)&DataFrame[Offset]; l2cap_hdr_t* header = (l2cap_hdr_t*)&data_frame[offset];
Offset += sizeof(l2cap_hdr_t); offset += sizeof(l2cap_hdr_t);
pHeader->dcid = cid; header->dcid = cid;
buffer.Write8(Offset, 0x05); buffer.Write8(offset, 0x05);
Offset++; offset++;
buffer.Write16(Offset, TransactionID); buffer.Write16(offset, transaction_id);
Offset += 2; // Transaction ID offset += 2; // Transaction ID
memcpy(buffer.GetPointer(Offset), pPacket, packetSize); memcpy(buffer.GetPointer(offset), packet, packet_size);
Offset += packetSize; offset += packet_size;
pHeader->length = (u16)(Offset - sizeof(l2cap_hdr_t)); header->length = (u16)(offset - sizeof(l2cap_hdr_t));
m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); m_pHost->SendACLPacket(GetConnectionHandle(), data_frame, header->length + sizeof(l2cap_hdr_t));
// Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, data_frame, header->length + sizeof(l2cap_hdr_t),
// "test response: "); // "test response: ");
} }
void WiimoteDevice::HandleSDP(u16 cid, u8* _pData, u32 _Size) void WiimoteDevice::HandleSDP(u16 cid, u8* data, u32 size)
{ {
// Debugger::PrintDataBuffer(LogTypes::WIIMOTE, _pData, _Size, "HandleSDP: "); // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, data, size, "HandleSDP: ");
CBigEndianBuffer buffer(_pData); CBigEndianBuffer buffer(data);
switch (buffer.Read8(0)) switch (buffer.Read8(0))
{ {
@ -804,14 +804,14 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* _pData, u32 _Size)
{ {
WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!"); WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!");
DEBUG_ASSERT(_Size == 13); DEBUG_ASSERT(size == 13);
u16 TransactionID = buffer.Read16(1); const u16 transaction_id = buffer.Read16(1);
u8* pServiceSearchPattern = buffer.GetPointer(5); u8* service_search_pattern = buffer.GetPointer(5);
u16 MaximumServiceRecordCount = buffer.Read16(10); const u16 maximum_service_record_count = buffer.Read16(10);
SDPSendServiceSearchResponse(cid, TransactionID, pServiceSearchPattern, SDPSendServiceSearchResponse(cid, transaction_id, service_search_pattern,
MaximumServiceRecordCount); maximum_service_record_count);
} }
break; break;
@ -820,28 +820,28 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* _pData, u32 _Size)
{ {
WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!"); WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!");
u16 startAttrID, endAttrID; u16 start_attr_id, end_attr_id;
u32 offset = 1; u32 offset = 1;
u16 TransactionID = buffer.Read16(offset); const u16 transaction_id = buffer.Read16(offset);
offset += 2; offset += 2;
// u16 ParameterLength = buffer.Read16(offset); // u16 parameter_length = buffer.Read16(offset);
offset += 2; offset += 2;
u32 ServiceHandle = buffer.Read32(offset); const u32 service_handle = buffer.Read32(offset);
offset += 4; offset += 4;
u16 MaximumAttributeByteCount = buffer.Read16(offset); const u16 maximum_attribute_byte_count = buffer.Read16(offset);
offset += 2; offset += 2;
offset += ParseAttribList(buffer.GetPointer(offset), startAttrID, endAttrID); offset += ParseAttribList(buffer.GetPointer(offset), start_attr_id, end_attr_id);
u8* pContinuationState = buffer.GetPointer(offset); u8* continuation_state = buffer.GetPointer(offset);
SDPSendServiceAttributeResponse(cid, TransactionID, ServiceHandle, startAttrID, endAttrID, SDPSendServiceAttributeResponse(cid, transaction_id, service_handle, start_attr_id, end_attr_id,
MaximumAttributeByteCount, pContinuationState); maximum_attribute_byte_count, continuation_state);
} }
break; break;
default: default:
ERROR_LOG(IOS_WIIMOTE, "WIIMOTE: Unknown SDP command %x", _pData[0]); ERROR_LOG(IOS_WIIMOTE, "WIIMOTE: Unknown SDP command %x", data[0]);
PanicAlert("WIIMOTE: Unknown SDP command %x", _pData[0]); PanicAlert("WIIMOTE: Unknown SDP command %x", data[0]);
break; break;
} }
} }
@ -857,58 +857,58 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* _pData, u32 _Size)
// //
// //
void WiimoteDevice::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLength, u8* _pCommandData) void WiimoteDevice::SendCommandToACL(u8 ident, u8 code, u8 command_length, u8* command_data)
{ {
u8 DataFrame[1024]; u8 data_frame[1024];
u32 Offset = 0; u32 offset = 0;
l2cap_hdr_t* pHeader = (l2cap_hdr_t*)&DataFrame[Offset]; l2cap_hdr_t* header = (l2cap_hdr_t*)&data_frame[offset];
Offset += sizeof(l2cap_hdr_t); offset += sizeof(l2cap_hdr_t);
pHeader->length = sizeof(l2cap_cmd_hdr_t) + _CommandLength; header->length = sizeof(l2cap_cmd_hdr_t) + command_length;
pHeader->dcid = L2CAP_SIGNAL_CID; header->dcid = L2CAP_SIGNAL_CID;
l2cap_cmd_hdr_t* pCommand = (l2cap_cmd_hdr_t*)&DataFrame[Offset]; l2cap_cmd_hdr_t* command = (l2cap_cmd_hdr_t*)&data_frame[offset];
Offset += sizeof(l2cap_cmd_hdr_t); offset += sizeof(l2cap_cmd_hdr_t);
pCommand->code = _Code; command->code = code;
pCommand->ident = _Ident; command->ident = ident;
pCommand->length = _CommandLength; command->length = command_length;
memcpy(&DataFrame[Offset], _pCommandData, _CommandLength); memcpy(&data_frame[offset], command_data, command_length);
DEBUG_LOG(IOS_WIIMOTE, "Send ACL Command to CPU"); DEBUG_LOG(IOS_WIIMOTE, "Send ACL Command to CPU");
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
DEBUG_LOG(IOS_WIIMOTE, " Code: 0x%02x", _Code); DEBUG_LOG(IOS_WIIMOTE, " Code: 0x%02x", code);
// send .... // send ....
m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); m_pHost->SendACLPacket(GetConnectionHandle(), data_frame, header->length + sizeof(l2cap_hdr_t));
// Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->length + sizeof(l2cap_hdr_t), // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, data_frame, header->length + sizeof(l2cap_hdr_t),
// "m_pHost->SendACLPacket: "); // "m_pHost->SendACLPacket: ");
} }
void WiimoteDevice::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) void WiimoteDevice::ReceiveL2capData(u16 scid, const void* data, u32 size)
{ {
// Allocate DataFrame // Allocate DataFrame
u8 DataFrame[1024]; u8 data_frame[1024];
u32 Offset = 0; u32 offset = 0;
l2cap_hdr_t* pHeader = (l2cap_hdr_t*)DataFrame; l2cap_hdr_t* header = (l2cap_hdr_t*)data_frame;
Offset += sizeof(l2cap_hdr_t); offset += sizeof(l2cap_hdr_t);
// Check if we are already reporting on this channel // Check if we are already reporting on this channel
DEBUG_ASSERT(DoesChannelExist(scid)); DEBUG_ASSERT(DoesChannelExist(scid));
SChannel& rChannel = m_Channel[scid]; const SChannel& channel = m_Channel[scid];
// Add an additional 4 byte header to the Wiimote report // Add an additional 4 byte header to the Wiimote report
pHeader->dcid = rChannel.DCID; header->dcid = channel.DCID;
pHeader->length = _Size; header->length = size;
// Copy the Wiimote report to DataFrame // Copy the Wiimote report to data_frame
memcpy(DataFrame + Offset, _pData, _Size); memcpy(data_frame + offset, data, size);
// Update Offset to the final size of the report // Update offset to the final size of the report
Offset += _Size; offset += size;
// Send the report // Send the report
m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, Offset); m_pHost->SendACLPacket(GetConnectionHandle(), data_frame, offset);
} }
} // namespace IOS::HLE } // namespace IOS::HLE
@ -916,18 +916,18 @@ namespace Core
{ {
/* This is called continuously from the Wiimote plugin as soon as it has received /* This is called continuously from the Wiimote plugin as soon as it has received
a reporting mode. _Size is the byte size of the report. */ a reporting mode. _Size is the byte size of the report. */
void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) void Callback_WiimoteInterruptChannel(int number, u16 channel_id, const void* opaque_data, u32 size)
{ {
const u8* pData = (const u8*)_pData; const u8* data = (const u8*)opaque_data;
DEBUG_LOG(WIIMOTE, "===================="); DEBUG_LOG(WIIMOTE, "====================");
DEBUG_LOG(WIIMOTE, "Callback_WiimoteInterruptChannel: (Wiimote: #%i)", _number); DEBUG_LOG(WIIMOTE, "Callback_WiimoteInterruptChannel: (Wiimote: #%i)", number);
DEBUG_LOG(WIIMOTE, " Data: %s", ArrayToString(pData, _Size, 50).c_str()); DEBUG_LOG(WIIMOTE, " Data: %s", ArrayToString(data, size, 50).c_str());
DEBUG_LOG(WIIMOTE, " Channel: %x", _channelID); DEBUG_LOG(WIIMOTE, " Channel: %x", channel_id);
const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>( const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
IOS::HLE::GetIOS()->GetDeviceByName("/dev/usb/oh1/57e/305")); IOS::HLE::GetIOS()->GetDeviceByName("/dev/usb/oh1/57e/305"));
if (bt) if (bt)
bt->m_WiiMotes[_number].ReceiveL2capData(_channelID, _pData, _Size); bt->m_WiiMotes[number].ReceiveL2capData(channel_id, opaque_data, size);
} }
} }

View File

@ -23,7 +23,7 @@ class BluetoothEmu;
class WiimoteDevice class WiimoteDevice
{ {
public: public:
WiimoteDevice(Device::BluetoothEmu* _pHost, int _Number, bdaddr_t _BD, bool ready = false); WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd, bool ready = false);
void DoState(PointerWrap& p); void DoState(PointerWrap& p);
@ -35,8 +35,8 @@ public:
bool LinkChannel(); bool LinkChannel();
void ResetChannels(); void ResetChannels();
void Activate(bool ready); void Activate(bool ready);
void ExecuteL2capCmd(u8* _pData, u32 _Size); // From CPU void ExecuteL2capCmd(u8* ptr, u32 size); // From CPU
void ReceiveL2capData(u16 scid, const void* _pData, u32 _Size); // From Wiimote void ReceiveL2capData(u16 scid, const void* data, u32 size); // From Wiimote
void EventConnectionAccepted(); void EventConnectionAccepted();
void EventDisconnect(); void EventDisconnect();
@ -99,28 +99,28 @@ private:
CChannelMap m_Channel; CChannelMap m_Channel;
bool DoesChannelExist(u16 scid) const { return m_Channel.find(scid) != m_Channel.end(); } bool DoesChannelExist(u16 scid) const { return m_Channel.find(scid) != m_Channel.end(); }
void SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLength, u8* _pCommandData); void SendCommandToACL(u8 ident, u8 code, u8 command_length, u8* command_data);
void SignalChannel(u8* _pData, u32 _Size); void SignalChannel(u8* data, u32 size);
void SendConnectionRequest(u16 _SCID, u16 _PSM); void SendConnectionRequest(u16 scid, u16 psm);
void SendConfigurationRequest(u16 _SCID, u16 _pMTU = 0, u16 _pFlushTimeOut = 0); void SendConfigurationRequest(u16 scid, u16 mtu = 0, u16 flush_time_out = 0);
void SendDisconnectRequest(u16 _SCID); void SendDisconnectRequest(u16 scid);
void ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size); void ReceiveConnectionReq(u8 ident, u8* data, u32 size);
void ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size); void ReceiveConnectionResponse(u8 ident, u8* data, u32 size);
void ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size); void ReceiveDisconnectionReq(u8 ident, u8* data, u32 size);
void ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size); void ReceiveConfigurationReq(u8 ident, u8* data, u32 size);
void ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size); void ReceiveConfigurationResponse(u8 ident, u8* data, u32 size);
// some new ugly stuff // some new ugly stuff
// should be inside the plugin // should be inside the plugin
void HandleSDP(u16 _SCID, u8* _pData, u32 _Size); void HandleSDP(u16 cid, u8* data, u32 size);
void SDPSendServiceSearchResponse(u16 _SCID, u16 _TransactionID, u8* _pServiceSearchPattern, void SDPSendServiceSearchResponse(u16 cid, u16 transaction_id, u8* service_search_pattern,
u16 _MaximumServiceRecordCount); u16 maximum_service_record_count);
void SDPSendServiceAttributeResponse(u16 _SCID, u16 TransactionID, u32 _ServiceHandle, void SDPSendServiceAttributeResponse(u16 cid, u16 transaction_id, u32 service_handle,
u16 _StartAttrID, u16 _EndAttrID, u16 start_attr_id, u16 end_attr_id,
u16 _MaximumAttributeByteCount, u8* _pContinuationState); u16 maximum_attribute_byte_count, u8* continuation_state);
}; };
} // namespace IOS::HLE } // namespace IOS::HLE