mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
Fix wiimote in homebrew
Marginally speed up old wiimote plugin by doing less memcpys A lot of changes went into the bt dongle emulation, so please test for regressions :) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6177 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -117,8 +117,6 @@ void SendReportCore(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
@ -142,9 +140,6 @@ void SendReportCoreAccel(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
@ -171,9 +166,6 @@ void SendReportCoreAccelIr12(u16 _channelID) {
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
@ -216,9 +208,6 @@ void SendReportCoreAccelExt16(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
@ -291,9 +280,6 @@ void SendReportCoreAccelIr10Ext(u16 _channelID)
|
||||
DEBUG_LOG(WIIMOTE, " Size: %08x", Offset);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
|
@ -605,11 +605,6 @@ void DoState(PointerWrap &p)
|
||||
response to Output from the Wii. */
|
||||
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
/* Debugging. We have not yet decided how much of 'data' we will use, it's
|
||||
not determined by sizeof(data). We have to determine it by looking at
|
||||
the data cases. */
|
||||
//InterruptDebugging(true, (const void*)_pData);
|
||||
|
||||
g_ID = _number;
|
||||
|
||||
hid_packet* hidp = (hid_packet*)_pData;
|
||||
@ -673,13 +668,11 @@ void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
else
|
||||
{
|
||||
// AyuanX: My experiment shows Control Channel is never used
|
||||
// shuffle2: but homebrew uses this, so we'll do what we must :)
|
||||
// shuffle2: but lwbt uses this, so we'll do what we must :)
|
||||
HidOutputReport(_channelID, (wm_report*)hidp->data);
|
||||
|
||||
u8 handshake = HID_HANDSHAKE_SUCCESS;
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, &handshake, 1);
|
||||
|
||||
PanicAlert("HID_TYPE_DATA - OUTPUT: Ambiguous Control Channel Report!");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -179,9 +179,6 @@ void WmSendAck(u16 _channelID, u8 _reportID)
|
||||
DEBUG_LOG(WIIMOTE, " Report ID: %02x", _reportID);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
|
||||
@ -367,9 +364,6 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _AddressHI,
|
||||
|
||||
// Update the size that is left
|
||||
_Size -= copySize;
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -542,9 +536,6 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
||||
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(g_ID, _channelID, DataFrame, Offset);
|
||||
|
||||
// Debugging
|
||||
//ReadDebugging(true, DataFrame, Offset);
|
||||
}
|
||||
|
||||
//http://snzgoo.blogspot.com for more details on what this is doing
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <iostream> // System
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "CommonTypes.h"
|
||||
@ -30,10 +30,8 @@
|
||||
#include <X11/XKBlib.h>
|
||||
extern Display* WMdisplay;
|
||||
#endif
|
||||
// Definitions and declarations
|
||||
|
||||
bool IsFocus();
|
||||
//void InterruptDebugging(bool Emu, const void* _pData);
|
||||
//void ReadDebugging(bool Emu, const void* _pData, int Size);
|
||||
|
||||
// Movement recording
|
||||
#define RECORDING_ROWS 15
|
||||
|
@ -127,10 +127,6 @@ void SendData(u16 _channelID, const u8* _pData, u32 _Size)
|
||||
memcpy(WriteEvent.m_PayLoad, _pData, _Size);
|
||||
WriteEvent._Size = _Size;
|
||||
m_EventWriteQueue.push(WriteEvent);
|
||||
|
||||
// Debugging
|
||||
//std::string Temp = ArrayToString(WriteEvent.m_PayLoad, 28, 0, 30);
|
||||
//DEBUG_LOG(WIIMOTE, "Wiimote Write:\n%s", Temp.c_str());
|
||||
}
|
||||
m_pCriticalSection->Leave();
|
||||
}
|
||||
@ -147,9 +143,10 @@ void ReadData()
|
||||
// Send data to the Wiimote
|
||||
if (!m_EventWriteQueue.empty())
|
||||
{
|
||||
//DEBUG_LOG(WIIMOTE, "Writing data to the Wiimote");
|
||||
SEvent& rEvent = m_EventWriteQueue.front();
|
||||
const SEvent& rEvent = m_EventWriteQueue.front();
|
||||
wiiuse_io_write(m_pWiiMote, (byte*)rEvent.m_PayLoad, rEvent._Size);
|
||||
//std::string Temp = ArrayToString(rEvent.m_PayLoad, rEvent._Size);
|
||||
//DEBUG_LOG(WIIMOTE, "Wiimote Write:\n%s:%d", Temp.c_str(), ret);
|
||||
#ifdef _WIN32
|
||||
if (m_pWiiMote->event == WIIUSE_UNEXPECTED_DISCONNECT)
|
||||
{
|
||||
@ -157,8 +154,6 @@ void ReadData()
|
||||
}
|
||||
#endif
|
||||
m_EventWriteQueue.pop();
|
||||
|
||||
// InterruptDebugging(false, rEvent.m_PayLoad);
|
||||
}
|
||||
|
||||
m_pCriticalSection->Leave();
|
||||
@ -168,6 +163,8 @@ void ReadData()
|
||||
if (wiiuse_io_read(m_pWiiMote))
|
||||
{
|
||||
const byte* pBuffer = m_pWiiMote->event_buf;
|
||||
//std::string Temp = ArrayToString(pBuffer, 20);
|
||||
//DEBUG_LOG(WIIMOTE, "Wiimote Read:\n%s", Temp.c_str());
|
||||
// Check if we have a channel (connection) if so save the data...
|
||||
if (m_channelID > 0)
|
||||
{
|
||||
@ -191,6 +188,8 @@ void ReadData()
|
||||
}
|
||||
m_pCriticalSection->Leave();
|
||||
}
|
||||
|
||||
memset((void*)&m_pWiiMote->event_buf,0,sizeof(m_pWiiMote->event_buf));
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if (m_pWiiMote->event == WIIUSE_UNEXPECTED_DISCONNECT)
|
||||
@ -277,9 +276,6 @@ void SendEvent(SEvent& _rEvent)
|
||||
|
||||
// Send it
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(m_WiimoteNumber, m_channelID, Buffer, Offset);
|
||||
|
||||
// Debugging
|
||||
// ReadDebugging(false, Buffer, Offset);
|
||||
}
|
||||
};
|
||||
|
||||
@ -541,8 +537,14 @@ void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u3
|
||||
|
||||
void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
//DEBUG_LOG(WIIMOTE, "Real ControlChannel on WiiMote #%i", _WiimoteNumber);
|
||||
g_WiiMotes[_WiimoteNumber]->SendData(_channelID, (const u8*)_pData, _Size);
|
||||
|
||||
const hid_packet* const hidp = (hid_packet*)_pData;
|
||||
if (hidp->type == HID_TYPE_SET_REPORT)
|
||||
{
|
||||
u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(_WiimoteNumber, _channelID, &handshake_ok, sizeof(handshake_ok));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,9 +68,6 @@ void Wiimote::ReportMode(const wm_report_mode* const dr)
|
||||
// reset IR camera
|
||||
//memset(m_reg_ir, 0, sizeof(*m_reg_ir)); //ugly hack
|
||||
|
||||
if (false == m_reporting_auto)
|
||||
PanicAlert("Wiimote: Reporting is set to OFF! Everything should be fine, but games never do this.");
|
||||
|
||||
if (dr->mode > 0x37)
|
||||
PanicAlert("Wiimote: Unsupported Reporting mode.");
|
||||
else if (dr->mode < WM_REPORT_CORE)
|
||||
|
@ -763,7 +763,7 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
|
||||
|
||||
INFO_LOG(WIIMOTE, "Emu ControlChannel (page: %i, type: 0x%02x, param: 0x%02x)", m_index, hidp->type, hidp->param);
|
||||
|
||||
switch(hidp->type)
|
||||
switch (hidp->type)
|
||||
{
|
||||
case HID_TYPE_HANDSHAKE :
|
||||
PanicAlert("HID_TYPE_HANDSHAKE - %s", (hidp->param == HID_PARAM_INPUT) ? "INPUT" : "OUPUT");
|
||||
@ -777,13 +777,11 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
|
||||
else
|
||||
{
|
||||
// AyuanX: My experiment shows Control Channel is never used
|
||||
// shuffle2: but homebrew uses this, so we'll do what we must :)
|
||||
// shuffle2: but lwbt uses this, so we'll do what we must :)
|
||||
HidOutputReport((wm_report*)hidp->data);
|
||||
|
||||
u8 handshake = HID_HANDSHAKE_SUCCESS;
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, _channelID, &handshake, 1);
|
||||
|
||||
PanicAlert("HID_TYPE_DATA - OUTPUT: Ambiguous Control Channel Report!");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -118,7 +118,15 @@ void Wiimote::ControlChannel(const u16 channel, const void* const data, const u3
|
||||
if (99 == channel)
|
||||
Disconnect();
|
||||
else
|
||||
{
|
||||
InterruptChannel(channel, data, size);
|
||||
const hid_packet* const hidp = (hid_packet*)data;
|
||||
if (hidp->type == HID_TYPE_SET_REPORT)
|
||||
{
|
||||
u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
|
||||
g_WiimoteInitialize.pWiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Wiimote::InterruptChannel(const u16 channel, const void* const data, const u32 size)
|
||||
|
Reference in New Issue
Block a user