Some clean up

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3377 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-06-08 14:36:00 +00:00
parent ad4ffaf0b6
commit 1a6b9d8174
21 changed files with 345 additions and 967 deletions

View File

@ -10,7 +10,7 @@ import wxconfig
import utils import utils
# Some features needs at least scons 0.98 # Some features needs at least scons 0.98
EnsureSConsVersion(0, 98) EnsureSConsVersion(1, 2)
# TODO: how do we use it in help? # TODO: how do we use it in help?
name="Dolphin" name="Dolphin"
@ -80,6 +80,7 @@ dirs = [
'Source/Plugins/Plugin_nJoy_SDL/Src', 'Source/Plugins/Plugin_nJoy_SDL/Src',
'Source/Plugins/Plugin_nJoy_Testing/Src', 'Source/Plugins/Plugin_nJoy_Testing/Src',
'Source/Plugins/Plugin_Wiimote/Src', 'Source/Plugins/Plugin_Wiimote/Src',
'Source/Plugins/Plugin_Wiimote-testing/Src',
'Source/Core/DolphinWX/Src', 'Source/Core/DolphinWX/Src',
'Source/Core/DebuggerWX/Src', 'Source/Core/DebuggerWX/Src',
] ]

View File

@ -47,7 +47,7 @@ lri $IX0, #0x1338
call send_back ; 8 call send_back ; 8
lri $IX0, #0x0000 lri $IX0, #0x0000
lri $SR, #0x000a lri $SR, #0x000a
ifg ifg
lri $IX0, #0x1337 lri $IX0, #0x1337

View File

@ -16,10 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
//#include "Common.h" // for u16
#include "CommonTypes.h" // for u16 #include "CommonTypes.h" // for u16
#include "IniFile.h" #include "IniFile.h"
#include "Timer.h" #include "Timer.h"
@ -33,24 +29,17 @@
#include "EmuMain.h" // for LoadRecordedMovements() #include "EmuMain.h" // for LoadRecordedMovements()
#include "EmuSubroutines.h" // for WmRequestStatus #include "EmuSubroutines.h" // for WmRequestStatus
#include "EmuDefinitions.h" // for joyinfo #include "EmuDefinitions.h" // for joyinfo
//////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Variables
// ----------------
// Trigger Type // Trigger Type
enum enum
{ {
CTL_TRIGGER_SDL = 0, // CTL_TRIGGER_SDL = 0, //
CTL_TRIGGER_XINPUT // The XBox 360 pad CTL_TRIGGER_XINPUT // The XBox 360 pad
}; };
//////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Event table // Event table
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CLOSE(ConfigDialog::OnClose) EVT_CLOSE(ConfigDialog::OnClose)
EVT_BUTTON(ID_CLOSE, ConfigDialog::CloseClick) EVT_BUTTON(ID_CLOSE, ConfigDialog::CloseClick)
@ -220,9 +209,7 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
UpdateGUI(); UpdateGUI();
} }
// ----------------------------------------------------
// Handle the keyboard key mapping // Handle the keyboard key mapping
// ------------------
std::string StrKey; std::string StrKey;
if(ClickedButton != NULL) if(ClickedButton != NULL)
{ {
@ -230,7 +217,7 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
if (g_Pressed == WXK_ESCAPE) if (g_Pressed == WXK_ESCAPE)
{ {
SaveKeyboardMapping(Page, ClickedButton->GetId(), -1); SaveKeyboardMapping(Page, ClickedButton->GetId(), -1);
SetButtonText(ClickedButton->GetId(), ""); SetButtonText(ClickedButton->GetId(), (char *)"");
ClickedButton = NULL; ClickedButton = NULL;
return; return;
} }
@ -259,7 +246,6 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
// Remove the button control pointer // Remove the button control pointer
ClickedButton = NULL; ClickedButton = NULL;
// ---------------------------
} }
// Input button clicked // Input button clicked
@ -267,7 +253,8 @@ void ConfigDialog::OnButtonClick(wxCommandEvent& event)
{ {
//INFO_LOG(CONSOLE, "OnButtonClick: %i\n", g_Pressed); //INFO_LOG(CONSOLE, "OnButtonClick: %i\n", g_Pressed);
// Don't allow space to start a new Press Key option, that will interfer with setting a key to space // Don't allow space to start a new Press Key option, that will interfer
// with setting a key to space
if (g_Pressed == WXK_SPACE) { g_Pressed = 0; return; } if (g_Pressed == WXK_SPACE) { g_Pressed = 0; return; }
// Reset the old label // Reset the old label
@ -294,9 +281,11 @@ void ConfigDialog::OnClose(wxCloseEvent& event)
event.Skip(); event.Skip();
} }
/* Timeout the shutdown. In Windows at least the g_pReadThread execution will hang at any attempt to /* Timeout the shutdown. In Windows at least the g_pReadThread execution will
call a frame function after the main thread has entered WaitForSingleObject() or any other loop. hang at any attempt to call a frame function after the main thread has
We must therefore shut down the thread from here and wait for that before we can call ShutDown(). */ entered WaitForSingleObject() or any other loop. We must therefore shut
down the thread from here and wait for that before we can call
ShutDown(). */
void ConfigDialog::ShutDown(wxTimerEvent& WXUNUSED(event)) void ConfigDialog::ShutDown(wxTimerEvent& WXUNUSED(event))
{ {
// Close() is a wxWidgets function that will trigger EVT_CLOSE() and then call this->Destroy(). // Close() is a wxWidgets function that will trigger EVT_CLOSE() and then call this->Destroy().
@ -350,11 +339,9 @@ void ConfigDialog::UpdateOnce(wxTimerEvent& event)
break; break;
} }
} }
//////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Save Settings // Save Settings
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ /* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
@ -374,7 +361,8 @@ void ConfigDialog::DoSave(bool ChangePad, int Slot)
if(ChangePad) if(ChangePad)
{ {
// Since we are selecting the pad to save to by the Id we can't update it when we change the pad // Since we are selecting the pad to save to by the Id we can't update
// it when we change the pad
for(int i = 0; i < 4; i++) SaveButtonMapping(i, true); for(int i = 0; i < 4; i++) SaveButtonMapping(i, true);
// Save the settings for the current pad // Save the settings for the current pad
g_Config.Save(Slot); g_Config.Save(Slot);
@ -393,12 +381,8 @@ void ConfigDialog::DoSave(bool ChangePad, int Slot)
INFO_LOG(CONSOLE, "WiiMoteEmu::PadMapping[%i].ID = %i\n", Page, m_Joyname[Page]->GetSelection()); INFO_LOG(CONSOLE, "WiiMoteEmu::PadMapping[%i].ID = %i\n", Page, m_Joyname[Page]->GetSelection());
} }
//////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Bitmap box and dot // Bitmap box and dot
// ----------------
wxBitmap ConfigDialog::CreateBitmap() wxBitmap ConfigDialog::CreateBitmap()
{ {
BoxW = 70, BoxH = 70; BoxW = 70, BoxH = 70;
@ -467,15 +451,12 @@ wxBitmap ConfigDialog::CreateBitmapClear()
//dc.SelectObject(wxNullBitmap); //dc.SelectObject(wxNullBitmap);
return bitmap; return bitmap;
} }
//////////////////////////////////////
void ConfigDialog::CreateGUIControls() void ConfigDialog::CreateGUIControls()
{ {
////////////////////////////////////////////////////////////////////////////////
// Notebook // Notebook
// ----------------
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize); m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
for (int i = 0; i < MAX_WIIMOTES; i++) for (int i = 0; i < MAX_WIIMOTES; i++)
@ -488,10 +469,7 @@ void ConfigDialog::CreateGUIControls()
m_PageRecording = new wxPanel(m_Notebook, ID_PAGE_RECORDING, wxDefaultPosition, wxDefaultSize); m_PageRecording = new wxPanel(m_Notebook, ID_PAGE_RECORDING, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_PageRecording, wxT("Recording")); m_Notebook->AddPage(m_PageRecording, wxT("Recording"));
////////////////////////////////////////////////////////////////////////////////
// Text lists // Text lists
// ----------------
// Search for devices and add them to the device list // Search for devices and add them to the device list
wxArrayString StrJoyname; // The string array wxArrayString StrJoyname; // The string array
@ -537,11 +515,8 @@ void ConfigDialog::CreateGUIControls()
// A small type font // A small type font
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
///////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// This can take a few seconds so we show a progress bar for it // This can take a few seconds so we show a progress bar for it
// ----------------
wxProgressDialog dialog(_T("Opening Wii Remote Configuration"), wxProgressDialog dialog(_T("Opening Wii Remote Configuration"),
wxT("Loading controls..."), wxT("Loading controls..."),
6, // range 6, // range
@ -555,16 +530,13 @@ void ConfigDialog::CreateGUIControls()
); );
// I'm not sure what parent this refers to // I'm not sure what parent this refers to
dialog.CenterOnParent(); dialog.CenterOnParent();
///////////////////////////////////////
/* Populate all four pages. Page 2, 3 and 4 are currently disabled since we can't use more than one /* Populate all four pages. Page 2, 3 and 4 are currently disabled since we
Wiimote at the moment */ can't use more than one Wiimote at the moment */
for (int i = 0; i < MAX_WIIMOTES; i++) for (int i = 0; i < MAX_WIIMOTES; i++)
{ {
////////////////////////////////////////////////////
// General and basic Settings // General and basic Settings
// ----------------
// Configuration controls sizes // Configuration controls sizes
static const int TxtW = 50, TxtH = 19, ChW = 257, BtW = 75, BtH = 20; static const int TxtW = 50, TxtH = 19, ChW = 257, BtW = 75, BtH = 20;
@ -605,9 +577,7 @@ void ConfigDialog::CreateGUIControls()
"Use the real Wiimote in the game. This can be changed during gameplay. This can not be selected" "Use the real Wiimote in the game. This can be changed during gameplay. This can not be selected"
" when a recording is to be done. No status in this window will be updated when this is checked.")); " when a recording is to be done. No status in this window will be updated when this is checked."));
// -----------------------------------------------
// Screen size // Screen size
// ---------------------
// Controls // Controls
m_TextScreenWidth[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Width: 000")); m_TextScreenWidth[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Width: 000"));
m_TextScreenHeight[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Height: 000")); m_TextScreenHeight[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Height: 000"));
@ -663,11 +633,8 @@ void ConfigDialog::CreateGUIControls()
// Tool tips // Tool tips
//m_ScreenSize[i]->SetToolTip(wxT("Use the adjusted screen size.")); //m_ScreenSize[i]->SetToolTip(wxT("Use the adjusted screen size."));
// -------------------------------
// --------------------------------------------------------------------
// Row 1 Sizers: General settings // Row 1 Sizers: General settings
// -----------------------------
m_SizeBasic[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("General Settings")); m_SizeBasic[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("General Settings"));
m_SizeEmu[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Emulated Wiimote")); m_SizeEmu[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Emulated Wiimote"));
m_SizeExtensions[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Emulated Extension")); m_SizeExtensions[i] = new wxStaticBoxSizer(wxVERTICAL, m_Controller[i], wxT("Emulated Extension"));
@ -704,20 +671,9 @@ void ConfigDialog::CreateGUIControls()
m_SizeBasicGeneral[i]->Add(m_SizeBasicGeneralLeft[i], 0, wxEXPAND | (wxUP), 0); m_SizeBasicGeneral[i]->Add(m_SizeBasicGeneralLeft[i], 0, wxEXPAND | (wxUP), 0);
m_SizeBasicGeneral[i]->Add(m_SizeBasicGeneralRight[i], 0, wxEXPAND | (wxLEFT), 5); m_SizeBasicGeneral[i]->Add(m_SizeBasicGeneralRight[i], 0, wxEXPAND | (wxLEFT), 5);
// ------------------------
///////////////////////////
////////////////////////////////////////////////////////////////////////
// Gamepad input // Gamepad input
// ----------------
// --------------------------------------------------------------------
// Controller
// -----------------------------
// Controller // Controller
m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, StrJoyname[0], wxDefaultPosition, wxSize(200, -1), StrJoyname, wxCB_READONLY); m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, StrJoyname[0], wxDefaultPosition, wxSize(200, -1), StrJoyname, wxCB_READONLY);
@ -780,10 +736,8 @@ void ConfigDialog::CreateGUIControls()
m_gJoyname[i]->AddStretchSpacer(); m_gJoyname[i]->AddStretchSpacer();
// --------------------------------------------------------------------
// Tilt Wiimote // Tilt Wiimote
// -----------------------------
/**/
// Controls // Controls
m_TiltComboInput[i] = new wxComboBox(m_Controller[i], ID_TILT_INPUT, StrTilt[0], wxDefaultPosition, wxDefaultSize, StrTilt, wxCB_READONLY); m_TiltComboInput[i] = new wxComboBox(m_Controller[i], ID_TILT_INPUT, StrTilt[0], wxDefaultPosition, wxDefaultSize, StrTilt, wxCB_READONLY);
m_TiltComboRangeRoll[i] = new wxComboBox(m_Controller[i], ID_TILT_RANGE_ROLL, StrTiltRangeRoll[0], wxDefaultPosition, wxDefaultSize, StrTiltRangeRoll, wxCB_READONLY); m_TiltComboRangeRoll[i] = new wxComboBox(m_Controller[i], ID_TILT_RANGE_ROLL, StrTiltRangeRoll[0], wxDefaultPosition, wxDefaultSize, StrTiltRangeRoll, wxCB_READONLY);
@ -822,10 +776,7 @@ void ConfigDialog::CreateGUIControls()
m_TiltComboRangeRoll[i]->SetToolTip(wxT("The maximum roll in degrees. Set to 0 to turn off.")); m_TiltComboRangeRoll[i]->SetToolTip(wxT("The maximum roll in degrees. Set to 0 to turn off."));
m_TiltComboRangePitch[i]->SetToolTip(wxT("The maximum pitch in degrees. Set to 0 to turn off.")); m_TiltComboRangePitch[i]->SetToolTip(wxT("The maximum pitch in degrees. Set to 0 to turn off."));
// --------------------------------------------------------------------
// Analog triggers // Analog triggers
// -----------------------------
/**/
m_gTrigger[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Triggers")); m_gTrigger[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Triggers"));
m_TriggerStatusL[i]= new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left: ")); m_TriggerStatusL[i]= new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left: "));
@ -883,9 +834,7 @@ void ConfigDialog::CreateGUIControls()
m_gTrigger[i]->Add(m_SizeAnalogTriggerVertLeft[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5); m_gTrigger[i]->Add(m_SizeAnalogTriggerVertLeft[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5);
m_gTrigger[i]->Add(m_SizeAnalogTriggerVertRight[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5); m_gTrigger[i]->Add(m_SizeAnalogTriggerVertRight[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5);
// --------------------------------------------------------------------
// Row 2 Sizers: Connected pads, tilt, triggers // Row 2 Sizers: Connected pads, tilt, triggers
// -----------------------------
m_HorizControllerTilt[i] = new wxBoxSizer(wxHORIZONTAL); m_HorizControllerTilt[i] = new wxBoxSizer(wxHORIZONTAL);
m_HorizControllerTilt[i]->Add(m_gJoyname[i], 0, wxALIGN_CENTER | wxEXPAND, 0); m_HorizControllerTilt[i]->Add(m_gJoyname[i], 0, wxALIGN_CENTER | wxEXPAND, 0);
m_HorizControllerTilt[i]->Add(m_gTilt[i], 0, wxEXPAND | (wxLEFT), 5); m_HorizControllerTilt[i]->Add(m_gTilt[i], 0, wxEXPAND | (wxLEFT), 5);
@ -896,9 +845,7 @@ void ConfigDialog::CreateGUIControls()
// --------------------------------------------------------------------
// Analog sticks // Analog sticks
// -----------------------------
// Status panels // Status panels
m_TStatusLeftIn[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("In")); m_TStatusLeftIn[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("In"));
@ -993,26 +940,18 @@ void ConfigDialog::CreateGUIControls()
m_gAnalogRight[i]->Add(m_SizeAnalogRight[i], 0, wxEXPAND | wxALIGN_CENTER_VERTICAL, 0); m_gAnalogRight[i]->Add(m_SizeAnalogRight[i], 0, wxEXPAND | wxALIGN_CENTER_VERTICAL, 0);
// --------------------------------------------------------------------
// Row 3 Sizers // Row 3 Sizers
// -----------------------------
m_HorizControllers[i] = new wxBoxSizer(wxHORIZONTAL); m_HorizControllers[i] = new wxBoxSizer(wxHORIZONTAL);
//m_HorizControllers[i]->AddStretchSpacer(); //m_HorizControllers[i]->AddStretchSpacer();
m_HorizControllers[i]->AddSpacer(17); m_HorizControllers[i]->AddSpacer(17);
m_HorizControllers[i]->Add(m_gAnalogLeft[i]); m_HorizControllers[i]->Add(m_gAnalogLeft[i]);
m_HorizControllers[i]->Add(m_gAnalogRight[i], 0, (wxLEFT), 5); m_HorizControllers[i]->Add(m_gAnalogRight[i], 0, (wxLEFT), 5);
//m_HorizControllers[i]->AddStretchSpacer(); //m_HorizControllers[i]->AddStretchSpacer();
///////////////////////////
////////////////////////////////////////////////////////////////////////
// Keyboard mapping // Keyboard mapping
// ----------------
// --------------------------------------------------------------------
// Wiimote // Wiimote
// -----------------------------
m_tWmA[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("A")); m_tWmA[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("A"));
m_tWmB[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("B")); m_tWmB[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("B"));
m_tWm1[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("1")); m_tWm1[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("1"));
@ -1100,9 +1039,7 @@ void ConfigDialog::CreateGUIControls()
m_gWiimote[i]->Add(m_SWmVertRight[i], 0, wxALIGN_RIGHT | (wxLEFT), 5); m_gWiimote[i]->Add(m_SWmVertRight[i], 0, wxALIGN_RIGHT | (wxLEFT), 5);
m_gWiimote[i]->AddSpacer(1); m_gWiimote[i]->AddSpacer(1);
// --------------------------------------------------------------------
// Nunchuck // Nunchuck
// -----------------------------
// Stick controls // Stick controls
m_NunchuckTextStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Stick")); m_NunchuckTextStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Stick"));
@ -1165,9 +1102,7 @@ void ConfigDialog::CreateGUIControls()
//Set values //Set values
m_NunchuckComboStick[i]->SetSelection(g_Config.Nunchuck.Type); m_NunchuckComboStick[i]->SetSelection(g_Config.Nunchuck.Type);
// --------------------------------------------------------------------
// Classic Controller // Classic Controller
// -----------------------------
// Stick controls // Stick controls
m_CcTextLeftStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left stick")); m_CcTextLeftStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Left stick"));
@ -1335,21 +1270,15 @@ void ConfigDialog::CreateGUIControls()
m_CcComboRightStick[i]->SetSelection(g_Config.ClassicController.RType); m_CcComboRightStick[i]->SetSelection(g_Config.ClassicController.RType);
m_CcComboTriggers[i]->SetSelection(g_Config.ClassicController.TType); m_CcComboTriggers[i]->SetSelection(g_Config.ClassicController.TType);
// --------------------------------------------------------------------
// Row 4 Sizers // Row 4 Sizers
// -----------------------------
m_HorizControllerMapping[i] = new wxBoxSizer(wxHORIZONTAL); m_HorizControllerMapping[i] = new wxBoxSizer(wxHORIZONTAL);
m_HorizControllerMapping[i]->AddStretchSpacer(); m_HorizControllerMapping[i]->AddStretchSpacer();
m_HorizControllerMapping[i]->Add(m_gWiimote[i]); m_HorizControllerMapping[i]->Add(m_gWiimote[i]);
m_HorizControllerMapping[i]->Add(m_gNunchuck[i], 0, (wxLEFT), 5); m_HorizControllerMapping[i]->Add(m_gNunchuck[i], 0, (wxLEFT), 5);
m_HorizControllerMapping[i]->Add(m_gClassicController[i], 0, (wxLEFT), 5); m_HorizControllerMapping[i]->Add(m_gClassicController[i], 0, (wxLEFT), 5);
m_HorizControllerMapping[i]->AddStretchSpacer(); m_HorizControllerMapping[i]->AddStretchSpacer();
///////////////////////////
////////////////////////////////////////////////////////////////
// Set up sizers and layout // Set up sizers and layout
// ----------------
m_SizeParent[i] = new wxBoxSizer(wxVERTICAL); m_SizeParent[i] = new wxBoxSizer(wxVERTICAL);
m_SizeParent[i]->Add(m_SizeBasicGeneral[i], 0, wxBORDER_STATIC | wxEXPAND | (wxALL), 5); m_SizeParent[i]->Add(m_SizeBasicGeneral[i], 0, wxBORDER_STATIC | wxEXPAND | (wxALL), 5);
m_SizeParent[i]->Add(m_HorizControllerTiltParent[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); m_SizeParent[i]->Add(m_HorizControllerTiltParent[i], 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
@ -1368,17 +1297,13 @@ void ConfigDialog::CreateGUIControls()
dialog.Update(i + 1, wxT("Loading notebook pages...")); dialog.Update(i + 1, wxT("Loading notebook pages..."));
} }
////////////////////////////////////////////
// Movement recording // Movement recording
// ----------------
CreateGUIControlsRecording(); CreateGUIControlsRecording();
/////////////////////////////////
// Update with the progress (i) and the message (msg) // Update with the progress (i) and the message (msg)
dialog.Update(5, wxT("Loading notebook pages...")); dialog.Update(5, wxT("Loading notebook pages..."));
//dialog.Close(); //dialog.Close();
////////////////////////////////////////////////////////////////////////////////
// Buttons // Buttons
//m_About = new wxButton(this, ID_ABOUTOGL, wxT("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); //m_About = new wxButton(this, ID_ABOUTOGL, wxT("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_Apply = new wxButton(this, ID_APPLY, wxT("Apply"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_Apply = new wxButton(this, ID_APPLY, wxT("Apply"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -1390,12 +1315,9 @@ void ConfigDialog::CreateGUIControls()
sButtons->AddStretchSpacer(); sButtons->AddStretchSpacer();
sButtons->Add(m_Apply, 0, (wxALL), 0); sButtons->Add(m_Apply, 0, (wxALL), 0);
sButtons->Add(m_Close, 0, (wxLEFT), 5); sButtons->Add(m_Close, 0, (wxLEFT), 5);
///////////////////////////////
////////////////////////////////////////////
// Set sizers and layout // Set sizers and layout
// ----------------
m_MainSizer = new wxBoxSizer(wxVERTICAL); m_MainSizer = new wxBoxSizer(wxVERTICAL);
m_MainSizer->Add(m_Notebook, 1, wxEXPAND | wxALL, 5); m_MainSizer->Add(m_Notebook, 1, wxEXPAND | wxALL, 5);
m_MainSizer->Add(sButtons, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); m_MainSizer->Add(sButtons, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
@ -1417,15 +1339,11 @@ void ConfigDialog::CreateGUIControls()
#endif #endif
ControlsCreated = true; ControlsCreated = true;
/////////////////////////////////
} }
/////////////////////////////////
// ===================================================
/* Do connect real wiimote */ /* Do connect real wiimote */
// ----------------
void ConfigDialog::DoConnectReal() void ConfigDialog::DoConnectReal()
{ {
g_Config.bConnectRealWiimote = m_ConnectRealWiimote[Page]->IsChecked(); g_Config.bConnectRealWiimote = m_ConnectRealWiimote[Page]->IsChecked();
@ -1454,10 +1372,8 @@ void ConfigDialog::DoConnectReal()
} }
// =================================================== /* Do use real wiimote. We let the game set up the real Wiimote reporting mode
/* Do use real wiimote. We let the game set up the real Wiimote reporting mode and init the Extension when we change and init the Extension when we change want to use it again. */
want to use it again. */
// ----------------
void ConfigDialog::DoUseReal() void ConfigDialog::DoUseReal()
{ {
// Clear any eventual events in the Wiimote queue // Clear any eventual events in the Wiimote queue
@ -1480,19 +1396,15 @@ void ConfigDialog::DoUseReal()
// Disable the checkbox for a moment // Disable the checkbox for a moment
SetCursor(wxCursor(wxCURSOR_WAIT)); SetCursor(wxCursor(wxCURSOR_WAIT));
m_bEnableUseRealWiimote = false; m_bEnableUseRealWiimote = false;
// We may not need this if there is already a message queue that allows the nessesary timeout
//sleep(100);
/* Start the timer to allow the approximate time it takes for the Wiimote to come online /* Start the timer to allow the approximate time it takes for the
it would simpler to use sleep(1000) but that doesn't work because we need the functions in main.cpp Wiimote to come online it would simpler to use sleep(1000) but that
to work */ doesn't work because we need the functions in main.cpp to work */
m_TimeoutOnce->Start(1000, true); m_TimeoutOnce->Start(1000, true);
} }
} }
// ===================================================
/* Generate connect/disconnect status event */ /* Generate connect/disconnect status event */
// ----------------
void ConfigDialog::DoExtensionConnectedDisconnected(int Extension) void ConfigDialog::DoExtensionConnectedDisconnected(int Extension)
{ {
// There is no need for this if no game is running // There is no need for this if no game is running
@ -1506,9 +1418,7 @@ void ConfigDialog::DoExtensionConnectedDisconnected(int Extension)
WiiMoteEmu::WmRequestStatus(WiiMoteEmu::g_ReportingChannel, rs, Extension); WiiMoteEmu::WmRequestStatus(WiiMoteEmu::g_ReportingChannel, rs, Extension);
} }
// ===================================================
/* Change settings */ /* Change settings */
// ----------------
void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
{ {
long TmpValue; long TmpValue;
@ -1528,9 +1438,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
g_Config.bSidewaysDPad = m_SidewaysDPad[Page]->IsChecked(); g_Config.bSidewaysDPad = m_SidewaysDPad[Page]->IsChecked();
break; break;
//////////////////////////
// Extensions // Extensions
// -----------
case ID_NUNCHUCKCONNECTED: case ID_NUNCHUCKCONNECTED:
// Don't allow two extensions at the same time // Don't allow two extensions at the same time
if(m_ClassicControllerConnected[Page]->IsChecked()) if(m_ClassicControllerConnected[Page]->IsChecked())
@ -1571,9 +1479,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
DoExtensionConnectedDisconnected(); DoExtensionConnectedDisconnected();
break; break;
//////////////////////////
// Gamepad // Gamepad
// -----------
case ID_TRIGGER_TYPE: case ID_TRIGGER_TYPE:
WiiMoteEmu::PadMapping[Page].triggertype = m_TriggerType[Page]->GetSelection(); WiiMoteEmu::PadMapping[Page].triggertype = m_TriggerType[Page]->GetSelection();
break; break;
@ -1616,9 +1522,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
SaveButtonMappingAll(Page); SaveButtonMappingAll(Page);
break; break;
//////////////////////////
// Recording // Recording
// -----------
case ID_UPDATE_REAL: case ID_UPDATE_REAL:
g_Config.bUpdateRealWiimote = m_UpdateMeters->IsChecked(); g_Config.bUpdateRealWiimote = m_UpdateMeters->IsChecked();
break; break;
@ -1651,15 +1555,12 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
// m_RecordHotKey[i]->GetSelection(), m_RecordHotKey[CurrentChoiceBox]->GetSelection()); // m_RecordHotKey[i]->GetSelection(), m_RecordHotKey[CurrentChoiceBox]->GetSelection());
} }
break; break;
/////////////////
} }
g_Config.Save(); g_Config.Save();
UpdateGUI(); UpdateGUI();
} }
// =======================================================
// Apparently we need a scroll event version of this for the sliders // Apparently we need a scroll event version of this for the sliders
// -------------
void ConfigDialog::GeneralSettingsChangedScroll(wxScrollEvent& event) void ConfigDialog::GeneralSettingsChangedScroll(wxScrollEvent& event)
{ {
switch (event.GetId()) switch (event.GetId())
@ -1682,9 +1583,7 @@ void ConfigDialog::GeneralSettingsChangedScroll(wxScrollEvent& event)
UpdateGUI(); UpdateGUI();
} }
// =======================================================
// Update the IR pointer calibration sliders // Update the IR pointer calibration sliders
// -------------
void ConfigDialog::UpdateControls() void ConfigDialog::UpdateControls()
{ {
// Update the slider position if a configuration has been loaded // Update the slider position if a configuration has been loaded
@ -1699,12 +1598,9 @@ void ConfigDialog::UpdateControls()
m_TextScreenLeft[Page]->SetLabel(wxString::Format(wxT("Left: %i"), g_Config.iIRLeft)); m_TextScreenLeft[Page]->SetLabel(wxString::Format(wxT("Left: %i"), g_Config.iIRLeft));
m_TextScreenTop[Page]->SetLabel(wxString::Format(wxT("Top: %i"), g_Config.iIRTop)); m_TextScreenTop[Page]->SetLabel(wxString::Format(wxT("Top: %i"), g_Config.iIRTop));
} }
// ==============================
// =======================================================
// Update the enabled/disabled status // Update the enabled/disabled status
// -------------
void ConfigDialog::UpdateGUI(int Slot) void ConfigDialog::UpdateGUI(int Slot)
{ {
//INFO_LOG(CONSOLE, "UpdateGUI: \n"); //INFO_LOG(CONSOLE, "UpdateGUI: \n");
@ -1718,19 +1614,21 @@ void ConfigDialog::UpdateGUI(int Slot)
// Update the Wiimote IR pointer calibration // Update the Wiimote IR pointer calibration
UpdateControls(); UpdateControls();
/* We only allow a change of extension if we are not currently using the real Wiimote, if it's in use the status will be updated /* We only allow a change of extension if we are not currently using the
from the data scanning functions in main.cpp */ real Wiimote, if it's in use the status will be updated from the data
scanning functions in main.cpp */
bool AllowExtensionChange = !(g_RealWiiMotePresent && g_Config.bConnectRealWiimote && g_Config.bUseRealWiimote && g_EmulatorRunning); bool AllowExtensionChange = !(g_RealWiiMotePresent && g_Config.bConnectRealWiimote && g_Config.bUseRealWiimote && g_EmulatorRunning);
m_NunchuckConnected[Page]->SetValue(g_Config.bNunchuckConnected); m_NunchuckConnected[Page]->SetValue(g_Config.bNunchuckConnected);
m_ClassicControllerConnected[Page]->SetValue(g_Config.bClassicControllerConnected); m_ClassicControllerConnected[Page]->SetValue(g_Config.bClassicControllerConnected);
m_NunchuckConnected[Page]->Enable(AllowExtensionChange); m_NunchuckConnected[Page]->Enable(AllowExtensionChange);
m_ClassicControllerConnected[Page]->Enable(AllowExtensionChange); m_ClassicControllerConnected[Page]->Enable(AllowExtensionChange);
/* I have disabled this option during a running game because it's enough to be able to switch /* I have disabled this option during a running game because it's enough to
between using and not using then. To also use the connect option during a running game would be able to switch between using and not using then. To also use the
mean that the wiimote must be sent the current reporting mode and the channel ID after it connect option during a running game would mean that the wiimote must be
has been initialized. Functions for that are basically already in place so these two options sent the current reporting mode and the channel ID after it has been
could possibly be simplified to one option. */ initialized. Functions for that are basically already in place so these
two options could possibly be simplified to one option. */
m_ConnectRealWiimote[Page]->Enable(!g_EmulatorRunning); m_ConnectRealWiimote[Page]->Enable(!g_EmulatorRunning);
m_UseRealWiimote[Page]->Enable((m_bEnableUseRealWiimote && g_RealWiiMotePresent && g_Config.bConnectRealWiimote) || (!g_EmulatorRunning && g_Config.bConnectRealWiimote)); m_UseRealWiimote[Page]->Enable((m_bEnableUseRealWiimote && g_RealWiiMotePresent && g_Config.bConnectRealWiimote) || (!g_EmulatorRunning && g_Config.bConnectRealWiimote));
@ -1738,8 +1636,8 @@ void ConfigDialog::UpdateGUI(int Slot)
// Disable all pad items if no pads are detected // Disable all pad items if no pads are detected
if(ControlsCreated) if(ControlsCreated)
{ {
bool PadEnabled = WiiMoteEmu::NumGoodPads != 0;
#ifdef _WIN32 #ifdef _WIN32
bool PadEnabled = WiiMoteEmu::NumGoodPads != 0;
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++) m_Notebook->FindItem(i)->Enable(PadEnabled); for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++) m_Notebook->FindItem(i)->Enable(PadEnabled);
m_Notebook->FindItem(IDC_JOYNAME)->Enable(PadEnabled); m_Notebook->FindItem(IDC_JOYNAME)->Enable(PadEnabled);
m_Notebook->FindItem(IDC_LEFT_C2S)->Enable(PadEnabled); m_Notebook->FindItem(IDC_LEFT_C2S)->Enable(PadEnabled);
@ -1751,8 +1649,8 @@ void ConfigDialog::UpdateGUI(int Slot)
} }
// Disable all recording buttons // Disable all recording buttons
bool ActiveRecording = !(m_bWaitForRecording || m_bRecording);
#ifdef _WIN32 #ifdef _WIN32
bool ActiveRecording = !(m_bWaitForRecording || m_bRecording);
for(int i = IDB_RECORD + 1; i < (IDB_RECORD + RECORDING_ROWS + 1); i++) for(int i = IDB_RECORD + 1; i < (IDB_RECORD + RECORDING_ROWS + 1); i++)
if(ControlsCreated) m_Notebook->FindItem(i)->Enable(ActiveRecording); if(ControlsCreated) m_Notebook->FindItem(i)->Enable(ActiveRecording);
#endif #endif

View File

@ -16,10 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
//#include "Common.h" // for u16
#include "CommonTypes.h" // for u16 #include "CommonTypes.h" // for u16
#include "IniFile.h" #include "IniFile.h"
#include "Timer.h" #include "Timer.h"
@ -32,15 +28,13 @@
#include "EmuMain.h" // for LoadRecordedMovements() #include "EmuMain.h" // for LoadRecordedMovements()
#include "EmuSubroutines.h" // for WmRequestStatus #include "EmuSubroutines.h" // for WmRequestStatus
#include "EmuDefinitions.h" // for joyinfo #include "EmuDefinitions.h" // for joyinfo
//////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// Change Joystick // Change Joystick
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ /* Function: When changing the joystick we save and load the settings and
/* Function: When changing the joystick we save and load the settings and update the PadMapping update the PadMapping and PadState array. PadState[].joy is the gamepad
and PadState array. PadState[].joy is the gamepad handle that is used to access the pad throughout handle that is used to access the pad throughout the plugin. Joyinfo[].joy
the plugin. Joyinfo[].joy is only used the first time the pads are checked. */ is only used the first time the pads are checked. */
void ConfigDialog::DoChangeJoystick() void ConfigDialog::DoChangeJoystick()
{ {
// Close the current pad, unless it's used by another slot // Close the current pad, unless it's used by another slot
@ -69,10 +63,10 @@ void ConfigDialog::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); 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); WiiMoteEmu::PadState[Open].joy = SDL_JoystickOpen(WiiMoteEmu::PadMapping[Open].ID);
} }
void ConfigDialog::PadClose(int Close) // Close for slot 1, 2, 3 or 4 void ConfigDialog::PadClose(int _Close) // Close for slot 1, 2, 3 or 4
{ {
if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[Close].joy); if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[_Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[_Close].joy);
WiiMoteEmu::PadState[Close].joy = NULL; WiiMoteEmu::PadState[_Close].joy = NULL;
} }
void ConfigDialog::DoChangeDeadZone(bool Left) void ConfigDialog::DoChangeDeadZone(bool Left)
@ -96,12 +90,9 @@ void ConfigDialog::DoChangeDeadZone(bool Left)
m_bmpDeadZoneRightIn[Page]->Refresh(); m_bmpDeadZoneRightIn[Page]->Refresh();
} }
} }
//////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// Change settings // Change settings
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Set the button text for all four Wiimotes // Set the button text for all four Wiimotes
void ConfigDialog::SetButtonTextAll(int id, char text[128]) void ConfigDialog::SetButtonTextAll(int id, char text[128])
@ -130,7 +121,6 @@ void ConfigDialog::SaveButtonMappingAll(int Slot)
} }
// Set dialog items from saved values // Set dialog items from saved values
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void ConfigDialog::UpdateGUIButtonMapping(int controller) void ConfigDialog::UpdateGUIButtonMapping(int controller)
{ {
// Temporary storage // Temporary storage
@ -324,18 +314,18 @@ void ConfigDialog::SaveKeyboardMapping(int Controller, int Id, int Key)
} }
// Replace the harder to understand -1 with "" for the sake of user friendliness // Replace the harder to understand -1 with "" for the sake of user friendliness
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ void ConfigDialog::ToBlank(bool _ToBlank)
void ConfigDialog::ToBlank(bool ToBlank)
{ {
if (!ControlsCreated) return; if (!ControlsCreated) return;
for (int j = 0; j < 1; j++) for (int j = 0; j < 1; j++)
{ {
if(ToBlank) if(_ToBlank)
{ {
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++) for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++)
#ifndef _WIN32 #ifndef _WIN32
if(GetButtonText(i, j).ToAscii() == "-1") SetButtonText(i, "", j); if(GetButtonText(i, j).ToAscii() == "-1")
SetButtonText(i, (char *)"", j);
#else #else
if(GetButtonText(i, j) == "-1") SetButtonText(i, "", j); if(GetButtonText(i, j) == "-1") SetButtonText(i, "", j);
#endif #endif
@ -343,11 +333,10 @@ void ConfigDialog::ToBlank(bool ToBlank)
else else
{ {
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++) 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);
} }
} }
} }
//////////////////////////////////////
@ -458,18 +447,20 @@ wxString ConfigDialog::GetButtonText(int id, int _Page)
// Wait for button press // Wait for button press
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
/* Loop or timer: There are basically two ways to do this. With a while() or for() loop, or with a /* Loop or timer: There are basically two ways to do this. With a while() or
timer. The downside with the while() or for() loop is that there is no way to stop it if the user for() loop, or with a timer. The downside with the while() or for() loop is
should select to configure another button while we are still in an old loop. What will happen then that there is no way to stop it if the user should select to configure
is that we start another parallel loop (at least in Windows) that blocks the old loop. And our only another button while we are still in an old loop. What will happen then is
option to wait for the old loop to finish is with a new loop, and that will block the old loop for as that we start another parallel loop (at least in Windows) that blocks the
long as it's going on. Therefore a timer is easier to control. */ 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 ConfigDialog::GetButtons(wxCommandEvent& event) void ConfigDialog::GetButtons(wxCommandEvent& event)
{ {
DoGetButtons(event.GetId()); DoGetButtons(event.GetId());
} }
void ConfigDialog::DoGetButtons(int GetId) void ConfigDialog::DoGetButtons(int _GetId)
{ {
// ============================================= // =============================================
// Collect the starting values // Collect the starting values
@ -483,11 +474,11 @@ void ConfigDialog::DoGetButtons(int GetId)
int TriggerType = WiiMoteEmu::PadMapping[Controller].triggertype; int TriggerType = WiiMoteEmu::PadMapping[Controller].triggertype;
// Collect the accepted buttons for this slot // 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 // 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); bool XInput = (TriggerType == InputCommon::CTL_TRIGGER_XINPUT);
@ -511,10 +502,10 @@ void ConfigDialog::DoGetButtons(int GetId)
// ======================= // =======================
//INFO_LOG(CONSOLE, "Before (%i) Id:%i %i IsRunning:%i\n", //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 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()) if(m_ButtonMappingTimer->IsRunning())
{ {
@ -522,26 +513,26 @@ void ConfigDialog::DoGetButtons(int GetId)
GetButtonWaitingTimer = 0; GetButtonWaitingTimer = 0;
// Update the old textbox // Update the old textbox
SetButtonText(GetButtonWaitingID, ""); SetButtonText(GetButtonWaitingID, (char *)"");
} }
// Save the button Id // Save the button Id
GetButtonWaitingID = GetId; GetButtonWaitingID = _GetId;
// Reset the key in case we happen to have an old one // Reset the key in case we happen to have an old one
g_Pressed = 0; g_Pressed = 0;
// Update the text box // Update the text box
sprintf(format, "[%d]", Seconds); sprintf(format, "[%d]", Seconds);
SetButtonText(GetId, format); SetButtonText(_GetId, format);
// Start the timer // Start the timer
#if wxUSE_TIMER #if wxUSE_TIMER
m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) ); m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) );
#endif #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", "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); Axis, LeftRight, XInput, Button, Hat);
} }
@ -575,7 +566,7 @@ void ConfigDialog::DoGetButtons(int GetId)
// Update text // Update text
sprintf(format, "[%d]", TmpTime); sprintf(format, "[%d]", TmpTime);
SetButtonText(GetId, format); SetButtonText(_GetId, format);
/* Debug /* Debug
INFO_LOG(CONSOLE, "Keyboard: %i\n", g_Pressed);*/ INFO_LOG(CONSOLE, "Keyboard: %i\n", g_Pressed);*/
@ -586,7 +577,7 @@ void ConfigDialog::DoGetButtons(int GetId)
{ {
Stop = true; Stop = true;
// Leave a blank mapping // Leave a blank mapping
SetButtonTextAll(GetId, "-1"); SetButtonTextAll(_GetId, (char *)"-1");
} }
// If we got a button // If we got a button
@ -595,7 +586,7 @@ void ConfigDialog::DoGetButtons(int GetId)
Stop = true; Stop = true;
// Write the number of the pressed button to the text box // Write the number of the pressed button to the text box
sprintf(format, "%d", pressed); sprintf(format, "%d", pressed);
SetButtonTextAll(GetId, format); SetButtonTextAll(_GetId, format);
} }
// Stop the timer // Stop the timer
@ -604,21 +595,23 @@ void ConfigDialog::DoGetButtons(int GetId)
m_ButtonMappingTimer->Stop(); m_ButtonMappingTimer->Stop();
GetButtonWaitingTimer = 0; GetButtonWaitingTimer = 0;
/* Update the button mapping for all slots that use this device. (It doesn't make sense to have several slots /* Update the button mapping for all slots that use this device. (It
controlled by the same device, but several DirectInput instances of different but identical devices may possible doesn't make sense to have several slots controlled by the same
have the same id, I don't know. So we have to do this. The user may also have selected the same device for device, but several DirectInput instances of different but identical
several disabled slots. */ 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); SaveButtonMappingAll(Controller);
INFO_LOG(CONSOLE, "Timer Stopped for Pad:%i GetId:%i\n", INFO_LOG(CONSOLE, "Timer Stopped for Pad:%i _GetId:%i\n",
WiiMoteEmu::PadMapping[Controller].ID, GetId); WiiMoteEmu::PadMapping[Controller].ID, _GetId);
} }
// If we got a bad button // If we got a bad button
if(g_Pressed == -1) if(g_Pressed == -1)
{ {
// Update text // Update text
SetButtonTextAll(GetId, "-1"); SetButtonTextAll(_GetId, (char *)"-1");
// Notify the user // Notify the user
wxMessageBox(wxString::Format(wxT( wxMessageBox(wxString::Format(wxT(
@ -635,32 +628,28 @@ void ConfigDialog::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() 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 // Show current input status
// ¯¯¯¯¯¯¯¯¯¯
// Convert the 0x8000 range values to BoxW and BoxH for the plot // Convert the 0x8000 range values to BoxW and BoxH for the plot
void ConfigDialog::Convert2Box(int &x) void ConfigDialog::Convert2Box(int &x)
{ {
// Border adjustment // Border adjustment
int BoxW_ = BoxW - 2; int BoxH_ = BoxH - 2; int BoxW_ = BoxW - 2;// int BoxH_ = BoxH - 2;
// Convert values // Convert values
x = (BoxW_ / 2) + (x * BoxW_ / (32767 * 2)); x = (BoxW_ / 2) + (x * BoxW_ / (32767 * 2));
} }
// Update the input status boxes // Update the input status boxes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void ConfigDialog::PadGetStatus() void ConfigDialog::PadGetStatus()
{ {
//INFO_LOG(CONSOLE, "SDL_WasInit: %i\n", SDL_WasInit(0)); //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 /* Return if it's not detected. The ID should never be less than zero here,
because of a manual ini file change, but we make that check anway. */ 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()) if(WiiMoteEmu::PadMapping[Page].ID < 0 || WiiMoteEmu::PadMapping[Page].ID >= SDL_NumJoysticks())
{ {
m_TStatusLeftIn[Page]->SetLabel(wxT("Not connected")); m_TStatusLeftIn[Page]->SetLabel(wxT("Not connected"));
@ -685,17 +674,15 @@ void ConfigDialog::PadGetStatus()
} }
// Get physical device status // Get physical device status
int PhysicalDevice = WiiMoteEmu::PadMapping[Page].ID; // int PhysicalDevice = WiiMoteEmu::PadMapping[Page].ID;
int TriggerType = WiiMoteEmu::PadMapping[Page].triggertype; // int TriggerType = WiiMoteEmu::PadMapping[Page].triggertype;
// Check that Dolphin is in focus, otherwise don't update the pad status // Check that Dolphin is in focus, otherwise don't update the pad status
//if (IsFocus()) //if (IsFocus())
WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page, WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Page].ID).NumButtons); WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page, WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Page].ID).NumButtons);
//////////////////////////////////////
// Analog stick // Analog stick
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Set Deadzones perhaps out of function // Set Deadzones perhaps out of function
//int deadzone = (int)(((float)(128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1)); //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)); //int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
@ -732,9 +719,7 @@ void ConfigDialog::PadGetStatus()
right_y_after = 0; right_y_after = 0;
} }
// -------------------------------------------
// Show the adjusted angles in the status box // Show the adjusted angles in the status box
// --------------
// Change 0x8000 to 180 // Change 0x8000 to 180
/* /*
float x8000 = 0x8000; float x8000 = 0x8000;
@ -750,7 +735,6 @@ void ConfigDialog::PadGetStatus()
main_x_after = main_x_after * (x8000 / 180); main_x_after = main_x_after * (x8000 / 180);
main_y_after = main_y_after * (x8000 / 180); main_y_after = main_y_after * (x8000 / 180);
*/ */
// ---------------------
// Convert the values to fractions // Convert the values to fractions
float f_x = main_x / 32767.0; float f_x = main_x / 32767.0;
@ -788,13 +772,9 @@ void ConfigDialog::PadGetStatus()
m_bmpDotLeftOut[Page]->SetPosition(wxPoint(main_x_after, main_y_after)); m_bmpDotLeftOut[Page]->SetPosition(wxPoint(main_x_after, main_y_after));
m_bmpDotRightIn[Page]->SetPosition(wxPoint(right_x, right_y)); m_bmpDotRightIn[Page]->SetPosition(wxPoint(right_x, right_y));
m_bmpDotRightOut[Page]->SetPosition(wxPoint(right_x_after, right_y_after)); m_bmpDotRightOut[Page]->SetPosition(wxPoint(right_x_after, right_y_after));
///////////////////// Analog stick
//////////////////////////////////////
// Triggers // Triggers
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int TriggerValue = 0;
// Get the selected keys // Get the selected keys
long Left, Right; long Left, Right;
@ -816,11 +796,9 @@ void ConfigDialog::PadGetStatus()
wxT("%03i"), TriggerLeft)); wxT("%03i"), TriggerLeft));
m_TriggerStatusRx[Page]->SetLabel(wxString::Format( m_TriggerStatusRx[Page]->SetLabel(wxString::Format(
wxT("%03i"), TriggerRight)); wxT("%03i"), TriggerRight));
///////////////////// Triggers
} }
// Populate the advanced tab // Populate the advanced tab
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void ConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event)) void ConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event))
{ {
// Show the current status // Show the current status
@ -835,4 +813,3 @@ void ConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event))
PadGetStatus(); PadGetStatus();
} }
/////////////////////////////////////////////////////

View File

@ -16,10 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
//#include "Common.h" // for u16
#include "CommonTypes.h" // for u16 #include "CommonTypes.h" // for u16
#include "IniFile.h" #include "IniFile.h"
#include "Timer.h" #include "Timer.h"
@ -31,9 +27,6 @@
#include "Config.h" #include "Config.h"
#include "EmuMain.h" // for LoadRecordedMovements() #include "EmuMain.h" // for LoadRecordedMovements()
#include "EmuSubroutines.h" // for WmRequestStatus #include "EmuSubroutines.h" // for WmRequestStatus
//////////////////////////////////////
void ConfigDialog::LoadFile() void ConfigDialog::LoadFile()
{ {
@ -123,18 +116,12 @@ void ConfigDialog::SaveFile()
/////////////////////////////////////////////////////////////////////////
// Create GUI // Create GUI
// ------------
void ConfigDialog::CreateGUIControlsRecording() void ConfigDialog::CreateGUIControlsRecording()
{ {
////////////////////////////////////////////////////////////////////////////////
// Real Wiimote // Real Wiimote
// ----------------
// ---------------------------------------------
// Status // Status
// ----------------
m_TextUpdateRate = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Update rate: 000 times/s")); m_TextUpdateRate = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Update rate: 000 times/s"));
m_UpdateMeters = new wxCheckBox(m_PageRecording, ID_UPDATE_REAL, wxT("Update gauges")); m_UpdateMeters = new wxCheckBox(m_PageRecording, ID_UPDATE_REAL, wxT("Update gauges"));
@ -144,7 +131,6 @@ void ConfigDialog::CreateGUIControlsRecording()
"You can turn this off when a game is running to avoid a potential slowdown that may come from redrawing the\n" "You can turn this off when a game is running to avoid a potential slowdown that may come from redrawing the\n"
"configuration screen. Remember that you also need to press '+' on your Wiimote before you can record movements." "configuration screen. Remember that you also need to press '+' on your Wiimote before you can record movements."
)); ));
// -----------------------
// Width and height of the gauges // Width and height of the gauges
static const int Gw = 35, Gh = 110; static const int Gw = 35, Gh = 110;
@ -162,9 +148,7 @@ void ConfigDialog::CreateGUIControlsRecording()
// The text controls // The text controls
m_TextIR = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Cursor: 000 000\nDistance: 0000")); m_TextIR = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Cursor: 000 000\nDistance: 0000"));
// ------------------------------------
// The sizers for all gauges together with their label // The sizers for all gauges together with their label
// -----------
wxBoxSizer * sBoxBattery = new wxBoxSizer(wxVERTICAL); wxBoxSizer * sBoxBattery = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * sBoxRoll[2]; wxBoxSizer * sBoxRoll[2];
sBoxRoll[0] = new wxBoxSizer(wxVERTICAL); sBoxRoll[0] = new wxBoxSizer(wxVERTICAL);
@ -185,11 +169,8 @@ void ConfigDialog::CreateGUIControlsRecording()
m_TextX[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextX[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextX[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextX[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
m_TextY[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextY[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextY[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextY[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
m_TextZ[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextZ[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextZ[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextZ[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
// ----------------
// ----------------------------------------------
// Row 1 Sizers // Row 1 Sizers
// -----------
sBoxBattery->Add(m_GaugeBattery, 0, wxEXPAND | (wxALL), 0); sBoxBattery->Add(m_TextBattery, 0, wxEXPAND | (wxUP), 5); sBoxBattery->Add(m_GaugeBattery, 0, wxEXPAND | (wxALL), 0); sBoxBattery->Add(m_TextBattery, 0, wxEXPAND | (wxUP), 5);
sBoxRoll[0]->Add(m_GaugeRoll[0], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 0); sBoxRoll[0]->Add(m_TextRoll, 0, wxEXPAND | (wxUP), 5); sBoxRoll[0]->Add(m_GaugeRoll[0], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 0); sBoxRoll[0]->Add(m_TextRoll, 0, wxEXPAND | (wxUP), 5);
@ -231,16 +212,12 @@ void ConfigDialog::CreateGUIControlsRecording()
sbRealWiimoteStatus->Add(sbRealRoll, 0, wxEXPAND | (wxLEFT), 5); sbRealWiimoteStatus->Add(sbRealRoll, 0, wxEXPAND | (wxLEFT), 5);
sbRealWiimoteStatus->Add(sbRealGForce, 0, wxEXPAND | (wxLEFT), 5); sbRealWiimoteStatus->Add(sbRealGForce, 0, wxEXPAND | (wxLEFT), 5);
sbRealWiimoteStatus->Add(sbRealAccel, 0, wxEXPAND | (wxLEFT), 5); sbRealWiimoteStatus->Add(sbRealAccel, 0, wxEXPAND | (wxLEFT), 5);
// --------------------
// Tool tips // Tool tips
m_GaugeBattery->SetToolTip(wxT("Press '+' to show the current status. Press '-' to stop recording the status.")); m_GaugeBattery->SetToolTip(wxT("Press '+' to show the current status. Press '-' to stop recording the status."));
// ==========================================
// ====================================================================
// Record movement // Record movement
// ----------------
wxStaticBoxSizer * sbRealRecord = new wxStaticBoxSizer(wxVERTICAL, m_PageRecording, wxT("Record movements")); wxStaticBoxSizer * sbRealRecord = new wxStaticBoxSizer(wxVERTICAL, m_PageRecording, wxT("Record movements"));
wxArrayString StrHotKeySwitch; wxArrayString StrHotKeySwitch;
@ -322,9 +299,7 @@ void ConfigDialog::CreateGUIControlsRecording()
m_RecordIRBytesText[i]->Enable(false); m_RecordIRBytesText[i]->Enable(false);
m_RecordSpeed[i]->Enable(false); m_RecordSpeed[i]->Enable(false);
// ------------------------------------
// Row 2 Sizers // Row 2 Sizers
// -----------
sRealRecord[i]->Add(m_RecordButton[i], 0, wxEXPAND | (wxLEFT), 5); sRealRecord[i]->Add(m_RecordButton[i], 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[i]->Add(m_RecordHotKeySwitch[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); sRealRecord[i]->Add(m_RecordHotKeyWiimote[i], 0, wxEXPAND | (wxLEFT), 2);
@ -338,24 +313,17 @@ void ConfigDialog::CreateGUIControlsRecording()
sbRealRecord->Add(sRealRecord[i], 0, wxEXPAND | (wxTOP), 2); sbRealRecord->Add(sRealRecord[i], 0, wxEXPAND | (wxTOP), 2);
} }
// ==========================================
// ----------------------------------------------------------------------
// Set up sizers for the whole page // Set up sizers for the whole page
// ----------------
m_sRecordingMain = new wxBoxSizer(wxVERTICAL); m_sRecordingMain = new wxBoxSizer(wxVERTICAL);
m_sRecordingMain->Add(sbRealWiimoteStatus, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxUP), 5); m_sRecordingMain->Add(sbRealWiimoteStatus, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxUP), 5);
m_sRecordingMain->Add(sbRealRecord, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5); m_sRecordingMain->Add(sbRealRecord, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
m_PageRecording->SetSizer(m_sRecordingMain); m_PageRecording->SetSizer(m_sRecordingMain);
} }
/////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/* Record movement */ /* Record movement */
// ------------
void ConfigDialog::ConvertToString() void ConfigDialog::ConvertToString()
{ {
// Load ini file // Load ini file
@ -382,8 +350,10 @@ void ConfigDialog::ConvertToString()
TmpTime += StringFromFormat("%05i", Time); TmpTime += StringFromFormat("%05i", Time);
if (i < ((int)m_vRecording.size() - 1)) TmpTime += ","; 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. /* Break just short of the IniFile.cpp byte limit so that we don't
This limit should never be hit because of the recording limit below. I keep it here just in case. */ 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)) if(TmpStr.length() > (1024*10 - 10) || TmpIR.length() > (1024*10 - 10) || TmpTime.length() > (1024*10 - 10))
{ {
break; break;
@ -452,8 +422,8 @@ void ConfigDialog::RecordMovement(wxCommandEvent& event)
else else
{ {
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Press +")); m_RecordButton[m_iRecordTo]->SetLabel(wxT("Press +"));
// This is for usability purposes, it may not be obvious at all that this must be unchecked // This is for usability purposes, it may not be obvious at all that
// for the recording to work // this must be unchecked for the recording to work
for(int i = 0; i < 1; i++) m_UseRealWiimote[i]->SetValue(false); g_Config.bUseRealWiimote = false; for(int i = 0; i < 1; i++) m_UseRealWiimote[i]->SetValue(false); g_Config.bUseRealWiimote = false;
return; return;
} }
@ -531,5 +501,4 @@ void ConfigDialog::DoRecordMovement(int _x, int _y, int _z, const u8 *_IR, int _
UpdateGUI(); UpdateGUI();
} }
} }
/////////////////////////////////

View File

@ -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
/* Data reports guide. The different structures location in the Input reports. The ? in in one byte.
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) 0x37: For the data reportingmode 0x37 there are five unused IR bytes in the
by "..." below, it seems like they can be set to either 0xff or 0x00 without affecting the end (represented) by "..." below, it seems like they can be set to either
IR emulation. */ 0xff or 0x00 without affecting the IR emulation. */
// ----------------
/* 0x33 /* 0x33 [c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y
[c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y ? ?
0x37 0x37 [c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2
[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 ... ext.jx jy ax ay az bt
The Data Report's path from here is The Data Report's path from here is
@ -41,15 +39,9 @@
WII_IPC_HLE_Device_usb.cpp: WII_IPC_HLE_Device_usb.cpp:
CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame() CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame()
at that point the message is queued and will be sent by the next 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()
*/
// ================
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include "pluginspecs_wiimote.h" #include "pluginspecs_wiimote.h"
#include <vector> #include <vector>
@ -64,17 +56,10 @@
#include "EmuSubroutines.h" #include "EmuSubroutines.h"
#include "EmuDefinitions.h" #include "EmuDefinitions.h"
#include "Encryption.h" // for extension encryption #include "Encryption.h" // for extension encryption
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
#include "Config.h" // for g_Config #include "Config.h" // for g_Config
///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Declarations and definitions
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;
///////////////////////////////
namespace WiiMoteEmu namespace WiiMoteEmu
{ {
@ -84,12 +69,9 @@ namespace WiiMoteEmu
//****************************************************************************** //******************************************************************************
// ===================================================
/* Update the data reporting mode */ /* Update the data reporting mode */
// ----------------
void WmDataReporting(u16 _channelID, wm_data_reporting* dr) 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, " Set Data reporting mode");
DEBUG_LOG(WII_IPC_WIIMOTE, " Rumble: %x", dr->rumble); DEBUG_LOG(WII_IPC_WIIMOTE, " Rumble: %x", dr->rumble);
DEBUG_LOG(WII_IPC_WIIMOTE, " Continuous: %x", dr->continuous); DEBUG_LOG(WII_IPC_WIIMOTE, " Continuous: %x", dr->continuous);
@ -117,14 +99,11 @@ void WmDataReporting(u16 _channelID, wm_data_reporting* dr)
// WmSendAck(_channelID, WM_DATA_REPORTING); // WmSendAck(_channelID, WM_DATA_REPORTING);
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
} }
// ===================================================
/* Case 0x30: Core Buttons */ /* Case 0x30: Core Buttons */
// ----------------
void SendReportCore(u16 _channelID) void SendReportCore(u16 _channelID)
{ {
u8 DataFrame[1024]; u8 DataFrame[1024];
@ -146,9 +125,7 @@ void SendReportCore(u16 _channelID)
} }
// ===================================================
/* 0x31: Core Buttons and Accelerometer */ /* 0x31: Core Buttons and Accelerometer */
// ----------------
void SendReportCoreAccel(u16 _channelID) void SendReportCoreAccel(u16 _channelID)
{ {
u8 DataFrame[1024]; u8 DataFrame[1024];
@ -174,9 +151,7 @@ void SendReportCoreAccel(u16 _channelID)
} }
// ===================================================
/* Case 0x33: Core Buttons and Accelerometer with 12 IR bytes */ /* Case 0x33: Core Buttons and Accelerometer with 12 IR bytes */
// ----------------
void SendReportCoreAccelIr12(u16 _channelID) { void SendReportCoreAccelIr12(u16 _channelID) {
u8 DataFrame[1024]; u8 DataFrame[1024];
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR12); u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR12);
@ -205,9 +180,7 @@ void SendReportCoreAccelIr12(u16 _channelID) {
} }
// ===================================================
/* Case 0x35: Core Buttons and Accelerometer with 16 Extension Bytes */ /* Case 0x35: Core Buttons and Accelerometer with 16 Extension Bytes */
// ----------------
void SendReportCoreAccelExt16(u16 _channelID) void SendReportCoreAccelExt16(u16 _channelID)
{ {
u8 DataFrame[1024]; u8 DataFrame[1024];
@ -252,9 +225,7 @@ void SendReportCoreAccelExt16(u16 _channelID)
} }
// ===================================================
/* Case 0x37: Core Buttons and Accelerometer with 10 IR bytes and 6 Extension Bytes */ /* Case 0x37: Core Buttons and Accelerometer with 10 IR bytes and 6 Extension Bytes */
// ----------------
void SendReportCoreAccelIr10Ext(u16 _channelID) void SendReportCoreAccelIr10Ext(u16 _channelID)
{ {
u8 DataFrame[1024]; u8 DataFrame[1024];

View File

@ -15,9 +15,6 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#ifndef _EMU_DEFINITIONS_ #ifndef _EMU_DEFINITIONS_
#define _EMU_DEFINITIONS_ #define _EMU_DEFINITIONS_
@ -29,8 +26,6 @@
#include "wiimote_hid.h" #include "wiimote_hid.h"
#include "EmuDefinitions.h" #include "EmuDefinitions.h"
#include "Encryption.h" #include "Encryption.h"
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
//////////////////////////
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;

View File

@ -29,7 +29,6 @@
#include "wiimote_hid.h" // Local #include "wiimote_hid.h" // Local
#include "Encryption.h" #include "Encryption.h"
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;

View File

@ -16,9 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <vector> #include <vector>
#include <string> #include <string>
@ -37,9 +34,7 @@
#include "EmuSubroutines.h" #include "EmuSubroutines.h"
#include "EmuMain.h" #include "EmuMain.h"
#include "Encryption.h" // for extension encryption #include "Encryption.h" // for extension encryption
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
#include "Config.h" // for g_Config #include "Config.h" // for g_Config
////////////////////////////////////
namespace WiiMoteEmu namespace WiiMoteEmu
@ -51,9 +46,7 @@ namespace WiiMoteEmu
//****************************************************************************** //******************************************************************************
//////////////////////////////////////////////////////////////////////////////////////////
// Test the calculations // Test the calculations
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void TiltTest(u8 x, u8 y, u8 z) void TiltTest(u8 x, u8 y, u8 z)
{ {
int Roll, Pitch, RollAdj, PitchAdj; int Roll, Pitch, RollAdj, PitchAdj;
@ -69,13 +62,11 @@ void TiltTest(u8 x, u8 y, u8 z)
(_Pitch >= 0) ? StringFromFormat(" %03i", (int)_Pitch).c_str() : StringFromFormat("%04i", (int)_Pitch).c_str()); (_Pitch >= 0) ? StringFromFormat(" %03i", (int)_Pitch).c_str() : StringFromFormat("%04i", (int)_Pitch).c_str());
INFO_LOG(CONSOLE, "%s\n", To.c_str()); INFO_LOG(CONSOLE, "%s\n", To.c_str());
} }
////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// /* Angles adjustment for the upside down state when both roll and pitch is
/* Angles adjustment for the upside down state when both roll and pitch is used. When the absolute values used. When the absolute values of the angles go over 90° the Wiimote is
of the angles go over 90° the Wiimote is upside down and these adjustments are needed. */ upside down and these adjustments are needed. */
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void AdjustAngles(float &Roll, float &Pitch) void AdjustAngles(float &Roll, float &Pitch)
{ {
float OldPitch = Pitch; float OldPitch = Pitch;
@ -96,12 +87,9 @@ void AdjustAngles(float &Roll, float &Pitch)
Roll = -180 - Roll; // -15 to -165 Roll = -180 - Roll; // -15 to -165
} }
} }
////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Angles to accelerometer values // Angles to accelerometer values
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z) void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z)
{ {
// We need radiands for the math functions // We need radiands for the math functions
@ -125,21 +113,22 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
else else
{ {
// ==================================================== // ====================================================
/* This seems to always produce the exact same combination of x, y, z and Roll and Pitch that the /* This seems to always produce the exact same combination of x, y, z
real Wiimote produce. There is an unlimited amount of x, y, z combinations for any combination of and Roll and Pitch that the real Wiimote produce. There is an
Roll and Pitch. But if we select a Z from the smallest of the absolute value of cos(Roll) and unlimited amount of x, y, z combinations for any combination of Roll
cos (Pitch) we get the right values. */ 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); 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 got these from reversing the calculation in
I don't know if we can derive these from some kind of matrix or something */ 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_num = 2 * tanf(0.5f * _Roll) * z;
float x_den = pow2f(tanf(0.5f * _Roll)) - 1; float x_den = pow2f(tanf(0.5f * _Roll)) - 1;
x = - (x_num / x_den); x = - (x_num / x_den);
float y_num = 2 * tanf(0.5f * _Pitch) * z; float y_num = 2 * tanf(0.5f * _Pitch) * z;
float y_den = pow2f(tanf(0.5f * _Pitch)) - 1; float y_den = pow2f(tanf(0.5f * _Pitch)) - 1;
y = - (y_num / y_den); y = - (y_num / y_den);
// =========================
} }
// Multiply with the neutral of z and its g // Multiply with the neutral of z and its g
@ -162,9 +151,7 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
_z = iz; _z = iz;
} }
//////////////////////////////////////////////////////////////////////////////////////////
// Accelerometer to roll and pitch angles // Accelerometer to roll and pitch angles
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
float AccelerometerToG(float Current, float Neutral, float G) float AccelerometerToG(float Current, float Neutral, float G)
{ {
float _G = (Current - Neutral) / G; float _G = (Current - Neutral) / G;
@ -214,11 +201,7 @@ void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, in
// IR data functions // IR data functions
//****************************************************************************** //******************************************************************************
//////////////////////////////////////////////////////////////////////////////////////////
// Calculate dot positions from the basic 10 byte IR data // Calculate dot positions from the basic 10 byte IR data
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void IRData2DotsBasic(u8 *Data) void IRData2DotsBasic(u8 *Data)
{ {
struct SDot* Dot = g_Wm.IR.Dot; struct SDot* Dot = g_Wm.IR.Dot;
@ -258,9 +241,7 @@ void IRData2DotsBasic(u8 *Data)
} }
//////////////////////////////////////////////////////////////////////////////////////////
// Calculate dot positions from the extented 12 byte IR data // Calculate dot positions from the extented 12 byte IR data
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void IRData2Dots(u8 *Data) void IRData2Dots(u8 *Data)
{ {
struct SDot* Dot = g_Wm.IR.Dot; struct SDot* Dot = g_Wm.IR.Dot;
@ -290,12 +271,9 @@ void IRData2Dots(u8 *Data)
ReorderIRDots(); ReorderIRDots();
IRData2Distance(); IRData2Distance();
} }
////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Reorder the IR dots according to their x-axis value // Reorder the IR dots according to their x-axis value
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void ReorderIRDots() void ReorderIRDots()
{ {
// Create a shortcut // Create a shortcut
@ -326,12 +304,9 @@ void ReorderIRDots()
Dot[i].Order = order; Dot[i].Order = order;
} }
} }
////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Calculate dot positions from the extented 12 byte IR data // Calculate dot positions from the extented 12 byte IR data
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
void IRData2Distance() void IRData2Distance()
{ {
// Create a shortcut // Create a shortcut
@ -361,7 +336,6 @@ void IRData2Distance()
// Save the distance // Save the distance
g_Wm.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd)); g_Wm.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
} }
////////////////////////////////
//****************************************************************************** //******************************************************************************
@ -380,4 +354,4 @@ std::string CCData2Values(u8 *Data)
(Data[2] & 0x1f)); (Data[2] & 0x1f));
} }
} // WiiMoteEmu } // WiiMoteEmu

View File

@ -16,9 +16,7 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <vector> #include <vector>
#include <string> #include <string>
@ -36,17 +34,14 @@
#include "EmuSubroutines.h" #include "EmuSubroutines.h"
#include "EmuMain.h" #include "EmuMain.h"
#include "Encryption.h" // for extension encryption #include "Encryption.h" // for extension encryption
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
#include "Config.h" // for g_Config #include "Config.h" // for g_Config
////////////////////////////////////
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu namespace WiiMoteEmu
{ {
// ===================================================
/* Bit shift conversions */ /* Bit shift conversions */
// -------------
u32 convert24bit(const u8* src) { u32 convert24bit(const u8* src) {
return (src[0] << 16) | (src[1] << 8) | src[2]; return (src[0] << 16) | (src[1] << 8) | src[2];
} }
@ -54,12 +49,9 @@ u32 convert24bit(const u8* src) {
u16 convert16bit(const u8* src) { u16 convert16bit(const u8* src) {
return (src[0] << 8) | src[1]; return (src[0] << 8) | src[1];
} }
// ==============
// ===================================================
/* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */ /* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */
// ----------------
void GetMousePos(float& x, float& y) void GetMousePos(float& x, float& y)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -184,12 +176,9 @@ void GetMousePos(float& x, float& y)
y = 0.5f; y = 0.5f;
#endif #endif
} }
// ==============
// ===================================================
/* Homebrew encryption for 16 byte zero keys. */ /* Homebrew encryption for 16 byte zero keys. */
// ----------------
void CryptBuffer(u8* _buffer, u8 _size) void CryptBuffer(u8* _buffer, u8 _size)
{ {
for (int i=0; i<_size; i++) for (int i=0; i<_size; i++)
@ -204,30 +193,23 @@ void WriteCrypted16(u8* _baseBlock, u16 _address, u16 _value)
CryptBuffer((u8*)&cryptedValue, sizeof(u16)); CryptBuffer((u8*)&cryptedValue, sizeof(u16));
*(u16*)(_baseBlock + _address) = cryptedValue; *(u16*)(_baseBlock + _address) = cryptedValue;
//PanicAlert("Converted %04x to %04x", _value, cryptedValue);
} }
// ================
// ===================================================
/* Calculate Extenstion Regisister Calibration Checksum */ /* Calculate Extenstion Regisister Calibration Checksum */
// This function is not currently used, it's just here to show how the values in EmuDefinitions.h are calculated. // This function is not currently used, it's just here to show how the values
// ---------------- // in EmuDefinitions.h are calculated.
void GetCalibrationChecksum() void GetCalibrationChecksum()
{ {
u8 sum = 0; u8 sum = 0;
for (int i = 0; i < sizeof(nunchuck_calibration) - 2; i++) for (u32 i = 0; i < sizeof(nunchuck_calibration) - 2; i++)
sum += nunchuck_calibration[i]; sum += nunchuck_calibration[i];
u8 Check1 = sum + 0x55;
u8 Check2 = sum + 0xaa; INFO_LOG(CONSOLE, "0x%02x 0x%02x", (sum + 0x55), (sum + 0xaa));
INFO_LOG(CONSOLE, "0x%02x 0x%02x", Check1, Check2);
} }
// ================
// ===================================================
/* Load pre-recorded movements */ /* Load pre-recorded movements */
// ----------------
void LoadRecordedMovements() void LoadRecordedMovements()
{ {
INFO_LOG(CONSOLE, "LoadRecordedMovements()\n"); INFO_LOG(CONSOLE, "LoadRecordedMovements()\n");
@ -282,12 +264,12 @@ void LoadRecordedMovements()
Tmp.y = atoi(StrY.c_str()); Tmp.y = atoi(StrY.c_str());
Tmp.z = atoi(StrZ.c_str()); Tmp.z = atoi(StrZ.c_str());
// ---------------------------------
// Go to next set of IR values // Go to next set of IR values
// ---------
// If there is no IR data saving we fill the array with zeroes. This should only be able to occur from manual ini editing // If there is no IR data saving we fill the array with
// but we check for it anyway // zeroes. This should only be able to occur from manual ini
if (TmpIRBytes == 0) for(int i = 0; i < 12; i++) Tmp.IR[i] = 0; // editing but we check for it anyway
if (TmpIRBytes == 0) for(int n = 0; n < 12; n++) Tmp.IR[n] = 0;
for(int ii = 0; ii < TmpIRBytes; ii++) for(int ii = 0; ii < TmpIRBytes; ii++)
{ {
if(TmpIR.length() < (u32)(k + i + TmpIRBytes)) continue; // Safety check if(TmpIR.length() < (u32)(k + i + TmpIRBytes)) continue; // Safety check
@ -297,7 +279,6 @@ void LoadRecordedMovements()
Tmp.IR[ii] = (u8)TmpU32; Tmp.IR[ii] = (u8)TmpU32;
} }
if (TmpIRBytes == 10) k += (10*2 + 1); else k += (12*2 + 1); if (TmpIRBytes == 10) k += (10*2 + 1); else k += (12*2 + 1);
// ---------------------
// Go to next set of time values // Go to next set of time values
double Time = (double)atoi(TmpTime.substr(l, 5).c_str()); double Time = (double)atoi(TmpTime.substr(l, 5).c_str());
@ -307,9 +288,7 @@ void LoadRecordedMovements()
// Save the values // Save the values
VRecording.at(i).Recording.push_back(Tmp); VRecording.at(i).Recording.push_back(Tmp);
// ---------------------------------
// Log results // Log results
// ---------
/*INFO_LOG(CONSOLE, "Time:%f\n", Tmp.Time); /*INFO_LOG(CONSOLE, "Time:%f\n", Tmp.Time);
std::string TmpIRLog = ArrayToString(Tmp.IR, TmpIRBytes, 0, 30); std::string TmpIRLog = ArrayToString(Tmp.IR, TmpIRBytes, 0, 30);
INFO_LOG(CONSOLE, "IR: %s\n", TmpIRLog.c_str()); INFO_LOG(CONSOLE, "IR: %s\n", TmpIRLog.c_str());
@ -326,9 +305,7 @@ void LoadRecordedMovements()
int TmpPlaybackSpeed; file.Get(SaveName.c_str(), "PlaybackSpeed", &TmpPlaybackSpeed, -1); int TmpPlaybackSpeed; file.Get(SaveName.c_str(), "PlaybackSpeed", &TmpPlaybackSpeed, -1);
VRecording.at(i).PlaybackSpeed = TmpPlaybackSpeed; VRecording.at(i).PlaybackSpeed = TmpPlaybackSpeed;
// ---------------------------------
// Logging // Logging
// ---------
/*std::string TmpIRLog; /*std::string TmpIRLog;
if(TmpIRBytes > 0 && VRecording.size() > i) if(TmpIRBytes > 0 && VRecording.size() > i)
TmpIRLog = ArrayToString(VRecording.at(i).Recording.at(0).IR, TmpIRBytes, 0, 30); TmpIRLog = ArrayToString(VRecording.at(i).Recording.at(0).IR, TmpIRBytes, 0, 30);
@ -340,10 +317,8 @@ void LoadRecordedMovements()
TmpIRLog.c_str(), TmpIRLog.c_str(),
VRecording.at(i).Recording.at(0).x, VRecording.at(i).Recording.at(0).y, VRecording.at(i).Recording.at(0).z VRecording.at(i).Recording.at(0).x, VRecording.at(i).Recording.at(0).y, VRecording.at(i).Recording.at(0).z
);*/ );*/
// ---------------------
} }
} }
// ================
// Update the accelerometer neutral values // Update the accelerometer neutral values
void UpdateEeprom() void UpdateEeprom()
@ -407,24 +382,19 @@ void UpdateEeprom()
// Calculate checksum for the nunchuck calibration. The last two bytes. // Calculate checksum for the nunchuck calibration. The last two bytes.
void ExtensionChecksum(u8 * Calibration) void ExtensionChecksum(u8 * Calibration)
{ {
u8 sum = 0; u8 Byte15, Byte16; u8 sum = 0; //u8 Byte15, Byte16;
for (int i = 0; i < sizeof(Calibration) - 2; i++) for (u32 i = 0; i < sizeof(Calibration) - 2; i++)
{ {
sum += Calibration[i]; sum += Calibration[i];
printf("Plus 0x%02x\n", Calibration[i]); printf("Plus 0x%02x\n", Calibration[i]);
} }
Byte15 = sum + 0x55; // Byte 15 // Byte15 = sum + 0x55; // Byte 15
Byte16 = sum + 0xaa; // Byte 16 // Byte16 = sum + 0xaa; // Byte 16
} }
// Set initial valuesm this done both in Init and Shutdown // Set initial valuesm this done both in Init and Shutdown
void ResetVariables() void ResetVariables()
{ {
u8 g_Leds = 0x0; // 4 bits
u8 g_Speaker = 0x0; // 1 = on
u8 g_SpeakerVoice = 0x0; // 1 = on
u8 g_IR = 0x0; // 1 = on
g_ReportingMode = 0; g_ReportingMode = 0;
g_ReportingChannel = 0; g_ReportingChannel = 0;
g_Encryption = false; g_Encryption = false;
@ -466,9 +436,7 @@ void SetDefaultExtensionRegistry()
} }
// ===================================================
/* Write initial values to Eeprom and registers. */ /* Write initial values to Eeprom and registers. */
// ----------------
void Initialize() void Initialize()
{ {
if (g_EmulatedWiiMoteInitialized) return; if (g_EmulatedWiiMoteInitialized) return;
@ -476,14 +444,15 @@ void Initialize()
// Reset variables // Reset variables
ResetVariables(); ResetVariables();
// Write default Eeprom data to g_Eeprom[], this may be overwritten by WiiMoteReal::Initialize() // Write default Eeprom data to g_Eeprom[], this may be overwritten by
// after this function. // WiiMoteReal::Initialize() after this function.
memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE); memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE);
memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0)); memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0));
memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0)); memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0));
/* Populate joyinfo for all attached devices and do g_Config.Load() if the configuration window is /* Populate joyinfo for all attached devices and do g_Config.Load() if the
not already open, if it's already open we continue with the settings we have */ configuration window is not already open, if it's already open we
continue with the settings we have */
if(!g_FrameOpen) if(!g_FrameOpen)
{ {
Search_Devices(joyinfo, NumPads, NumGoodPads); Search_Devices(joyinfo, NumPads, NumGoodPads);
@ -498,15 +467,15 @@ void Initialize()
// Load pre-recorded movements // Load pre-recorded movements
LoadRecordedMovements(); LoadRecordedMovements();
/* The Nuncheck extension ID for homebrew applications that use the zero key. This writes 0x0000 /* The Nuncheck extension ID for homebrew applications that use the zero
in encrypted form (0xfefe) to 0xfe in the extension register. */ key. This writes 0x0000 in encrypted form (0xfefe) to 0xfe in the
extension register. */
//WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk //WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk
// I forgot what these were for? Is this the zero key encrypted 0xa420? // I forgot what these were for? Is this the zero key encrypted 0xa420?
// g_RegExt[0xfd] = 0x1e; // g_RegExt[0xfd] = 0x1e;
// g_RegExt[0xfc] = 0x9a; // g_RegExt[0xfc] = 0x9a;
} }
// ================
void DoState(void* ptr, int mode) void DoState(void* ptr, int mode)
@ -514,24 +483,24 @@ void DoState(void* ptr, int mode)
//TODO: implement //TODO: implement
} }
/* This is not needed if we call FreeLibrary() when we stop a game, but if it's not called we need to reset /* This is not needed if we call FreeLibrary() when we stop a game, but if it's
these variables. */ not called we need to reset these variables. */
void Shutdown(void) void Shutdown(void)
{ {
INFO_LOG(CONSOLE, "ShutDown\n"); INFO_LOG(CONSOLE, "ShutDown\n");
ResetVariables(); ResetVariables();
/* Close all devices carefully. We must check that we are not accessing any undefined /* Close all devices carefully. We must check that we are not accessing any
vector elements or any bad devices */ undefined vector elements or any bad devices */
for (int i = 0; i < 1; i++) for (int i = 0; i < 1; i++)
{ {
if (PadMapping[i].enabled && joyinfo.size() > (u32)PadMapping[i].ID) if (PadMapping[i].enabled && joyinfo.size() > (u32)PadMapping[i].ID)
if (joyinfo.at(PadMapping[i].ID).Good) if (joyinfo.at(PadMapping[i].ID).Good)
{ {
INFO_LOG(CONSOLE, "ShutDown: %i\n", PadState[i].joy); INFO_LOG(CONSOLE, "ShutDown: %i\n", PadState[i].joy);
/* SDL_JoystickClose() crashes for some reason so I avoid this for now, SDL_Quit() should /* SDL_JoystickClose() crashes for some reason so I avoid this
close the pads to I think */ for now, SDL_Quit() should close the pads to I think */
//if(SDL_JoystickOpened(PadMapping[i].ID)) SDL_JoystickClose(PadState[i].joy); //if(SDL_JoystickOpened(PadMapping[i].ID)) SDL_JoystickClose(PadState[i].joy);
//PadState[i].joy = NULL; //PadState[i].joy = NULL;
} }
@ -547,12 +516,11 @@ void Shutdown(void)
} }
// =================================================== /* An ack delay of 1 was not small enough, but 2 seemed to work, that was about
/* An ack delay of 1 was not small enough, but 2 seemed to work, that was about between 20 ms and between 20 ms and 100 ms in my case in Zelda - TP. You may have to increase
100 ms in my case in Zelda - TP. You may have to increase this value for other things to work, for this value for other things to work, for example in the wpad demo I had to
example in the wpad demo I had to set it to at least 3 for the Sound to be able to turned on (I have set it to at least 3 for the Sound to be able to turned on (I have an update
an update rate of around 150 fps in the wpad demo) */ rate of around 150 fps in the wpad demo) */
// ----------------
void CreateAckDelay(u8 _ChannelID, u16 _ReportID) void CreateAckDelay(u8 _ChannelID, u16 _ReportID)
{ {
// Settings // Settings
@ -586,23 +554,20 @@ void CheckAckDelay()
} }
} }
} }
// ================
// =================================================== /* This function produce Wiimote Input, i.e. reports from the Wiimote in
/* This function produce Wiimote Input, i.e. reports from the Wiimote in response response to Output from the Wii. */
to Output from the Wii. */
// ----------------
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
{ {
//INFO_LOG(CONSOLE, "Emu InterruptChannel\n"); //INFO_LOG(CONSOLE, "Emu InterruptChannel\n");
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
DEBUG_LOG(WII_IPC_WIIMOTE, "Wiimote_Input"); DEBUG_LOG(WII_IPC_WIIMOTE, "Wiimote_Input");
const u8* data = (const u8*)_pData; const u8* data = (const u8*)_pData;
/* Debugging. We have not yet decided how much of 'data' we will use, it's not determined /* Debugging. We have not yet decided how much of 'data' we will use, it's
by sizeof(data). We have to determine it by looking at the data cases. */ not determined by sizeof(data). We have to determine it by looking at
the data cases. */
InterruptDebugging(true, data); InterruptDebugging(true, data);
hid_packet* hidp = (hid_packet*) data; hid_packet* hidp = (hid_packet*) data;
@ -617,19 +582,23 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
wm_report* sr = (wm_report*)hidp->data; wm_report* sr = (wm_report*)hidp->data;
HidOutputReport(_channelID, sr); HidOutputReport(_channelID, sr);
/* This is the 0x22 answer to all Inputs. In most games it didn't matter /* This is the 0x22 answer to all Inputs. In most games it
if it was written before or after HidOutputReport(), but Wii Sports didn't matter if it was written before or after
and Mario Galaxy would stop working if it was placed before HidOutputReport(), but Wii Sports and Mario Galaxy would
HidOutputReport(). Zelda - TP is even more sensitive and require stop working if it was placed before
a delay after the Input for the Nunchuck to work. It seemed to be HidOutputReport(). Zelda - TP is even more sensitive and
enough to delay only the Nunchuck registry reads and writes but require a delay after the Input for the Nunchuck to
for now I'm delaying all inputs. Both for status changes and Eeprom work. It seemed to be enough to delay only the Nunchuck
and registry reads and writes. */ registry reads and writes but for now I'm delaying all
inputs. Both for status changes and Eeprom and registry
reads and writes. */
// There are no 0x22 replys to these report from the real wiimote from what I could see // There are no 0x22 replys to these report from the real
// Report 0x10 that seems to be only used for rumble, and we don't need to answer that, // wiimote from what I could see Report 0x10 that seems to
// also if we do *we should update the 0x22 to have the core keys* otherwise the game will // be only used for rumble, and we don't need to answer
// think we release the key every time it rumbles // that, also if we do *we should update the 0x22 to have
// the core keys* otherwise the game will think we release
// the key every time it rumbles
if(!(data[1] == WM_READ_DATA && data[2] == 0x00) if(!(data[1] == WM_READ_DATA && data[2] == 0x00)
&& !(data[1] == WM_REQUEST_STATUS) && !(data[1] == WM_REQUEST_STATUS)
&& !(data[1] == WM_WRITE_SPEAKER_DATA) && !(data[1] == WM_WRITE_SPEAKER_DATA)
@ -639,7 +608,6 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
break; break;
default: default:
ERROR_LOG(WII_IPC_WIIMOTE, "HidInput: HID_TYPE_DATA - param 0x%02x", hidp->type, hidp->param);
PanicAlert("HidInput: HID_TYPE_DATA - param 0x%02x", hidp->type, hidp->param); PanicAlert("HidInput: HID_TYPE_DATA - param 0x%02x", hidp->type, hidp->param);
break; break;
} }
@ -647,11 +615,9 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
break; break;
default: default:
ERROR_LOG(WII_IPC_WIIMOTE,"HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param);
PanicAlert("HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param); PanicAlert("HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param);
break; break;
} }
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
} }
@ -676,12 +642,10 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
case HID_TYPE_HANDSHAKE: case HID_TYPE_HANDSHAKE:
if (hidp->param == HID_PARAM_INPUT) if (hidp->param == HID_PARAM_INPUT)
{ {
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_HANDSHAKE - HID_PARAM_INPUT");
PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_INPUT"); PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_INPUT");
} }
else else
{ {
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT");
PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT"); PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT");
} }
break; break;
@ -689,7 +653,6 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
case HID_TYPE_SET_REPORT: case HID_TYPE_SET_REPORT:
if (hidp->param == HID_PARAM_INPUT) if (hidp->param == HID_PARAM_INPUT)
{ {
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_SET_REPORT input");
PanicAlert("HID_TYPE_SET_REPORT input"); PanicAlert("HID_TYPE_SET_REPORT input");
} }
else else
@ -703,12 +666,10 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
break; break;
case HID_TYPE_DATA: case HID_TYPE_DATA:
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_DATA %s", hidp->type, hidp->param == HID_PARAM_INPUT ? "input" : "output");
PanicAlert("HID_TYPE_DATA %s", hidp->type, hidp->param == HID_PARAM_INPUT ? "input" : "output"); PanicAlert("HID_TYPE_DATA %s", hidp->type, hidp->param == HID_PARAM_INPUT ? "input" : "output");
break; break;
default: default:
ERROR_LOG(WII_IPC_WIIMOTE, "HidControlChannel: Unknown type %x and param %x", hidp->type, hidp->param);
PanicAlert("HidControlChannel: Unknown type %x and param %x", hidp->type, hidp->param); PanicAlert("HidControlChannel: Unknown type %x and param %x", hidp->type, hidp->param);
break; break;
} }
@ -716,11 +677,10 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
} }
// =================================================== /* This is called from Wiimote_Update(). See SystemTimers.cpp for a
/* This is called from Wiimote_Update(). See SystemTimers.cpp for a documentation. I'm documentation. I'm not sure exactly how often this function is called but I
not sure exactly how often this function is called but I think it's tied to the frame think it's tied to the frame rate of the game rather than a certain amount
rate of the game rather than a certain amount of times per second. */ of times per second. */
// ----------------
void Update() void Update()
{ {
//LOG(WII_IPC_WIIMOTE, "Wiimote_Update"); //LOG(WII_IPC_WIIMOTE, "Wiimote_Update");

View File

@ -16,9 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <vector> #include <vector>
#include <string> #include <string>
@ -36,18 +33,14 @@
#include "EmuSubroutines.h" #include "EmuSubroutines.h"
#include "EmuMain.h" #include "EmuMain.h"
#include "Encryption.h" // for extension encryption #include "Encryption.h" // for extension encryption
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
#include "Config.h" // for g_Config #include "Config.h" // for g_Config
////////////////////////////////////
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;
namespace WiiMoteEmu namespace WiiMoteEmu
{ {
// ===================================================
// Fill joyinfo with the current connected devices // Fill joyinfo with the current connected devices
// ----------------
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads) bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
{ {
bool Success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads); bool Success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
@ -72,11 +65,8 @@ bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_N
return Success; return Success;
} }
// ===========================
//////////////////////////////////////////////////////////////////////////////////////////
// Return adjusted input values // Return adjusted input values
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr) 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 // This has to be changed if multiple Wiimotes are to be supported later
@ -126,16 +116,11 @@ void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr)
} }
} }
////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Request joystick state // Request joystick state
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ /* Called from: PAD_GetStatus() Input: The virtual device 0, 1, 2 or 3
/* Called from: PAD_GetStatus() Function: Updates the PadState struct with the current pad status. The input
Input: The virtual device 0, 1, 2 or 3 value "controller" is for a virtual controller 0 to 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) void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONTROLLER_MAPPING_NEW _PadMapping, int controller, int NumButtons)
{ {
@ -188,7 +173,6 @@ void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONT
_PadState.Axis.Lx, _PadState.Axis.Ly _PadState.Axis.Lx, _PadState.Axis.Ly
);*/ );*/
} }
////////////////////////////////////////////
} // end of namespace WiiMoteEmu } // end of namespace WiiMoteEmu

View File

@ -16,11 +16,7 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
// ===================================================
/* HID reports access guide. */ /* HID reports access guide. */
// ----------------
/* 0x10 - 0x1a Output EmuMain.cpp: HidOutputReport() /* 0x10 - 0x1a Output EmuMain.cpp: HidOutputReport()
0x10 - 0x14: General 0x10 - 0x14: General
@ -33,12 +29,6 @@
0x10 - 0x1a leads to a 0x22 Input report 0x10 - 0x1a leads to a 0x22 Input report
0x30 - 0x3f Input This file: Update() */ 0x30 - 0x3f Input This file: Update() */
// ================
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <vector> #include <vector>
#include <string> #include <string>
@ -48,9 +38,7 @@
#include "EmuMain.h" // Local #include "EmuMain.h" // Local
#include "EmuSubroutines.h" #include "EmuSubroutines.h"
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
#include "Config.h" // for g_Config #include "Config.h" // for g_Config
/////////////////////////////////
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;
@ -63,10 +51,10 @@ namespace WiiMoteEmu
//****************************************************************************** //******************************************************************************
// =================================================== /* Here we process the Output Reports that the Wii sends. Our response will be
/* Here we process the Output Reports that the Wii sends. Our response will be an Input Report an Input Report back to the Wii. Input and Output is from the Wii's
back to the Wii. Input and Output is from the Wii's perspective, Output means data to perspective, Output means data to the Wiimote (from the Wii), Input means
the Wiimote (from the Wii), Input means data from the Wiimote. data from the Wiimote.
The call browser: The call browser:
@ -75,10 +63,9 @@ namespace WiiMoteEmu
The IR lights and speaker enable/disable and mute/unmute values are The IR lights and speaker enable/disable and mute/unmute values are
0x2 = Disable 0x2 = Disable
0x6 = Enable */ 0x6 = Enable
// ---------------- */
void HidOutputReport(u16 _channelID, wm_report* sr) { void HidOutputReport(u16 _channelID, wm_report* sr) {
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
INFO_LOG(WII_IPC_WIIMOTE, "HidOutputReport (0x%02x)", sr->channel); INFO_LOG(WII_IPC_WIIMOTE, "HidOutputReport (0x%02x)", sr->channel);
std::string Temp; std::string Temp;
@ -102,8 +89,8 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmReadData(_channelID, (wm_read_data*)sr->data); if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmReadData(_channelID, (wm_read_data*)sr->data);
break; break;
/* This enables or disables the IR lights, we update the global variable g_IR /* This enables or disables the IR lights, we update the global variable
so that WmRequestStatus() knows about it */ g_IR so that WmRequestStatus() knows about it */
case WM_IR_PIXEL_CLOCK: // 0x13 case WM_IR_PIXEL_CLOCK: // 0x13
case WM_IR_LOGIC: // 0x1a case WM_IR_LOGIC: // 0x1a
WARN_LOG(WII_IPC_WIIMOTE, " IR Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]); WARN_LOG(WII_IPC_WIIMOTE, " IR Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
@ -132,18 +119,15 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
break; break;
default: default:
ERROR_LOG(WII_IPC_WIIMOTE, "HidOutputReport: Unknown channel 0x%02x", sr->channel);
PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->channel); PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->channel);
return; return;
} }
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
} }
// =================================================== /* Generate the right header for wm reports. The returned values is the length
/* Generate the right header for wm reports. The returned values is the length of the header before of the header before the data begins. It's always two for all reports 0x20 -
the data begins. It's always two for all reports 0x20 - 0x22, 0x30 - 0x37 */ 0x22, 0x30 - 0x37 */
// ----------------
int WriteWmReport(u8* dst, u8 channel) int WriteWmReport(u8* dst, u8 channel)
{ {
// Update the first byte to 0xa1 // Update the first byte to 0xa1
@ -161,26 +145,18 @@ int WriteWmReport(u8* dst, u8 channel)
} }
// ===================================================
/* LED (blue lights) report. */ /* LED (blue lights) report. */
// ----------------
void WmLeds(u16 _channelID, wm_leds* leds) { void WmLeds(u16 _channelID, wm_leds* leds) {
INFO_LOG(WII_IPC_WIIMOTE, "==========================================================="); INFO_LOG(WII_IPC_WIIMOTE, " Set LEDs Leds: %x Rumble: %x", leds->leds, leds->rumble);
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);
g_Leds = leds->leds; g_Leds = leds->leds;
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
} }
// ===================================================
/* This will generate the 0x22 acknowledgment after all Input reports. It will /* 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, have the form a1 22 00 00 _reportID 00. The first two bytes are the core
they are 00 00 when nothing is pressed. The last byte is the success code 00. */ 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) void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
{ {
u8 DataFrame[1024]; u8 DataFrame[1024];
@ -220,26 +196,22 @@ void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
} }
// ===================================================
/* Read data from Wiimote and Extensions registers. */ /* Read data from Wiimote and Extensions registers. */
// ----------------
void WmReadData(u16 _channelID, wm_read_data* rd) void WmReadData(u16 _channelID, wm_read_data* rd)
{ {
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
u32 address = convert24bit(rd->address); u32 address = convert24bit(rd->address);
u16 size = convert16bit(rd->size); u16 size = convert16bit(rd->size);
std::string Temp; std::string Temp;
INFO_LOG(WII_IPC_WIIMOTE, "Read data"); INFO_LOG(WII_IPC_WIIMOTE, "Read data Address space: %x", rd->space);
INFO_LOG(WII_IPC_WIIMOTE, " Address space: %x", rd->space); INFO_LOG(WII_IPC_WIIMOTE, "Read data Address: 0x%06x", address);
INFO_LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address); INFO_LOG(WII_IPC_WIIMOTE, "Read data Size: 0x%04x", size);
INFO_LOG(WII_IPC_WIIMOTE, " Size: 0x%04x", size); INFO_LOG(WII_IPC_WIIMOTE, "Read data Rumble: %x", rd->rumble);
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", rd->rumble);
//u32 _address = address; //u32 _address = address;
std::string Tmp; // Debugging std::string Tmp; // Debugging
/* Now we determine what address space we are reading from. Space 0 is Eeprom and /* Now we determine what address space we are reading from. Space 0 is
space 1 and 2 is the registers. */ Eeprom and space 1 and 2 is the registers. */
if(rd->space == WM_SPACE_EEPROM) if(rd->space == WM_SPACE_EEPROM)
{ {
if (address + size > WIIMOTE_EEPROM_SIZE) if (address + size > WIIMOTE_EEPROM_SIZE)
@ -286,14 +258,11 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
break; break;
default: default:
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: bad register block!"); ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: bad register block!");
PanicAlert("WmWriteData: bad register block!");
return; return;
} }
// -----------------------------------------
// Encrypt data that is read from the Wiimote Extension Register // Encrypt data that is read from the Wiimote Extension Register
// -------------
if(((address >> 16) & 0xfe) == 0xa4) if(((address >> 16) & 0xfe) == 0xa4)
{ {
/* Debugging /* Debugging
@ -338,24 +307,21 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
PanicAlert("WmReadData: unimplemented parameters (size: %i, addr: 0x%x!", size, rd->space); 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 /* Here we produce the actual 0x21 Input report that we send to the Wii. The
is divided into 16 bytes pieces and sent piece by piece. There will be five formatting message is divided into 16 bytes pieces and sent piece by piece. There will
bytes at the begging of all reports. A common format is 00 00 f0 00 20, the 00 00 be five formatting bytes at the begging of all reports. A common format is
means that no buttons are pressed, the f means 16 bytes in the message, the 0 00 00 f0 00 20, the 00 00 means that no buttons are pressed, the f means 16
means no error, the 00 20 means that the message is at the 00 20 offest in the bytes in the message, the 0 means no error, the 00 20 means that the message
registry that was read. is at the 00 20 offest in the registry that was read.
_Base: The data beginning at _Base[0] _Base: The data beginning at _Base[0] _Address: The starting address inside
_Address: The starting address inside the registry, this is used to check for out of bounds reading the registry, this is used to check for out of bounds reading _Size: The
_Size: The total size to send total size to send
*/ */
// ----------------
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size) void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
{ {
INFO_LOG(WII_IPC_WIIMOTE, "=========================================");
int dataOffset = 0; int dataOffset = 0;
const u8* data = (const u8*)_Base; const u8* data = (const u8*)_Base;
@ -389,10 +355,11 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
// Update DataOffset for the next loop // Update DataOffset for the next loop
dataOffset += copySize; dataOffset += copySize;
/* Out of bounds. The real Wiimote generate an error for the first request to 0x1770 /* Out of bounds. The real Wiimote generate an error for the first
if we dont't replicate that the game will never read the capibration data at the request to 0x1770 if we dont't replicate that the game will never
beginning of Eeprom. I think this error is supposed to occur when we try to read above read the capibration data at the beginning of Eeprom. I think this
the freely usable space that ends at 0x16ff. */ 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) if (Common::swap16(pReply->address + pReply->size) > WIIMOTE_EEPROM_FREE_SIZE)
{ {
pReply->size = 0x0f; pReply->size = 0x0f;
@ -424,20 +391,14 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
} }
if (_Size != 0) { if (_Size != 0) {
ERROR_LOG(WII_IPC_WIIMOTE, "WiiMote-Plugin: SendReadDataReply() failed");
PanicAlert("WiiMote-Plugin: SendReadDataReply() failed"); PanicAlert("WiiMote-Plugin: SendReadDataReply() failed");
} }
INFO_LOG(WII_IPC_WIIMOTE, "==========================================");
} }
// ================
// ===================================================
/* Write data to Wiimote and Extensions registers. */ /* Write data to Wiimote and Extensions registers. */
// ----------------
void WmWriteData(u16 _channelID, wm_write_data* wd) void WmWriteData(u16 _channelID, wm_write_data* wd)
{ {
INFO_LOG(WII_IPC_WIIMOTE, "========================================================");
u32 address = convert24bit(wd->address); u32 address = convert24bit(wd->address);
INFO_LOG(WII_IPC_WIIMOTE, "Write data"); INFO_LOG(WII_IPC_WIIMOTE, "Write data");
DEBUG_LOG(WII_IPC_WIIMOTE, " Address space: %x", wd->space); DEBUG_LOG(WII_IPC_WIIMOTE, " Address space: %x", wd->space);
@ -477,9 +438,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
case 0xA4: case 0xA4:
block = g_RegExt; // Extension Controller register block = g_RegExt; // Extension Controller register
blockSize = WIIMOTE_REG_EXT_SIZE; blockSize = WIIMOTE_REG_EXT_SIZE;
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
INFO_LOG(WII_IPC_WIIMOTE, " Case 0xa4: ExtReg"); 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", /*INFO_LOG(CONSOLE, "Write RegExt Size: %i Address: %08x Offset: %08x \n",
wd->size, address, (address & 0xffff)); wd->size, address, (address & 0xffff));
INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str());*/ INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str());*/
@ -503,7 +462,6 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
// Check if the address is within bounds // Check if the address is within bounds
if(address + wd->size > blockSize) { if(address + wd->size > blockSize) {
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: address + size out of bounds!");
PanicAlert("WmWriteData: address + size out of bounds!"); PanicAlert("WmWriteData: address + size out of bounds!");
return; return;
} }
@ -512,9 +470,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
memcpy(block + address, wd->data, wd->size); memcpy(block + address, wd->data, wd->size);
// -----------------------------------------
// Generate key for the Wiimote Extension // Generate key for the Wiimote Extension
// -------------
if(blockSize == WIIMOTE_REG_EXT_SIZE) if(blockSize == WIIMOTE_REG_EXT_SIZE)
{ {
/* Debugging. Write the data. /* Debugging. Write the data.
@ -531,29 +487,23 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
} else { } else {
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: unimplemented parameters!");
PanicAlert("WmWriteData: unimplemented parameters!"); PanicAlert("WmWriteData: unimplemented parameters!");
} }
/* Just added for home brew... Isn't it enough that we call this from /* 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()? Or is there a separate route here that don't pass
InterruptChannel()? */ though InterruptChannel()? */
//WmSendAck(_channelID, WM_WRITE_DATA, _address); //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
/* Here we produce a 0x20 status report to send to the Wii. We currently ignore the status the status request rs and all its eventual instructions it may include (for
request rs and all its eventual instructions it may include (for example turn off example turn off rumble or something else) and just send the status
rumble or something else) and just send the status report. */ report. */
// ----------------
void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension) void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
{ {
//PanicAlert("WmRequestStatus"); INFO_LOG(WII_IPC_WIIMOTE, " Request Status: Rumble: %x Channel: %04x",
INFO_LOG(WII_IPC_WIIMOTE, "================================================"); rs->rumble, _channelID);
INFO_LOG(WII_IPC_WIIMOTE, " Request Status");
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", rs->rumble);
INFO_LOG(WII_IPC_WIIMOTE, " Channel: %04x", _channelID);
//SendStatusReport(); //SendStatusReport();
u8 DataFrame[1024]; u8 DataFrame[1024];
@ -593,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, " Extension: %x", pStatus->extension);
INFO_LOG(WII_IPC_WIIMOTE, " SendStatusReport()"); INFO_LOG(WII_IPC_WIIMOTE, " SendStatusReport() Flags: 0x%02x Battery: %d"
DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%02x", pStatus->padding1[2]); pStatus->padding1[2], pStatus->battery);
DEBUG_LOG(WII_IPC_WIIMOTE, " Battery: %d", pStatus->battery);
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
INFO_LOG(WII_IPC_WIIMOTE, "=================================================");
// Debugging // Debugging
ReadDebugging(true, DataFrame, Offset); ReadDebugging(true, DataFrame, Offset);

View File

@ -16,9 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Include
// ¯¯¯¯¯¯¯¯¯
#ifndef _EMU_SUBFUNCTIONS_ #ifndef _EMU_SUBFUNCTIONS_
#define _EMU_SUBFUNCTIONS_ #define _EMU_SUBFUNCTIONS_
@ -32,13 +29,8 @@
#include "wiimote_hid.h" // Local #include "wiimote_hid.h" // Local
#include "EmuDefinitions.h" #include "EmuDefinitions.h"
#include "Encryption.h" #include "Encryption.h"
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Declarations and definitions // Declarations and definitions
// ¯¯¯¯¯¯¯¯¯
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;

View File

@ -19,7 +19,6 @@
#include "pluginspecs_wiimote.h" #include "pluginspecs_wiimote.h"
#include "Common.h" #include "Common.h"
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
#include "Encryption.h" #include "Encryption.h"
@ -247,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 */ /* Generate key from the 0x40-0x4c data in g_RegExt */
// ----------------
void wiimote_gen_key(wiimote_key *key, u8 *keydata) void wiimote_gen_key(wiimote_key *key, u8 *keydata)
{ {
u8 rand[10]; u8 rand[10];
@ -283,9 +280,7 @@ void wiimote_gen_key(wiimote_key *key, u8 *keydata)
} }
// ===================================================
/* Encrypt data */ /* Encrypt data */
// ----------------
void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len) void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
{ {
for(int i = 0; i < len; i++, addr++) for(int i = 0; i < len; i++, addr++)
@ -293,11 +288,9 @@ void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
} }
// ===================================================
/* Decrypt data */ /* Decrypt data */
// ----------------
void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len) void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len)
{ {
for(int i = 0; i < len; i++, addr++) for(int i = 0; i < len; i++, addr++)
data[i] = (data[i] ^ key->sb[addr%8]) + key->ft[addr%8]; data[i] = (data[i] ^ key->sb[addr%8]) + key->ft[addr%8];
} }

View File

@ -16,9 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <vector> #include <vector>
@ -33,9 +30,7 @@
#include "EmuMain.h" #include "EmuMain.h"
#include "EmuSubroutines.h" #include "EmuSubroutines.h"
#include "EmuDefinitions.h" #include "EmuDefinitions.h"
#include "Logging.h" // For startConsoleWin, Console::Print, GetConsoleHwnd
#include "Config.h" // For g_Config #include "Config.h" // For g_Config
//////////////////////////////////
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;
@ -43,24 +38,19 @@ namespace WiiMoteEmu
{ {
//************************************************************************************** //****************************************************************************
// Recorded movements // Recorded movements
//************************************************************************************** //****************************************************************************
// ------------------------------------------
// Variables: 0 = Wiimote, 1 = Nunchuck // Variables: 0 = Wiimote, 1 = Nunchuck
// ----------------
int g_RecordingPlaying[3]; //g_RecordingPlaying[0] = -1; g_RecordingPlaying[1] = -1; int g_RecordingPlaying[3]; //g_RecordingPlaying[0] = -1; g_RecordingPlaying[1] = -1;
int g_RecordingCounter[3]; //g_RecordingCounter[0] = 0; g_RecordingCounter[1] = 0; int g_RecordingCounter[3]; //g_RecordingCounter[0] = 0; g_RecordingCounter[1] = 0;
int g_RecordingPoint[3]; //g_RecordingPoint[0] = 0; g_RecordingPoint[1] = 0; int g_RecordingPoint[3]; //g_RecordingPoint[0] = 0; g_RecordingPoint[1] = 0;
double g_RecordingStart[3]; //g_RecordingStart[0] = 0; g_RecordingStart[1] = 0; double g_RecordingStart[3]; //g_RecordingStart[0] = 0; g_RecordingStart[1] = 0;
double g_RecordingCurrentTime[3]; //g_RecordingCurrentTime[0] = 0; g_RecordingCurrentTime[1] = 0; double g_RecordingCurrentTime[3]; //g_RecordingCurrentTime[0] = 0; g_RecordingCurrentTime[1] = 0;
// --------------------------
/////////////////////////////////////////////////////////////////////////
/* Convert from -350 to -3.5 g. The Nunchuck gravity size is 51 compared to the 26 to 28 for the Wiimote. /* Convert from -350 to -3.5 g. The Nunchuck gravity size is 51 compared to the 26 to 28 for the Wiimote.
So the maximum g values are higher for the Wiimote. */ So the maximum g values are higher for the Wiimote. */
// ---------------
int G2Accelerometer(int _G, int XYZ, int Wm) int G2Accelerometer(int _G, int XYZ, int Wm)
{ {
float G = (float)_G / 100.0; float G = (float)_G / 100.0;
@ -384,12 +374,9 @@ int IsKey(int Key)
return false; return false;
#endif #endif
} }
//////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// Wiimote core buttons // Wiimote core buttons
// ---------------
void FillReportInfo(wm_core& _core) void FillReportInfo(wm_core& _core)
{ {
/* This has to be filled with zeroes (and not for example 0xff) because when no buttons are pressed the /* This has to be filled with zeroes (and not for example 0xff) because when no buttons are pressed the
@ -431,24 +418,20 @@ void FillReportInfo(wm_core& _core)
_core.down = IsKey(g_Wm.D) ? 1 : 0; _core.down = IsKey(g_Wm.D) ? 1 : 0;
} }
} }
//////////////////////////
///////////////////////////////////////////////////////////////////
// Wiimote accelerometer // Wiimote accelerometer
// --------------- /* The accelerometer x, y and z values range from 0x00 to 0xff with the default
/* The accelerometer x, y and z values range from 0x00 to 0xff with the default netural values netural values being [y = 0x84, x = 0x84, z = 0x9f] according to a
being [y = 0x84, x = 0x84, z = 0x9f] according to a source. The extremes are 0x00 for (-) source. The extremes are 0x00 for (-) and 0xff for (+). It's important that
and 0xff for (+). It's important that all values are not 0x80, the mouse pointer can disappear all values are not 0x80, the mouse pointer can disappear from the screen
from the screen permanently then, until z is adjusted back. This is because the game detects permanently then, until z is adjusted back. This is because the game detects
a steep pitch of the Wiimote then. */ a steep pitch of the Wiimote then. */
// ---------- // Global declarations for FillReportAcc: These variables are global so they
// Global declarations for FillReportAcc: These variables are global so they can be changed during debugging //can be changed during debugging int A = 0, B = 128, C = 64; // for debugging
//int A = 0, B = 128, C = 64; // for debugging //int a = 1, b = 1, c = 2, d = -2; // for debugging int consoleDisplay = 0;
//int a = 1, b = 1, c = 2, d = -2; // for debugging
//int consoleDisplay = 0;
// For all functions // For all functions
u8 g_x, g_y, g_z, g_X, g_Y, g_Z; u8 g_x, g_y, g_z, g_X, g_Y, g_Z;
@ -460,9 +443,7 @@ int Shake[] = {-1, -1};
std::vector<u8> yhist(15, 0); float KbDegree; std::vector<u8> yhist(15, 0); float KbDegree;
// ------------------------------------------
// Single shake of Wiimote while holding it sideways (Wario Land pound ground) // Single shake of Wiimote while holding it sideways (Wario Land pound ground)
// ---------------
void SingleShake(u8 &_y, u8 &_z, int i) void SingleShake(u8 &_y, u8 &_z, int i)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -489,11 +470,9 @@ void SingleShake(u8 &_y, u8 &_z, int i)
} }
// ------------------------------------------ /* Tilting Wiimote with gamepad. We can guess that the game will calculate a
/* Tilting Wiimote with gamepad. We can guess that the game will calculate a Wiimote pitch and use it as a Wiimote pitch and use it as a measure of the tilting of the Wiimote. We are
measure of the tilting of the Wiimote. We are interested in this tilting range interested in this tilting range 90° to -90° */
90° to -90° */
// ---------------
void TiltWiimoteGamepad(float &Roll, float &Pitch) void TiltWiimoteGamepad(float &Roll, float &Pitch)
{ {
// Return if we have no pads // Return if we have no pads
@ -502,10 +481,12 @@ void TiltWiimoteGamepad(float &Roll, float &Pitch)
// This has to be changed if multiple Wiimotes are to be supported later // This has to be changed if multiple Wiimotes are to be supported later
const int Page = 0; const int Page = 0;
/* Adjust the pad state values, including a downscaling from the original 0x8000 size values /* Adjust the pad state values, including a downscaling from the original
to 0x80. The only reason we do this is that the code below crrently assume that the range 0x8000 size values to 0x80. The only reason we do this is that the code
is 0 to 255 for all axes. If we lose any precision by doing this we could consider not below crrently assume that the range is 0 to 255 for all axes. If we
doing this adjustment. And instead for example upsize the XInput trigger from 0x80 to 0x8000. */ lose any precision by doing this we could consider not doing this
adjustment. And instead for example upsize the XInput trigger from 0x80
to 0x8000. */
int _Lx, _Ly, _Rx, _Ry, _Tl, _Tr; int _Lx, _Ly, _Rx, _Ry, _Tl, _Tr;
PadStateAdjustments(_Lx, _Ly, _Rx, _Ry, _Tl, _Tr); PadStateAdjustments(_Lx, _Ly, _Rx, _Ry, _Tl, _Tr);
float Lx = (float)_Lx; float Lx = (float)_Lx;
@ -532,8 +513,9 @@ void TiltWiimoteGamepad(float &Roll, float &Pitch)
- Tr * (PitchRange / 128.0); - Tr * (PitchRange / 128.0);
} }
/* For the analog stick roll us by default set to the X-axis, pitch is by default set to the Y-axis. /* For the analog stick roll us by default set to the X-axis, pitch is by
By changing the axis mapping and the invert options this can be altered in any way */ default set to the Y-axis. By changing the axis mapping and the invert
options this can be altered in any way */
else if (g_Config.Trigger.Type == g_Config.Trigger.ANALOG1) else if (g_Config.Trigger.Type == g_Config.Trigger.ANALOG1)
{ {
// Adjust the trigger to go between negative and positive values // Adjust the trigger to go between negative and positive values
@ -566,9 +548,7 @@ void TiltWiimoteGamepad(float &Roll, float &Pitch)
} }
// ------------------------------------------
// Tilting Wiimote with keyboard // Tilting Wiimote with keyboard
// ---------------
void TiltWiimoteKeyboard(float &Roll, float &Pitch) void TiltWiimoteKeyboard(float &Roll, float &Pitch)
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -585,9 +565,7 @@ void TiltWiimoteKeyboard(float &Roll, float &Pitch)
KbDegree -= 3; // aim right KbDegree -= 3; // aim right
} }
// -----------------------------------
// Check for inactivity in the tilting, the Y value will be reset after ten inactive updates // Check for inactivity in the tilting, the Y value will be reset after ten inactive updates
// ----------
// Check for activity // Check for activity
yhist[yhist.size() - 1] = ( yhist[yhist.size() - 1] = (
IsKey(g_Wm.PITCH_L) IsKey(g_Wm.PITCH_L)
@ -611,13 +589,10 @@ void TiltWiimoteKeyboard(float &Roll, float &Pitch)
Pitch = KbDegree; Pitch = KbDegree;
//INFO_LOG(CONSOLE, "Degree: %2.1f\n", KbDegree); //INFO_LOG(CONSOLE, "Degree: %2.1f\n", KbDegree);
} }
// --------------------
#endif #endif
} }
// ------------------------------------------
// Tilting Wiimote (Wario Land aiming, Mario Kart steering and other things) // Tilting Wiimote (Wario Land aiming, Mario Kart steering and other things)
// ---------------
void Tilt(u8 &_x, u8 &_y, u8 &_z) void Tilt(u8 &_x, u8 &_y, u8 &_z)
{ {
// Ceck if it's on // Ceck if it's on
@ -641,7 +616,6 @@ void Tilt(u8 &_x, u8 &_y, u8 &_z)
if (g_DebugData) if (g_DebugData)
{ {
//Console::ClearScreen();
/*INFO_LOG(CONSOLE, "L:%2.1f R:%2.1f Lx:%2.1f Range:%2.1f Degree:%2.1f L:%i R:%i\n", /*INFO_LOG(CONSOLE, "L:%2.1f R:%2.1f Lx:%2.1f Range:%2.1f Degree:%2.1f L:%i R:%i\n",
Tl, Tr, Lx, Range, Degree, PadState[Page].Axis.Tl, PadState[Page].Axis.Tr);*/ Tl, Tr, Lx, Range, Degree, PadState[Page].Axis.Tl, PadState[Page].Axis.Tr);*/
/*INFO_LOG(CONSOLE, "Roll:%2.1f Pitch:%2.1f\n", Roll, Pitch);*/ /*INFO_LOG(CONSOLE, "Roll:%2.1f Pitch:%2.1f\n", Roll, Pitch);*/
@ -650,9 +624,7 @@ void Tilt(u8 &_x, u8 &_y, u8 &_z)
void FillReportAcc(wm_accel& _acc) void FillReportAcc(wm_accel& _acc)
{ {
// ------------------------------------
// Recorded movements // Recorded movements
// --------------
// Check for a playback command // Check for a playback command
if(g_RecordingPlaying[0] < 0) if(g_RecordingPlaying[0] < 0)
{ {
@ -664,7 +636,6 @@ void FillReportAcc(wm_accel& _acc)
if (RecordingPlay(_acc.x, _acc.y, _acc.z, 0)) return; if (RecordingPlay(_acc.x, _acc.y, _acc.z, 0)) return;
//INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); //INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z);
} }
// ---------------------
// The default values can change so we need to update them all the time // The default values can change so we need to update them all the time
g_X = g_wm.cal_zero.x; g_X = g_wm.cal_zero.x;
@ -681,9 +652,7 @@ void FillReportAcc(wm_accel& _acc)
return; return;
} }
// ------------------------------------------------
// Wiimote to Gamepad translations // Wiimote to Gamepad translations
// ------------
// The following functions may or may not update these values // The following functions may or may not update these values
g_x = g_X; g_x = g_X;
@ -702,9 +671,7 @@ void FillReportAcc(wm_accel& _acc)
_acc.z = g_z; _acc.z = g_z;
// ----------------------------
// Debugging for translating Wiimote to Keyboard (or Gamepad) // Debugging for translating Wiimote to Keyboard (or Gamepad)
// ----------
/* /*
// Toogle console display // Toogle console display
@ -779,7 +746,6 @@ void FillReportAcc(wm_accel& _acc)
AX, AY, AZ AX, AY, AZ
);*/ );*/
} }
/////////////////////////
@ -789,14 +755,10 @@ void FillReportAcc(wm_accel& _acc)
Bottom = BOTTOM, SensorBarRadius = SENSOR_BAR_RADIUS; Bottom = BOTTOM, SensorBarRadius = SENSOR_BAR_RADIUS;
*/ */
///////////////////////////////////////////////////////////////////
// The extended 12 byte (3 byte per object) reporting // The extended 12 byte (3 byte per object) reporting
// ---------------
void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1) void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
{ {
// ------------------------------------
// Recorded movements // Recorded movements
// --------------
// Check for a playback command // Check for a playback command
if(g_RecordingPlaying[2] < 0) if(g_RecordingPlaying[2] < 0)
{ {
@ -807,10 +769,10 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
//INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); //INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z);
if (RecordingPlayIR(_ir0)) return; if (RecordingPlayIR(_ir0)) return;
} }
// ---------------------
/* Fill with 0xff if empty. The real Wiimote seems to use 0xff when it doesn't see a certain point, /* Fill with 0xff if empty. The real Wiimote seems to use 0xff when it
at least from how WiiMoteReal::SendEvent() works. */ doesn't see a certain point, at least from how WiiMoteReal::SendEvent()
works. */
memset(&_ir0, 0xff, sizeof(wm_ir_extended)); memset(&_ir0, 0xff, sizeof(wm_ir_extended));
memset(&_ir1, 0xff, sizeof(wm_ir_extended)); memset(&_ir1, 0xff, sizeof(wm_ir_extended));
@ -820,19 +782,13 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
// If we are outside the screen leave the values at 0xff // If we are outside the screen leave the values at 0xff
if(MouseX > 1 || MouseX < 0 || MouseY > 1 || MouseY < 0) return; if(MouseX > 1 || MouseX < 0 || MouseY > 1 || MouseY < 0) return;
// --------------------------------------
// Position calculation // Position calculation
// ----------
int y0 = g_Config.iIRTop + (MouseY * g_Config.iIRHeight); int y0 = g_Config.iIRTop + (MouseY * g_Config.iIRHeight);
int y1 = y0; int y1 = y0;
// The distance between the x positions are two sensor bar radii // The distance between the x positions are two sensor bar radii
int x0 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) - SENSOR_BAR_RADIUS; int x0 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) - SENSOR_BAR_RADIUS;
int x1 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) + SENSOR_BAR_RADIUS; int x1 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) + SENSOR_BAR_RADIUS;
// ------------------
// ----------------------------
// Debugging for calibration // Debugging for calibration
// ----------
/* /*
if(!GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_RIGHT)) if(!GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_RIGHT))
Right +=1; Right +=1;
@ -860,12 +816,9 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
INFO_LOG(CONSOLE, "x0:%03i x1:%03i y0:%03i y1:%03i | T:%i L:%i R:%i B:%i S:%i\n", INFO_LOG(CONSOLE, "x0:%03i x1:%03i y0:%03i y1:%03i | T:%i L:%i R:%i B:%i S:%i\n",
x0, x1, y0, y1, Top, Left, Right, Bottom, SensorBarRadius x0, x1, y0, y1, Top, Left, Right, Bottom, SensorBarRadius
);*/ );*/
// ------------------
// --------------------------------------
// Converted to IR data // Converted to IR data
// ----------
// The width is 0 to 1023 // The width is 0 to 1023
// The height is 0 to 767 // The height is 0 to 767
x0 = 1023 - x0; x0 = 1023 - x0;
@ -878,18 +831,13 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
_ir1.x = x1 & 0xff; _ir1.xHi = x1 >> 8; _ir1.x = x1 & 0xff; _ir1.xHi = x1 >> 8;
_ir1.y = y1 & 0xff; _ir1.yHi = y1 >> 8; _ir1.y = y1 & 0xff; _ir1.yHi = y1 >> 8;
_ir1.size = 10; _ir1.size = 10;
// ------------------
} }
///////////////////////////////////////////////////////////////////
// The 10 byte reporting used when an extension is connected // The 10 byte reporting used when an extension is connected
// ---------------
void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1) void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
{ {
// ------------------------------------
// Recorded movements // Recorded movements
// --------------
// Check for a playback command // Check for a playback command
if(g_RecordingPlaying[2] < 0) if(g_RecordingPlaying[2] < 0)
{ {
@ -901,7 +849,6 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
//INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z); //INFO_LOG(CONSOLE, "X, Y, Z: %u %u %u\n", _acc.x, _acc.y, _acc.z);
if (RecordingPlayIR(_ir0)) return; if (RecordingPlayIR(_ir0)) return;
} }
// ---------------------
// Fill with 0xff if empty // Fill with 0xff if empty
memset(&_ir0, 0xff, sizeof(wm_ir_basic)); memset(&_ir0, 0xff, sizeof(wm_ir_basic));
@ -919,8 +866,9 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
int x1 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) - SENSOR_BAR_RADIUS; int x1 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) - SENSOR_BAR_RADIUS;
int x2 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) + SENSOR_BAR_RADIUS; int x2 = g_Config.iIRLeft + (MouseX * g_Config.iIRWidth) + SENSOR_BAR_RADIUS;
/* As with the extented report we settle with emulating two out of four possible objects /* As with the extented report we settle with emulating two out of four
the only difference is that we don't report any size of the tracked object here */ possible objects the only difference is that we don't report any size of
the tracked object here */
x1 = 1023 - x1; x1 = 1023 - x1;
_ir0.x1 = x1 & 0xff; _ir0.x1Hi = (x1 >> 8); // we are dealing with 2 bit values here _ir0.x1 = x1 & 0xff; _ir0.x1Hi = (x1 >> 8); // we are dealing with 2 bit values here
_ir0.y1 = y1 & 0xff; _ir0.y1Hi = (y1 >> 8); _ir0.y1 = y1 & 0xff; _ir0.y1Hi = (y1 >> 8);
@ -930,9 +878,7 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
_ir0.y2 = y2 & 0xff; _ir0.y2Hi = (y2 >> 8); _ir0.y2 = y2 & 0xff; _ir0.y2Hi = (y2 >> 8);
// ------------------------------------
// Debugging for calibration // Debugging for calibration
// ----------
/* /*
if(GetAsyncKeyState(VK_NUMPAD1)) if(GetAsyncKeyState(VK_NUMPAD1))
Right +=1; Right +=1;
@ -972,19 +918,16 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
} }
//************************************************************************************** //*****************************************************************************
// Extensions // Extensions
//************************************************************************************** //*****************************************************************************
// =================================================== /* Generate the 6 byte extension report for the Nunchuck, encrypted. The bytes
/* Generate the 6 byte extension report for the Nunchuck, encrypted. The bytes are JX JY AX AY AZ BT. */ are JX JY AX AY AZ BT. */
// ----------------
void FillReportExtension(wm_extension& _ext) void FillReportExtension(wm_extension& _ext)
{ {
// ------------------------------------------
// Recorded movements // Recorded movements
// --------------
// Check for a playback command // Check for a playback command
if(g_RecordingPlaying[1] < 0) g_RecordingPlaying[1] = RecordingCheckKeys(1); if(g_RecordingPlaying[1] < 0) g_RecordingPlaying[1] = RecordingCheckKeys(1);
@ -996,18 +939,14 @@ void FillReportExtension(wm_extension& _ext)
_ext.ay = g_nu.cal_zero.y; _ext.ay = g_nu.cal_zero.y;
_ext.az = g_nu.cal_zero.z + g_nu.cal_g.z; _ext.az = g_nu.cal_zero.z + g_nu.cal_g.z;
} }
// ---------------------
// Shake the Wiimote // Shake the Wiimote
SingleShake(_ext.ay, _ext.az, 1); SingleShake(_ext.ay, _ext.az, 1);
// ------------------------------------
// The default joystick and button values unless we use them // The default joystick and button values unless we use them
// --------------
_ext.jx = g_nu.jx.center; _ext.jx = g_nu.jx.center;
_ext.jy = g_nu.jy.center; _ext.jy = g_nu.jy.center;
_ext.bt = 0x03; // 0x03 means no button pressed, the button is zero active _ext.bt = 0x03; // 0x03 means no button pressed, the button is zero active
// ---------------------
// Update the analog stick // Update the analog stick
if (g_Config.Nunchuck.Type == g_Config.Nunchuck.KEYBOARD) if (g_Config.Nunchuck.Type == g_Config.Nunchuck.KEYBOARD)
@ -1032,9 +971,10 @@ void FillReportExtension(wm_extension& _ext)
_Ly = 0xff - _Ly; _Ly = 0xff - _Ly;
_Ry = 0xff - _Ry; _Ry = 0xff - _Ry;
/* This is if we are also using a real Nunchuck that we are sharing the calibration with. It's not /* This is if we are also using a real Nunchuck that we are sharing the
needed if we are using our default values. We adjust the values to the configured range, we even calibration with. It's not needed if we are using our default
allow the center to not be 0x80. */ values. We adjust the values to the configured range, we even allow
the center to not be 0x80. */
if(g_nu.jx.max != 0xff || g_nu.jy.max != 0xff if(g_nu.jx.max != 0xff || g_nu.jy.max != 0xff
|| g_nu.jx.min != 0 || g_nu.jy.min != 0 || g_nu.jx.min != 0 || g_nu.jy.min != 0
|| g_nu.jx.center != 0x80 || g_nu.jy.center != 0x80) || g_nu.jx.center != 0x80 || g_nu.jy.center != 0x80)
@ -1043,8 +983,8 @@ void FillReportExtension(wm_extension& _ext)
float Ly = (float)_Ly; float Ly = (float)_Ly;
float Rx = (float)_Rx; float Rx = (float)_Rx;
float Ry = (float)_Ry; float Ry = (float)_Ry;
float Tl = (float)_Tl; // float Tl = (float)_Tl;
float Tr = (float)_Tr; // float Tr = (float)_Tr;
float XRangePos = (float) (g_nu.jx.max - g_nu.jx.center); float XRangePos = (float) (g_nu.jx.max - g_nu.jx.center);
float XRangeNeg = (float) (g_nu.jx.center - g_nu.jx.min); float XRangeNeg = (float) (g_nu.jx.center - g_nu.jx.min);
@ -1099,13 +1039,10 @@ void FillReportExtension(wm_extension& _ext)
// Write it back to the struct // Write it back to the struct
memcpy(&_ext, Tmp, sizeof(_ext)); memcpy(&_ext, Tmp, sizeof(_ext));
} }
// =======================
// ===================================================
/* Generate the 6 byte extension report for the Classic Controller, encrypted. /* Generate the 6 byte extension report for the Classic Controller, encrypted.
The bytes are ... */ The bytes are ... */
// ----------------
void FillReportClassicExtension(wm_classic_extension& _ext) void FillReportClassicExtension(wm_classic_extension& _ext)
{ {
/* These are the default neutral values for the analog triggers and sticks */ /* These are the default neutral values for the analog triggers and sticks */
@ -1131,11 +1068,9 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
_ext.b2.bB = 0x01; _ext.b2.bB = 0x01;
_ext.b2.bZL = 0x01; _ext.b2.bZL = 0x01;
// --------------------------------------
// Check that Dolphin is in focus // Check that Dolphin is in focus
if (IsFocus()) if (IsFocus())
{ {
// --------------------------------------
/* Left and right analog sticks and analog triggers /* Left and right analog sticks and analog triggers
u8 Lx : 6; // byte 0 u8 Lx : 6; // byte 0
@ -1175,10 +1110,13 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
_Ly = 0xff - _Ly; _Ly = 0xff - _Ly;
_Ry = 0xff - _Ry; _Ry = 0xff - _Ry;
/* This is if we are also using a real Classic Controller that we are sharing the calibration with. /* This is if we are also using a real Classic Controller that we
It's not needed if we are using our default values. We adjust the values to the configured range. are sharing the calibration with. It's not needed if we are
using our default values. We adjust the values to the configured
range.
Status: Not added, we are not currently sharing the calibration with the real Classic Controller Status: Not added, we are not currently sharing the calibration
with the real Classic Controller
*/ */
if (g_Config.ClassicController.LType == g_Config.ClassicController.ANALOG1) if (g_Config.ClassicController.LType == g_Config.ClassicController.ANALOG1)
@ -1214,10 +1152,13 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
_Ly = 0xff - _Ly; _Ly = 0xff - _Ly;
_Ry = 0xff - _Ry; _Ry = 0xff - _Ry;
/* This is if we are also using a real Classic Controller that we are sharing the calibration with. /* This is if we are also using a real Classic Controller that we
It's not needed if we are using our default values. We adjust the values to the configured range. are sharing the calibration with. It's not needed if we are
using our default values. We adjust the values to the configured
range.
Status: Not added, we are not currently sharing the calibration with the real Classic Controller Status: Not added, we are not currently sharing the calibration
with the real Classic Controller
*/ */
if (g_Config.ClassicController.RType == g_Config.ClassicController.ANALOG1) if (g_Config.ClassicController.RType == g_Config.ClassicController.ANALOG1)
@ -1246,25 +1187,28 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
int _Lx, _Ly, _Rx, _Ry, _Tl, _Tr; int _Lx, _Ly, _Rx, _Ry, _Tl, _Tr;
PadStateAdjustments(_Lx, _Ly, _Rx, _Ry, _Tl, _Tr); PadStateAdjustments(_Lx, _Ly, _Rx, _Ry, _Tl, _Tr);
/* This is if we are also using a real Classic Controller that we are sharing the calibration with. /* This is if we are also using a real Classic Controller that we
It's not needed if we are using our default values. We adjust the values to the configured range. are sharing the calibration with. It's not needed if we are
using our default values. We adjust the values to the configured
range.
Status: Not added, we are not currently sharing the calibration with the real Classic Controller Status: Not added, we are not currently sharing the calibration
with the real Classic Controller
*/ */
// Check if the trigger is fully pressed, then update the digital trigger values to // Check if the trigger is fully pressed, then update the digital
// trigger values to
if (_Tl == 0xff) _ext.b1.bLT = 0x00; if (_Tl == 0xff) _ext.b1.bLT = 0x00;
if (_Tr == 0xff) _ext.b1.bRT = 0x00; if (_Tr == 0xff) _ext.b1.bRT = 0x00;
// These can be copied directly, the bitshift further down fix this value to // These can be copied directly, the bitshift further down fix this
// value to
lT = _Tl; lT = _Tl;
rT = _Tr; rT = _Tr;
} }
// --------------
// --------------------------------------
/* D-Pad /* D-Pad
u8 b1; u8 b1;
@ -1280,9 +1224,7 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
if(IsKey(g_Cc.Du)) _ext.b2.bdU = 0x00; // Up if(IsKey(g_Cc.Du)) _ext.b2.bdU = 0x00; // Up
if(IsKey(g_Cc.Dr)) _ext.b1.bdR = 0x00; // Right if(IsKey(g_Cc.Dr)) _ext.b1.bdR = 0x00; // Right
if(IsKey(g_Cc.Dd)) _ext.b1.bdD = 0x00; // Down if(IsKey(g_Cc.Dd)) _ext.b1.bdD = 0x00; // Down
// --------------
// --------------------------------------
/* Buttons /* Buttons
u8 b1; u8 b1;
0: 0:
@ -1329,14 +1271,10 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
// All buttons pressed // All buttons pressed
//if(GetAsyncKeyState('C') && GetAsyncKeyState('Z')) //if(GetAsyncKeyState('C') && GetAsyncKeyState('Z'))
// { _ext.b2.bA = 0x01; _ext.b2.bB = 0x01; } // { _ext.b2.bA = 0x01; _ext.b2.bB = 0x01; }
// --------------
} }
// --------------------------------------
// --------------------------------------
// Convert data for reporting // Convert data for reporting
// --------------
_ext.Lx = (Lx >> 2); _ext.Lx = (Lx >> 2);
_ext.Ly = (Ly >> 2); _ext.Ly = (Ly >> 2);
// 5 bit to 1 bit // 5 bit to 1 bit
@ -1352,7 +1290,6 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
// 5 bit to the highest two bits // 5 bit to the highest two bits
_ext.lT2 = (lT >> 3) >> 3; _ext.lT2 = (lT >> 3) >> 3;
_ext.rT = (rT >> 3); _ext.rT = (rT >> 3);
// --------------
/* Here we encrypt the report */ /* Here we encrypt the report */
@ -1368,7 +1305,4 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
// Write it back to the struct // Write it back to the struct
memcpy(&_ext, Tmp, sizeof(_ext)); memcpy(&_ext, Tmp, sizeof(_ext));
} }
// =======================
} // end of namespace } // end of namespace

View File

@ -1,119 +0,0 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// -------------
#include <string>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif
#include "StringUtil.h"
#define HAVE_WX 1
#if defined(HAVE_WX) && HAVE_WX // wxWidgets
#include <wx/datetime.h> // for the timestamps
#endif
///////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Settings
// -------------
// On and off
bool g_consoleEnable = true;
bool gSaveFile = true;
#define DEBUG_WIIMOTE // On or off
const int nFiles = 1;
// Create handles
#ifdef DEBUG_WIIMOTE
FILE* __fStdOut[nFiles];
#endif
#ifdef _WIN32
HANDLE __hStdOut = NULL;
#endif
//////////////////////////////
// =======================================================================================
/* Get Timestamp */
// -------------
std::string Tm(bool Ms)
{
#if defined(HAVE_WX) && HAVE_WX
std::string Tmp;
if(Ms)
{
wxDateTime datetime = wxDateTime::UNow(); // Get timestamp
Tmp = StringFromFormat("%02i:%02i:%03i",
datetime.GetMinute(), datetime.GetSecond(), datetime.GetMillisecond());
}
else
{
wxDateTime datetime = wxDateTime::Now(); // Get timestamp
Tmp = StringFromFormat("%02i:%02i",
datetime.GetMinute(), datetime.GetSecond());
}
return Tmp;
#else
std::string Tmp = "";
return Tmp;
#endif
}
// ===========================
// ---------------------------------------------------------------------------------------
// File printf function
// ---------------
int PrintFile(int a, char *fmt, ...)
{
#if defined(DEBUG_WIIMOTE) && defined(_WIN32)
if(gSaveFile)
{
char s[500]; // WARNING: mind this value
va_list argptr;
int cnt;
va_start(argptr, fmt);
cnt = vsnprintf(s, 500, fmt, argptr); // remember to update this value to
va_end(argptr);
// ---------------------------------------------------------------------------------------
if(__fStdOut[a]) // TODO: make this work, we have to set all default values to NULL
//to make it work
fprintf(__fStdOut[a], s);
fflush(__fStdOut[0]); // Write file now, don't wait
// -------------
return(cnt);
}
else
{
return 0;
}
#else
return 0;
#endif
}

View File

@ -1,40 +0,0 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef WIIMOTE_CONSOLE_H
#define WIIMOTE_CONSOLE_H
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <iostream>
//////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Declarations
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
std::string Tm(bool Ms = false);
int PrintFile(int a, const char *fmt, ...);
void ClearScreen();
#ifdef _WIN32
HWND GetConsoleHwnd(void);
#endif
///////////////////////////////
#endif // WIIMOTE_CONSOLE_H

View File

@ -3,8 +3,8 @@
Import('env') Import('env')
import sys import sys
wmenv = env.Clone() wiienv = env.Clone()
name = "Plugin_Wiimote" name = "Plugin_Wiimote-testing"
files = [ files = [
"Config.cpp", "Config.cpp",
@ -17,12 +17,11 @@ files = [
"Encryption.cpp", "Encryption.cpp",
"main.cpp", "main.cpp",
] ]
if wmenv['HAVE_WX']: if wiienv['HAVE_WX']:
files += [ files += [
"ConfigDlg.cpp", "ConfigDlg.cpp",
"ConfigGamepad.cpp", "ConfigGamepad.cpp",
"ConfigRecording.cpp", "ConfigRecording.cpp",
"Logging.cpp",
"FillReport.cpp", "FillReport.cpp",
] ]
@ -31,23 +30,23 @@ libs = [ 'common', 'inputcommon' ]
cxxflags = [ '-fPIC' ] cxxflags = [ '-fPIC' ]
if wmenv['HAVE_WIIUSE']: if wiienv['HAVE_WIIUSE']:
libs += [ 'wiiuse' ] libs += [ 'wiiuse' ]
files += [ "wiimote_real.cpp" ] files += [ "wiimote_real.cpp" ]
files += [ "ReadWiimote.cpp" ] files += [ "ReadWiimote.cpp" ]
cxxflags += ['-DHAVE_WIIUSE'] cxxflags += ['-DHAVE_WIIUSE']
if sys.platform == 'darwin': if sys.platform == 'darwin':
wmenv.Append( wiienv.Append(
CXXFLAGS = cxxflags, CXXFLAGS = cxxflags,
LINKFLAGS = ['-framework' ,'IOBluetooth'], LINKFLAGS = ['-framework' ,'IOBluetooth'],
LIBS = libs, LIBS = libs,
) )
else: else:
wmenv.Append( wiienv.Append(
CXXFLAGS = cxxflags, CXXFLAGS = cxxflags,
LIBS = libs, LIBS = libs,
) )
wmenv.SharedLibrary(env['plugin_dir']+name, files) wiienv.SharedLibrary(env['plugin_dir']+name, files)

View File

@ -16,34 +16,31 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Current issues // 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:
The real Wiimote fails to answer the core correctly sometmes. Leading to an unwanted disconnection. And 1. Make a reconnect function in the IOS emulation
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 first solution seems easier, if I knew a little better how the /dev/usb/oh1 and Wiimote functions 2. Detect failed answers in this plugin and solve it by replacing them with
worked. emulated answers.
/////////////////////////////////////////////*/ The first solution seems easier, if I knew a little better how the /dev/usb/oh1
and Wiimote functions worked.
*/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include "Common.h" // Common #include "Common.h" // Common
#include "StringUtil.h" #include "StringUtil.h"
#include "Timer.h" #include "Timer.h"
#define EXCLUDEMAIN_H // Avoid certain declarations in main.h
#include "EmuDefinitions.h" // Local #include "EmuDefinitions.h" // Local
#include "wiimote_hid.h" #include "wiimote_hid.h"
#include "main.h" #include "main.h"
#include "Logging.h"
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
#include "ConfigDlg.h" #include "ConfigDlg.h"
#endif #endif
@ -53,12 +50,8 @@ worked.
#if HAVE_WIIUSE #if HAVE_WIIUSE
#include "wiimote_real.h" #include "wiimote_real.h"
#endif #endif
///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Declarations and definitions
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
SWiimoteInitialize g_WiimoteInitialize; SWiimoteInitialize g_WiimoteInitialize;
PLUGIN_GLOBALS* globals = NULL; PLUGIN_GLOBALS* globals = NULL;
@ -114,12 +107,9 @@ HWND g_ParentHWND = NULL;
IMPLEMENT_APP_NO_MAIN(wxDLLApp) IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
#endif #endif
////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Main function and WxWidgets initialization // Main function and WxWidgets initialization
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#ifdef _WIN32 #ifdef _WIN32
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
DWORD dwReason, // reason called DWORD dwReason, // reason called
@ -149,7 +139,6 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
return TRUE; return TRUE;
} }
#endif #endif
/////////////////////////////////////
//****************************************************************************** //******************************************************************************
@ -536,9 +525,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
// data[4]: Size and error // data[4]: Size and error
// data[5, 6]: The registry offset // data[5, 6]: The registry offset
// ---------------------------------------------------------------------
// Show the extension ID // 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 || data[4] == 0x20 || data[4] == 0x50) && data[5] == 0x00 && (data[6] == 0xfa || data[6] == 0xfe))
{ {
if(data[4] == 0x10) if(data[4] == 0x10)
@ -584,13 +571,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]); 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 // Show the Wiimote neutral values
// -------------------------- /* The only difference between the Nunchuck and Wiimote that we go
/* The only difference between the Nunchuck and Wiimote that we go after is calibration here is after is calibration here is the offset in memory. If needed we can
the offset in memory. If needed we can check the preceding 0x17 request to. */ check the preceding 0x17 request to. */
if(data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10) if(data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10)
{ {
if(data[6] == 0x10) if(data[6] == 0x10)
@ -604,11 +589,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
INFO_LOG(CONSOLE, "Cal_g.z: %i\n", data[7 +12]); INFO_LOG(CONSOLE, "Cal_g.z: %i\n", data[7 +12]);
} }
} }
// ---------------------------------------------
// ---------------------------------------------------------------------
// Show the Nunchuck neutral values // Show the Nunchuck neutral values
// --------------------------
if(data[4] == 0xf0 && data[5] == 0x00 && (data[6] == 0x20 || data[6] == 0x30)) if(data[4] == 0xf0 && data[5] == 0x00 && (data[6] == 0x20 || data[6] == 0x30))
{ {
// Save the encrypted data // Save the encrypted data
@ -680,7 +662,6 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
// Show the encrypted data // Show the encrypted data
INFO_LOG(CONSOLE, "%s", TmpData.c_str()); INFO_LOG(CONSOLE, "%s", TmpData.c_str());
} }
// ---------------------------------------------
break; break;
case WM_WRITE_DATA_REPLY: // 0x22 case WM_WRITE_DATA_REPLY: // 0x22
@ -727,9 +708,9 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
if (!DataReport && g_DebugComm) 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()); //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 //INFO_LOG(CONSOLE, " (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp
} }
@ -1083,18 +1064,16 @@ int GetUpdateRate()
void DoInitialize() void DoInitialize()
{ {
// Open console
//OpenConsole(true);
// Run this first so that WiiMoteReal::Initialize() overwrites g_Eeprom // Run this first so that WiiMoteReal::Initialize() overwrites g_Eeprom
WiiMoteEmu::Initialize(); WiiMoteEmu::Initialize();
/* We will run WiiMoteReal::Initialize() even if we are not using a real wiimote, /* We will run WiiMoteReal::Initialize() even if we are not using a real
to check if there is a real wiimote connected. We will initiate wiiuse.dll, but wiimote, to check if there is a real wiimote connected. We will initiate
we will return before creating a new thread for it if we find no real Wiimotes. wiiuse.dll, but we will return before creating a new thread for it if we
Then g_RealWiiMotePresent will also be false. This function call will be done find no real Wiimotes. Then g_RealWiiMotePresent will also be
instantly whether there is a real Wiimote connected or not. It takes no time for false. This function call will be done instantly whether there is a real
Wiiuse to check for connected Wiimotes. */ Wiimote connected or not. It takes no time for Wiiuse to check for
connected Wiimotes. */
#if HAVE_WIIUSE #if HAVE_WIIUSE
if (g_Config.bConnectRealWiimote) WiiMoteReal::Initialize(); if (g_Config.bConnectRealWiimote) WiiMoteReal::Initialize();
#endif #endif

View File

@ -16,9 +16,7 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
//////////////////////////////////////////////////////////////////////////////////////////
// Includes // Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <iostream> // System #include <iostream> // System
#include <queue> #include <queue>
@ -35,15 +33,13 @@
#include "Config.h" #include "Config.h"
#include "EmuMain.h" #include "EmuMain.h"
#include "EmuDefinitions.h" #include "EmuDefinitions.h"
#define EXCLUDE_H // Avoid certain declarations in wiimote_real.h #include "Thread.h"
#include "wiimote_real.h" #include "wiimote_real.h"
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
#include "ConfigDlg.h" #include "ConfigDlg.h"
#endif #endif
extern SWiimoteInitialize g_WiimoteInitialize; extern SWiimoteInitialize g_WiimoteInitialize;
////////////////////////////////////////
namespace WiiMoteReal namespace WiiMoteReal
{ {
@ -54,11 +50,8 @@ namespace WiiMoteReal
class CWiiMote; class CWiiMote;
#ifdef _WIN32 THREAD_RETURN ReadWiimote_ThreadFunc(void* arg);
DWORD WINAPI ReadWiimote_ThreadFunc(void* arg);
#else
void* ReadWiimote_ThreadFunc(void* arg);
#endif
//****************************************************************************** //******************************************************************************
// Variable declarations // Variable declarations
//****************************************************************************** //******************************************************************************
@ -86,15 +79,12 @@ class CWiiMote
{ {
public: public:
//////////////////////////////////////////
// On create and on uncreate
// ---------------
CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote) CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
: m_WiimoteNumber(_WiimoteNumber) : m_WiimoteNumber(_WiimoteNumber)
, m_channelID(0) , m_channelID(0)
, m_pWiiMote(_pWiimote)
, m_pCriticalSection(NULL) , m_pCriticalSection(NULL)
, m_LastReportValid(false) , m_LastReportValid(false)
, m_pWiiMote(_pWiimote)
{ {
m_pCriticalSection = new Common::CriticalSection(); m_pCriticalSection = new Common::CriticalSection();
@ -110,12 +100,9 @@ virtual ~CWiiMote()
{ {
delete m_pCriticalSection; delete m_pCriticalSection;
}; };
//////////////////////
//////////////////////////////////////////
// Queue raw HID data from the core to the wiimote // Queue raw HID data from the core to the wiimote
// ---------------
void SendData(u16 _channelID, const u8* _pData, u32 _Size) void SendData(u16 _channelID, const u8* _pData, u32 _Size)
{ {
m_channelID = _channelID; m_channelID = _channelID;
@ -132,12 +119,9 @@ void SendData(u16 _channelID, const u8* _pData, u32 _Size)
} }
m_pCriticalSection->Leave(); m_pCriticalSection->Leave();
} }
/////////////////////
//////////////////////////////////////////////////
/* Read and write data to the Wiimote */ /* Read and write data to the Wiimote */
// ---------------
void ReadData() void ReadData()
{ {
m_pCriticalSection->Enter(); m_pCriticalSection->Enter();
@ -193,12 +177,9 @@ void ReadData()
} }
} }
}; };
/////////////////////
//////////////////////////////////////////
// Send queued data to the core // Send queued data to the core
// ---------------
void Update() void Update()
{ {
// Thread function // Thread function
@ -218,12 +199,9 @@ void Update()
m_pCriticalSection->Leave(); m_pCriticalSection->Leave();
}; };
/////////////////////
//////////////////////////////////////////
// Clear events // Clear events
// ---------------
void ClearEvents() void ClearEvents()
{ {
while (!m_EventReadQueue.empty()) while (!m_EventReadQueue.empty())
@ -231,7 +209,6 @@ void ClearEvents()
while (!m_EventWriteQueue.empty()) while (!m_EventWriteQueue.empty())
m_EventWriteQueue.pop(); m_EventWriteQueue.pop();
} }
/////////////////////
private: private:
@ -254,9 +231,7 @@ private:
SEvent m_LastReport; SEvent m_LastReport;
wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[] wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[]
//////////////////////////////////////////
// Send queued data to the core // Send queued data to the core
// ---------------
void SendEvent(SEvent& _rEvent) void SendEvent(SEvent& _rEvent)
{ {
// We don't have an answer channel // We don't have an answer channel
@ -272,8 +247,9 @@ void SendEvent(SEvent& _rEvent)
// Create the buffer // Create the buffer
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, MAX_PAYLOAD); 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 /* This Offset value is not exactly correct like it is for the emulated
often to big, but I guess that's okay. The game will know how big the actual data is. */ 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; Offset += MAX_PAYLOAD;
// Send it // Send it
@ -282,7 +258,6 @@ void SendEvent(SEvent& _rEvent)
// Debugging // Debugging
// ReadDebugging(false, Buffer, Offset); // ReadDebugging(false, Buffer, Offset);
} }
/////////////////////
}; };
@ -385,11 +360,13 @@ int Initialize()
// If we are not using the emulated wiimote we can run the thread temporary until the data has beeen copied // 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; if(g_Config.bUseRealWiimote) g_RunTemporary = true;
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values to g_Eeprom. Unlike with /* Allocate memory and copy the Wiimote eeprom accelerometer neutral values
and extension we have to do this here, because this data is only read once when the Wiimote to g_Eeprom. Unlike with and extension we have to do this here, because
is connected. Also, we can't change the neutral values the wiimote will report, I think, unless this data is only read once when the Wiimote is connected. Also, we
we update its eeprom? In any case it's probably better to let the current calibration be where it can't change the neutral values the wiimote will report, I think, unless
is and adjust the global values after that to avoid overwriting critical data on any Wiimote. */ 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? // TODO: Update for multiple wiimotes?
byte *data = (byte*)malloc(sizeof(byte) * sizeof(WiiMoteEmu::EepromData_0)); byte *data = (byte*)malloc(sizeof(byte) * sizeof(WiiMoteEmu::EepromData_0));
wiiuse_read_data(g_WiiMotesFromWiiUse[0], data, 0, sizeof(WiiMoteEmu::EepromData_0)); wiiuse_read_data(g_WiiMotesFromWiiUse[0], data, 0, sizeof(WiiMoteEmu::EepromData_0));
@ -450,9 +427,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
} }
//////////////////////////////////
// Read the Wiimote once // Read the Wiimote once
// ---------------
void Update() void Update()
{ {
//INFO_LOG(CONSOLE, "Real Update\n"); //INFO_LOG(CONSOLE, "Real Update\n");
@ -462,16 +437,11 @@ void Update()
} }
} }
////////////////////////////////// /* Continuously read the Wiimote status. However, the actual sending of data
/* Continuously read the Wiimote status. However, the actual sending of data occurs in Update(). If we are occurs in Update(). If we are not currently using the real Wiimote we allow
not currently using the real Wiimote we allow the separate ReadWiimote() function to run. Wo don't use the separate ReadWiimote() function to run. Wo don't use them at the same
them at the same time to avoid a potential collision. */ time to avoid a potential collision. */
// --------------- THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
#ifdef _WIN32
DWORD WINAPI ReadWiimote_ThreadFunc(void* arg)
#else
void *ReadWiimote_ThreadFunc(void* arg)
#endif
{ {
while (!g_Shutdown) while (!g_Shutdown)
{ {

View File

@ -20,12 +20,7 @@
#define WIIMOTE_REAL_H #define WIIMOTE_REAL_H
//////////////////////////////////////////////////////////////////////////////////////////
// Includes
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
#include "wiiuse.h" #include "wiiuse.h"
///////////////////////////////////
namespace WiiMoteReal namespace WiiMoteReal
{ {
@ -47,20 +42,18 @@ void ClearEvents();
void ReadWiimote(); void ReadWiimote();
bool IRDataOK(struct wiimote_t* wm); bool IRDataOK(struct wiimote_t* wm);
#ifndef EXCLUDE_H extern wiimote_t** g_WiiMotesFromWiiUse;
extern wiimote_t** g_WiiMotesFromWiiUse; extern bool g_Shutdown;
extern bool g_Shutdown; extern bool g_ThreadGoing;
extern bool g_ThreadGoing; extern int g_NumberOfWiiMotes;
extern int g_NumberOfWiiMotes; extern bool g_MotionSensing;
extern bool g_MotionSensing; extern bool g_IRSensing;
extern bool g_IRSensing; extern u64 g_UpdateTime;
extern u64 g_UpdateTime; extern int g_UpdateCounter;
extern int g_UpdateCounter; extern bool g_RunTemporary;
extern bool g_RunTemporary; extern int g_RunTemporaryCountdown;
extern int g_RunTemporaryCountdown; extern u8 g_EventBuffer[32];
extern u8 g_EventBuffer[32];
#endif
}; // WiiMoteReal }; // WiiMoteReal
#endif #endif