mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Wiimote plugin cleanup & linux build fix
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3677 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -29,10 +29,10 @@
|
||||
#include "EmuDefinitions.h" // for joyinfo
|
||||
|
||||
// Change Joystick
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Function: When changing the joystick we save and load the settings and update the PadMapping
|
||||
and PadState array. PadState[].joy is the gamepad handle that is used to access the pad throughout
|
||||
the plugin. Joyinfo[].joy is only used the first time the pads are checked. */
|
||||
/* Function: When changing the joystick we save and load the settings and
|
||||
update the PadMapping and PadState array. PadState[].joy is the gamepad
|
||||
handle that is used to access the pad throughout the plugin. Joyinfo[].joy
|
||||
is only used the first time the pads are checked. */
|
||||
void WiimotePadConfigDialog::DoChangeJoystick()
|
||||
{
|
||||
// Close the current pad, unless it's used by another slot
|
||||
@@ -61,10 +61,10 @@ void WiimotePadConfigDialog::PadOpen(int Open) // Open for slot 1, 2, 3 or 4
|
||||
INFO_LOG(CONSOLE, "Update the Slot %i handle to Id %i\n", Page, WiiMoteEmu::PadMapping[Open].ID);
|
||||
WiiMoteEmu::PadState[Open].joy = SDL_JoystickOpen(WiiMoteEmu::PadMapping[Open].ID);
|
||||
}
|
||||
void WiimotePadConfigDialog::PadClose(int Close) // Close for slot 1, 2, 3 or 4
|
||||
void WiimotePadConfigDialog::PadClose(int _Close) // Close for slot 1, 2, 3 or 4
|
||||
{
|
||||
if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[Close].joy);
|
||||
WiiMoteEmu::PadState[Close].joy = NULL;
|
||||
if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[_Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[_Close].joy);
|
||||
WiiMoteEmu::PadState[_Close].joy = NULL;
|
||||
}
|
||||
|
||||
void WiimotePadConfigDialog::DoChangeDeadZone(bool Left)
|
||||
@@ -88,12 +88,9 @@ void WiimotePadConfigDialog::DoChangeDeadZone(bool Left)
|
||||
m_bmpDeadZoneRightIn[Page]->Refresh();
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Change settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Set the button text for all four Wiimotes
|
||||
void WiimotePadConfigDialog::SetButtonTextAll(int id, char text[128])
|
||||
@@ -120,7 +117,6 @@ void WiimotePadConfigDialog::SaveButtonMappingAll(int Slot)
|
||||
}
|
||||
|
||||
// Set dialog items from saved values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller)
|
||||
{
|
||||
// Temporary storage
|
||||
@@ -206,7 +202,7 @@ void WiimotePadConfigDialog::UpdateGUIButtonMapping(int controller)
|
||||
|
||||
/* Populate the PadMapping array with the dialog items settings (for example
|
||||
selected joystick, enabled or disabled status and so on) */
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
void WiimotePadConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int FromSlot)
|
||||
{
|
||||
// Temporary storage
|
||||
@@ -314,18 +310,18 @@ void WiimotePadConfigDialog::SaveKeyboardMapping(int Controller, int Id, int Key
|
||||
}
|
||||
|
||||
// Replace the harder to understand -1 with "" for the sake of user friendliness
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void WiimotePadConfigDialog::ToBlank(bool ToBlank)
|
||||
void WiimotePadConfigDialog::ToBlank(bool _ToBlank)
|
||||
{
|
||||
if (!ControlsCreated) return;
|
||||
|
||||
for (int j = 0; j < 1; j++)
|
||||
{
|
||||
if(ToBlank)
|
||||
if(_ToBlank)
|
||||
{
|
||||
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++)
|
||||
#ifndef _WIN32
|
||||
if(GetButtonText(i, j).ToAscii() == "-1") SetButtonText(i, "", j);
|
||||
if(GetButtonText(i, j).ToAscii() == "-1")
|
||||
SetButtonText(i, (char *)"", j);
|
||||
#else
|
||||
if(GetButtonText(i, j) == "-1") SetButtonText(i, "", j);
|
||||
#endif
|
||||
@@ -333,11 +329,11 @@ void WiimotePadConfigDialog::ToBlank(bool ToBlank)
|
||||
else
|
||||
{
|
||||
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++)
|
||||
if(GetButtonText(i, j).IsEmpty()) SetButtonText(i, "-1", j);
|
||||
if(GetButtonText(i, j).IsEmpty())
|
||||
SetButtonText(i, (char *)"-1", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
@@ -441,25 +437,24 @@ wxString WiimotePadConfigDialog::GetButtonText(int id, int _Page)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Configure button mapping
|
||||
// ¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
|
||||
// Wait for button press
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Loop or timer: There are basically two ways to do this. With a while() or for() loop, or with a
|
||||
timer. The downside with the while() or for() loop is that there is no way to stop it if the user
|
||||
should select to configure another button while we are still in an old loop. What will happen then
|
||||
is that we start another parallel loop (at least in Windows) that blocks the old loop. And our only
|
||||
option to wait for the old loop to finish is with a new loop, and that will block the old loop for as
|
||||
long as it's going on. Therefore a timer is easier to control. */
|
||||
|
||||
/* Loop or timer: There are basically two ways to do this. With a while() or
|
||||
for() loop, or with a timer. The downside with the while() or for() loop is
|
||||
that there is no way to stop it if the user should select to configure
|
||||
another button while we are still in an old loop. What will happen then is
|
||||
that we start another parallel loop (at least in Windows) that blocks the
|
||||
old loop. And our only option to wait for the old loop to finish is with a
|
||||
new loop, and that will block the old loop for as long as it's going
|
||||
on. Therefore a timer is easier to control. */
|
||||
void WiimotePadConfigDialog::GetButtons(wxCommandEvent& event)
|
||||
{
|
||||
DoGetButtons(event.GetId());
|
||||
}
|
||||
|
||||
void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
void WiimotePadConfigDialog::DoGetButtons(int _GetId)
|
||||
{
|
||||
// =============================================
|
||||
// Collect the starting values
|
||||
@@ -473,11 +468,11 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
int TriggerType = WiiMoteEmu::PadMapping[Controller].triggertype;
|
||||
|
||||
// Collect the accepted buttons for this slot
|
||||
bool LeftRight = (GetId == IDB_TRIGGER_L || GetId == IDB_TRIGGER_R);
|
||||
bool LeftRight = (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R);
|
||||
|
||||
bool Axis = (GetId >= IDB_ANALOG_LEFT_X && GetId <= IDB_TRIGGER_R)
|
||||
bool Axis = (_GetId >= IDB_ANALOG_LEFT_X && _GetId <= IDB_TRIGGER_R)
|
||||
// Don't allow SDL axis input for the shoulder buttons if XInput is selected
|
||||
&& !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (GetId == IDB_TRIGGER_L || GetId == IDB_TRIGGER_R) );
|
||||
&& !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R) );
|
||||
|
||||
bool XInput = (TriggerType == InputCommon::CTL_TRIGGER_XINPUT);
|
||||
|
||||
@@ -501,10 +496,10 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
// =======================
|
||||
|
||||
//INFO_LOG(CONSOLE, "Before (%i) Id:%i %i IsRunning:%i\n",
|
||||
// GetButtonWaitingTimer, GetButtonWaitingID, GetId, m_ButtonMappingTimer->IsRunning());
|
||||
// GetButtonWaitingTimer, GetButtonWaitingID, _GetId, m_ButtonMappingTimer->IsRunning());
|
||||
|
||||
// If the Id has changed or the timer is not running we should start one
|
||||
if( GetButtonWaitingID != GetId || !m_ButtonMappingTimer->IsRunning() )
|
||||
if( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer->IsRunning() )
|
||||
{
|
||||
if(m_ButtonMappingTimer->IsRunning())
|
||||
{
|
||||
@@ -512,26 +507,26 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
GetButtonWaitingTimer = 0;
|
||||
|
||||
// Update the old textbox
|
||||
SetButtonText(GetButtonWaitingID, "");
|
||||
SetButtonText(GetButtonWaitingID, (char *)"");
|
||||
}
|
||||
|
||||
// Save the button Id
|
||||
GetButtonWaitingID = GetId;
|
||||
GetButtonWaitingID = _GetId;
|
||||
|
||||
// Reset the key in case we happen to have an old one
|
||||
g_Pressed = 0;
|
||||
|
||||
// Update the text box
|
||||
sprintf(format, "[%d]", Seconds);
|
||||
SetButtonText(GetId, format);
|
||||
SetButtonText(_GetId, format);
|
||||
|
||||
// Start the timer
|
||||
#if wxUSE_TIMER
|
||||
m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) );
|
||||
#endif
|
||||
INFO_LOG(CONSOLE, "Timer Started for Pad:%i GetId:%i\n"
|
||||
INFO_LOG(CONSOLE, "Timer Started for Pad:%i _GetId:%i\n"
|
||||
"Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i\n",
|
||||
WiiMoteEmu::PadMapping[Controller].ID, GetId,
|
||||
WiiMoteEmu::PadMapping[Controller].ID, _GetId,
|
||||
Axis, LeftRight, XInput, Button, Hat);
|
||||
}
|
||||
|
||||
@@ -565,7 +560,7 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
|
||||
// Update text
|
||||
sprintf(format, "[%d]", TmpTime);
|
||||
SetButtonText(GetId, format);
|
||||
SetButtonText(_GetId, format);
|
||||
|
||||
/* Debug
|
||||
INFO_LOG(CONSOLE, "Keyboard: %i\n", g_Pressed);*/
|
||||
@@ -576,7 +571,7 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
{
|
||||
Stop = true;
|
||||
// Leave a blank mapping
|
||||
SetButtonTextAll(GetId, "-1");
|
||||
SetButtonTextAll(_GetId, (char *)"-1");
|
||||
}
|
||||
|
||||
// If we got a button
|
||||
@@ -585,7 +580,7 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
Stop = true;
|
||||
// Write the number of the pressed button to the text box
|
||||
sprintf(format, "%d", pressed);
|
||||
SetButtonTextAll(GetId, format);
|
||||
SetButtonTextAll(_GetId, format);
|
||||
}
|
||||
|
||||
// Stop the timer
|
||||
@@ -594,21 +589,23 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
m_ButtonMappingTimer->Stop();
|
||||
GetButtonWaitingTimer = 0;
|
||||
|
||||
/* Update the button mapping for all slots that use this device. (It doesn't make sense to have several slots
|
||||
controlled by the same device, but several DirectInput instances of different but identical devices may possible
|
||||
have the same id, I don't know. So we have to do this. The user may also have selected the same device for
|
||||
several disabled slots. */
|
||||
/* Update the button mapping for all slots that use this device. (It
|
||||
doesn't make sense to have several slots controlled by the same
|
||||
device, but several DirectInput instances of different but identical
|
||||
devices may possible have the same id, I don't know. So we have to
|
||||
do this. The user may also have selected the same device for several
|
||||
disabled slots. */
|
||||
SaveButtonMappingAll(Controller);
|
||||
|
||||
INFO_LOG(CONSOLE, "Timer Stopped for Pad:%i GetId:%i\n",
|
||||
WiiMoteEmu::PadMapping[Controller].ID, GetId);
|
||||
INFO_LOG(CONSOLE, "Timer Stopped for Pad:%i _GetId:%i\n",
|
||||
WiiMoteEmu::PadMapping[Controller].ID, _GetId);
|
||||
}
|
||||
|
||||
// If we got a bad button
|
||||
if(g_Pressed == -1)
|
||||
{
|
||||
// Update text
|
||||
SetButtonTextAll(GetId, "-1");
|
||||
SetButtonTextAll(_GetId, (char *)"-1");
|
||||
|
||||
// Notify the user
|
||||
wxMessageBox(wxString::Format(wxT(
|
||||
@@ -625,14 +622,10 @@ void WiimotePadConfigDialog::DoGetButtons(int GetId)
|
||||
m_JoyButtonHalfpress[0]->GetValue().c_str(), m_JoyButtonHalfpress[1]->GetValue().c_str(), m_JoyButtonHalfpress[2]->GetValue().c_str(), m_JoyButtonHalfpress[3]->GetValue().c_str()
|
||||
);*/
|
||||
}
|
||||
/////////////////////////////////////////////////////////// Configure button mapping
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Show current input status
|
||||
// ¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Convert the 0x8000 range values to BoxW and BoxH for the plot
|
||||
void WiimotePadConfigDialog::Convert2Box(int &x)
|
||||
{
|
||||
@@ -644,13 +637,13 @@ void WiimotePadConfigDialog::Convert2Box(int &x)
|
||||
}
|
||||
|
||||
// Update the input status boxes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void WiimotePadConfigDialog::PadGetStatus()
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "SDL_WasInit: %i\n", SDL_WasInit(0));
|
||||
|
||||
/* Return if it's not detected. The ID should never be less than zero here, it can only be that
|
||||
because of a manual ini file change, but we make that check anway. */
|
||||
/* Return if it's not detected. The ID should never be less than zero here,
|
||||
it can only be that because of a manual ini file change, but we make
|
||||
that check anway. */
|
||||
if(WiiMoteEmu::PadMapping[Page].ID < 0 || WiiMoteEmu::PadMapping[Page].ID >= SDL_NumJoysticks())
|
||||
{
|
||||
m_TStatusLeftIn[Page]->SetLabel(wxT("Not connected"));
|
||||
@@ -685,7 +678,6 @@ void WiimotePadConfigDialog::PadGetStatus()
|
||||
|
||||
//////////////////////////////////////
|
||||
// Analog stick
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Set Deadzones perhaps out of function
|
||||
//int deadzone = (int)(((float)(128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
|
||||
//int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
|
||||
@@ -722,9 +714,7 @@ void WiimotePadConfigDialog::PadGetStatus()
|
||||
right_y_after = 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------
|
||||
// Show the adjusted angles in the status box
|
||||
// --------------
|
||||
// Change 0x8000 to 180
|
||||
/*
|
||||
float x8000 = 0x8000;
|
||||
@@ -740,7 +730,6 @@ void WiimotePadConfigDialog::PadGetStatus()
|
||||
main_x_after = main_x_after * (x8000 / 180);
|
||||
main_y_after = main_y_after * (x8000 / 180);
|
||||
*/
|
||||
// ---------------------
|
||||
|
||||
// Convert the values to fractions
|
||||
float f_x = main_x / 32767.0;
|
||||
@@ -778,13 +767,9 @@ void WiimotePadConfigDialog::PadGetStatus()
|
||||
m_bmpDotLeftOut[Page]->SetPosition(wxPoint(main_x_after, main_y_after));
|
||||
m_bmpDotRightIn[Page]->SetPosition(wxPoint(right_x, right_y));
|
||||
m_bmpDotRightOut[Page]->SetPosition(wxPoint(right_x_after, right_y_after));
|
||||
///////////////////// Analog stick
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
// Triggers
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
int TriggerValue = 0;
|
||||
|
||||
// Get the selected keys
|
||||
long Left, Right;
|
||||
@@ -806,11 +791,9 @@ void WiimotePadConfigDialog::PadGetStatus()
|
||||
wxT("%03i"), TriggerLeft));
|
||||
m_TriggerStatusRx[Page]->SetLabel(wxString::Format(
|
||||
wxT("%03i"), TriggerRight));
|
||||
///////////////////// Triggers
|
||||
}
|
||||
|
||||
// Populate the advanced tab
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void WiimotePadConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event))
|
||||
{
|
||||
// Show the current status
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "EmuMain.h" // for LoadRecordedMovements()
|
||||
#include "EmuSubroutines.h" // for WmRequestStatus
|
||||
|
||||
|
||||
void WiimoteRecordingConfigDialog::LoadFile()
|
||||
{
|
||||
INFO_LOG(CONSOLE, "LoadFile()\n");
|
||||
@@ -289,9 +288,7 @@ void WiimoteRecordingConfigDialog::CreateGUIControlsRecording()
|
||||
m_RecordIRBytesText[i]->Enable(false);
|
||||
m_RecordSpeed[i]->Enable(false);
|
||||
|
||||
// ------------------------------------
|
||||
// Row 2 Sizers
|
||||
// -----------
|
||||
sRealRecord[i]->Add(m_RecordButton[i], 0, wxEXPAND | (wxLEFT), 5);
|
||||
sRealRecord[i]->Add(m_RecordHotKeySwitch[i], 0, wxEXPAND | (wxLEFT), 5);
|
||||
sRealRecord[i]->Add(m_RecordHotKeyWiimote[i], 0, wxEXPAND | (wxLEFT), 2);
|
||||
@@ -364,8 +361,10 @@ void WiimoteRecordingConfigDialog::ConvertToString()
|
||||
TmpTime += StringFromFormat("%05i", Time);
|
||||
if (i < ((int)m_vRecording.size() - 1)) TmpTime += ",";
|
||||
|
||||
// Break just short of the IniFile.cpp byte limit so that we don't crash file.Load() the next time.
|
||||
// This limit should never be hit because of the recording limit below. I keep it here just in case.
|
||||
/* Break just short of the IniFile.cpp byte limit so that we don't
|
||||
crash file.Load() the next time. This limit should never be hit
|
||||
because of the recording limit below. I keep it here just in
|
||||
case. */
|
||||
if(TmpStr.length() > (1024*10 - 10) || TmpIR.length() > (1024*10 - 10) || TmpTime.length() > (1024*10 - 10))
|
||||
{
|
||||
break;
|
||||
@@ -434,8 +433,8 @@ void WiimoteRecordingConfigDialog::RecordMovement(wxCommandEvent& event)
|
||||
else
|
||||
{
|
||||
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Press +"));
|
||||
// This is for usability purposes, it may not be obvious at all that this must be unchecked
|
||||
// for the recording to work
|
||||
// This is for usability purposes, it may not be obvious at all that
|
||||
// this must be unchecked for the recording to work
|
||||
for(int i = 0; i < MAX_WIIMOTES; i++)
|
||||
m_BasicConfigFrame->m_UseRealWiimote[i]->SetValue(false);
|
||||
g_Config.bUseRealWiimote = false;
|
||||
@@ -513,4 +512,5 @@ void WiimoteRecordingConfigDialog::DoRecordMovement(int _x, int _y, int _z, cons
|
||||
ConvertToString();
|
||||
UpdateRecordingGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,21 +17,19 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Data reports guide. The different structures location in the Input reports. The ? in
|
||||
the IR coordinates is the High coordinates that are four in one byte.
|
||||
/* Data reports guide. The different structures location in the Input
|
||||
reports. The ? in the IR coordinates is the High coordinates that are four
|
||||
in one byte.
|
||||
|
||||
0x37: For the data reportingmode 0x37 there are five unused IR bytes in the end (represented)
|
||||
by "..." below, it seems like they can be set to either 0xff or 0x00 without affecting the
|
||||
IR emulation. */
|
||||
// ----------------
|
||||
0x37: For the data reportingmode 0x37 there are five unused IR bytes in the
|
||||
end (represented) by "..." below, it seems like they can be set to either
|
||||
0xff or 0x00 without affecting the IR emulation. */
|
||||
|
||||
/* 0x33
|
||||
[c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y ?
|
||||
/* 0x33 [c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y
|
||||
?
|
||||
|
||||
0x37
|
||||
[c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2 ... ext.jx jy ax ay az bt
|
||||
0x37 [c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2
|
||||
... ext.jx jy ax ay az bt
|
||||
|
||||
|
||||
The Data Report's path from here is
|
||||
@@ -41,9 +39,8 @@
|
||||
WII_IPC_HLE_Device_usb.cpp:
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame()
|
||||
at that point the message is queued and will be sent by the next
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() */
|
||||
|
||||
// ================
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
||||
*/
|
||||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
@@ -61,23 +58,19 @@
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Config.h" // for g_Config
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
//******************************************************************************
|
||||
// Subroutines
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Update the data reporting mode */
|
||||
// ----------------
|
||||
// Update the data reporting mode
|
||||
|
||||
void WmDataReporting(u16 _channelID, wm_data_reporting* dr)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Set Data reporting mode");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Rumble: %x", dr->rumble);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Continuous: %x", dr->continuous);
|
||||
@@ -105,14 +98,11 @@ void WmDataReporting(u16 _channelID, wm_data_reporting* dr)
|
||||
|
||||
// WmSendAck(_channelID, WM_DATA_REPORTING);
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x30: Core Buttons */
|
||||
// ----------------
|
||||
void SendReportCore(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
@@ -134,9 +124,7 @@ void SendReportCore(u16 _channelID)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* 0x31: Core Buttons and Accelerometer */
|
||||
// ----------------
|
||||
void SendReportCoreAccel(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
@@ -162,9 +150,7 @@ void SendReportCoreAccel(u16 _channelID)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x33: Core Buttons and Accelerometer with 12 IR bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelIr12(u16 _channelID) {
|
||||
u8 DataFrame[1024];
|
||||
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR12);
|
||||
@@ -193,9 +179,7 @@ void SendReportCoreAccelIr12(u16 _channelID) {
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x35: Core Buttons and Accelerometer with 16 Extension Bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelExt16(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
@@ -225,7 +209,7 @@ void SendReportCoreAccelExt16(u16 _channelID)
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
FillReportClassicExtension(_ext);
|
||||
#endif
|
||||
// Copy _ext to pReport->ext
|
||||
//TODO // Copy _ext to pReport->ext
|
||||
memcpy(&pReport->ext, &_ext, sizeof(_ext));
|
||||
}
|
||||
|
||||
@@ -240,9 +224,7 @@ void SendReportCoreAccelExt16(u16 _channelID)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x37: Core Buttons and Accelerometer with 10 IR bytes and 6 Extension Bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelIr10Ext(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
@@ -261,7 +243,7 @@ void SendReportCoreAccelIr10Ext(u16 _channelID)
|
||||
FillReportAcc(pReport->a);
|
||||
FillReportIRBasic(pReport->ir[0], pReport->ir[1]);
|
||||
#endif
|
||||
|
||||
//TODO
|
||||
if(g_Config.iExtensionConnected == EXT_NUNCHUCK)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
|
||||
@@ -45,9 +45,7 @@ namespace WiiMoteEmu
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Test the calculations
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void TiltTest(u8 x, u8 y, u8 z)
|
||||
{
|
||||
int Roll, Pitch, RollAdj, PitchAdj;
|
||||
@@ -63,13 +61,11 @@ void TiltTest(u8 x, u8 y, u8 z)
|
||||
(_Pitch >= 0) ? StringFromFormat(" %03i", (int)_Pitch).c_str() : StringFromFormat("%04i", (int)_Pitch).c_str());
|
||||
INFO_LOG(CONSOLE, "%s\n", To.c_str());
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Angles adjustment for the upside down state when both roll and pitch is used. When the absolute values
|
||||
of the angles go over 90° the Wiimote is upside down and these adjustments are needed. */
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Angles adjustment for the upside down state when both roll and pitch is
|
||||
used. When the absolute values of the angles go over 90° the Wiimote is
|
||||
upside down and these adjustments are needed. */
|
||||
void AdjustAngles(float &Roll, float &Pitch)
|
||||
{
|
||||
float OldPitch = Pitch;
|
||||
@@ -90,12 +86,9 @@ void AdjustAngles(float &Roll, float &Pitch)
|
||||
Roll = -180 - Roll; // -15 to -165
|
||||
}
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Angles to accelerometer values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z)
|
||||
{
|
||||
// We need radiands for the math functions
|
||||
@@ -119,21 +112,22 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
|
||||
else
|
||||
{
|
||||
// ====================================================
|
||||
/* This seems to always produce the exact same combination of x, y, z and Roll and Pitch that the
|
||||
real Wiimote produce. There is an unlimited amount of x, y, z combinations for any combination of
|
||||
Roll and Pitch. But if we select a Z from the smallest of the absolute value of cos(Roll) and
|
||||
cos (Pitch) we get the right values. */
|
||||
/* This seems to always produce the exact same combination of x, y, z
|
||||
and Roll and Pitch that the real Wiimote produce. There is an
|
||||
unlimited amount of x, y, z combinations for any combination of Roll
|
||||
and Pitch. But if we select a Z from the smallest of the absolute
|
||||
value of cos(Roll) and cos (Pitch) we get the right values. */
|
||||
// ---------
|
||||
if (abs(cos(_Roll)) < abs(cos(_Pitch))) z = cos(_Roll); else z = cos(_Pitch);
|
||||
/* I got these from reversing the calculation in PitchAccelerometerToDegree() in a math program
|
||||
I don't know if we can derive these from some kind of matrix or something */
|
||||
/* I got these from reversing the calculation in
|
||||
PitchAccelerometerToDegree() in a math program I don't know if we
|
||||
can derive these from some kind of matrix or something */
|
||||
float x_num = 2 * tanf(0.5f * _Roll) * z;
|
||||
float x_den = pow2f(tanf(0.5f * _Roll)) - 1;
|
||||
x = - (x_num / x_den);
|
||||
float y_num = 2 * tanf(0.5f * _Pitch) * z;
|
||||
float y_den = pow2f(tanf(0.5f * _Pitch)) - 1;
|
||||
y = - (y_num / y_den);
|
||||
// =========================
|
||||
}
|
||||
|
||||
// Multiply with the neutral of z and its g
|
||||
@@ -156,9 +150,7 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
|
||||
_z = iz;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Accelerometer to roll and pitch angles
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
float AccelerometerToG(float Current, float Neutral, float G)
|
||||
{
|
||||
float _G = (Current - Neutral) / G;
|
||||
@@ -208,11 +200,7 @@ void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, in
|
||||
// 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;
|
||||
@@ -252,9 +240,7 @@ void IRData2DotsBasic(u8 *Data)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2Dots(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wiimote_kbd.IR.Dot;
|
||||
@@ -284,12 +270,9 @@ void IRData2Dots(u8 *Data)
|
||||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Reorder the IR dots according to their x-axis value
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ReorderIRDots()
|
||||
{
|
||||
// Create a shortcut
|
||||
@@ -320,12 +303,9 @@ void ReorderIRDots()
|
||||
Dot[i].Order = order;
|
||||
}
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2Distance()
|
||||
{
|
||||
// Create a shortcut
|
||||
@@ -355,7 +335,6 @@ void IRData2Distance()
|
||||
// Save the distance
|
||||
g_Wiimote_kbd.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -39,9 +40,7 @@ extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
// ===================================================
|
||||
// Fill joyinfo with the current connected devices
|
||||
// ----------------
|
||||
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
||||
{
|
||||
bool Success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
|
||||
@@ -66,11 +65,8 @@ bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_N
|
||||
|
||||
return Success;
|
||||
}
|
||||
// ===========================
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Return adjusted input values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr)
|
||||
{
|
||||
// This has to be changed if multiple Wiimotes are to be supported later
|
||||
@@ -120,16 +116,11 @@ void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Request joystick state
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Called from: PAD_GetStatus()
|
||||
Input: The virtual device 0, 1, 2 or 3
|
||||
Function: Updates the PadState struct with the current pad status. The input value "controller" is
|
||||
for a virtual controller 0 to 3. */
|
||||
/* Called from: PAD_GetStatus() Input: The virtual device 0, 1, 2 or 3
|
||||
Function: Updates the PadState struct with the current pad status. The input
|
||||
value "controller" is for a virtual controller 0 to 3. */
|
||||
|
||||
void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONTROLLER_MAPPING_NEW _PadMapping, int controller, int NumButtons)
|
||||
{
|
||||
@@ -182,7 +173,6 @@ void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONT
|
||||
_PadState.Axis.Lx, _PadState.Axis.Ly
|
||||
);*/
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
} // end of namespace WiiMoteEmu
|
||||
|
||||
@@ -16,11 +16,7 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* HID reports access guide. */
|
||||
// ----------------
|
||||
|
||||
/* 0x10 - 0x1a Output EmuMain.cpp: HidOutputReport()
|
||||
0x10 - 0x14: General
|
||||
@@ -33,9 +29,6 @@
|
||||
0x10 - 0x1a leads to a 0x22 Input report
|
||||
0x30 - 0x3f Input This file: Update() */
|
||||
|
||||
// ================
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -46,7 +39,6 @@
|
||||
#include "EmuMain.h" // Local
|
||||
#include "EmuSubroutines.h"
|
||||
#include "Config.h" // for g_Config
|
||||
/////////////////////////////////
|
||||
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
@@ -59,10 +51,10 @@ namespace WiiMoteEmu
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Here we process the Output Reports that the Wii sends. Our response will be an Input Report
|
||||
back to the Wii. Input and Output is from the Wii's perspective, Output means data to
|
||||
the Wiimote (from the Wii), Input means data from the Wiimote.
|
||||
/* Here we process the Output Reports that the Wii sends. Our response will be
|
||||
an Input Report back to the Wii. Input and Output is from the Wii's
|
||||
perspective, Output means data to the Wiimote (from the Wii), Input means
|
||||
data from the Wiimote.
|
||||
|
||||
The call browser:
|
||||
|
||||
@@ -71,10 +63,9 @@ namespace WiiMoteEmu
|
||||
|
||||
The IR lights and speaker enable/disable and mute/unmute values are
|
||||
0x2 = Disable
|
||||
0x6 = Enable */
|
||||
// ----------------
|
||||
0x6 = Enable
|
||||
*/
|
||||
void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "HidOutputReport (0x%02x)", sr->channel);
|
||||
std::string Temp;
|
||||
|
||||
@@ -98,8 +89,8 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmReadData(_channelID, (wm_read_data*)sr->data);
|
||||
break;
|
||||
|
||||
/* This enables or disables the IR lights, we update the global variable g_IR
|
||||
so that WmRequestStatus() knows about it */
|
||||
/* This enables or disables the IR lights, we update the global variable
|
||||
g_IR so that WmRequestStatus() knows about it */
|
||||
case WM_IR_PIXEL_CLOCK: // 0x13
|
||||
case WM_IR_LOGIC: // 0x1a
|
||||
WARN_LOG(WII_IPC_WIIMOTE, " IR Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
||||
@@ -128,18 +119,15 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HidOutputReport: Unknown channel 0x%02x", sr->channel);
|
||||
PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->channel);
|
||||
return;
|
||||
}
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Generate the right header for wm reports. The returned values is the length of the header before
|
||||
the data begins. It's always two for all reports 0x20 - 0x22, 0x30 - 0x37 */
|
||||
// ----------------
|
||||
/* Generate the right header for wm reports. The returned values is the length
|
||||
of the header before the data begins. It's always two for all reports 0x20 -
|
||||
0x22, 0x30 - 0x37 */
|
||||
int WriteWmReport(u8* dst, u8 channel)
|
||||
{
|
||||
// Update the first byte to 0xa1
|
||||
@@ -157,26 +145,18 @@ int WriteWmReport(u8* dst, u8 channel)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* LED (blue lights) report. */
|
||||
// ----------------
|
||||
void WmLeds(u16 _channelID, wm_leds* leds) {
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Set LEDs");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Leds: %x", leds->leds);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", leds->rumble);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Set LEDs Leds: %x Rumble: %x", leds->leds, leds->rumble);
|
||||
|
||||
g_Leds = leds->leds;
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* This will generate the 0x22 acknowledgment after all Input reports. It will
|
||||
have the form a1 22 00 00 _reportID 00. The first two bytes are the core buttons data,
|
||||
they are 00 00 when nothing is pressed. The last byte is the success code 00. */
|
||||
// ----------------
|
||||
have the form a1 22 00 00 _reportID 00. The first two bytes are the core
|
||||
buttons data, they are 00 00 when nothing is pressed. The last byte is the
|
||||
success code 00. */
|
||||
void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
@@ -216,26 +196,22 @@ void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Read data from Wiimote and Extensions registers. */
|
||||
// ----------------
|
||||
void WmReadData(u16 _channelID, wm_read_data* rd)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
u32 address = convert24bit(rd->address);
|
||||
u16 size = convert16bit(rd->size);
|
||||
std::string Temp;
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Address space: %x", rd->space);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Size: 0x%04x", size);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", rd->rumble);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Address space: %x", rd->space);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Address: 0x%06x", address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Size: 0x%04x", size);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Rumble: %x", rd->rumble);
|
||||
|
||||
//u32 _address = address;
|
||||
std::string Tmp; // Debugging
|
||||
|
||||
/* Now we determine what address space we are reading from. Space 0 is Eeprom and
|
||||
space 1 and 2 is the registers. */
|
||||
/* Now we determine what address space we are reading from. Space 0 is
|
||||
Eeprom and space 1 and 2 is the registers. */
|
||||
if(rd->space == WM_SPACE_EEPROM)
|
||||
{
|
||||
if (address + size > WIIMOTE_EEPROM_SIZE)
|
||||
@@ -281,15 +257,12 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
|
||||
size, address, (address & 0xffff), Tmp.c_str());*/
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WmReadData: bad register block!");
|
||||
PanicAlert("WmReadData: bad register block!");
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: bad register block!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
// Encrypt data that is read from the Wiimote Extension Register
|
||||
// -------------
|
||||
if(((address >> 16) & 0xfe) == 0xa4)
|
||||
{
|
||||
/* Debugging
|
||||
@@ -334,25 +307,21 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
|
||||
PanicAlert("WmReadData: unimplemented parameters (size: %i, addr: 0x%x!", size, rd->space);
|
||||
}
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
// ===================================================
|
||||
/* Here we produce the actual 0x21 Input report that we send to the Wii. The message
|
||||
is divided into 16 bytes pieces and sent piece by piece. There will be five formatting
|
||||
bytes at the begging of all reports. A common format is 00 00 f0 00 20, the 00 00
|
||||
means that no buttons are pressed, the f means 16 bytes in the message, the 0
|
||||
means no error, the 00 20 means that the message is at the 00 20 offest in the
|
||||
registry that was read.
|
||||
/* Here we produce the actual 0x21 Input report that we send to the Wii. The
|
||||
message is divided into 16 bytes pieces and sent piece by piece. There will
|
||||
be five formatting bytes at the begging of all reports. A common format is
|
||||
00 00 f0 00 20, the 00 00 means that no buttons are pressed, the f means 16
|
||||
bytes in the message, the 0 means no error, the 00 20 means that the message
|
||||
is at the 00 20 offest in the registry that was read.
|
||||
|
||||
_Base: The data beginning at _Base[0]
|
||||
_Address: The starting address inside the registry, this is used to check for out of bounds reading
|
||||
_Size: The total size to send
|
||||
_Base: The data beginning at _Base[0] _Address: The starting address inside
|
||||
the registry, this is used to check for out of bounds reading _Size: The
|
||||
total size to send
|
||||
*/
|
||||
// ----------------
|
||||
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "=========================================");
|
||||
int dataOffset = 0;
|
||||
const u8* data = (const u8*)_Base;
|
||||
|
||||
@@ -386,10 +355,11 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
|
||||
// Update DataOffset for the next loop
|
||||
dataOffset += copySize;
|
||||
|
||||
/* Out of bounds. The real Wiimote generate an error for the first request to 0x1770
|
||||
if we dont't replicate that the game will never read the capibration data at the
|
||||
beginning of Eeprom. I think this error is supposed to occur when we try to read above
|
||||
the freely usable space that ends at 0x16ff. */
|
||||
/* Out of bounds. The real Wiimote generate an error for the first
|
||||
request to 0x1770 if we dont't replicate that the game will never
|
||||
read the capibration data at the beginning of Eeprom. I think this
|
||||
error is supposed to occur when we try to read above the freely
|
||||
usable space that ends at 0x16ff. */
|
||||
if (Common::swap16(pReply->address + pReply->size) > WIIMOTE_EEPROM_FREE_SIZE)
|
||||
{
|
||||
pReply->size = 0x0f;
|
||||
@@ -421,20 +391,14 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
|
||||
}
|
||||
|
||||
if (_Size != 0) {
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WiiMote-Plugin: SendReadDataReply() failed");
|
||||
PanicAlert("WiiMote-Plugin: SendReadDataReply() failed");
|
||||
}
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "==========================================");
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Write data to Wiimote and Extensions registers. */
|
||||
// ----------------
|
||||
void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "========================================================");
|
||||
u32 address = convert24bit(wd->address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Write data");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Address space: %x", wd->space);
|
||||
@@ -474,9 +438,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
case 0xA4:
|
||||
block = g_RegExt; // Extension Controller register
|
||||
blockSize = WIIMOTE_REG_EXT_SIZE;
|
||||
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Case 0xa4: ExtReg");
|
||||
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
|
||||
/*INFO_LOG(CONSOLE, "Write RegExt Size: %i Address: %08x Offset: %08x \n",
|
||||
wd->size, address, (address & 0xffff));
|
||||
INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str());*/
|
||||
@@ -500,7 +462,6 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
|
||||
// Check if the address is within bounds
|
||||
if(address + wd->size > blockSize) {
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: address + size out of bounds!");
|
||||
PanicAlert("WmWriteData: address + size out of bounds!");
|
||||
return;
|
||||
}
|
||||
@@ -509,9 +470,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
memcpy(block + address, wd->data, wd->size);
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
// Generate key for the Wiimote Extension
|
||||
// -------------
|
||||
if(blockSize == WIIMOTE_REG_EXT_SIZE)
|
||||
{
|
||||
/* Debugging. Write the data.
|
||||
@@ -528,29 +487,23 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
|
||||
|
||||
} else {
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: unimplemented parameters!");
|
||||
PanicAlert("WmWriteData: unimplemented parameters!");
|
||||
}
|
||||
|
||||
/* Just added for home brew... Isn't it enough that we call this from
|
||||
InterruptChannel()? Or is there a separate route here that don't pass though
|
||||
InterruptChannel()? */
|
||||
InterruptChannel()? Or is there a separate route here that don't pass
|
||||
though InterruptChannel()? */
|
||||
//WmSendAck(_channelID, WM_WRITE_DATA, _address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "==========================================================");
|
||||
}
|
||||
|
||||
// ===================================================
|
||||
/* Here we produce a 0x20 status report to send to the Wii. We currently ignore the status
|
||||
request rs and all its eventual instructions it may include (for example turn off
|
||||
rumble or something else) and just send the status report. */
|
||||
// ----------------
|
||||
/* Here we produce a 0x20 status report to send to the Wii. We currently ignore
|
||||
the status request rs and all its eventual instructions it may include (for
|
||||
example turn off rumble or something else) and just send the status
|
||||
report. */
|
||||
void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
||||
{
|
||||
//PanicAlert("WmRequestStatus");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "================================================");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Request Status");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", rs->rumble);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Channel: %04x", _channelID);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Request Status: Rumble: %x Channel: %04x",
|
||||
rs->rumble, _channelID);
|
||||
|
||||
//SendStatusReport();
|
||||
u8 DataFrame[1024];
|
||||
@@ -590,12 +543,11 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
||||
}
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Extension: %x", pStatus->extension);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendStatusReport()");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%02x", pStatus->padding1[2]);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Battery: %d", pStatus->battery);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendStatusReport() Flags: 0x%02x Battery: %d"
|
||||
,pStatus->padding1[2], pStatus->battery);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "=================================================");
|
||||
|
||||
|
||||
// Debugging
|
||||
ReadDebugging(true, DataFrame, Offset);
|
||||
|
||||
@@ -246,9 +246,7 @@ void gentabs(u8 *rand, u8 *key, u8 idx, u8 *ft, u8 *sb)
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Generate key from the 0x40-0x4c data in g_RegExt */
|
||||
// ----------------
|
||||
void wiimote_gen_key(wiimote_key *key, u8 *keydata)
|
||||
{
|
||||
u8 rand[10];
|
||||
@@ -282,9 +280,7 @@ void wiimote_gen_key(wiimote_key *key, u8 *keydata)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Encrypt data */
|
||||
// ----------------
|
||||
void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
{
|
||||
for(int i = 0; i < len; i++, addr++)
|
||||
@@ -292,9 +288,7 @@ void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Decrypt data */
|
||||
// ----------------
|
||||
void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
{
|
||||
for(int i = 0; i < len; i++, addr++)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -229,7 +229,6 @@ void handle_event(struct wiimote_t* wm)
|
||||
|
||||
if(!g_DebugData)
|
||||
{
|
||||
// Console::ClearScreen();
|
||||
INFO_LOG(CONSOLE, "Roll:%03i Pitch:%03i\n", (int)wm->orient.roll, (int)wm->orient.pitch);
|
||||
}
|
||||
if(m_PadConfigFrame)
|
||||
|
||||
@@ -24,7 +24,6 @@ if wmenv['HAVE_WX']:
|
||||
"ConfigRecordingDlg.cpp",
|
||||
"ConfigGamepad.cpp",
|
||||
"ConfigRecording.cpp",
|
||||
"Logging.cpp",
|
||||
"FillReport.cpp",
|
||||
]
|
||||
|
||||
|
||||
@@ -16,15 +16,20 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
|
||||
// Current issues
|
||||
/*
|
||||
The real Wiimote fails to answer the core correctly sometmes. Leading to an unwanted disconnection. And
|
||||
there is currenty no functions to reconnect with the game. There are two ways to solve this:
|
||||
1. Make a reconnect function in the IOS emulation
|
||||
2. Detect failed answers in this plugin and solve it by replacing them with emulated answers.
|
||||
The real Wiimote fails to answer the core correctly sometmes. Leading to an
|
||||
unwanted disconnection. And there is currenty no functions to reconnect with
|
||||
the game. There are two ways to solve this:
|
||||
|
||||
The first solution seems easier, if I knew a little better how the /dev/usb/oh1 and Wiimote functions
|
||||
worked.
|
||||
1. Make a reconnect function in the IOS emulation
|
||||
|
||||
2. Detect failed answers in this plugin and solve it by replacing them with
|
||||
emulated answers.
|
||||
|
||||
The first solution seems easier, if I knew a little better how the /dev/usb/oh1
|
||||
and Wiimote functions worked.
|
||||
*/
|
||||
|
||||
#include "Common.h" // Common
|
||||
@@ -119,7 +124,7 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
@@ -150,9 +155,7 @@ wxWindow* GetParentedWxWindow(HWND Parent)
|
||||
}
|
||||
#endif
|
||||
|
||||
//******************************************************************************
|
||||
// Exports
|
||||
//******************************************************************************
|
||||
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
||||
{
|
||||
_PluginInfo->Version = 0x0100;
|
||||
@@ -179,7 +182,7 @@ void DllDebugger(HWND _hParent, bool Show) {}
|
||||
void DllConfig(HWND _hParent)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
|
||||
|
||||
DoInitialize();
|
||||
|
||||
if (!m_BasicConfigFrame)
|
||||
@@ -198,7 +201,7 @@ void DllConfig(HWND _hParent)
|
||||
void Initialize(void *init)
|
||||
{
|
||||
// Declarations
|
||||
SWiimoteInitialize _WiimoteInitialize = *(SWiimoteInitialize *)init;
|
||||
SWiimoteInitialize _WiimoteInitialize = *(SWiimoteInitialize *)init;
|
||||
g_WiimoteInitialize = _WiimoteInitialize;
|
||||
|
||||
g_EmulatorRunning = true;
|
||||
@@ -283,17 +286,14 @@ void DoState(unsigned char **ptr, int mode)
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* This function produce Wiimote Input (reports from the Wiimote) in response
|
||||
to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp.
|
||||
|
||||
Switch between real and emulated wiimote: We send all this Input to WiiMoteEmu::InterruptChannel()
|
||||
so that it knows the channel ID and the data reporting mode at all times.
|
||||
*/
|
||||
// ----------------
|
||||
void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
// Debugging
|
||||
@@ -311,18 +311,13 @@ void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
if (g_RealWiiMotePresent)
|
||||
WiiMoteReal::InterruptChannel(_channelID, _pData, _Size);
|
||||
#endif
|
||||
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
}
|
||||
// ==============================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Function: Used for the initial Bluetooth HID handshake. */
|
||||
// ----------------
|
||||
// Function: Used for the initial Bluetooth HID handshake.
|
||||
|
||||
void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
// Check for custom communication
|
||||
@@ -351,16 +346,11 @@ void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
if (g_RealWiiMotePresent)
|
||||
WiiMoteReal::ControlChannel(_channelID, _pData, _Size);
|
||||
#endif
|
||||
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
}
|
||||
// ==============================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* This sends a Data Report from the Wiimote. See SystemTimers.cpp for the documentation of this
|
||||
update. */
|
||||
// ----------------
|
||||
void Wiimote_Update()
|
||||
{
|
||||
// Tell us about the update rate, but only about once every second to avoid a major slowdown
|
||||
@@ -407,55 +397,15 @@ unsigned int Wiimote_GetAttachedControllers()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Supporting functions
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------
|
||||
// Debugging window
|
||||
// ----------
|
||||
/*
|
||||
void OpenConsole(bool Open)
|
||||
{
|
||||
// Close the console window
|
||||
#ifdef _WIN32
|
||||
// if (Console::GetHwnd() != NULL && !Open)
|
||||
#else
|
||||
if (false)
|
||||
#endif
|
||||
{
|
||||
// Console::Close();
|
||||
// Wait here until we have let go of the button again
|
||||
#ifdef _WIN32
|
||||
while(GetAsyncKeyState(VK_INSERT)) {Sleep(10);}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the console window
|
||||
// Console::Open(140, 1000, "Wiimote"); // give room for 20 rows
|
||||
INFO_LOG(CONSOLE, "\n\nWiimote console opened\n");
|
||||
|
||||
// Move window
|
||||
#ifdef _WIN32
|
||||
//MoveWindow(Console::GetHwnd(), 0,400, 100*8,10*14, true); // small window
|
||||
//MoveWindow(Console::GetHwnd(), 400,0, 100*8,70*14, true); // big window
|
||||
// MoveWindow(Console::GetHwnd(), 200,0, 140*8,70*14, true); // big wide window
|
||||
#endif
|
||||
}*/
|
||||
// ---------------
|
||||
|
||||
// ----------------------------------------
|
||||
// Check if Dolphin is in focus
|
||||
// ----------
|
||||
|
||||
bool IsFocus()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -538,9 +488,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
// 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)
|
||||
@@ -590,13 +538,11 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
INFO_LOG(CONSOLE, "Game got the decrypted extension ID: %02x%02x%02x%02x%02x%02x\n\n", 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. */
|
||||
/* 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)
|
||||
@@ -610,11 +556,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
INFO_LOG(CONSOLE, "Cal_g.z: %i\n", 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
|
||||
@@ -686,7 +629,6 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
// Show the encrypted data
|
||||
INFO_LOG(CONSOLE, "%s", TmpData.c_str());
|
||||
}
|
||||
// ---------------------------------------------
|
||||
|
||||
break;
|
||||
case WM_WRITE_DATA_REPLY: // 0x22
|
||||
@@ -733,9 +675,9 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
||||
|
||||
if (!DataReport && g_DebugComm)
|
||||
{
|
||||
std::string TmpData = ArrayToString(data, size + 2, 0, 30);
|
||||
std::string tmpData = ArrayToString(data, size + 2, 0, 30);
|
||||
//LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
INFO_LOG(CONSOLE, "Read[%s] %s: %s\n", (Emu ? "Emu" : "Real"), Name.c_str(), TmpData.c_str()); // No timestamp
|
||||
INFO_LOG(CONSOLE, "Read[%s] %s: %s\n", (Emu ? "Emu" : "Real"), Name.c_str(), tmpData.c_str()); // No timestamp
|
||||
//INFO_LOG(CONSOLE, " (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp
|
||||
}
|
||||
|
||||
@@ -1036,9 +978,9 @@ double GetDoubleTime()
|
||||
wxDateTime datetime = wxDateTime::UNow(); // Get timestamp
|
||||
u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970(); // Get continous timestamp
|
||||
|
||||
// Remove a few years. We only really want enough seconds to make sure that we are
|
||||
// detecting actual actions, perhaps 60 seconds is enough really, but I leave a
|
||||
// year of seconds anyway, in case the user's clock is incorrect or something like that
|
||||
/* Remove a few years. We only really want enough seconds to make sure that we are
|
||||
detecting actual actions, perhaps 60 seconds is enough really, but I leave a
|
||||
year of seconds anyway, in case the user's clock is incorrect or something like that */
|
||||
TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60);
|
||||
|
||||
//if (TmpSeconds < 0) return 0; // Check the the user's clock is working somewhat
|
||||
@@ -1092,13 +1034,14 @@ void DoInitialize()
|
||||
// Run this first so that WiiMoteReal::Initialize() overwrites g_Eeprom
|
||||
WiiMoteEmu::Initialize();
|
||||
|
||||
/* We will run WiiMoteReal::Initialize() even if we are not using a real wiimote,
|
||||
to check if there is a real wiimote connected. We will initiate wiiuse.dll, but
|
||||
we will return before creating a new thread for it if we find no real Wiimotes.
|
||||
Then g_RealWiiMotePresent will also be 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. */
|
||||
/* We will run WiiMoteReal::Initialize() even if we are not using a real
|
||||
wiimote, to check if there is a real wiimote connected. We will initiate
|
||||
wiiuse.dll, but we will return before creating a new thread for it if we
|
||||
find no real Wiimotes. Then g_RealWiiMotePresent will also be
|
||||
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();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -82,10 +82,6 @@ struct SRecordingAll
|
||||
|
||||
// Movement recording
|
||||
extern std::vector<SRecordingAll> VRecording;
|
||||
|
||||
//#if defined(HAVE_WX) && HAVE_WX && defined(__CONFIGDIALOG_h__)
|
||||
// extern ConfigDialog *frame;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -259,9 +259,7 @@ struct wm_GH3_extension
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Data reports
|
||||
//******************************************************************************
|
||||
|
||||
#define WM_REPORT_CORE 0x30
|
||||
struct wm_report_core {
|
||||
@@ -321,9 +319,7 @@ struct wm_report_ext21
|
||||
#define WM_WRITE_SPEAKER_DATA 0x18
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Custom structs
|
||||
//******************************************************************************
|
||||
|
||||
/**
|
||||
* @struct accel_t
|
||||
@@ -367,4 +363,4 @@ struct gh3_cal
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //WIIMOTE_HID_H
|
||||
#endif //WIIMOTE_HID_H
|
||||
@@ -37,14 +37,11 @@
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
|
||||
namespace WiiMoteReal
|
||||
{
|
||||
|
||||
//******************************************************************************
|
||||
// Forwarding
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
class CWiiMote;
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -52,10 +49,9 @@ class CWiiMote;
|
||||
#else
|
||||
void* ReadWiimote_ThreadFunc(void* arg);
|
||||
#endif
|
||||
//******************************************************************************
|
||||
|
||||
// Variable declarations
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
wiimote_t** g_WiiMotesFromWiiUse = NULL;
|
||||
Common::Thread* g_pReadThread = NULL;
|
||||
int g_NumberOfWiiMotes;
|
||||
@@ -71,17 +67,12 @@ bool g_RunTemporary = false;
|
||||
int g_RunTemporaryCountdown = 0;
|
||||
u8 g_EventBuffer[32];
|
||||
|
||||
//******************************************************************************
|
||||
// Probably this class should be in its own file
|
||||
//******************************************************************************
|
||||
|
||||
class CWiiMote
|
||||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////
|
||||
// On create and on uncreate
|
||||
// ---------------
|
||||
CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
|
||||
: m_WiimoteNumber(_WiimoteNumber)
|
||||
, m_channelID(0)
|
||||
@@ -103,12 +94,9 @@ virtual ~CWiiMote()
|
||||
{
|
||||
delete m_pCriticalSection;
|
||||
};
|
||||
//////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Queue raw HID data from the core to the wiimote
|
||||
// ---------------
|
||||
void SendData(u16 _channelID, const u8* _pData, u32 _Size)
|
||||
{
|
||||
m_channelID = _channelID;
|
||||
@@ -125,12 +113,9 @@ void SendData(u16 _channelID, const u8* _pData, u32 _Size)
|
||||
}
|
||||
m_pCriticalSection->Leave();
|
||||
}
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
/* Read and write data to the Wiimote */
|
||||
// ---------------
|
||||
void ReadData()
|
||||
{
|
||||
m_pCriticalSection->Enter();
|
||||
@@ -188,12 +173,9 @@ void ReadData()
|
||||
}
|
||||
}
|
||||
};
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Send queued data to the core
|
||||
// ---------------
|
||||
void Update()
|
||||
{
|
||||
// Thread function
|
||||
@@ -213,12 +195,9 @@ void Update()
|
||||
|
||||
m_pCriticalSection->Leave();
|
||||
};
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Clear events
|
||||
// ---------------
|
||||
void ClearEvents()
|
||||
{
|
||||
while (!m_EventReadQueue.empty())
|
||||
@@ -226,7 +205,6 @@ void ClearEvents()
|
||||
while (!m_EventWriteQueue.empty())
|
||||
m_EventWriteQueue.pop();
|
||||
}
|
||||
/////////////////////
|
||||
|
||||
private:
|
||||
|
||||
@@ -249,9 +227,7 @@ private:
|
||||
SEvent m_LastReport;
|
||||
wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[]
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Send queued data to the core
|
||||
// ---------------
|
||||
void SendEvent(SEvent& _rEvent)
|
||||
{
|
||||
// We don't have an answer channel
|
||||
@@ -267,8 +243,9 @@ void SendEvent(SEvent& _rEvent)
|
||||
|
||||
// Create the buffer
|
||||
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, MAX_PAYLOAD);
|
||||
/* This Offset value is not exactly correct like it is for the emulated Wiimote reports. It's
|
||||
often to big, but I guess that's okay. The game will know how big the actual data is. */
|
||||
/* This Offset value is not exactly correct like it is for the emulated
|
||||
Wiimote reports. It's often to big, but I guess that's okay. The game
|
||||
will know how big the actual data is. */
|
||||
Offset += MAX_PAYLOAD;
|
||||
|
||||
// Send it
|
||||
@@ -277,14 +254,11 @@ void SendEvent(SEvent& _rEvent)
|
||||
// Debugging
|
||||
// ReadDebugging(false, Buffer, Offset);
|
||||
}
|
||||
/////////////////////
|
||||
};
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Function Definitions
|
||||
//******************************************************************************
|
||||
|
||||
void SendAcc(u8 _ReportID)
|
||||
{
|
||||
@@ -381,11 +355,13 @@ int Initialize()
|
||||
// If we are not using the emulated wiimote we can run the thread temporary until the data has beeen copied
|
||||
if(g_Config.bUseRealWiimote) g_RunTemporary = true;
|
||||
|
||||
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values to g_Eeprom. Unlike with
|
||||
and extension we have to do this here, because this data is only read once when the Wiimote
|
||||
is connected. Also, we can't change the neutral values the wiimote will report, I think, unless
|
||||
we update its eeprom? In any case it's probably better to let the current calibration be where it
|
||||
is and adjust the global values after that to avoid overwriting critical data on any Wiimote. */
|
||||
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values
|
||||
to g_Eeprom. Unlike with and extension we have to do this here, because
|
||||
this data is only read once when the Wiimote is connected. Also, we
|
||||
can't change the neutral values the wiimote will report, I think, unless
|
||||
we update its eeprom? In any case it's probably better to let the
|
||||
current calibration be where it is and adjust the global values after
|
||||
that to avoid overwriting critical data on any Wiimote. */
|
||||
// TODO: Update for multiple wiimotes?
|
||||
byte *data = (byte*)malloc(sizeof(byte) * sizeof(WiiMoteEmu::EepromData_0));
|
||||
wiiuse_read_data(g_WiiMotesFromWiiUse[0], data, 0, sizeof(WiiMoteEmu::EepromData_0));
|
||||
@@ -449,9 +425,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
// Read the Wiimote once
|
||||
// ---------------
|
||||
void Update()
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "Real Update\n");
|
||||
@@ -461,11 +435,10 @@ void Update()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
/* Continuously read the Wiimote status. However, the actual sending of data occurs in Update(). If we are
|
||||
not currently using the real Wiimote we allow the separate ReadWiimote() function to run. Wo don't use
|
||||
them at the same time to avoid a potential collision. */
|
||||
// ---------------
|
||||
/* Continuously read the Wiimote status. However, the actual sending of data
|
||||
occurs in Update(). If we are not currently using the real Wiimote we allow
|
||||
the separate ReadWiimote() function to run. Wo don't use them at the same
|
||||
time to avoid a potential collision. */
|
||||
#ifdef _WIN32
|
||||
DWORD WINAPI ReadWiimote_ThreadFunc(void* arg)
|
||||
#else
|
||||
@@ -477,8 +450,7 @@ void Update()
|
||||
// We need g_ThreadGoing to do a manual WaitForSingleObject() from the configuration window
|
||||
g_ThreadGoing = true;
|
||||
if(g_Config.bUseRealWiimote && !g_RunTemporary)
|
||||
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||
g_WiiMotes[i]->ReadData();
|
||||
for (int i = 0; i < g_NumberOfWiiMotes; i++) g_WiiMotes[i]->ReadData();
|
||||
else
|
||||
ReadWiimote();
|
||||
g_ThreadGoing = false;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "wiiuse.h"
|
||||
#include "ChunkFile.h"
|
||||
|
||||
|
||||
namespace WiiMoteReal
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user