Some Wiimote Cleanup, re/moved some globals to where they belong.
A few things could be solved differently/in a better way, but that would involve some classes and stuff (plus work) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5097 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
b6a3df2fcf
commit
f7f11211a1
|
@ -65,10 +65,8 @@ WiimoteBasicConfigDialog::WiimoteBasicConfigDialog(wxWindow *parent, wxWindowID
|
|||
ControlsCreated = false;
|
||||
m_Page = 0;
|
||||
|
||||
m_bEnableUseRealWiimote = true;
|
||||
// Initialize the Real WiiMotes here, so we get a count of how many were found and set everything properly
|
||||
if (!g_RealWiiMoteInitialized)
|
||||
WiiMoteReal::Initialize();
|
||||
WiiMoteReal::Initialize();
|
||||
|
||||
CreateGUIControls();
|
||||
UpdateGUI();
|
||||
|
@ -293,19 +291,17 @@ void WiimoteBasicConfigDialog::UpdateOnce(wxTimerEvent& event)
|
|||
{
|
||||
case IDTM_UPDATE_ONCE:
|
||||
// Reenable the checkbox
|
||||
m_bEnableUseRealWiimote = true;
|
||||
SetCursor(wxCursor(wxCURSOR_ARROW));
|
||||
UpdateGUI();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_WIIUSE
|
||||
void WiimoteBasicConfigDialog::DoRefreshReal()
|
||||
{
|
||||
if (g_RealWiiMoteInitialized)
|
||||
WiiMoteReal::Shutdown();
|
||||
if (!g_RealWiiMoteInitialized)
|
||||
WiiMoteReal::Initialize();
|
||||
WiiMoteReal::Shutdown();
|
||||
WiiMoteReal::Initialize();
|
||||
}
|
||||
|
||||
void WiimoteBasicConfigDialog::DoUseReal()
|
||||
|
@ -332,7 +328,6 @@ void WiimoteBasicConfigDialog::DoUseReal()
|
|||
{
|
||||
// Disable the checkbox for a moment
|
||||
SetCursor(wxCursor(wxCURSOR_WAIT));
|
||||
m_bEnableUseRealWiimote = false;
|
||||
// We may not need this if there is already a message queue that allows the nessesary timeout
|
||||
//sleep(100);
|
||||
|
||||
|
@ -342,6 +337,7 @@ void WiimoteBasicConfigDialog::DoUseReal()
|
|||
m_TimeoutOnce->Start(1000, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Generate connect/disconnect status event
|
||||
void WiimoteBasicConfigDialog::DoExtensionConnectedDisconnected(int Extension)
|
||||
|
|
|
@ -56,7 +56,7 @@ class WiimoteBasicConfigDialog : public wxDialog
|
|||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
bool ControlsCreated, m_bEnableUseRealWiimote;
|
||||
bool ControlsCreated;
|
||||
int m_Page;
|
||||
|
||||
wxNotebook *m_Notebook;
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
#endif
|
||||
|
||||
// Replace the harder to understand -1 with "" for the sake of user friendliness
|
||||
void WiimotePadConfigDialog::ToBlank(bool ToBlank, int Id)
|
||||
void WiimotePadConfigDialog::ToBlank(bool toBlank, int Id)
|
||||
{
|
||||
if (!m_ControlsCreated)
|
||||
return;
|
||||
|
||||
if(ToBlank)
|
||||
if(toBlank)
|
||||
{
|
||||
if (GetButtonText(Id) == wxString(wxT("-1")))
|
||||
SetButtonText(Id, wxString());
|
||||
|
|
|
@ -97,9 +97,9 @@ void WiimoteRecordingConfigDialog::CloseClick(wxCommandEvent& event)
|
|||
switch(event.GetId())
|
||||
{
|
||||
case ID_CLOSE:
|
||||
if (g_RealWiiMoteInitialized)
|
||||
WiiMoteReal::g_StopThreadTemporary.Set(); //WiiMoteReal::SafecloseRemoteFunc over takes the closing of the Dlg
|
||||
else
|
||||
#if HAVE_WIIUSE
|
||||
if (!WiiMoteReal::SafeClose())
|
||||
#endif
|
||||
Close();
|
||||
break;
|
||||
case ID_APPLY:
|
||||
|
|
|
@ -417,246 +417,4 @@ void RotateIRDot(int &_x, int &_y, STiltData &_TiltData)
|
|||
if (_y < 0 || _y > 767) _y = 0xFFFF;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// Test the calculations
|
||||
void TiltTest(u8 x, u8 y, u8 z)
|
||||
{
|
||||
int Roll, Pitch, RollAdj, PitchAdj;
|
||||
PitchAccelerometerToDegree(x, y, z, Roll, Pitch, RollAdj, PitchAdj);
|
||||
std::string From = StringFromFormat("From: X:%i Y:%i Z:%i Roll:%s Pitch:%s", x, y, z,
|
||||
(Roll >= 0) ? StringFromFormat(" %03i", Roll).c_str() : StringFromFormat("%04i", Roll).c_str(),
|
||||
(Pitch >= 0) ? StringFromFormat(" %03i", Pitch).c_str() : StringFromFormat("%04i", Pitch).c_str());
|
||||
|
||||
float _Roll = (float)Roll, _Pitch = (float)Pitch;
|
||||
PitchDegreeToAccelerometer(_Roll, _Pitch, x, y, z);
|
||||
std::string To = StringFromFormat("%s\nTo: X:%i Y:%i Z:%i Roll:%s Pitch:%s", From.c_str(), x, y, z,
|
||||
(_Roll >= 0) ? StringFromFormat(" %03i", (int)_Roll).c_str() : StringFromFormat("%04i", (int)_Roll).c_str(),
|
||||
(_Pitch >= 0) ? StringFromFormat(" %03i", (int)_Pitch).c_str() : StringFromFormat("%04i", (int)_Pitch).c_str());
|
||||
NOTICE_LOG(CONSOLE, "\n%s", To.c_str());
|
||||
}
|
||||
|
||||
// Accelerometer to roll and pitch angles
|
||||
float AccelerometerToG(float Current, float Neutral, float G)
|
||||
{
|
||||
float _G = (Current - Neutral) / G;
|
||||
return _G;
|
||||
}
|
||||
|
||||
void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int &_RollAdj, int &_PitchAdj)
|
||||
{
|
||||
// Definitions
|
||||
float Roll = 0, Pitch = 0;
|
||||
|
||||
// Calculate how many g we are from the neutral
|
||||
float x = AccelerometerToG((float)_x, (float)g_wm.cal_zero.x, (float)g_wm.cal_g.x);
|
||||
float y = AccelerometerToG((float)_y, (float)g_wm.cal_zero.y, (float)g_wm.cal_g.y);
|
||||
float z = AccelerometerToG((float)_z, (float)g_wm.cal_zero.z, (float)g_wm.cal_g.z);
|
||||
|
||||
if (!g_Config.bUpright)
|
||||
{
|
||||
// If it is over 1g then it is probably accelerating and may not reliable
|
||||
//if (abs(accel->x - ac->cal_zero.x) <= ac->cal_g.x)
|
||||
{
|
||||
// Calculate the degree
|
||||
Roll = InputCommon::Rad2Deg(atan2(x, z));
|
||||
}
|
||||
|
||||
//if (abs(_y - g_wm.cal_zero.y) <= g_wm.cal_g.y)
|
||||
{
|
||||
// Calculate the degree
|
||||
Pitch = InputCommon::Rad2Deg(atan2(y, z));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (abs(accel->z - ac->cal_zero.z) <= ac->cal_g.x)
|
||||
{
|
||||
// Calculate the degree
|
||||
Roll = InputCommon::Rad2Deg(atan2(z, -y));
|
||||
}
|
||||
|
||||
//if (abs(_x - g_wm.cal_zero.x) <= g_wm.cal_g.x)
|
||||
{
|
||||
// Calculate the degree
|
||||
Pitch = InputCommon::Rad2Deg(atan2(-x, -y));
|
||||
}
|
||||
}
|
||||
|
||||
_Roll = (int)Roll;
|
||||
_Pitch = (int)Pitch;
|
||||
|
||||
// Don't allow forces bigger than 1g
|
||||
if (x < -1.0) x = -1.0; else if (x > 1.0) x = 1.0;
|
||||
if (y < -1.0) y = -1.0; else if (y > 1.0) y = 1.0;
|
||||
if (z < -1.0) z = -1.0; else if (z > 1.0) z = 1.0;
|
||||
if (!g_Config.bUpright)
|
||||
{
|
||||
Roll = InputCommon::Rad2Deg(atan2(x, z));
|
||||
Pitch = InputCommon::Rad2Deg(atan2(y, z));
|
||||
}
|
||||
else
|
||||
{
|
||||
Roll = InputCommon::Rad2Deg(atan2(z, -y));
|
||||
Pitch = InputCommon::Rad2Deg(atan2(-x, -y));
|
||||
}
|
||||
_RollAdj = (int)Roll;
|
||||
_PitchAdj = (int)Pitch;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
// IR data functions
|
||||
//******************************************************************************
|
||||
|
||||
// Calculate dot positions from the basic 10 byte IR data
|
||||
void IRData2DotsBasic(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
|
||||
|
||||
Dot[0].Rx = 1023 - (Data[0] | ((Data[2] & 0x30) << 4));
|
||||
Dot[0].Ry = Data[1] | ((Data[2] & 0xc0) << 2);
|
||||
|
||||
Dot[1].Rx = 1023 - (Data[3] | ((Data[2] & 0x03) << 8));
|
||||
Dot[1].Ry = Data[4] | ((Data[2] & 0x0c) << 6);
|
||||
|
||||
Dot[2].Rx = 1023 - (Data[5] | ((Data[7] & 0x30) << 4));
|
||||
Dot[2].Ry = Data[6] | ((Data[7] & 0xc0) << 2);
|
||||
|
||||
Dot[3].Rx = 1023 - (Data[8] | ((Data[7] & 0x03) << 8));
|
||||
Dot[3].Ry = Data[9] | ((Data[7] & 0x0c) << 6);
|
||||
|
||||
// set each IR spot to visible if spot is in range
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (Dot[i].Ry == 1023)
|
||||
{
|
||||
Dot[i].Visible = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dot[i].Visible = 1;
|
||||
Dot[i].Size = 0; // since we don't know the size, set it as 0
|
||||
}
|
||||
|
||||
// For now we let our virtual resolution be the same as the default one
|
||||
Dot[i].X = Dot[i].Rx; Dot[i].Y = Dot[i].Ry;
|
||||
}
|
||||
|
||||
// Calculate the other values
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
void IRData2Dots(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
//Console::Print("Rx: %i\n", Dot[i].Rx);
|
||||
|
||||
Dot[i].Rx = 1023 - (Data[3*i] | ((Data[(3*i)+2] & 0x30) << 4));
|
||||
Dot[i].Ry = Data[(3*i)+1] | ((Data[(3*i)+2] & 0xc0) << 2);
|
||||
|
||||
Dot[i].Size = Data[(3*i)+2] & 0x0f;
|
||||
|
||||
// if in range set to visible
|
||||
if (Dot[i].Ry == 1023)
|
||||
Dot[i].Visible = false;
|
||||
else
|
||||
Dot[i].Visible = true;
|
||||
|
||||
//Console::Print("Rx: %i\n", Dot[i].Rx);
|
||||
|
||||
// For now we let our virtual resolution be the same as the default one
|
||||
Dot[i].X = Dot[i].Rx; Dot[i].Y = Dot[i].Ry;
|
||||
}
|
||||
|
||||
// Calculate the other values
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
|
||||
// Reorder the IR dots according to their x-axis value
|
||||
void ReorderIRDots()
|
||||
{
|
||||
// Create a shortcut
|
||||
SDot* Dot = g_Wiimote_kbd.IR.Dot;
|
||||
|
||||
// Variables
|
||||
int i, j, order;
|
||||
|
||||
// Reset the dot ordering to zero
|
||||
for (i = 0; i < 4; ++i)
|
||||
Dot[i].Order = 0;
|
||||
|
||||
// is this just a weird filter+sort?
|
||||
for (order = 1; order < 5; ++order)
|
||||
{
|
||||
i = 0;
|
||||
|
||||
//
|
||||
for (; !Dot[i].Visible || Dot[i].Order; ++i)
|
||||
if (i > 4) return;
|
||||
|
||||
//
|
||||
for (j = 0; j < 4; ++j)
|
||||
{
|
||||
if (Dot[j].Visible && !Dot[j].Order && (Dot[j].X < Dot[i].X))
|
||||
i = j;
|
||||
}
|
||||
|
||||
Dot[i].Order = order;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
void IRData2Distance()
|
||||
{
|
||||
// Create a shortcut
|
||||
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
|
||||
|
||||
// Make these ones global
|
||||
int i1, i2;
|
||||
|
||||
for (i1 = 0; i1 < 4; ++i1)
|
||||
if (Dot[i1].Visible) break;
|
||||
|
||||
// Only one dot was visible, we can not calculate the distance
|
||||
if (i1 == 4) { g_Wiimote_kbd.IR.Distance = 0; return; }
|
||||
|
||||
// Look at the next dot
|
||||
for (i2 = i1 + 1; i2 < 4; ++i2)
|
||||
if (Dot[i2].Visible) break;
|
||||
|
||||
// Only one dot was visible, we can not calculate the distance
|
||||
if (i2 == 4) { g_Wiimote_kbd.IR.Distance = 0; return; }
|
||||
|
||||
// For the emulated Wiimote the y distance is always zero so then the distance is the
|
||||
// simple distance between the x dots, i.e. the sensor bar width
|
||||
int xd = Dot[i2].X - Dot[i1].X;
|
||||
int yd = Dot[i2].Y - Dot[i1].Y;
|
||||
|
||||
// Save the distance
|
||||
g_Wiimote_kbd.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
// Classic Controller functions
|
||||
//******************************************************************************
|
||||
|
||||
std::string CCData2Values(u8 *Data)
|
||||
{
|
||||
return StringFromFormat(
|
||||
"Tl:%03i Tr:%03i Lx:%03i Ly:%03i Rx:%03i Ry:%03i",
|
||||
(((Data[2] & 0x60) >> 2) | ((Data[3] & 0xe0) >> 5)),
|
||||
(Data[3] & 0x1f),
|
||||
(Data[0] & 0x3f),
|
||||
(Data[1] & 0x3f),
|
||||
((Data[0] & 0xc0) >> 3) | ((Data[1] & 0xc0) >> 5) | ((Data[2] & 0x80) >> 7),
|
||||
(Data[2] & 0x1f));
|
||||
}
|
||||
*/
|
||||
|
||||
} // WiiMoteEmu
|
||||
|
|
|
@ -36,6 +36,14 @@ extern SWiimoteInitialize g_WiimoteInitialize;
|
|||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
// Settings
|
||||
accel_cal g_wm;
|
||||
nu_cal g_nu;
|
||||
cc_cal g_ClassicContCalibration;
|
||||
gh3_cal g_GH3Calibration;
|
||||
|
||||
bool g_EmulatedWiiMoteInitialized = false;
|
||||
|
||||
/* Homebrew encryption for 16 byte zero keys. */
|
||||
void CryptBuffer(u8* _buffer, u8 _size)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,14 @@
|
|||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
// TODO: those are only used with Emulated wiimote.
|
||||
// if it were a class, we didn't need the extern here.
|
||||
// Settings
|
||||
extern accel_cal g_wm;
|
||||
extern nu_cal g_nu;
|
||||
extern cc_cal g_ClassicContCalibration;
|
||||
extern gh3_cal g_GH3Calibration;
|
||||
|
||||
u32 convert24bit(const u8* src);
|
||||
u16 convert16bit(const u8* src);
|
||||
|
||||
|
|
|
@ -52,15 +52,6 @@ bool g_EmulatorRunning = false;
|
|||
u32 g_ISOId = 0;
|
||||
bool g_SearchDeviceDone = false;
|
||||
bool g_RealWiiMotePresent = false;
|
||||
bool g_RealWiiMoteInitialized = false;
|
||||
bool g_RealWiiMoteAllocated = false;
|
||||
bool g_EmulatedWiiMoteInitialized = false;
|
||||
|
||||
// Settings
|
||||
accel_cal g_wm;
|
||||
nu_cal g_nu;
|
||||
cc_cal g_ClassicContCalibration;
|
||||
gh3_cal g_GH3Calibration;
|
||||
|
||||
// Debugging
|
||||
bool g_DebugAccelerometer = false;
|
||||
|
@ -212,7 +203,7 @@ void Initialize(void *init)
|
|||
g_ISOId = g_WiimoteInitialize.ISOId;
|
||||
// Load the settings
|
||||
g_Config.Load();
|
||||
if(m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
||||
m_BasicConfigFrame->UpdateGUI();
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
|
@ -235,13 +226,10 @@ void Initialize(void *init)
|
|||
false. This function call will be done instantly whether there is a real
|
||||
Wiimote connected or not. It takes no time for Wiiuse to check for
|
||||
connected Wiimotes. */
|
||||
#if HAVE_WIIUSE
|
||||
//if (g_Config.bConnectRealWiimote) WiiMoteReal::Initialize();
|
||||
if(!g_RealWiiMoteInitialized)
|
||||
WiiMoteReal::Initialize();
|
||||
if(!g_RealWiiMoteAllocated)
|
||||
WiiMoteReal::Allocate();
|
||||
#endif
|
||||
#if HAVE_WIIUSE
|
||||
WiiMoteReal::Initialize();
|
||||
WiiMoteReal::Allocate();
|
||||
#endif
|
||||
}
|
||||
|
||||
// If a game is not running this is called by the Configuration window when it's closed
|
||||
|
@ -254,7 +242,7 @@ void Shutdown(void)
|
|||
g_ISOId = 0;
|
||||
|
||||
#if HAVE_WIIUSE
|
||||
if (g_RealWiiMoteInitialized) WiiMoteReal::Shutdown();
|
||||
WiiMoteReal::Shutdown();
|
||||
#endif
|
||||
WiiMoteEmu::Shutdown();
|
||||
}
|
||||
|
@ -466,545 +454,3 @@ int GetUpdateRate()
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
// Turn off all extensions
|
||||
void DisableExtensions()
|
||||
{
|
||||
g_Config.iExtensionConnected = EXT_NONE;
|
||||
}
|
||||
|
||||
void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
{
|
||||
//
|
||||
//const u8* data = (const u8*)_pData;
|
||||
//u8* data = (u8*)_pData;
|
||||
// Copy the data to a new location that we know are the right size
|
||||
u8 data[32];
|
||||
memset(data, 0, sizeof(data));
|
||||
memcpy(data, _pData, Size);
|
||||
|
||||
int size;
|
||||
bool DataReport = false;
|
||||
std::string Name, TmpData;
|
||||
switch(data[1])
|
||||
{
|
||||
case WM_STATUS_REPORT: // 0x20
|
||||
size = sizeof(wm_status_report);
|
||||
Name = "WM_STATUS_REPORT";
|
||||
{
|
||||
wm_status_report* pStatus = (wm_status_report*)(data + 2);
|
||||
DEBUG_LOG(WIIMOTE, ""
|
||||
"Extension Controller: %i "
|
||||
//"Speaker enabled: %i "
|
||||
//"IR camera enabled: %i "
|
||||
//"LED 1: %i "
|
||||
//"LED 2: %i "
|
||||
//"LED 3: %i "
|
||||
//"LED 4: %i "
|
||||
"Battery low: %i",
|
||||
pStatus->extension,
|
||||
//pStatus->speaker,
|
||||
//pStatus->ir,
|
||||
//(pStatus->leds >> 0),
|
||||
//(pStatus->leds >> 1),
|
||||
//(pStatus->leds >> 2),
|
||||
//(pStatus->leds >> 3),
|
||||
pStatus->battery_low
|
||||
);
|
||||
// Update the global (for both the real and emulated) extension settings from whatever
|
||||
// the real Wiimote use. We will enable the extension from the 0x21 report.
|
||||
if(!Emu && !pStatus->extension)
|
||||
{
|
||||
DisableExtensions();
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
if (m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_READ_DATA_REPLY: // 0x21
|
||||
size = sizeof(wm_read_data_reply);
|
||||
Name = "REPLY";
|
||||
// data[4]: Size and error
|
||||
// data[5, 6]: The registry offset
|
||||
|
||||
// Show the extension ID
|
||||
if ((data[4] == 0x10 || data[4] == 0x20 || data[4] == 0x50) && data[5] == 0x00 && (data[6] == 0xfa || data[6] == 0xfe))
|
||||
{
|
||||
if(data[4] == 0x10)
|
||||
TmpData.append(StringFromFormat("Game got the encrypted extension ID: %02x%02x", data[7], data[8]));
|
||||
else if(data[4] == 0x50)
|
||||
TmpData.append(StringFromFormat("Game got the encrypted extension ID: %02x%02x%02x%02x%02x%02x", data[7], data[8], data[9], data[10], data[11], data[12]));
|
||||
|
||||
// We have already sent the data report so we can safely decrypt it now
|
||||
if(WiiMoteEmu::g_Encryption)
|
||||
{
|
||||
if(data[4] == 0x10)
|
||||
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[0x07], 0x06, (data[4] >> 0x04) + 1);
|
||||
if(data[4] == 0x50)
|
||||
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[0x07], 0x02, (data[4] >> 0x04) + 1);
|
||||
}
|
||||
|
||||
// Update the global extension settings. Enable the emulated extension from reading
|
||||
// what the real Wiimote has connected. To keep the emulated and real Wiimote in sync.
|
||||
if(data[4] == 0x10)
|
||||
{
|
||||
if (!Emu) DisableExtensions();
|
||||
if (!Emu && data[7] == 0x00 && data[8] == 0x00)
|
||||
g_Config.iExtensionConnected = EXT_NUNCHUCK;
|
||||
if (!Emu && data[7] == 0x01 && data[8] == 0x01)
|
||||
g_Config.iExtensionConnected = EXT_CLASSIC_CONTROLLER;
|
||||
g_Config.Save();
|
||||
WiiMoteEmu::UpdateEeprom();
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
if (m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
||||
#endif
|
||||
DEBUG_LOG(WIIMOTE, "%s", TmpData.c_str());
|
||||
DEBUG_LOG(WIIMOTE, "Game got the decrypted extension ID: %02x%02x", data[7], data[8]);
|
||||
}
|
||||
else if(data[4] == 0x50)
|
||||
{
|
||||
if (!Emu) DisableExtensions();
|
||||
if (!Emu && data[11] == 0x00 && data[12] == 0x00)
|
||||
g_Config.iExtensionConnected = EXT_NUNCHUCK;
|
||||
if (!Emu && data[11] == 0x01 && data[12] == 0x01)
|
||||
g_Config.iExtensionConnected = EXT_CLASSIC_CONTROLLER;
|
||||
g_Config.Save();
|
||||
WiiMoteEmu::UpdateEeprom();
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
if (m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI();
|
||||
#endif
|
||||
DEBUG_LOG(WIIMOTE, "%s", TmpData.c_str());
|
||||
DEBUG_LOG(WIIMOTE, "Game got the decrypted extension ID: %02x%02x%02x%02x%02x%02x", data[7], data[8], data[9], data[10], data[11], data[12]);
|
||||
}
|
||||
}
|
||||
|
||||
// Show the Wiimote neutral values
|
||||
// The only difference between the Nunchuck and Wiimote that we go
|
||||
// after is calibration here is the offset in memory. If needed we can
|
||||
// check the preceding 0x17 request to.
|
||||
if(data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10)
|
||||
{
|
||||
if(data[6] == 0x10)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Game got the Wiimote calibration:");
|
||||
DEBUG_LOG(WIIMOTE, "Cal_zero.x: %i", data[7 + 6]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_zero.y: %i", data[7 + 7]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_zero.z: %i", data[7 + 8]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_g.x: %i", data[7 + 10]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_g.y: %i", data[7 + 11]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_g.z: %i", data[7 +12]);
|
||||
}
|
||||
}
|
||||
|
||||
// Show the Nunchuck neutral values
|
||||
if(data[4] == 0xf0 && data[5] == 0x00 && (data[6] == 0x20 || data[6] == 0x30))
|
||||
{
|
||||
// Save the encrypted data
|
||||
TmpData = StringFromFormat("Read[%s] (enc): %s", (Emu ? "Emu" : "Real"), ArrayToString(data, size + 2, 0, 30).c_str());
|
||||
|
||||
// We have already sent the data report so we can safely decrypt it now
|
||||
if(WiiMoteEmu::g_Encryption)
|
||||
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[0x07], 0x00, (data[4] >> 0x04) + 1);
|
||||
|
||||
if (g_Config.iExtensionConnected == EXT_NUNCHUCK)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Game got the Nunchuck calibration:");
|
||||
DEBUG_LOG(WIIMOTE, "Cal_zero.x: %i", data[7 + 0]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_zero.y: %i", data[7 + 1]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_zero.z: %i", data[7 + 2]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_g.x: %i", data[7 + 4]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_g.y: %i", data[7 + 5]);
|
||||
DEBUG_LOG(WIIMOTE, "Cal_g.z: %i", data[7 + 6]);
|
||||
DEBUG_LOG(WIIMOTE, "Js.Max.x: %i", data[7 + 8]);
|
||||
DEBUG_LOG(WIIMOTE, "Js.Min.x: %i", data[7 + 9]);
|
||||
DEBUG_LOG(WIIMOTE, "Js.Center.x: %i", data[7 + 10]);
|
||||
DEBUG_LOG(WIIMOTE, "Js.Max.y: %i", data[7 + 11]);
|
||||
DEBUG_LOG(WIIMOTE, "Js.Min.y: %i", data[7 + 12]);
|
||||
DEBUG_LOG(WIIMOTE, "JS.Center.y: %i", data[7 + 13]);
|
||||
}
|
||||
else // g_Config.bClassicControllerConnected
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Game got the Classic Controller calibration:");
|
||||
DEBUG_LOG(WIIMOTE, "Lx.Max: %i", data[7 + 0]);
|
||||
DEBUG_LOG(WIIMOTE, "Lx.Min: %i", data[7 + 1]);
|
||||
DEBUG_LOG(WIIMOTE, "Lx.Center: %i", data[7 + 2]);
|
||||
DEBUG_LOG(WIIMOTE, "Ly.Max: %i", data[7 + 3]);
|
||||
DEBUG_LOG(WIIMOTE, "Ly.Min: %i", data[7 + 4]);
|
||||
DEBUG_LOG(WIIMOTE, "Ly.Center: %i", data[7 + 5]);
|
||||
DEBUG_LOG(WIIMOTE, "Rx.Max.x: %i", data[7 + 6]);
|
||||
DEBUG_LOG(WIIMOTE, "Rx.Min.x: %i", data[7 + 7]);
|
||||
DEBUG_LOG(WIIMOTE, "Rx.Center.x: %i", data[7 + 8]);
|
||||
DEBUG_LOG(WIIMOTE, "Ry.Max.y: %i", data[7 + 9]);
|
||||
DEBUG_LOG(WIIMOTE, "Ry.Min: %i", data[7 + 10]);
|
||||
DEBUG_LOG(WIIMOTE, "Ry.Center: %i", data[7 + 11]);
|
||||
DEBUG_LOG(WIIMOTE, "Lt.Neutral: %i", data[7 + 12]);
|
||||
DEBUG_LOG(WIIMOTE, "Rt.Neutral %i", data[7 + 13]);
|
||||
}
|
||||
|
||||
// Save the values if they come from the real Wiimote
|
||||
if (!Emu)
|
||||
{
|
||||
// Save the values from the Nunchuck
|
||||
if(data[7 + 0] != 0xff)
|
||||
{
|
||||
memcpy(WiiMoteEmu::g_RegExt + 0x20, &data[7], 0x10);
|
||||
memcpy(WiiMoteEmu::g_RegExt + 0x30, &data[7], 0x10);
|
||||
|
||||
}
|
||||
// Save the default values that should work with Wireless Nunchucks
|
||||
else
|
||||
{
|
||||
WiiMoteEmu::UpdateExtRegisterBlocks();
|
||||
}
|
||||
WiiMoteEmu::UpdateEeprom();
|
||||
}
|
||||
// We got a third party nunchuck
|
||||
else if(data[7 + 0] == 0xff)
|
||||
{
|
||||
memcpy(WiiMoteEmu::g_RegExt + 0x20, WiiMoteEmu::wireless_nunchuck_calibration, sizeof(WiiMoteEmu::wireless_nunchuck_calibration));
|
||||
memcpy(WiiMoteEmu::g_RegExt + 0x30, WiiMoteEmu::wireless_nunchuck_calibration, sizeof(WiiMoteEmu::wireless_nunchuck_calibration));
|
||||
}
|
||||
|
||||
// Show the encrypted data
|
||||
DEBUG_LOG(WIIMOTE, "%s", TmpData.c_str());
|
||||
}
|
||||
|
||||
break;
|
||||
case WM_ACK_DATA: // 0x22
|
||||
size = sizeof(wm_acknowledge) - 1;
|
||||
Name = "REPLY";
|
||||
break;
|
||||
case WM_REPORT_CORE: // 0x30-0x37
|
||||
size = sizeof(wm_report_core);
|
||||
DataReport = true;
|
||||
break;
|
||||
case WM_REPORT_CORE_ACCEL:
|
||||
size = sizeof(wm_report_core_accel);
|
||||
DataReport = true;
|
||||
break;
|
||||
case WM_REPORT_CORE_EXT8:
|
||||
size = sizeof(wm_report_core_accel_ir12);
|
||||
DataReport = true;
|
||||
break;
|
||||
case WM_REPORT_CORE_ACCEL_IR12:
|
||||
size = sizeof(wm_report_core_accel_ir12);
|
||||
DataReport = true;
|
||||
break;
|
||||
case WM_REPORT_CORE_EXT19:
|
||||
size = sizeof(wm_report_core_accel_ext16);
|
||||
DataReport = true;
|
||||
break;
|
||||
case WM_REPORT_CORE_ACCEL_EXT16:
|
||||
size = sizeof(wm_report_core_accel_ext16);
|
||||
DataReport = true;
|
||||
break;
|
||||
case WM_REPORT_CORE_IR10_EXT9:
|
||||
size = sizeof(wm_report_core_accel_ir10_ext6);
|
||||
DataReport = true;
|
||||
break;
|
||||
case WM_REPORT_CORE_ACCEL_IR10_EXT6:
|
||||
size = sizeof(wm_report_core_accel_ir10_ext6);
|
||||
DataReport = true;
|
||||
break;
|
||||
default:
|
||||
//PanicAlert("%s ReadDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]);
|
||||
DEBUG_LOG(WIIMOTE, "%s ReadDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DataReport && g_DebugComm)
|
||||
{
|
||||
std::string tmpData = ArrayToString(data, size + 2, 0, 30);
|
||||
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
DEBUG_LOG(WIIMOTE, "Read[%s] %s: %s", (Emu ? "Emu" : "Real"), Name.c_str(), tmpData.c_str()); // No timestamp
|
||||
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str()); // Timestamp
|
||||
}
|
||||
|
||||
if (DataReport && g_DebugData)
|
||||
{
|
||||
// Decrypt extension data
|
||||
if(WiiMoteEmu::g_ReportingMode == 0x37)
|
||||
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[17], 0x00, 0x06);
|
||||
if(WiiMoteEmu::g_ReportingMode == 0x35)
|
||||
wiimote_decrypt(&WiiMoteEmu::g_ExtKey, &data[7], 0x00, 0x06);
|
||||
|
||||
// Produce string
|
||||
//std::string TmpData = ArrayToString(data, size + 2, 0, 30);
|
||||
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
std::string TmpCore = "", TmpAccel = "", TmpIR = "", TmpExt = "", CCData = "";
|
||||
TmpCore = StringFromFormat(
|
||||
"%02x %02x %02x %02x",
|
||||
data[0], data[1], data[2], data[3]); // Header and core buttons
|
||||
|
||||
TmpAccel = StringFromFormat(
|
||||
"%03i %03i %03i",
|
||||
data[4], data[5], data[6]); // Wiimote accelerometer
|
||||
|
||||
if (data[1] == 0x33) // WM_REPORT_CORE_ACCEL_IR12
|
||||
{
|
||||
TmpIR = StringFromFormat(
|
||||
"%02x %02x %02x %02x %02x %02x"
|
||||
" %02x %02x %02x %02x %02x %02x",
|
||||
data[7], data[8], data[9], data[10], data[11], data[12],
|
||||
data[13], data[14], data[15], data[16], data[17], data[18]);
|
||||
}
|
||||
if (data[1] == 0x35) // WM_REPORT_CORE_ACCEL_EXT16
|
||||
{
|
||||
TmpExt = StringFromFormat(
|
||||
"%02x %02x %02x %02x %02x %02x",
|
||||
data[7], data[8], // Nunchuck stick
|
||||
data[9], data[10], data[11], // Nunchuck Accelerometer
|
||||
data[12]); // Nunchuck buttons
|
||||
|
||||
CCData = WiiMoteEmu::CCData2Values(&data[7]);
|
||||
}
|
||||
if (data[1] == 0x37) // WM_REPORT_CORE_ACCEL_IR10_EXT6
|
||||
{
|
||||
TmpIR = StringFromFormat(
|
||||
"%02x %02x %02x %02x %02x"
|
||||
" %02x %02x %02x %02x %02x",
|
||||
data[7], data[8], data[9], data[10], data[11],
|
||||
data[12], data[13], data[14], data[15], data[16]);
|
||||
TmpExt = StringFromFormat(
|
||||
"%02x %02x %02x %02x %02x %02x",
|
||||
data[17], data[18], // Nunchuck stick
|
||||
data[19], data[20], data[21], // Nunchuck Accelerometer
|
||||
data[22]); // Nunchuck buttons
|
||||
CCData = WiiMoteEmu::CCData2Values(&data[17]);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
// Calculate the Wiimote roll and pitch in degrees
|
||||
// -----------
|
||||
int Roll, Pitch, RollAdj, PitchAdj;
|
||||
WiiMoteEmu::PitchAccelerometerToDegree(data[4], data[5], data[6], Roll, Pitch, RollAdj, PitchAdj);
|
||||
std::string RollPitch = StringFromFormat("%s %s %s %s",
|
||||
(Roll >= 0) ? StringFromFormat(" %03i", Roll).c_str() : StringFromFormat("%04i", Roll).c_str(),
|
||||
(Pitch >= 0) ? StringFromFormat(" %03i", Pitch).c_str() : StringFromFormat("%04i", Pitch).c_str(),
|
||||
(RollAdj == Roll) ? " " : StringFromFormat("%04i*", RollAdj).c_str(),
|
||||
(PitchAdj == Pitch) ? " " : StringFromFormat("%04i*", PitchAdj).c_str());
|
||||
// -------------------------
|
||||
|
||||
// ---------------------------------------------
|
||||
// Test the angles to x, y, z values formula by calculating the values back and forth
|
||||
// -----------
|
||||
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
|
||||
Console->ClearScreen();
|
||||
// Show a test of our calculations
|
||||
WiiMoteEmu::TiltTest(data[4], data[5], data[6]);
|
||||
u8 x, y, z;
|
||||
//WiiMoteEmu::Tilt(x, y, z);
|
||||
//WiiMoteEmu::TiltTest(x, y, z);
|
||||
|
||||
// -------------------------
|
||||
|
||||
// ---------------------------------------------
|
||||
// Show the number of g forces on the axes
|
||||
// -----------
|
||||
float Gx = WiiMoteEmu::AccelerometerToG((float)data[4], (float)g_wm.cal_zero.x, (float)g_wm.cal_g.x);
|
||||
float Gy = WiiMoteEmu::AccelerometerToG((float)data[5], (float)g_wm.cal_zero.y, (float)g_wm.cal_g.y);
|
||||
float Gz = WiiMoteEmu::AccelerometerToG((float)data[6], (float)g_wm.cal_zero.z, (float)g_wm.cal_g.z);
|
||||
std::string GForce = StringFromFormat("%s %s %s",
|
||||
((int)Gx >= 0) ? StringFromFormat(" %i", (int)Gx).c_str() : StringFromFormat("%i", (int)Gx).c_str(),
|
||||
((int)Gy >= 0) ? StringFromFormat(" %i", (int)Gy).c_str() : StringFromFormat("%i", (int)Gy).c_str(),
|
||||
((int)Gz >= 0) ? StringFromFormat(" %i", (int)Gz).c_str() : StringFromFormat("%i", (int)Gz).c_str());
|
||||
// -------------------------
|
||||
|
||||
// ---------------------------------------------
|
||||
// Calculate the IR data
|
||||
// -----------
|
||||
if (data[1] == WM_REPORT_CORE_ACCEL_IR10_EXT6) WiiMoteEmu::IRData2DotsBasic(&data[7]); else WiiMoteEmu::IRData2Dots(&data[7]);
|
||||
std::string IRData;
|
||||
// Create a shortcut
|
||||
struct WiiMoteEmu::SDot* Dot = WiiMoteEmu::g_Wiimote_kbd.IR.Dot;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
if(Dot[i].Visible)
|
||||
IRData += StringFromFormat("[%i] X:%04i Y:%04i Size:%i ", Dot[i].Order, Dot[i].Rx, Dot[i].Ry, Dot[i].Size);
|
||||
else
|
||||
IRData += StringFromFormat("[%i]", Dot[i].Order);
|
||||
}
|
||||
// Dot distance
|
||||
IRData += StringFromFormat(" | Distance:%i", WiiMoteEmu::g_Wiimote_kbd.IR.Distance);
|
||||
// -------------------------
|
||||
|
||||
// Classic Controller data
|
||||
DEBUG_LOG(WIIMOTE, "Read[%s]: %s | %s | %s | %s | %s", (Emu ? "Emu" : "Real"),
|
||||
TmpCore.c_str(), TmpAccel.c_str(), TmpIR.c_str(), TmpExt.c_str(), CCData.c_str());
|
||||
// Formatted data only
|
||||
//DEBUG_LOG(WIIMOTE, "Read[%s]: 0x%02x | %s | %s | %s", (Emu ? "Emu" : "Real"), data[1], RollPitch.c_str(), GForce.c_str(), IRData.c_str());
|
||||
// IR data
|
||||
//DEBUG_LOG(WIIMOTE, "Read[%s]: %s | %s", (Emu ? "Emu" : "Real"), TmpData.c_str(), IRData.c_str());
|
||||
// Accelerometer data
|
||||
//DEBUG_LOG(WIIMOTE, "Read[%s]: %s | %s | %s | %s | %s | %s | %s", (Emu ? "Emu" : "Real"),
|
||||
// TmpCore.c_str(), TmpAccel.c_str(), TmpIR.c_str(), TmpExt.c_str(), RollPitch.c_str(), GForce.c_str(), CCData.c_str());
|
||||
// Timestamp
|
||||
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str());
|
||||
|
||||
}
|
||||
if(g_DebugAccelerometer)
|
||||
{
|
||||
// Accelerometer only
|
||||
// Console::ClearScreen();
|
||||
DEBUG_LOG(WIIMOTE, "Accel x, y, z: %03u %03u %03u", data[4], data[5], data[6]);
|
||||
}
|
||||
}
|
||||
|
||||
void InterruptDebugging(bool Emu, const void* _pData)
|
||||
{
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
std::string Name;
|
||||
int size;
|
||||
u16 SampleValue;
|
||||
bool SoundData = false;
|
||||
|
||||
if (g_DebugComm) Name += StringFromFormat("Write[%s] ", (Emu ? "Emu" : "Real"));
|
||||
|
||||
switch(data[1])
|
||||
{
|
||||
case 0x10:
|
||||
size = 4; // I don't know the size
|
||||
if (g_DebugComm) Name.append("0x10");
|
||||
break;
|
||||
case WM_LEDS: // 0x11
|
||||
size = sizeof(wm_leds);
|
||||
if (g_DebugComm) Name.append("WM_LEDS");
|
||||
break;
|
||||
case WM_REPORT_MODE: // 0x12
|
||||
size = sizeof(wm_report_mode);
|
||||
if (g_DebugComm) Name.append("WM_REPORT_MODE");
|
||||
break;
|
||||
case WM_REQUEST_STATUS: // 0x15
|
||||
size = sizeof(wm_request_status);
|
||||
if (g_DebugComm) Name.append("WM_REQUEST_STATUS");
|
||||
break;
|
||||
case WM_WRITE_DATA: // 0x16
|
||||
if (g_DebugComm) Name.append("WM_WRITE_DATA");
|
||||
size = sizeof(wm_write_data);
|
||||
// data[2]: The address space 0, 1 or 2
|
||||
// data[3]: The registry type
|
||||
// data[5]: The registry offset
|
||||
// data[6]: The number of bytes
|
||||
switch(data[2] >> 0x01)
|
||||
{
|
||||
case WM_SPACE_EEPROM:
|
||||
if (g_DebugComm) Name.append(" REG_EEPROM"); break;
|
||||
case WM_SPACE_REGS1:
|
||||
case WM_SPACE_REGS2:
|
||||
switch(data[3])
|
||||
{
|
||||
case 0xa2:
|
||||
// data[8]: FF, 0x00 or 0x40
|
||||
// data[9, 10]: RR RR, 0xd007 or 0x401f
|
||||
// data[11]: VV, 0x00 to 0xff or 0x00 to 0x40
|
||||
if (g_DebugComm)
|
||||
{
|
||||
Name.append(" REG_SPEAKER");
|
||||
if(data[6] == 7)
|
||||
{
|
||||
DEBUG_LOG(WIIMOTE, "Sound configuration:");
|
||||
if(data[8] == 0x00)
|
||||
{
|
||||
memcpy(&SampleValue, &data[9], 2);
|
||||
DEBUG_LOG(WIIMOTE, " Data format: 4-bit ADPCM (%i Hz)", 6000000 / SampleValue);
|
||||
DEBUG_LOG(WIIMOTE, " Volume: %02i%%", (data[11] / 0x40) * 100);
|
||||
}
|
||||
else if (data[8] == 0x40)
|
||||
{
|
||||
memcpy(&SampleValue, &data[9], 2);
|
||||
DEBUG_LOG(WIIMOTE, " Data format: 8-bit PCM (%i Hz)", 12000000 / SampleValue);
|
||||
DEBUG_LOG(WIIMOTE, " Volume: %02i%%", (data[11] / 0xff) * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xa4:
|
||||
if (g_DebugComm) Name.append(" REG_EXT");
|
||||
// Update the encryption mode
|
||||
if (data[3] == 0xa4 && data[5] == 0xf0)
|
||||
{
|
||||
if (data[7] == 0xaa)
|
||||
WiiMoteEmu::g_Encryption = true;
|
||||
else if (data[7] == 0x55)
|
||||
WiiMoteEmu::g_Encryption = false;
|
||||
DEBUG_LOG(WIIMOTE, "Extension enryption turned %s", WiiMoteEmu::g_Encryption ? "On" : "Off");
|
||||
}
|
||||
break;
|
||||
case 0xb0:
|
||||
if (g_DebugComm) Name.append(" REG_IR"); break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WM_READ_DATA: // 0x17
|
||||
size = sizeof(wm_read_data);
|
||||
// data[2]: The address space 0, 1 or 2
|
||||
// data[3]: The registry type
|
||||
// data[5]: The registry offset
|
||||
// data[7]: The number of bytes, 6 and 7 together
|
||||
if (g_DebugComm) Name.append("WM_READ_DATA");
|
||||
switch(data[2] >> 0x01)
|
||||
{
|
||||
case WM_SPACE_EEPROM:
|
||||
if (g_DebugComm) Name.append(" REG_EEPROM"); break;
|
||||
case WM_SPACE_REGS1:
|
||||
case WM_SPACE_REGS2:
|
||||
switch(data[3])
|
||||
{
|
||||
case 0xa2:
|
||||
if (g_DebugComm) Name.append(" REG_SPEAKER"); break;
|
||||
case 0xa4:
|
||||
if (g_DebugComm) Name.append(" REG_EXT"); break;
|
||||
case 0xb0:
|
||||
if (g_DebugComm) Name.append(" REG_IR"); break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_IR_PIXEL_CLOCK: // 0x13
|
||||
case WM_IR_LOGIC: // 0x1a
|
||||
if (g_DebugComm) Name.append("WM_IR");
|
||||
size = 1;
|
||||
break;
|
||||
case WM_SPEAKER_ENABLE: // 0x14
|
||||
case WM_SPEAKER_MUTE: // 0x19
|
||||
if (g_DebugComm) Name.append("WM_SPEAKER");
|
||||
size = 1;
|
||||
if(data[1] == 0x14) {
|
||||
DEBUG_LOG(WIIMOTE, "Speaker %s", (data[2] & 4) ? "On" : "Off");
|
||||
} else if(data[1] == 0x19) {
|
||||
DEBUG_LOG(WIIMOTE, "Speaker %s", (data[2] & 4) ? "Muted" : "Unmuted");
|
||||
}
|
||||
break;
|
||||
case WM_WRITE_SPEAKER_DATA: // 0x18
|
||||
if (g_DebugComm) Name.append("WM_SPEAKER_DATA");
|
||||
size = 21;
|
||||
break;
|
||||
|
||||
default:
|
||||
size = 15;
|
||||
DEBUG_LOG(WIIMOTE, "%s InterruptDebugging: Unknown channel 0x%02x", (Emu ? "Emu" : "Real"), data[1]);
|
||||
break;
|
||||
}
|
||||
if (g_DebugComm && !SoundData)
|
||||
{
|
||||
std::string Temp = ArrayToString(data, size + 2, 0, 30);
|
||||
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
DEBUG_LOG(WIIMOTE, "%s: %s", Name.c_str(), Temp.c_str());
|
||||
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str());
|
||||
}
|
||||
if (g_DebugSoundData && SoundData)
|
||||
{
|
||||
std::string Temp = ArrayToString(data, size + 2, 0, 30);
|
||||
//LOGV(WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
DEBUG_LOG(WIIMOTE, "%s: %s", Name.c_str(), Temp.c_str());
|
||||
//DEBUG_LOG(WIIMOTE, " (%s): %s", Tm(true).c_str(), Temp.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -63,15 +63,6 @@ struct SRecordingAll
|
|||
extern u32 g_ISOId;
|
||||
extern bool g_SearchDeviceDone;
|
||||
extern bool g_RealWiiMotePresent;
|
||||
extern bool g_RealWiiMoteInitialized;
|
||||
extern bool g_RealWiiMoteAllocated;
|
||||
extern bool g_EmulatedWiiMoteInitialized;
|
||||
|
||||
// Settings
|
||||
extern accel_cal g_wm;
|
||||
extern nu_cal g_nu;
|
||||
extern cc_cal g_ClassicContCalibration;
|
||||
extern gh3_cal g_GH3Calibration;
|
||||
|
||||
// Debugging
|
||||
extern bool g_DebugAccelerometer;
|
||||
|
|
|
@ -49,6 +49,9 @@ extern SWiimoteInitialize g_WiimoteInitialize;
|
|||
namespace WiiMoteReal
|
||||
{
|
||||
|
||||
bool g_RealWiiMoteInitialized = false;
|
||||
bool g_RealWiiMoteAllocated = false;
|
||||
|
||||
// Forwarding
|
||||
|
||||
class CWiiMote;
|
||||
|
@ -387,6 +390,8 @@ int Initialize()
|
|||
// Allocate each Real WiiMote found to a WiiMote slot with Source set to "WiiMote Real"
|
||||
void Allocate()
|
||||
{
|
||||
if (g_RealWiiMoteAllocated)
|
||||
return;
|
||||
if (!g_RealWiiMoteInitialized)
|
||||
Initialize();
|
||||
|
||||
|
@ -469,6 +474,8 @@ void DoState(PointerWrap &p)
|
|||
|
||||
void Shutdown(void)
|
||||
{
|
||||
if (!g_RealWiiMoteInitialized)
|
||||
return;
|
||||
// Stop the loop in the thread
|
||||
g_Shutdown = true; // not safe .. might crash when still @ReadWiimote
|
||||
|
||||
|
@ -553,6 +560,20 @@ THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns whether SafeClose_ThreadFunc will take over closing of Recording dialog.
|
||||
// FIXME: this whole threading stuff is bad, and should be removed.
|
||||
// OSX is having problems with the threading anyways, since WiiUse is used
|
||||
// from multiple threads, and not just the one where it was created on.
|
||||
bool SafeClose()
|
||||
{
|
||||
if (!g_RealWiiMoteInitialized)
|
||||
return false;
|
||||
|
||||
g_StopThreadTemporary.Set();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Thread to avoid racing conditions by directly closing of ReadWiimote_ThreadFunc() resp. ReadWiimote()
|
||||
// shutting down the Dlg while still beeing @ReadWiimote will result in a crash;
|
||||
THREAD_RETURN SafeCloseReadWiimote_ThreadFunc(void* arg)
|
||||
|
|
|
@ -45,6 +45,8 @@ void SendAcc(u8 _ReportID);
|
|||
void SetDataReportingMode(u8 ReportingMode = 0);
|
||||
void ClearEvents();
|
||||
|
||||
bool SafeClose();
|
||||
|
||||
// The alternative Wiimote loop
|
||||
void ReadWiimote();
|
||||
bool IRDataOK(struct wiimote_t* wm);
|
||||
|
|
Loading…
Reference in New Issue