wiimote code cleaning
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1001 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
95b359ec89
commit
566d0cf9e3
|
@ -23,8 +23,6 @@
|
|||
// ugly hacks for "SendEventNumberOfCompletedPackets"
|
||||
int g_HCICount = 0;
|
||||
int g_GlobalHandle = 0;
|
||||
bool g_ConnectionRequested = false;
|
||||
|
||||
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _DeviceID, const std::string& _rDeviceName)
|
||||
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
|
||||
|
@ -310,6 +308,15 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
|||
g_HCICount = 0;
|
||||
}
|
||||
|
||||
if (m_AclFrameQue.empty())
|
||||
{
|
||||
for (size_t i=0; i<m_WiiMotes.size(); i++)
|
||||
{
|
||||
if (m_WiiMotes[i].Update())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_AclFrameQue.empty())
|
||||
{
|
||||
PluginWiimote::Wiimote_Update();
|
||||
|
@ -331,15 +338,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
|||
}
|
||||
test = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SendEventNumberOfCompletedPackets(g_GlobalHandle, 10);
|
||||
}
|
||||
}
|
||||
/* else
|
||||
{
|
||||
test = true;
|
||||
}*/
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -528,8 +527,6 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRequestConnection(CWII_IPC_HL
|
|||
LOG(WIIMOTE, " COD[2]: 0x%02x", pEventRequestConnection->uclass[2]);
|
||||
LOG(WIIMOTE, " LinkType: %s", LinkType[pEventRequestConnection->LinkType]);
|
||||
|
||||
g_ConnectionRequested = true;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -605,6 +602,13 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(bdaddr_t _
|
|||
|
||||
AddEventToQueue(Event);
|
||||
|
||||
CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(_bd);
|
||||
if (pWiimote)
|
||||
{
|
||||
pWiimote->EventConnectionAccepted();
|
||||
}
|
||||
|
||||
|
||||
g_GlobalHandle = pConnectionComplete->Connection_Handle;
|
||||
|
||||
#ifdef LOGGING
|
||||
|
@ -1554,14 +1558,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input)
|
|||
}
|
||||
|
||||
SendEventConnectionComplete(pAcceptCon->bdaddr);
|
||||
|
||||
|
||||
|
||||
CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pAcceptCon->bdaddr);
|
||||
if (pWiimote)
|
||||
{
|
||||
pWiimote->EventConnectionAccepted();
|
||||
}
|
||||
}
|
||||
|
||||
void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadClockOffset(u8* _Input)
|
||||
|
@ -1577,14 +1573,8 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadClockOffset(u8* _Input)
|
|||
SendEventReadClockOffsetComplete(pReadClockOffset->con_handle);
|
||||
|
||||
|
||||
if (g_ConnectionRequested)
|
||||
{
|
||||
CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pReadClockOffset->con_handle);
|
||||
SendEventRequestLinkKey(pWiiMote->GetBD());
|
||||
|
||||
// CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pReadClockOffset->con_handle);
|
||||
pWiiMote->Connect();
|
||||
}
|
||||
// SendEventRequestLinkKey(pWiiMote->GetBD());
|
||||
}
|
||||
|
||||
void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadRemoteVerInfo(u8* _Input)
|
||||
|
@ -1625,11 +1615,10 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkPolicy(u8* _Input)
|
|||
|
||||
SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS);
|
||||
|
||||
// just HB calls the WriteLinkPolicy...
|
||||
if (g_ConnectionRequested)
|
||||
CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pLinkPolicy->con_handle);
|
||||
if (pWiimote)
|
||||
{
|
||||
CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pLinkPolicy->con_handle);
|
||||
pWiiMote->Connect();
|
||||
pWiimote->EventCommandWriteLinkPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1738,13 +1727,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandLinkKeyRep(u8* _Input)
|
|||
Reply.bdaddr = pKeyRep->bdaddr;
|
||||
|
||||
SendEventCommandComplete(HCI_CMD_LINK_KEY_REP, &Reply, sizeof(hci_link_key_rep_rp));
|
||||
|
||||
if (g_ConnectionRequested)
|
||||
{
|
||||
// CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pKeyRep->bdaddr);
|
||||
// SendEventAuthenticationCompleted(pWiiMote->GetConnectionHandle());
|
||||
// pWiiMote->Connect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,7 @@
|
|||
#define _WII_IPC_HLE_WII_MOTE_
|
||||
|
||||
#include <map>
|
||||
#include "hci.h"
|
||||
|
||||
class CWII_IPC_HLE_Device_usb_oh1_57e_305;
|
||||
|
||||
|
@ -71,6 +72,9 @@ private:
|
|||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CWII_IPC_HLE_WiiMote
|
||||
{
|
||||
public:
|
||||
|
@ -84,12 +88,14 @@ public:
|
|||
// ugly Host handling....
|
||||
// we really have to clean all this code
|
||||
|
||||
bool Update();
|
||||
bool IsConnected() const { return m_Connected; }
|
||||
|
||||
|
||||
void EventConnectionAccepted();
|
||||
void EventDisconnect();
|
||||
bool EventPagingChanged(u8 _pageMode);
|
||||
void EventCommandWriteLinkPolicy();
|
||||
|
||||
const bdaddr_t& GetBD() const { return m_BD; }
|
||||
|
||||
|
@ -109,15 +115,26 @@ public:
|
|||
|
||||
void SendACLFrame(u8* _pData, u32 _Size); //to wiimote
|
||||
|
||||
void Connect();
|
||||
|
||||
void SendL2capData(u16 scid, const void* _pData, u32 _Size); //from wiimote
|
||||
|
||||
const u8* GetLinkKey() const { return m_LinkKey; }
|
||||
|
||||
private:
|
||||
|
||||
// state machine
|
||||
bool m_Connected;
|
||||
bool m_HIDControlChannel_Connected;
|
||||
bool m_HIDControlChannel_ConnectedWait;
|
||||
bool m_HIDControlChannel_Config;
|
||||
bool m_HIDControlChannelHost_Config;
|
||||
bool m_HIDControlChannel_ConfigWait;
|
||||
bool m_HIDInterruptChannel_Connected;
|
||||
bool m_HIDInterruptChannel_ConnectedWait;
|
||||
bool m_HIDInterruptChannel_Config;
|
||||
bool m_HIDInterruptChannelHost_Config;
|
||||
bool m_HIDInterruptChannel_ConfigWait;
|
||||
|
||||
|
||||
|
||||
// STATE_TO_SAVE
|
||||
bdaddr_t m_BD;
|
||||
|
@ -160,9 +177,9 @@ private:
|
|||
|
||||
void SignalChannel(u8* _pData, u32 _Size);
|
||||
|
||||
void SendConnectionRequest(u16 scid, u16 psm);
|
||||
void SendConfigurationRequest(u16 scid, u16* MTU, u16* FlushTimeOut);
|
||||
void SendDisconnectRequest(u16 scid);
|
||||
void SendConnectionRequest(u16 _SCID, u16 _PSM);
|
||||
void SendConfigurationRequest(u16 _SCID, u16* _pMTU = NULL, u16* _pFlushTimeOut = NULL);
|
||||
void SendDisconnectRequest(u16 _SCID);
|
||||
|
||||
void CommandConnectionReq(u8 _Ident, u8* _pData, u32 _Size);
|
||||
void CommandCofigurationReq(u8 _Ident, u8* _pData, u32 _Size);
|
||||
|
@ -176,14 +193,14 @@ private:
|
|||
//
|
||||
// should be inside the plugin
|
||||
//
|
||||
void HandleSDP(u16 cid, u8* _pData, u32 _Size);
|
||||
void SDPSendServiceSearchResponse(u16 cid, u16 TransactionID, u8* pServiceSearchPattern, u16 MaximumServiceRecordCount);
|
||||
void HandleSDP(u16 _SCID, u8* _pData, u32 _Size);
|
||||
void SDPSendServiceSearchResponse(u16 _SCID, u16 _TransactionID, u8* _pServiceSearchPattern, u16 _MaximumServiceRecordCount);
|
||||
|
||||
void SDPSendServiceAttributeResponse(u16 cid, u16 TransactionID, u32 ServiceHandle,
|
||||
u16 startAttrID, u16 endAttrID,
|
||||
u16 MaximumAttributeByteCount, u8* pContinuationState);
|
||||
void SDPSendServiceAttributeResponse(u16 _SCID, u16 TransactionID, u32 _ServiceHandle,
|
||||
u16 _StartAttrID, u16 _EndAttrID,
|
||||
u16 _MaximumAttributeByteCount, u8* _pContinuationState);
|
||||
|
||||
u16 AddAttribToList(int attribID, u8* pBuffer);
|
||||
u16 AddAttribToList(int _AttribID, u8* _pBuffer);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace PluginWiimote
|
|||
TDllConfig DllConfig = 0;
|
||||
TWiimote_Initialize Wiimote_Initialize = 0;
|
||||
TWiimote_Shutdown Wiimote_Shutdown = 0;
|
||||
TWiimote_Output Wiimote_Output = 0;
|
||||
TWiimote_Input Wiimote_Input = 0;
|
||||
TWiimote_Output Wiimote_ControlChannel = 0;
|
||||
TWiimote_Input Wiimote_InterruptChannel = 0;
|
||||
TWiimote_Update Wiimote_Update = 0;
|
||||
TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers = 0;
|
||||
TWiimote_DoState Wiimote_DoState = 0;
|
||||
|
@ -50,8 +50,8 @@ namespace PluginWiimote
|
|||
DllConfig = 0;
|
||||
Wiimote_Initialize = 0;
|
||||
Wiimote_Shutdown = 0;
|
||||
Wiimote_Output = 0;
|
||||
Wiimote_Input = 0;
|
||||
Wiimote_ControlChannel = 0;
|
||||
Wiimote_InterruptChannel = 0;
|
||||
Wiimote_Update = 0;
|
||||
Wiimote_GetAttachedControllers = 0;
|
||||
Wiimote_DoState = 0;
|
||||
|
@ -66,8 +66,8 @@ namespace PluginWiimote
|
|||
DllConfig = reinterpret_cast<TDllConfig> (plugin.Get("DllConfig"));
|
||||
Wiimote_Initialize = reinterpret_cast<TWiimote_Initialize> (plugin.Get("Wiimote_Initialize"));
|
||||
Wiimote_Shutdown = reinterpret_cast<TWiimote_Shutdown> (plugin.Get("Wiimote_Shutdown"));
|
||||
Wiimote_Output = reinterpret_cast<TWiimote_Output> (plugin.Get("Wiimote_Output"));
|
||||
Wiimote_Input = reinterpret_cast<TWiimote_Input> (plugin.Get("Wiimote_Input"));
|
||||
Wiimote_ControlChannel = reinterpret_cast<TWiimote_Output> (plugin.Get("Wiimote_ControlChannel"));
|
||||
Wiimote_InterruptChannel = reinterpret_cast<TWiimote_Input> (plugin.Get("Wiimote_InterruptChannel"));
|
||||
Wiimote_Update = reinterpret_cast<TWiimote_Update> (plugin.Get("Wiimote_Update"));
|
||||
Wiimote_GetAttachedControllers = reinterpret_cast<TWiimote_GetAttachedControllers> (plugin.Get("Wiimote_GetAttachedControllers"));
|
||||
Wiimote_DoState = reinterpret_cast<TWiimote_DoState> (plugin.Get("Wiimote_DoState"));
|
||||
|
@ -76,16 +76,16 @@ namespace PluginWiimote
|
|||
LOG(MASTER_LOG, "%s: 0x%p", "DllConfig", DllConfig);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Initialize", Wiimote_Initialize);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Shutdown", Wiimote_Shutdown);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Output", Wiimote_Output);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Input", Wiimote_Input);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_ControlChannel", Wiimote_ControlChannel);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_InterruptChannel", Wiimote_InterruptChannel);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Update", Wiimote_Update);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_GetAttachedControllers", Wiimote_GetAttachedControllers);
|
||||
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_DoState", Wiimote_DoState);
|
||||
if ((GetDllInfo != 0) &&
|
||||
(Wiimote_Initialize != 0) &&
|
||||
(Wiimote_Shutdown != 0) &&
|
||||
(Wiimote_Output != 0) &&
|
||||
(Wiimote_Input != 0) &&
|
||||
(Wiimote_ControlChannel != 0) &&
|
||||
(Wiimote_InterruptChannel != 0) &&
|
||||
(Wiimote_Update != 0) &&
|
||||
(Wiimote_GetAttachedControllers != 0) &&
|
||||
(Wiimote_DoState != 0))
|
||||
|
|
|
@ -43,8 +43,8 @@ extern TGetDllInfo GetDllInfo;
|
|||
extern TDllConfig DllConfig;
|
||||
extern TWiimote_Initialize Wiimote_Initialize;
|
||||
extern TWiimote_Shutdown Wiimote_Shutdown;
|
||||
extern TWiimote_Output Wiimote_Output;
|
||||
extern TWiimote_Input Wiimote_Input;
|
||||
extern TWiimote_Output Wiimote_ControlChannel;
|
||||
extern TWiimote_Input Wiimote_InterruptChannel;
|
||||
extern TWiimote_Update Wiimote_Update;
|
||||
extern TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers;
|
||||
extern TWiimote_DoState Wiimote_DoState;
|
||||
|
|
|
@ -67,20 +67,20 @@ EXPORT void CALL Wiimote_Shutdown();
|
|||
// __________________________________________________________________________________________________
|
||||
// Function: Wiimote_Output
|
||||
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
|
||||
// on the HID OUTPUT channel.
|
||||
// on the HID CONTROL channel.
|
||||
// input: Da pakket.
|
||||
// output: none
|
||||
//
|
||||
EXPORT void CALL Wiimote_Output(u16 _channelID, const void* _pData, u32 _Size);
|
||||
EXPORT void CALL Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size);
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Function: Wiimote_Input
|
||||
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
|
||||
// on the HID INPUT channel.
|
||||
// on the HID INTERRUPT channel.
|
||||
// input: Da pakket.
|
||||
// output: none
|
||||
//
|
||||
EXPORT void CALL Wiimote_Input(u16 _channelID, const void* _pData, u32 _Size);
|
||||
EXPORT void CALL Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size);
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Function: Wiimote_Update
|
||||
|
|
|
@ -239,7 +239,7 @@ extern "C" void Wiimote_Shutdown(void)
|
|||
{
|
||||
}
|
||||
|
||||
extern "C" void Wiimote_Input(u16 _channelID, const void* _pData, u32 _Size)
|
||||
extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
@ -285,12 +285,12 @@ extern "C" void Wiimote_Input(u16 _channelID, const void* _pData, u32 _Size)
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" void Wiimote_Output(u16 _channelID, const void* _pData, u32 _Size)
|
||||
extern "C" void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
const u8* data = (const u8*)_pData;
|
||||
// dump raw data
|
||||
{
|
||||
LOG(WIIMOTE, "Wiimote_Output");
|
||||
LOG(WIIMOTE, "Wiimote_ControlChannel");
|
||||
std::string Temp;
|
||||
for (u32 j=0; j<_Size; j++)
|
||||
{
|
||||
|
@ -302,8 +302,6 @@ extern "C" void Wiimote_Output(u16 _channelID, const void* _pData, u32 _Size)
|
|||
}
|
||||
|
||||
hid_packet* hidp = (hid_packet*) data;
|
||||
PanicAlert("HidOutput: Unknown type %x and param %x", hidp->type, hidp->param);
|
||||
|
||||
switch(hidp->type)
|
||||
{
|
||||
case HID_TYPE_HANDSHAKE:
|
||||
|
@ -325,6 +323,10 @@ extern "C" void Wiimote_Output(u16 _channelID, const void* _pData, u32 _Size)
|
|||
else
|
||||
{
|
||||
HidOutputReport(_channelID, (wm_report*)hidp->data);
|
||||
|
||||
//return handshake
|
||||
u8 handshake = 0;
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, &handshake, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -333,7 +335,7 @@ extern "C" void Wiimote_Output(u16 _channelID, const void* _pData, u32 _Size)
|
|||
break;
|
||||
|
||||
default:
|
||||
PanicAlert("HidOutput: Unknown type %x and param %x", hidp->type, hidp->param);
|
||||
PanicAlert("HidControlChanel: Unknown type %x and param %x", hidp->type, hidp->param);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -710,6 +712,9 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
|||
} else {
|
||||
PanicAlert("WmWriteData: unimplemented parameters!");
|
||||
}
|
||||
|
||||
// just added for home brew.... hmmmm
|
||||
WmSendAck(_channelID, WM_WRITE_DATA);
|
||||
}
|
||||
|
||||
int WriteWmReport(u8* dst, u8 channel) {
|
||||
|
|
Loading…
Reference in New Issue