summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorfires.gc <fires.gc@gmail.com>2008-10-26 21:08:19 +0000
committerfires.gc <fires.gc@gmail.com>2008-10-26 21:08:19 +0000
commit6b021b874c2d9bbb14e63c352288bcbf7ff4a43b (patch)
tree25e37005ed4a67d51350a4a26323807ab9cff1b5 /Source/Core
parentc9a8672987a1f4335885816f0637bbc77f4d9cf5 (diff)
some more wpad stuff
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@974 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp101
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h4
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp8
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h3
-rw-r--r--Source/Core/Core/Src/IPC_HLE/hci.h9
5 files changed, 111 insertions, 14 deletions
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
index 8cfcf2113d..303ab173bb 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
@@ -308,7 +308,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
PluginWiimote::Wiimote_Update();
}
-
+#ifdef _WIN32
static bool test = true;
if (GetAsyncKeyState(VK_LBUTTON) && GetAsyncKeyState(VK_RBUTTON))
{
@@ -316,7 +316,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
{
for (size_t i=0; i<m_WiiMotes.size(); i++)
{
- // if (m_WiiMotes[i].EventPagingChanged(2))
+ if (m_WiiMotes[i].EventPagingChanged(2))
{
SendEventRequestConnection(m_WiiMotes[i].GetBD());
}
@@ -324,10 +324,11 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
test = false;
}
}
- else
+/* else
{
test = true;
- }
+ }*/
+#endif
return 0;
}
@@ -540,6 +541,32 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRequestLinkKey(bdaddr_t _bd)
return true;
};
+bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventLinkKeyNotification(const CWII_IPC_HLE_WiiMote& _rWiiMote)
+{
+ SQueuedEvent Event(sizeof(SHCIEventLinkKeyNotification), 0);
+
+ SHCIEventLinkKeyNotification* pEventLinkKey = (SHCIEventLinkKeyNotification*)Event.m_buffer;
+
+ pEventLinkKey->EventType = 0x18;
+ pEventLinkKey->PayloadLength = sizeof(SHCIEventLinkKeyNotification) - 2;
+ pEventLinkKey->bdaddr = _rWiiMote.GetBD();
+ memcpy(pEventLinkKey->LinkKey, _rWiiMote.GetLinkKey(), 16);
+ pEventLinkKey->Key_Type = 0x00;
+
+ AddEventToQueue(Event);
+
+
+ LOG(WIIMOTE, "Event: SendEventLinkKeyNotification");
+ LOG(WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x",
+ pEventLinkKey->bdaddr.b[0], pEventLinkKey->bdaddr.b[1], pEventLinkKey->bdaddr.b[2],
+ pEventLinkKey->bdaddr.b[3], pEventLinkKey->bdaddr.b[4], pEventLinkKey->bdaddr.b[5]);
+ LOG(WIIMOTE, " link key: no reason to show it...");
+ LOG(WIIMOTE, " key type: 0x02%x", pEventLinkKey->Key_Type);
+
+ return true;
+};
+
+
bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(bdaddr_t _bd)
{
@@ -588,7 +615,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(bdaddr_t _
return true;
}
-bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd)
+bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd, bool _master)
{
CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd);
if (pWiiMote == NULL)
@@ -607,7 +634,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd)
pRoleChange->PayloadLength = sizeof(SHCIEventRoleChange) - 2;
pRoleChange->Status = 0x00;
pRoleChange->bdaddr = pWiiMote->GetBD();
- pRoleChange->NewRole = 0x00;
+ pRoleChange->NewRole = _master ? 0x00 : 0x01;
AddEventToQueue(Event);
@@ -984,6 +1011,11 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom
CommandLinkKeyNegRep(pInput);
break;
+ case HCI_CMD_LINK_KEY_REP:
+ CommandLinkKeyRep(pInput);
+ break;
+
+
//
// --- default ---
//
@@ -1123,9 +1155,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadStoredLinkKey(u8* _Input)
// command parameters
hci_read_stored_link_key_cp* ReadStoredLinkKey = (hci_read_stored_link_key_cp*)_Input;
#endif
- // reply
- hci_read_stored_link_key_rp Reply;
- Reply.status = 0x00;
LOG(WIIMOTE, "Command: HCI_CMD_READ_STORED_LINK_KEY:");
LOG(WIIMOTE, "input:");
@@ -1136,7 +1165,28 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadStoredLinkKey(u8* _Input)
LOG(WIIMOTE, "return:");
LOG(WIIMOTE, " no idea what i should answer :)");
+
+ // reply
+ hci_read_stored_link_key_rp Reply;
+ Reply.status = 0x00;
+
+ Reply.max_num_keys = 255;
+ if (ReadStoredLinkKey->read_all)
+ {
+ Reply.num_keys_read = 1;
+ }
+ else
+ {
+ PanicAlert("CommandReadStoredLinkKey");
+ }
+
SendEventCommandComplete(HCI_CMD_READ_STORED_LINK_KEY, &Reply, sizeof(hci_read_stored_link_key_rp));
+
+ // generate link key
+ for (int i=0; i<m_WiiMotes.size(); i++)
+ {
+ SendEventLinkKeyNotification(m_WiiMotes[i]);
+ }
}
void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteUnitClass(u8* _Input)
@@ -1495,6 +1545,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input)
pWiimote->EventConnectionAccepted();
}
+ SendEventRoleChange(pAcceptCon->bdaddr, false);
SendEventConnectionComplete(pAcceptCon->bdaddr);
}
@@ -1510,7 +1561,10 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadClockOffset(u8* _Input)
SendEventCommandStatus(HCI_CMD_READ_CLOCK_OFFSET);
SendEventReadClockOffsetComplete(pReadClockOffset->con_handle);
- //CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pReadClockOffset->con_handle);
+ CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pReadClockOffset->con_handle);
+ SendEventRequestLinkKey(pWiiMote->GetBD());
+
+// CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pReadClockOffset->con_handle);
// pWiiMote->Connect();
}
@@ -1646,6 +1700,33 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandLinkKeyNegRep(u8* _Input)
// pWiiMote->Connect();
}
+void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandLinkKeyRep(u8* _Input)
+{
+ // command parameters
+ hci_link_key_rep_cp* pKeyRep = (hci_link_key_rep_cp*)_Input;
+
+ LOG(WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP");
+ LOG(WIIMOTE, "Input:");
+ LOG(WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x",
+ pKeyRep->bdaddr.b[0], pKeyRep->bdaddr.b[1], pKeyRep->bdaddr.b[2],
+ pKeyRep->bdaddr.b[3], pKeyRep->bdaddr.b[4], pKeyRep->bdaddr.b[5]);
+ LOG(WIIMOTE, " link key: %02x (all the values are the same)", pKeyRep->key[0]);
+
+
+ hci_link_key_rep_rp Reply;
+ Reply.status = 0x00;
+ Reply.bdaddr = pKeyRep->bdaddr;
+
+ SendEventCommandComplete(HCI_CMD_LINK_KEY_REP, &Reply, sizeof(hci_link_key_rep_rp));
+
+
+
+ CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(pKeyRep->bdaddr);
+ SendEventAuthenticationCompleted(pWiiMote->GetConnectionHandle());
+
+ pWiiMote->Connect();
+}
+
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h
index 2cbf3a4adf..a7b9ea7644 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h
@@ -157,12 +157,13 @@ private:
bool SendEventReadClockOffsetComplete(u16 _connectionHandle);
bool SendEventReadRemoteVerInfo(u16 _connectionHandle);
bool SendEventReadRemoteFeatures(u16 _connectionHandle);
- bool SendEventRoleChange(bdaddr_t _bd);
+ bool SendEventRoleChange(bdaddr_t _bd, bool _master);
bool SendEventNumberOfCompletedPackets(u16 _connectionHandle, u16 _count);
bool SendEventAuthenticationCompleted(u16 _connectionHandle);
bool SendEventModeChange(u16 _connectionHandle, u8 _mode, u16 _value);
bool SendEventDisconnect(u16 _connectionHandle, u8 _Reason);
bool SendEventRequestLinkKey(bdaddr_t _bd);
+ bool SendEventLinkKeyNotification(const CWII_IPC_HLE_WiiMote& _rWiiMote);
// Execute HCI Message
void ExecuteHCICommandMessage(const SHCICommandMessage& _rCtrlMessage);
@@ -182,6 +183,7 @@ private:
void CommandInquiry(u8* _Input);
void CommandDisconnect(u8* _Input);
void CommandLinkKeyNegRep(u8* _Input);
+ void CommandLinkKeyRep(u8* _Input);
// OGF 0x02 Link policy commands and return parameters
void CommandWriteLinkPolicy(u8* _Input);
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
index 16d5b1b558..df020ee021 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
@@ -184,6 +184,8 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305*
lmp_version = 0x2;
lmp_subversion = 0x229;
+
+ memset(m_LinkKey, _Number+1, 16);
}
void CWII_IPC_HLE_WiiMote::EventConnectionAccepted()
@@ -322,10 +324,10 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng
void CWII_IPC_HLE_WiiMote::Connect()
{
- SendConnectionRequest(0x0040, 1);
+// SendConnectionRequest(0x0040, 1);
-// SendConnectionRequest(0x0041, HIDP_OUTPUT_CHANNEL);
-// SendConnectionRequest(0x0042, HIDP_INPUT_CHANNEL);
+ SendConnectionRequest(0x0041, HIDP_OUTPUT_CHANNEL);
+ SendConnectionRequest(0x0042, HIDP_INPUT_CHANNEL);
}
void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm)
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h
index 2e8a71cbb8..78d5102475 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h
@@ -113,6 +113,8 @@ public:
void SendL2capData(u16 scid, const void* _pData, u32 _Size); //from wiimote
+ const u8* GetLinkKey() const { return m_LinkKey; }
+
private:
bool m_Connected;
@@ -130,6 +132,7 @@ private:
u16 lmp_subversion;
+ u8 m_LinkKey[16];
std::string m_Name;
diff --git a/Source/Core/Core/Src/IPC_HLE/hci.h b/Source/Core/Core/Src/IPC_HLE/hci.h
index e218c1c266..54561e4112 100644
--- a/Source/Core/Core/Src/IPC_HLE/hci.h
+++ b/Source/Core/Core/Src/IPC_HLE/hci.h
@@ -2541,6 +2541,15 @@ struct SHCIEventRequestLinkKey
bdaddr_t bdaddr;
};
+struct SHCIEventLinkKeyNotification
+{
+ u8 EventType;
+ u8 PayloadLength;
+ bdaddr_t bdaddr;
+ u8 LinkKey[16];
+ u8 Key_Type;
+};
+
#ifdef __cplusplus
}
#endif