Hi guys,
I'm trying to figure out why this wiimote:
http://cgi.ebay.ie/ws/eBayISAPI.dll?View...0393544125
doesn't work in-game. I'm on x86_64-linux, and working with current git.
Dolphin does detect it, and manages to tell it to rumble. In game, no button or anything appears to do anything, except for the disconnect button, which does close the bluetooth socket, and dolphin detects that okay.
One thing that I notice is that when dolphin handshakes the the wiimote, it tries to set the
corresponding led, and then imediatelly tells the wiimote to rumble. Thing is, the setleds command doesn't actually manage to set the leds most of the time. However, if I put a few sleeps around this, then I always get the leds set correctly, and I get the rumble too. See patch pasted below. I wonder if there's some overflow going on somewhere.
Moving past that, I'm trying to figure out what I _should_ be seeing in the logs in-game. There's a bunch of HCI dialog going on that I don't grok yet. I don't have a nintendo wiimote yet to compare either. So I'm hoping that someone in the know could take a quick look at the logs below and quickly point out if there's anything that looks suspicious. I've tweaked the code a bit to suppress a bunch of log output that doesn't appear to be meaningful (periodic logs of when nothing happens). Again, see patchlet below.
Here's the log. I'm opening the wiimote config dialog, clicking the update button, and pressing 1+2 on the wiimote. Then, I'm booting Mortal Kombat Armageddon. I wait a bit until the game loads. A log of HCI/wiimote spewage happens at this point, which appears to be the wii talking to bluetooth stack and to the wiimote, setting up things. Then, nothing happens when I press buttons. Finally, I give up, and press disconnect. dolphin's read on the bluetooth socket returns 0 at this point, indicating socket closed on the other end. This indicates the socket was open all along, but that nothing was coming through... (???) It sounds like the wiimote gets stuck in some state waiting for the wii to send it something ???.
Can anyone help?
Edit: attached the log instead.
BTW, if someone with a working wiimote were to apply the patch, run a game under dolphin, press a few wiimote buttons, and send me over the dolphin.log so I could compare, I'd be super grateful. That might help a lot already.
You'd need to enable Wiimote and WII_IPC_WIIMOTE logging.
I'm trying to figure out why this wiimote:
http://cgi.ebay.ie/ws/eBayISAPI.dll?View...0393544125
doesn't work in-game. I'm on x86_64-linux, and working with current git.
Dolphin does detect it, and manages to tell it to rumble. In game, no button or anything appears to do anything, except for the disconnect button, which does close the bluetooth socket, and dolphin detects that okay.
One thing that I notice is that when dolphin handshakes the the wiimote, it tries to set the
corresponding led, and then imediatelly tells the wiimote to rumble. Thing is, the setleds command doesn't actually manage to set the leds most of the time. However, if I put a few sleeps around this, then I always get the leds set correctly, and I get the rumble too. See patch pasted below. I wonder if there's some overflow going on somewhere.
Moving past that, I'm trying to figure out what I _should_ be seeing in the logs in-game. There's a bunch of HCI dialog going on that I don't grok yet. I don't have a nintendo wiimote yet to compare either. So I'm hoping that someone in the know could take a quick look at the logs below and quickly point out if there's anything that looks suspicious. I've tweaked the code a bit to suppress a bunch of log output that doesn't appear to be meaningful (periodic logs of when nothing happens). Again, see patchlet below.
Code:
---
Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp | 14 ++++++++++++--
Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp | 11 ++++++++++-
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp | 14 +++++++++-----
3 files changed, 31 insertions(+), 8 deletions(-)
Index: src/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp
===================================================================
--- src.orig/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp 2011-09-24 20:16:45.868207614 +0100
+++ src/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp 2011-09-24 20:20:28.438207800 +0100
@@ -171,14 +171,24 @@ bool Wiimote::Connect()
m_connected = true;
- // Do the handshake
- Handshake();
+ // Try a handshake to see if the device is actually connected
+ if (!Handshake())
+ {
+ m_connected = false;
+ return false;
+ }
+
+ SLEEP(200);
// Set LEDs
SetLEDs(WIIMOTE_LED_1 << index);
+ SLEEP(200);
+
m_wiimote_thread = std::thread(std::mem_fun(&Wiimote::ThreadFunc), this);
+ NOTICE_LOG(WIIMOTE, "Connected to wiimote %i.", index + 1);
+
return true;
}
Index: src/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
===================================================================
--- src.orig/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp 2011-09-24 20:16:45.868207614 +0100
+++ src/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp 2011-09-24 20:20:28.438207800 +0100
@@ -304,10 +304,19 @@ bool Wiimote::Handshake()
bool Wiimote::SendRequest(unsigned char report_type, unsigned char* data, int length)
{
unsigned char buffer[32] = {WM_SET_REPORT | WM_BT_OUTPUT, report_type};
+ int sent;
memcpy(buffer + 2, data, length);
- return (IOWrite(buffer, length + 2) != 0);
+ sent = IOWrite(buffer, length + 2);
+
+ if (sent != length + 2)
+ {
+ DEBUG_LOG(WIIMOTE, "request failed");
+ return false;
+ }
+
+ return true;
}
void Wiimote::ThreadFunc()
Index: src/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
===================================================================
--- src.orig/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp 2011-09-24 20:16:45.868207614 +0100
+++ src/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp 2011-09-24 20:20:28.448207800 +0100
@@ -891,8 +891,6 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305
{
SQueuedEvent Event(sizeof(hci_event_hdr_t) + sizeof(hci_num_compl_pkts_ep) + sizeof(hci_num_compl_pkts_info) * m_WiiMotes.size(), 0);
- INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventNumberOfCompletedPackets");
-
hci_event_hdr_t* event_hdr = (hci_event_hdr_t*)Event.m_buffer;
hci_num_compl_pkts_ep* event = (hci_num_compl_pkts_ep*)((u8*)event_hdr + sizeof(hci_event_hdr_t));
hci_num_compl_pkts_info* info = (hci_num_compl_pkts_info*)((u8*)event + sizeof(hci_num_compl_pkts_ep));
@@ -910,8 +908,14 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305
info->compl_pkts = m_PacketCount[i];
info->con_handle = m_WiiMotes[i].GetConnectionHandle();
- DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", info->con_handle);
- DEBUG_LOG(WII_IPC_WIIMOTE, " Number_Of_Completed_Packets: %i", info->compl_pkts);
+ if (info->compl_pkts)
+ {
+ if (acc == 0)
+ INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventNumberOfCompletedPackets");
+
+ DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", info->con_handle);
+ DEBUG_LOG(WII_IPC_WIIMOTE, " Number_Of_Completed_Packets: %i", info->compl_pkts);
+ }
acc += info->compl_pkts;
m_PacketCount[i] = 0;
@@ -922,7 +926,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305
AddEventToQueue(Event);
else
{
- INFO_LOG(WII_IPC_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event");
+ // INFO_LOG(WII_IPC_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event");
}
return true;
Here's the log. I'm opening the wiimote config dialog, clicking the update button, and pressing 1+2 on the wiimote. Then, I'm booting Mortal Kombat Armageddon. I wait a bit until the game loads. A log of HCI/wiimote spewage happens at this point, which appears to be the wii talking to bluetooth stack and to the wiimote, setting up things. Then, nothing happens when I press buttons. Finally, I give up, and press disconnect. dolphin's read on the bluetooth socket returns 0 at this point, indicating socket closed on the other end. This indicates the socket was open all along, but that nothing was coming through... (???) It sounds like the wiimote gets stuck in some state waiting for the wii to send it something ???.
Can anyone help?
Edit: attached the log instead.
BTW, if someone with a working wiimote were to apply the patch, run a game under dolphin, press a few wiimote buttons, and send me over the dolphin.log so I could compare, I'd be super grateful. That might help a lot already.
You'd need to enable Wiimote and WII_IPC_WIIMOTE logging.