Some clean up
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3377 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ad4ffaf0b6
commit
1a6b9d8174
|
@ -10,7 +10,7 @@ import wxconfig
|
|||
import utils
|
||||
|
||||
# Some features needs at least scons 0.98
|
||||
EnsureSConsVersion(0, 98)
|
||||
EnsureSConsVersion(1, 2)
|
||||
|
||||
# TODO: how do we use it in help?
|
||||
name="Dolphin"
|
||||
|
@ -80,6 +80,7 @@ dirs = [
|
|||
'Source/Plugins/Plugin_nJoy_SDL/Src',
|
||||
'Source/Plugins/Plugin_nJoy_Testing/Src',
|
||||
'Source/Plugins/Plugin_Wiimote/Src',
|
||||
'Source/Plugins/Plugin_Wiimote-testing/Src',
|
||||
'Source/Core/DolphinWX/Src',
|
||||
'Source/Core/DebuggerWX/Src',
|
||||
]
|
||||
|
|
|
@ -47,7 +47,7 @@ lri $IX0, #0x1338
|
|||
call send_back ; 8
|
||||
|
||||
lri $IX0, #0x0000
|
||||
lri $SR, #0x000a
|
||||
lri $SR, #0x000a
|
||||
|
||||
ifg
|
||||
lri $IX0, #0x1337
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
//#include "Common.h" // for u16
|
||||
#include "CommonTypes.h" // for u16
|
||||
#include "IniFile.h"
|
||||
#include "Timer.h"
|
||||
|
@ -33,24 +29,17 @@
|
|||
#include "EmuMain.h" // for LoadRecordedMovements()
|
||||
#include "EmuSubroutines.h" // for WmRequestStatus
|
||||
#include "EmuDefinitions.h" // for joyinfo
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Variables
|
||||
// ----------------
|
||||
// Trigger Type
|
||||
enum
|
||||
{
|
||||
CTL_TRIGGER_SDL = 0, //
|
||||
CTL_TRIGGER_XINPUT // The XBox 360 pad
|
||||
};
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Event table
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
|
||||
EVT_CLOSE(ConfigDialog::OnClose)
|
||||
EVT_BUTTON(ID_CLOSE, ConfigDialog::CloseClick)
|
||||
|
@ -220,9 +209,7 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
|
|||
UpdateGUI();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Handle the keyboard key mapping
|
||||
// ------------------
|
||||
std::string StrKey;
|
||||
if(ClickedButton != NULL)
|
||||
{
|
||||
|
@ -230,7 +217,7 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
|
|||
if (g_Pressed == WXK_ESCAPE)
|
||||
{
|
||||
SaveKeyboardMapping(Page, ClickedButton->GetId(), -1);
|
||||
SetButtonText(ClickedButton->GetId(), "");
|
||||
SetButtonText(ClickedButton->GetId(), (char *)"");
|
||||
ClickedButton = NULL;
|
||||
return;
|
||||
}
|
||||
|
@ -259,7 +246,6 @@ void ConfigDialog::OnKeyDown(wxKeyEvent& event)
|
|||
|
||||
// Remove the button control pointer
|
||||
ClickedButton = NULL;
|
||||
// ---------------------------
|
||||
}
|
||||
|
||||
// Input button clicked
|
||||
|
@ -267,7 +253,8 @@ void ConfigDialog::OnButtonClick(wxCommandEvent& event)
|
|||
{
|
||||
//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; }
|
||||
|
||||
// Reset the old label
|
||||
|
@ -294,9 +281,11 @@ void ConfigDialog::OnClose(wxCloseEvent& event)
|
|||
event.Skip();
|
||||
}
|
||||
|
||||
/* Timeout the shutdown. In Windows at least the g_pReadThread execution will hang at any attempt to
|
||||
call a frame function after the main thread has entered WaitForSingleObject() or any other loop.
|
||||
We must therefore shut down the thread from here and wait for that before we can call ShutDown(). */
|
||||
/* Timeout the shutdown. In Windows at least the g_pReadThread execution will
|
||||
hang at any attempt to call a frame function after the main thread has
|
||||
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))
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Save Settings
|
||||
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
|
@ -374,7 +361,8 @@ void ConfigDialog::DoSave(bool ChangePad, int Slot)
|
|||
|
||||
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);
|
||||
// Save the settings for the current pad
|
||||
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());
|
||||
}
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Bitmap box and dot
|
||||
// ----------------
|
||||
wxBitmap ConfigDialog::CreateBitmap()
|
||||
{
|
||||
BoxW = 70, BoxH = 70;
|
||||
|
@ -467,15 +451,12 @@ wxBitmap ConfigDialog::CreateBitmapClear()
|
|||
//dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
void ConfigDialog::CreateGUIControls()
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Notebook
|
||||
// ----------------
|
||||
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
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_Notebook->AddPage(m_PageRecording, wxT("Recording"));
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Text lists
|
||||
// ----------------
|
||||
|
||||
// Search for devices and add them to the device list
|
||||
wxArrayString StrJoyname; // The string array
|
||||
|
@ -537,11 +515,8 @@ void ConfigDialog::CreateGUIControls()
|
|||
|
||||
// A small type font
|
||||
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
///////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This can take a few seconds so we show a progress bar for it
|
||||
// ----------------
|
||||
wxProgressDialog dialog(_T("Opening Wii Remote Configuration"),
|
||||
wxT("Loading controls..."),
|
||||
6, // range
|
||||
|
@ -555,16 +530,13 @@ void ConfigDialog::CreateGUIControls()
|
|||
);
|
||||
// I'm not sure what parent this refers to
|
||||
dialog.CenterOnParent();
|
||||
///////////////////////////////////////
|
||||
|
||||
/* Populate all four pages. Page 2, 3 and 4 are currently disabled since we can't use more than one
|
||||
Wiimote at the moment */
|
||||
/* Populate all four pages. Page 2, 3 and 4 are currently disabled since we
|
||||
can't use more than one Wiimote at the moment */
|
||||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// General and basic Settings
|
||||
// ----------------
|
||||
|
||||
// Configuration controls sizes
|
||||
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"
|
||||
" when a recording is to be done. No status in this window will be updated when this is checked."));
|
||||
|
||||
// -----------------------------------------------
|
||||
// Screen size
|
||||
// ---------------------
|
||||
// Controls
|
||||
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"));
|
||||
|
@ -663,11 +633,8 @@ void ConfigDialog::CreateGUIControls()
|
|||
|
||||
// Tool tips
|
||||
//m_ScreenSize[i]->SetToolTip(wxT("Use the adjusted screen size."));
|
||||
// -------------------------------
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Row 1 Sizers: 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_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_SizeBasicGeneralRight[i], 0, wxEXPAND | (wxLEFT), 5);
|
||||
// ------------------------
|
||||
|
||||
///////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Gamepad input
|
||||
// ----------------
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Controller
|
||||
// -----------------------------
|
||||
|
||||
// Controller
|
||||
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();
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Tilt Wiimote
|
||||
// -----------------------------
|
||||
/**/
|
||||
|
||||
// Controls
|
||||
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);
|
||||
|
@ -822,10 +776,7 @@ void ConfigDialog::CreateGUIControls()
|
|||
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."));
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Analog triggers
|
||||
// -----------------------------
|
||||
/**/
|
||||
m_gTrigger[i] = new wxStaticBoxSizer (wxHORIZONTAL, m_Controller[i], wxT("Triggers"));
|
||||
|
||||
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_SizeAnalogTriggerVertRight[i], 0, wxEXPAND | (wxLEFT | wxRIGHT), 5);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Row 2 Sizers: Connected pads, tilt, triggers
|
||||
// -----------------------------
|
||||
m_HorizControllerTilt[i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_HorizControllerTilt[i]->Add(m_gJoyname[i], 0, wxALIGN_CENTER | wxEXPAND, 0);
|
||||
m_HorizControllerTilt[i]->Add(m_gTilt[i], 0, wxEXPAND | (wxLEFT), 5);
|
||||
|
@ -896,9 +845,7 @@ void ConfigDialog::CreateGUIControls()
|
|||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Analog sticks
|
||||
// -----------------------------
|
||||
|
||||
// Status panels
|
||||
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);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Row 3 Sizers
|
||||
// -----------------------------
|
||||
m_HorizControllers[i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
//m_HorizControllers[i]->AddStretchSpacer();
|
||||
m_HorizControllers[i]->AddSpacer(17);
|
||||
m_HorizControllers[i]->Add(m_gAnalogLeft[i]);
|
||||
m_HorizControllers[i]->Add(m_gAnalogRight[i], 0, (wxLEFT), 5);
|
||||
//m_HorizControllers[i]->AddStretchSpacer();
|
||||
///////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Keyboard mapping
|
||||
// ----------------
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Wiimote
|
||||
// -----------------------------
|
||||
|
||||
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_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]->AddSpacer(1);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Nunchuck
|
||||
// -----------------------------
|
||||
|
||||
// Stick controls
|
||||
m_NunchuckTextStick[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Stick"));
|
||||
|
@ -1165,9 +1102,7 @@ void ConfigDialog::CreateGUIControls()
|
|||
//Set values
|
||||
m_NunchuckComboStick[i]->SetSelection(g_Config.Nunchuck.Type);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Classic Controller
|
||||
// -----------------------------
|
||||
|
||||
// Stick controls
|
||||
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_CcComboTriggers[i]->SetSelection(g_Config.ClassicController.TType);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Row 4 Sizers
|
||||
// -----------------------------
|
||||
m_HorizControllerMapping[i] = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_HorizControllerMapping[i]->AddStretchSpacer();
|
||||
m_HorizControllerMapping[i]->Add(m_gWiimote[i]);
|
||||
m_HorizControllerMapping[i]->Add(m_gNunchuck[i], 0, (wxLEFT), 5);
|
||||
m_HorizControllerMapping[i]->Add(m_gClassicController[i], 0, (wxLEFT), 5);
|
||||
m_HorizControllerMapping[i]->AddStretchSpacer();
|
||||
///////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Set up sizers and layout
|
||||
// ----------------
|
||||
m_SizeParent[i] = new wxBoxSizer(wxVERTICAL);
|
||||
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);
|
||||
|
@ -1368,17 +1297,13 @@ void ConfigDialog::CreateGUIControls()
|
|||
dialog.Update(i + 1, wxT("Loading notebook pages..."));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
// Movement recording
|
||||
// ----------------
|
||||
CreateGUIControlsRecording();
|
||||
/////////////////////////////////
|
||||
|
||||
// Update with the progress (i) and the message (msg)
|
||||
dialog.Update(5, wxT("Loading notebook pages..."));
|
||||
//dialog.Close();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Buttons
|
||||
//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);
|
||||
|
@ -1390,12 +1315,9 @@ void ConfigDialog::CreateGUIControls()
|
|||
sButtons->AddStretchSpacer();
|
||||
sButtons->Add(m_Apply, 0, (wxALL), 0);
|
||||
sButtons->Add(m_Close, 0, (wxLEFT), 5);
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////
|
||||
// Set sizers and layout
|
||||
// ----------------
|
||||
m_MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_MainSizer->Add(m_Notebook, 1, wxEXPAND | wxALL, 5);
|
||||
m_MainSizer->Add(sButtons, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
|
||||
|
@ -1417,15 +1339,11 @@ void ConfigDialog::CreateGUIControls()
|
|||
#endif
|
||||
|
||||
ControlsCreated = true;
|
||||
/////////////////////////////////
|
||||
}
|
||||
/////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Do connect real wiimote */
|
||||
// ----------------
|
||||
void ConfigDialog::DoConnectReal()
|
||||
{
|
||||
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 and init the Extension when we change
|
||||
want to use it again. */
|
||||
// ----------------
|
||||
/* Do use real wiimote. We let the game set up the real Wiimote reporting mode
|
||||
and init the Extension when we change want to use it again. */
|
||||
void ConfigDialog::DoUseReal()
|
||||
{
|
||||
// Clear any eventual events in the Wiimote queue
|
||||
|
@ -1480,19 +1396,15 @@ void ConfigDialog::DoUseReal()
|
|||
// Disable the checkbox for a moment
|
||||
SetCursor(wxCursor(wxCURSOR_WAIT));
|
||||
m_bEnableUseRealWiimote = false;
|
||||
// We may not need this if there is already a message queue that allows the nessesary timeout
|
||||
//sleep(100);
|
||||
|
||||
/* Start the timer to allow the approximate time it takes for the Wiimote to come online
|
||||
it would simpler to use sleep(1000) but that doesn't work because we need the functions in main.cpp
|
||||
to work */
|
||||
/* Start the timer to allow the approximate time it takes for the
|
||||
Wiimote to come online it would simpler to use sleep(1000) but that
|
||||
doesn't work because we need the functions in main.cpp to work */
|
||||
m_TimeoutOnce->Start(1000, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================
|
||||
/* Generate connect/disconnect status event */
|
||||
// ----------------
|
||||
void ConfigDialog::DoExtensionConnectedDisconnected(int Extension)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
// ===================================================
|
||||
/* Change settings */
|
||||
// ----------------
|
||||
void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
||||
{
|
||||
long TmpValue;
|
||||
|
@ -1528,9 +1438,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
|||
g_Config.bSidewaysDPad = m_SidewaysDPad[Page]->IsChecked();
|
||||
break;
|
||||
|
||||
//////////////////////////
|
||||
// Extensions
|
||||
// -----------
|
||||
case ID_NUNCHUCKCONNECTED:
|
||||
// Don't allow two extensions at the same time
|
||||
if(m_ClassicControllerConnected[Page]->IsChecked())
|
||||
|
@ -1571,9 +1479,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
|||
DoExtensionConnectedDisconnected();
|
||||
break;
|
||||
|
||||
//////////////////////////
|
||||
// Gamepad
|
||||
// -----------
|
||||
case ID_TRIGGER_TYPE:
|
||||
WiiMoteEmu::PadMapping[Page].triggertype = m_TriggerType[Page]->GetSelection();
|
||||
break;
|
||||
|
@ -1616,9 +1522,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
|||
SaveButtonMappingAll(Page);
|
||||
break;
|
||||
|
||||
//////////////////////////
|
||||
// Recording
|
||||
// -----------
|
||||
case ID_UPDATE_REAL:
|
||||
g_Config.bUpdateRealWiimote = m_UpdateMeters->IsChecked();
|
||||
break;
|
||||
|
@ -1651,15 +1555,12 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
|||
// m_RecordHotKey[i]->GetSelection(), m_RecordHotKey[CurrentChoiceBox]->GetSelection());
|
||||
}
|
||||
break;
|
||||
/////////////////
|
||||
}
|
||||
g_Config.Save();
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
// =======================================================
|
||||
// Apparently we need a scroll event version of this for the sliders
|
||||
// -------------
|
||||
void ConfigDialog::GeneralSettingsChangedScroll(wxScrollEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
|
@ -1682,9 +1583,7 @@ void ConfigDialog::GeneralSettingsChangedScroll(wxScrollEvent& event)
|
|||
UpdateGUI();
|
||||
}
|
||||
|
||||
// =======================================================
|
||||
// Update the IR pointer calibration sliders
|
||||
// -------------
|
||||
void ConfigDialog::UpdateControls()
|
||||
{
|
||||
// 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_TextScreenTop[Page]->SetLabel(wxString::Format(wxT("Top: %i"), g_Config.iIRTop));
|
||||
}
|
||||
// ==============================
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Update the enabled/disabled status
|
||||
// -------------
|
||||
void ConfigDialog::UpdateGUI(int Slot)
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "UpdateGUI: \n");
|
||||
|
@ -1718,19 +1614,21 @@ void ConfigDialog::UpdateGUI(int Slot)
|
|||
// Update the Wiimote IR pointer calibration
|
||||
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
|
||||
from the data scanning functions in main.cpp */
|
||||
/* 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 from the data
|
||||
scanning functions in main.cpp */
|
||||
bool AllowExtensionChange = !(g_RealWiiMotePresent && g_Config.bConnectRealWiimote && g_Config.bUseRealWiimote && g_EmulatorRunning);
|
||||
m_NunchuckConnected[Page]->SetValue(g_Config.bNunchuckConnected);
|
||||
m_ClassicControllerConnected[Page]->SetValue(g_Config.bClassicControllerConnected);
|
||||
m_NunchuckConnected[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
|
||||
between using and not using then. To also use the connect option during a running game would
|
||||
mean that the wiimote must be sent the current reporting mode and the channel ID after it
|
||||
has been initialized. Functions for that are basically already in place so these two options
|
||||
could possibly be simplified to one option. */
|
||||
/* I have disabled this option during a running game because it's enough to
|
||||
be able to switch between using and not using then. To also use the
|
||||
connect option during a running game would mean that the wiimote must be
|
||||
sent the current reporting mode and the channel ID after it has been
|
||||
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_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
|
||||
if(ControlsCreated)
|
||||
{
|
||||
bool PadEnabled = WiiMoteEmu::NumGoodPads != 0;
|
||||
#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);
|
||||
m_Notebook->FindItem(IDC_JOYNAME)->Enable(PadEnabled);
|
||||
m_Notebook->FindItem(IDC_LEFT_C2S)->Enable(PadEnabled);
|
||||
|
@ -1751,8 +1649,8 @@ void ConfigDialog::UpdateGUI(int Slot)
|
|||
}
|
||||
|
||||
// Disable all recording buttons
|
||||
bool ActiveRecording = !(m_bWaitForRecording || m_bRecording);
|
||||
#ifdef _WIN32
|
||||
bool ActiveRecording = !(m_bWaitForRecording || m_bRecording);
|
||||
for(int i = IDB_RECORD + 1; i < (IDB_RECORD + RECORDING_ROWS + 1); i++)
|
||||
if(ControlsCreated) m_Notebook->FindItem(i)->Enable(ActiveRecording);
|
||||
#endif
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
//#include "Common.h" // for u16
|
||||
#include "CommonTypes.h" // for u16
|
||||
#include "IniFile.h"
|
||||
#include "Timer.h"
|
||||
|
@ -32,15 +28,13 @@
|
|||
#include "EmuMain.h" // for LoadRecordedMovements()
|
||||
#include "EmuSubroutines.h" // for WmRequestStatus
|
||||
#include "EmuDefinitions.h" // for joyinfo
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Change Joystick
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Function: When changing the joystick we save and load the settings and update the PadMapping
|
||||
and PadState array. PadState[].joy is the gamepad handle that is used to access the pad throughout
|
||||
the plugin. Joyinfo[].joy is only used the first time the pads are checked. */
|
||||
/* Function: When changing the joystick we save and load the settings and
|
||||
update the PadMapping and PadState array. PadState[].joy is the gamepad
|
||||
handle that is used to access the pad throughout the plugin. Joyinfo[].joy
|
||||
is only used the first time the pads are checked. */
|
||||
void ConfigDialog::DoChangeJoystick()
|
||||
{
|
||||
// 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);
|
||||
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);
|
||||
WiiMoteEmu::PadState[Close].joy = NULL;
|
||||
if (SDL_JoystickOpened(WiiMoteEmu::PadMapping[_Close].ID)) SDL_JoystickClose(WiiMoteEmu::PadState[_Close].joy);
|
||||
WiiMoteEmu::PadState[_Close].joy = NULL;
|
||||
}
|
||||
|
||||
void ConfigDialog::DoChangeDeadZone(bool Left)
|
||||
|
@ -96,12 +90,9 @@ void ConfigDialog::DoChangeDeadZone(bool Left)
|
|||
m_bmpDeadZoneRightIn[Page]->Refresh();
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Change settings
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Set the button text for all four Wiimotes
|
||||
void ConfigDialog::SetButtonTextAll(int id, char text[128])
|
||||
|
@ -130,7 +121,6 @@ void ConfigDialog::SaveButtonMappingAll(int Slot)
|
|||
}
|
||||
|
||||
// Set dialog items from saved values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigDialog::UpdateGUIButtonMapping(int controller)
|
||||
{
|
||||
// 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
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigDialog::ToBlank(bool ToBlank)
|
||||
void ConfigDialog::ToBlank(bool _ToBlank)
|
||||
{
|
||||
if (!ControlsCreated) return;
|
||||
|
||||
for (int j = 0; j < 1; j++)
|
||||
{
|
||||
if(ToBlank)
|
||||
if(_ToBlank)
|
||||
{
|
||||
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++)
|
||||
#ifndef _WIN32
|
||||
if(GetButtonText(i, j).ToAscii() == "-1") SetButtonText(i, "", j);
|
||||
if(GetButtonText(i, j).ToAscii() == "-1")
|
||||
SetButtonText(i, (char *)"", j);
|
||||
#else
|
||||
if(GetButtonText(i, j) == "-1") SetButtonText(i, "", j);
|
||||
#endif
|
||||
|
@ -343,11 +333,10 @@ void ConfigDialog::ToBlank(bool ToBlank)
|
|||
else
|
||||
{
|
||||
for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++)
|
||||
if(GetButtonText(i, j).IsEmpty()) SetButtonText(i, "-1", j);
|
||||
if(GetButtonText(i, j).IsEmpty()) SetButtonText(i, (char *)"-1", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
@ -458,18 +447,20 @@ wxString ConfigDialog::GetButtonText(int id, int _Page)
|
|||
|
||||
// Wait for button press
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Loop or timer: There are basically two ways to do this. With a while() or for() loop, or with a
|
||||
timer. The downside with the while() or for() loop is that there is no way to stop it if the user
|
||||
should select to configure another button while we are still in an old loop. What will happen then
|
||||
is that we start another parallel loop (at least in Windows) that blocks the old loop. And our only
|
||||
option to wait for the old loop to finish is with a new loop, and that will block the old loop for as
|
||||
long as it's going on. Therefore a timer is easier to control. */
|
||||
/* Loop or timer: There are basically two ways to do this. With a while() or
|
||||
for() loop, or with a timer. The downside with the while() or for() loop is
|
||||
that there is no way to stop it if the user should select to configure
|
||||
another button while we are still in an old loop. What will happen then is
|
||||
that we start another parallel loop (at least in Windows) that blocks the
|
||||
old loop. And our only option to wait for the old loop to finish is with a
|
||||
new loop, and that will block the old loop for as long as it's going
|
||||
on. Therefore a timer is easier to control. */
|
||||
void ConfigDialog::GetButtons(wxCommandEvent& event)
|
||||
{
|
||||
DoGetButtons(event.GetId());
|
||||
}
|
||||
|
||||
void ConfigDialog::DoGetButtons(int GetId)
|
||||
void ConfigDialog::DoGetButtons(int _GetId)
|
||||
{
|
||||
// =============================================
|
||||
// Collect the starting values
|
||||
|
@ -483,11 +474,11 @@ void ConfigDialog::DoGetButtons(int GetId)
|
|||
int TriggerType = WiiMoteEmu::PadMapping[Controller].triggertype;
|
||||
|
||||
// Collect the accepted buttons for this slot
|
||||
bool LeftRight = (GetId == IDB_TRIGGER_L || GetId == IDB_TRIGGER_R);
|
||||
bool LeftRight = (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R);
|
||||
|
||||
bool Axis = (GetId >= IDB_ANALOG_LEFT_X && GetId <= IDB_TRIGGER_R)
|
||||
bool Axis = (_GetId >= IDB_ANALOG_LEFT_X && _GetId <= IDB_TRIGGER_R)
|
||||
// Don't allow SDL axis input for the shoulder buttons if XInput is selected
|
||||
&& !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (GetId == IDB_TRIGGER_L || GetId == IDB_TRIGGER_R) );
|
||||
&& !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (_GetId == IDB_TRIGGER_L || _GetId == IDB_TRIGGER_R) );
|
||||
|
||||
bool XInput = (TriggerType == InputCommon::CTL_TRIGGER_XINPUT);
|
||||
|
||||
|
@ -511,10 +502,10 @@ void ConfigDialog::DoGetButtons(int GetId)
|
|||
// =======================
|
||||
|
||||
//INFO_LOG(CONSOLE, "Before (%i) Id:%i %i IsRunning:%i\n",
|
||||
// GetButtonWaitingTimer, GetButtonWaitingID, GetId, m_ButtonMappingTimer->IsRunning());
|
||||
// GetButtonWaitingTimer, GetButtonWaitingID, _GetId, m_ButtonMappingTimer->IsRunning());
|
||||
|
||||
// If the Id has changed or the timer is not running we should start one
|
||||
if( GetButtonWaitingID != GetId || !m_ButtonMappingTimer->IsRunning() )
|
||||
if( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer->IsRunning() )
|
||||
{
|
||||
if(m_ButtonMappingTimer->IsRunning())
|
||||
{
|
||||
|
@ -522,26 +513,26 @@ void ConfigDialog::DoGetButtons(int GetId)
|
|||
GetButtonWaitingTimer = 0;
|
||||
|
||||
// Update the old textbox
|
||||
SetButtonText(GetButtonWaitingID, "");
|
||||
SetButtonText(GetButtonWaitingID, (char *)"");
|
||||
}
|
||||
|
||||
// Save the button Id
|
||||
GetButtonWaitingID = GetId;
|
||||
GetButtonWaitingID = _GetId;
|
||||
|
||||
// Reset the key in case we happen to have an old one
|
||||
g_Pressed = 0;
|
||||
|
||||
// Update the text box
|
||||
sprintf(format, "[%d]", Seconds);
|
||||
SetButtonText(GetId, format);
|
||||
SetButtonText(_GetId, format);
|
||||
|
||||
// Start the timer
|
||||
#if wxUSE_TIMER
|
||||
m_ButtonMappingTimer->Start( floor((double)(1000 / TimesPerSecond)) );
|
||||
#endif
|
||||
INFO_LOG(CONSOLE, "Timer Started for Pad:%i GetId:%i\n"
|
||||
INFO_LOG(CONSOLE, "Timer Started for Pad:%i _GetId:%i\n"
|
||||
"Allowed input is Axis:%i LeftRight:%i XInput:%i Button:%i Hat:%i\n",
|
||||
WiiMoteEmu::PadMapping[Controller].ID, GetId,
|
||||
WiiMoteEmu::PadMapping[Controller].ID, _GetId,
|
||||
Axis, LeftRight, XInput, Button, Hat);
|
||||
}
|
||||
|
||||
|
@ -575,7 +566,7 @@ void ConfigDialog::DoGetButtons(int GetId)
|
|||
|
||||
// Update text
|
||||
sprintf(format, "[%d]", TmpTime);
|
||||
SetButtonText(GetId, format);
|
||||
SetButtonText(_GetId, format);
|
||||
|
||||
/* Debug
|
||||
INFO_LOG(CONSOLE, "Keyboard: %i\n", g_Pressed);*/
|
||||
|
@ -586,7 +577,7 @@ void ConfigDialog::DoGetButtons(int GetId)
|
|||
{
|
||||
Stop = true;
|
||||
// Leave a blank mapping
|
||||
SetButtonTextAll(GetId, "-1");
|
||||
SetButtonTextAll(_GetId, (char *)"-1");
|
||||
}
|
||||
|
||||
// If we got a button
|
||||
|
@ -595,7 +586,7 @@ void ConfigDialog::DoGetButtons(int GetId)
|
|||
Stop = true;
|
||||
// Write the number of the pressed button to the text box
|
||||
sprintf(format, "%d", pressed);
|
||||
SetButtonTextAll(GetId, format);
|
||||
SetButtonTextAll(_GetId, format);
|
||||
}
|
||||
|
||||
// Stop the timer
|
||||
|
@ -604,21 +595,23 @@ void ConfigDialog::DoGetButtons(int GetId)
|
|||
m_ButtonMappingTimer->Stop();
|
||||
GetButtonWaitingTimer = 0;
|
||||
|
||||
/* Update the button mapping for all slots that use this device. (It doesn't make sense to have several slots
|
||||
controlled by the same device, but several DirectInput instances of different but identical devices may possible
|
||||
have the same id, I don't know. So we have to do this. The user may also have selected the same device for
|
||||
several disabled slots. */
|
||||
/* Update the button mapping for all slots that use this device. (It
|
||||
doesn't make sense to have several slots controlled by the same
|
||||
device, but several DirectInput instances of different but identical
|
||||
devices may possible have the same id, I don't know. So we have to
|
||||
do this. The user may also have selected the same device for several
|
||||
disabled slots. */
|
||||
SaveButtonMappingAll(Controller);
|
||||
|
||||
INFO_LOG(CONSOLE, "Timer Stopped for Pad:%i GetId:%i\n",
|
||||
WiiMoteEmu::PadMapping[Controller].ID, GetId);
|
||||
INFO_LOG(CONSOLE, "Timer Stopped for Pad:%i _GetId:%i\n",
|
||||
WiiMoteEmu::PadMapping[Controller].ID, _GetId);
|
||||
}
|
||||
|
||||
// If we got a bad button
|
||||
if(g_Pressed == -1)
|
||||
{
|
||||
// Update text
|
||||
SetButtonTextAll(GetId, "-1");
|
||||
SetButtonTextAll(_GetId, (char *)"-1");
|
||||
|
||||
// Notify the user
|
||||
wxMessageBox(wxString::Format(wxT(
|
||||
|
@ -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()
|
||||
);*/
|
||||
}
|
||||
/////////////////////////////////////////////////////////// Configure button mapping
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Show current input status
|
||||
// ¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Convert the 0x8000 range values to BoxW and BoxH for the plot
|
||||
void ConfigDialog::Convert2Box(int &x)
|
||||
{
|
||||
// Border adjustment
|
||||
int BoxW_ = BoxW - 2; int BoxH_ = BoxH - 2;
|
||||
int BoxW_ = BoxW - 2;// int BoxH_ = BoxH - 2;
|
||||
|
||||
// Convert values
|
||||
x = (BoxW_ / 2) + (x * BoxW_ / (32767 * 2));
|
||||
}
|
||||
|
||||
// Update the input status boxes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigDialog::PadGetStatus()
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "SDL_WasInit: %i\n", SDL_WasInit(0));
|
||||
|
||||
/* Return if it's not detected. The ID should never be less than zero here, it can only be that
|
||||
because of a manual ini file change, but we make that check anway. */
|
||||
/* Return if it's not detected. The ID should never be less than zero here,
|
||||
it can only be that because of a manual ini file change, but we make
|
||||
that check anway. */
|
||||
if(WiiMoteEmu::PadMapping[Page].ID < 0 || WiiMoteEmu::PadMapping[Page].ID >= SDL_NumJoysticks())
|
||||
{
|
||||
m_TStatusLeftIn[Page]->SetLabel(wxT("Not connected"));
|
||||
|
@ -685,17 +674,15 @@ void ConfigDialog::PadGetStatus()
|
|||
}
|
||||
|
||||
// Get physical device status
|
||||
int PhysicalDevice = WiiMoteEmu::PadMapping[Page].ID;
|
||||
int TriggerType = WiiMoteEmu::PadMapping[Page].triggertype;
|
||||
// int PhysicalDevice = WiiMoteEmu::PadMapping[Page].ID;
|
||||
// int TriggerType = WiiMoteEmu::PadMapping[Page].triggertype;
|
||||
|
||||
// Check that Dolphin is in focus, otherwise don't update the pad status
|
||||
//if (IsFocus())
|
||||
WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page, WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Page].ID).NumButtons);
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
// Analog stick
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Set Deadzones perhaps out of function
|
||||
//int deadzone = (int)(((float)(128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
|
||||
//int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
|
||||
|
@ -732,9 +719,7 @@ void ConfigDialog::PadGetStatus()
|
|||
right_y_after = 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------
|
||||
// Show the adjusted angles in the status box
|
||||
// --------------
|
||||
// Change 0x8000 to 180
|
||||
/*
|
||||
float x8000 = 0x8000;
|
||||
|
@ -750,7 +735,6 @@ void ConfigDialog::PadGetStatus()
|
|||
main_x_after = main_x_after * (x8000 / 180);
|
||||
main_y_after = main_y_after * (x8000 / 180);
|
||||
*/
|
||||
// ---------------------
|
||||
|
||||
// Convert the values to fractions
|
||||
float f_x = main_x / 32767.0;
|
||||
|
@ -788,13 +772,9 @@ void ConfigDialog::PadGetStatus()
|
|||
m_bmpDotLeftOut[Page]->SetPosition(wxPoint(main_x_after, main_y_after));
|
||||
m_bmpDotRightIn[Page]->SetPosition(wxPoint(right_x, right_y));
|
||||
m_bmpDotRightOut[Page]->SetPosition(wxPoint(right_x_after, right_y_after));
|
||||
///////////////////// Analog stick
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
// Triggers
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
int TriggerValue = 0;
|
||||
|
||||
// Get the selected keys
|
||||
long Left, Right;
|
||||
|
@ -816,11 +796,9 @@ void ConfigDialog::PadGetStatus()
|
|||
wxT("%03i"), TriggerLeft));
|
||||
m_TriggerStatusRx[Page]->SetLabel(wxString::Format(
|
||||
wxT("%03i"), TriggerRight));
|
||||
///////////////////// Triggers
|
||||
}
|
||||
|
||||
// Populate the advanced tab
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event))
|
||||
{
|
||||
// Show the current status
|
||||
|
@ -835,4 +813,3 @@ void ConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event))
|
|||
|
||||
PadGetStatus();
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
//#include "Common.h" // for u16
|
||||
#include "CommonTypes.h" // for u16
|
||||
#include "IniFile.h"
|
||||
#include "Timer.h"
|
||||
|
@ -31,9 +27,6 @@
|
|||
#include "Config.h"
|
||||
#include "EmuMain.h" // for LoadRecordedMovements()
|
||||
#include "EmuSubroutines.h" // for WmRequestStatus
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
void ConfigDialog::LoadFile()
|
||||
{
|
||||
|
@ -123,18 +116,12 @@ void ConfigDialog::SaveFile()
|
|||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Create GUI
|
||||
// ------------
|
||||
void ConfigDialog::CreateGUIControlsRecording()
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Real Wiimote
|
||||
// ----------------
|
||||
|
||||
// ---------------------------------------------
|
||||
// Status
|
||||
// ----------------
|
||||
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"));
|
||||
|
||||
|
@ -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"
|
||||
"configuration screen. Remember that you also need to press '+' on your Wiimote before you can record movements."
|
||||
));
|
||||
// -----------------------
|
||||
|
||||
// Width and height of the gauges
|
||||
static const int Gw = 35, Gh = 110;
|
||||
|
@ -162,9 +148,7 @@ void ConfigDialog::CreateGUIControlsRecording()
|
|||
// The text controls
|
||||
m_TextIR = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Cursor: 000 000\nDistance: 0000"));
|
||||
|
||||
// ------------------------------------
|
||||
// The sizers for all gauges together with their label
|
||||
// -----------
|
||||
wxBoxSizer * sBoxBattery = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer * sBoxRoll[2];
|
||||
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_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);
|
||||
// ----------------
|
||||
|
||||
// ----------------------------------------------
|
||||
// Row 1 Sizers
|
||||
// -----------
|
||||
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);
|
||||
|
@ -231,16 +212,12 @@ void ConfigDialog::CreateGUIControlsRecording()
|
|||
sbRealWiimoteStatus->Add(sbRealRoll, 0, wxEXPAND | (wxLEFT), 5);
|
||||
sbRealWiimoteStatus->Add(sbRealGForce, 0, wxEXPAND | (wxLEFT), 5);
|
||||
sbRealWiimoteStatus->Add(sbRealAccel, 0, wxEXPAND | (wxLEFT), 5);
|
||||
// --------------------
|
||||
|
||||
// Tool tips
|
||||
m_GaugeBattery->SetToolTip(wxT("Press '+' to show the current status. Press '-' to stop recording the status."));
|
||||
// ==========================================
|
||||
|
||||
|
||||
// ====================================================================
|
||||
// Record movement
|
||||
// ----------------
|
||||
wxStaticBoxSizer * sbRealRecord = new wxStaticBoxSizer(wxVERTICAL, m_PageRecording, wxT("Record movements"));
|
||||
|
||||
wxArrayString StrHotKeySwitch;
|
||||
|
@ -322,9 +299,7 @@ void ConfigDialog::CreateGUIControlsRecording()
|
|||
m_RecordIRBytesText[i]->Enable(false);
|
||||
m_RecordSpeed[i]->Enable(false);
|
||||
|
||||
// ------------------------------------
|
||||
// Row 2 Sizers
|
||||
// -----------
|
||||
sRealRecord[i]->Add(m_RecordButton[i], 0, wxEXPAND | (wxLEFT), 5);
|
||||
sRealRecord[i]->Add(m_RecordHotKeySwitch[i], 0, wxEXPAND | (wxLEFT), 5);
|
||||
sRealRecord[i]->Add(m_RecordHotKeyWiimote[i], 0, wxEXPAND | (wxLEFT), 2);
|
||||
|
@ -338,24 +313,17 @@ void ConfigDialog::CreateGUIControlsRecording()
|
|||
|
||||
sbRealRecord->Add(sRealRecord[i], 0, wxEXPAND | (wxTOP), 2);
|
||||
}
|
||||
// ==========================================
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Set up sizers for the whole page
|
||||
// ----------------
|
||||
m_sRecordingMain = new wxBoxSizer(wxVERTICAL);
|
||||
m_sRecordingMain->Add(sbRealWiimoteStatus, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxUP), 5);
|
||||
m_sRecordingMain->Add(sbRealRecord, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
|
||||
|
||||
m_PageRecording->SetSizer(m_sRecordingMain);
|
||||
}
|
||||
/////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/* Record movement */
|
||||
// ------------
|
||||
|
||||
void ConfigDialog::ConvertToString()
|
||||
{
|
||||
// Load ini file
|
||||
|
@ -382,8 +350,10 @@ void ConfigDialog::ConvertToString()
|
|||
TmpTime += StringFromFormat("%05i", Time);
|
||||
if (i < ((int)m_vRecording.size() - 1)) TmpTime += ",";
|
||||
|
||||
/* Break just short of the IniFile.cpp byte limit so that we don't crash file.Load() the next time.
|
||||
This limit should never be hit because of the recording limit below. I keep it here just in case. */
|
||||
/* Break just short of the IniFile.cpp byte limit so that we don't
|
||||
crash file.Load() the next time. This limit should never be hit
|
||||
because of the recording limit below. I keep it here just in
|
||||
case. */
|
||||
if(TmpStr.length() > (1024*10 - 10) || TmpIR.length() > (1024*10 - 10) || TmpTime.length() > (1024*10 - 10))
|
||||
{
|
||||
break;
|
||||
|
@ -452,8 +422,8 @@ void ConfigDialog::RecordMovement(wxCommandEvent& event)
|
|||
else
|
||||
{
|
||||
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Press +"));
|
||||
// This is for usability purposes, it may not be obvious at all that this must be unchecked
|
||||
// for the recording to work
|
||||
// This is for usability purposes, it may not be obvious at all that
|
||||
// this must be unchecked for the recording to work
|
||||
for(int i = 0; i < 1; i++) m_UseRealWiimote[i]->SetValue(false); g_Config.bUseRealWiimote = false;
|
||||
return;
|
||||
}
|
||||
|
@ -531,5 +501,4 @@ void ConfigDialog::DoRecordMovement(int _x, int _y, int _z, const u8 *_IR, int _
|
|||
UpdateGUI();
|
||||
}
|
||||
}
|
||||
/////////////////////////////////
|
||||
|
||||
|
|
|
@ -17,21 +17,19 @@
|
|||
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Data reports guide. The different structures location in the Input reports. The ? in
|
||||
the IR coordinates is the High coordinates that are four in one byte.
|
||||
/* Data reports guide. The different structures location in the Input
|
||||
reports. The ? in the IR coordinates is the High coordinates that are four
|
||||
in one byte.
|
||||
|
||||
0x37: For the data reportingmode 0x37 there are five unused IR bytes in the end (represented)
|
||||
by "..." below, it seems like they can be set to either 0xff or 0x00 without affecting the
|
||||
IR emulation. */
|
||||
// ----------------
|
||||
0x37: For the data reportingmode 0x37 there are five unused IR bytes in the
|
||||
end (represented) by "..." below, it seems like they can be set to either
|
||||
0xff or 0x00 without affecting the IR emulation. */
|
||||
|
||||
/* 0x33
|
||||
[c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y ?
|
||||
/* 0x33 [c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y
|
||||
?
|
||||
|
||||
0x37
|
||||
[c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2 ... ext.jx jy ax ay az bt
|
||||
0x37 [c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2
|
||||
... ext.jx jy ax ay az bt
|
||||
|
||||
|
||||
The Data Report's path from here is
|
||||
|
@ -41,15 +39,9 @@
|
|||
WII_IPC_HLE_Device_usb.cpp:
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame()
|
||||
at that point the message is queued and will be sent by the next
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() */
|
||||
|
||||
// ================
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include <vector>
|
||||
|
@ -64,17 +56,10 @@
|
|||
#include "EmuSubroutines.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations and definitions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
@ -84,12 +69,9 @@ namespace WiiMoteEmu
|
|||
//******************************************************************************
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Update the data reporting mode */
|
||||
// ----------------
|
||||
void WmDataReporting(u16 _channelID, wm_data_reporting* dr)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Set Data reporting mode");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Rumble: %x", dr->rumble);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Continuous: %x", dr->continuous);
|
||||
|
@ -117,14 +99,11 @@ void WmDataReporting(u16 _channelID, wm_data_reporting* dr)
|
|||
|
||||
// WmSendAck(_channelID, WM_DATA_REPORTING);
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x30: Core Buttons */
|
||||
// ----------------
|
||||
void SendReportCore(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
|
@ -146,9 +125,7 @@ void SendReportCore(u16 _channelID)
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* 0x31: Core Buttons and Accelerometer */
|
||||
// ----------------
|
||||
void SendReportCoreAccel(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
|
@ -174,9 +151,7 @@ void SendReportCoreAccel(u16 _channelID)
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x33: Core Buttons and Accelerometer with 12 IR bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelIr12(u16 _channelID) {
|
||||
u8 DataFrame[1024];
|
||||
u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR12);
|
||||
|
@ -205,9 +180,7 @@ void SendReportCoreAccelIr12(u16 _channelID) {
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Case 0x35: Core Buttons and Accelerometer with 16 Extension Bytes */
|
||||
// ----------------
|
||||
void SendReportCoreAccelExt16(u16 _channelID)
|
||||
{
|
||||
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 */
|
||||
// ----------------
|
||||
void SendReportCoreAccelIr10Ext(u16 _channelID)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#ifndef _EMU_DEFINITIONS_
|
||||
#define _EMU_DEFINITIONS_
|
||||
|
||||
|
@ -29,8 +26,6 @@
|
|||
#include "wiimote_hid.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Encryption.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
//////////////////////////
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "wiimote_hid.h" // Local
|
||||
#include "Encryption.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -37,9 +34,7 @@
|
|||
#include "EmuSubroutines.h"
|
||||
#include "EmuMain.h"
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
namespace WiiMoteEmu
|
||||
|
@ -51,9 +46,7 @@ namespace WiiMoteEmu
|
|||
//******************************************************************************
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Test the calculations
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void TiltTest(u8 x, u8 y, u8 z)
|
||||
{
|
||||
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());
|
||||
INFO_LOG(CONSOLE, "%s\n", To.c_str());
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Angles adjustment for the upside down state when both roll and pitch is used. When the absolute values
|
||||
of the angles go over 90° the Wiimote is upside down and these adjustments are needed. */
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Angles adjustment for the upside down state when both roll and pitch is
|
||||
used. When the absolute values of the angles go over 90° the Wiimote is
|
||||
upside down and these adjustments are needed. */
|
||||
void AdjustAngles(float &Roll, float &Pitch)
|
||||
{
|
||||
float OldPitch = Pitch;
|
||||
|
@ -96,12 +87,9 @@ void AdjustAngles(float &Roll, float &Pitch)
|
|||
Roll = -180 - Roll; // -15 to -165
|
||||
}
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Angles to accelerometer values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_z)
|
||||
{
|
||||
// We need radiands for the math functions
|
||||
|
@ -125,21 +113,22 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
|
|||
else
|
||||
{
|
||||
// ====================================================
|
||||
/* This seems to always produce the exact same combination of x, y, z and Roll and Pitch that the
|
||||
real Wiimote produce. There is an unlimited amount of x, y, z combinations for any combination of
|
||||
Roll and Pitch. But if we select a Z from the smallest of the absolute value of cos(Roll) and
|
||||
cos (Pitch) we get the right values. */
|
||||
/* This seems to always produce the exact same combination of x, y, z
|
||||
and Roll and Pitch that the real Wiimote produce. There is an
|
||||
unlimited amount of x, y, z combinations for any combination of Roll
|
||||
and Pitch. But if we select a Z from the smallest of the absolute
|
||||
value of cos(Roll) and cos (Pitch) we get the right values. */
|
||||
// ---------
|
||||
if (abs(cos(_Roll)) < abs(cos(_Pitch))) z = cos(_Roll); else z = cos(_Pitch);
|
||||
/* I got these from reversing the calculation in PitchAccelerometerToDegree() in a math program
|
||||
I don't know if we can derive these from some kind of matrix or something */
|
||||
/* I got these from reversing the calculation in
|
||||
PitchAccelerometerToDegree() in a math program I don't know if we
|
||||
can derive these from some kind of matrix or something */
|
||||
float x_num = 2 * tanf(0.5f * _Roll) * z;
|
||||
float x_den = pow2f(tanf(0.5f * _Roll)) - 1;
|
||||
x = - (x_num / x_den);
|
||||
float y_num = 2 * tanf(0.5f * _Pitch) * z;
|
||||
float y_den = pow2f(tanf(0.5f * _Pitch)) - 1;
|
||||
y = - (y_num / y_den);
|
||||
// =========================
|
||||
}
|
||||
|
||||
// Multiply with the neutral of z and its g
|
||||
|
@ -162,9 +151,7 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_
|
|||
_z = iz;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Accelerometer to roll and pitch angles
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
float AccelerometerToG(float Current, float Neutral, float G)
|
||||
{
|
||||
float _G = (Current - Neutral) / G;
|
||||
|
@ -214,11 +201,7 @@ void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, in
|
|||
// IR data functions
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the basic 10 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2DotsBasic(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
|
@ -258,9 +241,7 @@ void IRData2DotsBasic(u8 *Data)
|
|||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2Dots(u8 *Data)
|
||||
{
|
||||
struct SDot* Dot = g_Wm.IR.Dot;
|
||||
|
@ -290,12 +271,9 @@ void IRData2Dots(u8 *Data)
|
|||
ReorderIRDots();
|
||||
IRData2Distance();
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Reorder the IR dots according to their x-axis value
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ReorderIRDots()
|
||||
{
|
||||
// Create a shortcut
|
||||
|
@ -326,12 +304,9 @@ void ReorderIRDots()
|
|||
Dot[i].Order = order;
|
||||
}
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Calculate dot positions from the extented 12 byte IR data
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void IRData2Distance()
|
||||
{
|
||||
// Create a shortcut
|
||||
|
@ -361,7 +336,6 @@ void IRData2Distance()
|
|||
// Save the distance
|
||||
g_Wm.IR.Distance = (int)sqrt((float)(xd*xd) + (float)(yd*yd));
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
|
@ -380,4 +354,4 @@ std::string CCData2Values(u8 *Data)
|
|||
(Data[2] & 0x1f));
|
||||
}
|
||||
|
||||
} // WiiMoteEmu
|
||||
} // WiiMoteEmu
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -36,17 +34,14 @@
|
|||
#include "EmuSubroutines.h"
|
||||
#include "EmuMain.h"
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
////////////////////////////////////
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
// ===================================================
|
||||
/* Bit shift conversions */
|
||||
// -------------
|
||||
u32 convert24bit(const u8* src) {
|
||||
return (src[0] << 16) | (src[1] << 8) | src[2];
|
||||
}
|
||||
|
@ -54,12 +49,9 @@ u32 convert24bit(const u8* src) {
|
|||
u16 convert16bit(const u8* src) {
|
||||
return (src[0] << 8) | src[1];
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */
|
||||
// ----------------
|
||||
void GetMousePos(float& x, float& y)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -184,12 +176,9 @@ void GetMousePos(float& x, float& y)
|
|||
y = 0.5f;
|
||||
#endif
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Homebrew encryption for 16 byte zero keys. */
|
||||
// ----------------
|
||||
void CryptBuffer(u8* _buffer, u8 _size)
|
||||
{
|
||||
for (int i=0; i<_size; i++)
|
||||
|
@ -204,30 +193,23 @@ void WriteCrypted16(u8* _baseBlock, u16 _address, u16 _value)
|
|||
CryptBuffer((u8*)&cryptedValue, sizeof(u16));
|
||||
|
||||
*(u16*)(_baseBlock + _address) = cryptedValue;
|
||||
//PanicAlert("Converted %04x to %04x", _value, cryptedValue);
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* 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()
|
||||
{
|
||||
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];
|
||||
u8 Check1 = sum + 0x55;
|
||||
u8 Check2 = sum + 0xaa;
|
||||
INFO_LOG(CONSOLE, "0x%02x 0x%02x", Check1, Check2);
|
||||
|
||||
INFO_LOG(CONSOLE, "0x%02x 0x%02x", (sum + 0x55), (sum + 0xaa));
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Load pre-recorded movements */
|
||||
// ----------------
|
||||
void LoadRecordedMovements()
|
||||
{
|
||||
INFO_LOG(CONSOLE, "LoadRecordedMovements()\n");
|
||||
|
@ -282,12 +264,12 @@ void LoadRecordedMovements()
|
|||
Tmp.y = atoi(StrY.c_str());
|
||||
Tmp.z = atoi(StrZ.c_str());
|
||||
|
||||
// ---------------------------------
|
||||
// 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
|
||||
// but we check for it anyway
|
||||
if (TmpIRBytes == 0) for(int i = 0; i < 12; i++) Tmp.IR[i] = 0;
|
||||
|
||||
// If there is no IR data saving we fill the array with
|
||||
// zeroes. This should only be able to occur from manual ini
|
||||
// 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++)
|
||||
{
|
||||
if(TmpIR.length() < (u32)(k + i + TmpIRBytes)) continue; // Safety check
|
||||
|
@ -297,7 +279,6 @@ void LoadRecordedMovements()
|
|||
Tmp.IR[ii] = (u8)TmpU32;
|
||||
}
|
||||
if (TmpIRBytes == 10) k += (10*2 + 1); else k += (12*2 + 1);
|
||||
// ---------------------
|
||||
|
||||
// Go to next set of time values
|
||||
double Time = (double)atoi(TmpTime.substr(l, 5).c_str());
|
||||
|
@ -307,9 +288,7 @@ void LoadRecordedMovements()
|
|||
// Save the values
|
||||
VRecording.at(i).Recording.push_back(Tmp);
|
||||
|
||||
// ---------------------------------
|
||||
// Log results
|
||||
// ---------
|
||||
/*INFO_LOG(CONSOLE, "Time:%f\n", Tmp.Time);
|
||||
std::string TmpIRLog = ArrayToString(Tmp.IR, TmpIRBytes, 0, 30);
|
||||
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);
|
||||
VRecording.at(i).PlaybackSpeed = TmpPlaybackSpeed;
|
||||
|
||||
// ---------------------------------
|
||||
// Logging
|
||||
// ---------
|
||||
/*std::string TmpIRLog;
|
||||
if(TmpIRBytes > 0 && VRecording.size() > i)
|
||||
TmpIRLog = ArrayToString(VRecording.at(i).Recording.at(0).IR, TmpIRBytes, 0, 30);
|
||||
|
@ -340,10 +317,8 @@ void LoadRecordedMovements()
|
|||
TmpIRLog.c_str(),
|
||||
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
|
||||
void UpdateEeprom()
|
||||
|
@ -407,24 +382,19 @@ void UpdateEeprom()
|
|||
// Calculate checksum for the nunchuck calibration. The last two bytes.
|
||||
void ExtensionChecksum(u8 * Calibration)
|
||||
{
|
||||
u8 sum = 0; u8 Byte15, Byte16;
|
||||
for (int i = 0; i < sizeof(Calibration) - 2; i++)
|
||||
u8 sum = 0; //u8 Byte15, Byte16;
|
||||
for (u32 i = 0; i < sizeof(Calibration) - 2; i++)
|
||||
{
|
||||
sum += Calibration[i];
|
||||
printf("Plus 0x%02x\n", Calibration[i]);
|
||||
}
|
||||
Byte15 = sum + 0x55; // Byte 15
|
||||
Byte16 = sum + 0xaa; // Byte 16
|
||||
// Byte15 = sum + 0x55; // Byte 15
|
||||
// Byte16 = sum + 0xaa; // Byte 16
|
||||
}
|
||||
|
||||
// Set initial valuesm this done both in Init and Shutdown
|
||||
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_ReportingChannel = 0;
|
||||
g_Encryption = false;
|
||||
|
@ -466,9 +436,7 @@ void SetDefaultExtensionRegistry()
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Write initial values to Eeprom and registers. */
|
||||
// ----------------
|
||||
void Initialize()
|
||||
{
|
||||
if (g_EmulatedWiiMoteInitialized) return;
|
||||
|
@ -476,14 +444,15 @@ void Initialize()
|
|||
// Reset variables
|
||||
ResetVariables();
|
||||
|
||||
// Write default Eeprom data to g_Eeprom[], this may be overwritten by WiiMoteReal::Initialize()
|
||||
// after this function.
|
||||
// Write default Eeprom data to g_Eeprom[], this may be overwritten by
|
||||
// WiiMoteReal::Initialize() after this function.
|
||||
memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE);
|
||||
memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0));
|
||||
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
|
||||
not already open, if it's already open we continue with the settings we have */
|
||||
/* Populate joyinfo for all attached devices and do g_Config.Load() if the
|
||||
configuration window is not already open, if it's already open we
|
||||
continue with the settings we have */
|
||||
if(!g_FrameOpen)
|
||||
{
|
||||
Search_Devices(joyinfo, NumPads, NumGoodPads);
|
||||
|
@ -498,15 +467,15 @@ void Initialize()
|
|||
// Load pre-recorded movements
|
||||
LoadRecordedMovements();
|
||||
|
||||
/* The Nuncheck extension ID for homebrew applications that use the zero key. This writes 0x0000
|
||||
in encrypted form (0xfefe) to 0xfe in the extension register. */
|
||||
/* The Nuncheck extension ID for homebrew applications that use the zero
|
||||
key. This writes 0x0000 in encrypted form (0xfefe) to 0xfe in the
|
||||
extension register. */
|
||||
//WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk
|
||||
|
||||
// I forgot what these were for? Is this the zero key encrypted 0xa420?
|
||||
// g_RegExt[0xfd] = 0x1e;
|
||||
// g_RegExt[0xfc] = 0x9a;
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
void DoState(void* ptr, int mode)
|
||||
|
@ -514,24 +483,24 @@ void DoState(void* ptr, int mode)
|
|||
//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
|
||||
these variables. */
|
||||
/* This is not needed if we call FreeLibrary() when we stop a game, but if it's
|
||||
not called we need to reset these variables. */
|
||||
void Shutdown(void)
|
||||
{
|
||||
INFO_LOG(CONSOLE, "ShutDown\n");
|
||||
|
||||
ResetVariables();
|
||||
|
||||
/* Close all devices carefully. We must check that we are not accessing any undefined
|
||||
vector elements or any bad devices */
|
||||
/* Close all devices carefully. We must check that we are not accessing any
|
||||
undefined vector elements or any bad devices */
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
if (PadMapping[i].enabled && joyinfo.size() > (u32)PadMapping[i].ID)
|
||||
if (joyinfo.at(PadMapping[i].ID).Good)
|
||||
{
|
||||
INFO_LOG(CONSOLE, "ShutDown: %i\n", PadState[i].joy);
|
||||
/* SDL_JoystickClose() crashes for some reason so I avoid this for now, SDL_Quit() should
|
||||
close the pads to I think */
|
||||
/* SDL_JoystickClose() crashes for some reason so I avoid this
|
||||
for now, SDL_Quit() should close the pads to I think */
|
||||
//if(SDL_JoystickOpened(PadMapping[i].ID)) SDL_JoystickClose(PadState[i].joy);
|
||||
//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 between 20 ms and
|
||||
100 ms in my case in Zelda - TP. You may have to increase this value for other things to work, for
|
||||
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
|
||||
an update rate of around 150 fps in the wpad demo) */
|
||||
// ----------------
|
||||
/* An ack delay of 1 was not small enough, but 2 seemed to work, that was about
|
||||
between 20 ms and 100 ms in my case in Zelda - TP. You may have to increase
|
||||
this value for other things to work, for 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 an update
|
||||
rate of around 150 fps in the wpad demo) */
|
||||
void CreateAckDelay(u8 _ChannelID, u16 _ReportID)
|
||||
{
|
||||
// Settings
|
||||
|
@ -586,23 +554,20 @@ void CheckAckDelay()
|
|||
}
|
||||
}
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* This function produce Wiimote Input, i.e. reports from the Wiimote in response
|
||||
to Output from the Wii. */
|
||||
// ----------------
|
||||
/* This function produce Wiimote Input, i.e. reports from the Wiimote in
|
||||
response to Output from the Wii. */
|
||||
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "Emu InterruptChannel\n");
|
||||
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "Wiimote_Input");
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
/* Debugging. We have not yet decided how much of 'data' we will use, it's not determined
|
||||
by sizeof(data). We have to determine it by looking at the data cases. */
|
||||
/* Debugging. We have not yet decided how much of 'data' we will use, it's
|
||||
not determined by sizeof(data). We have to determine it by looking at
|
||||
the data cases. */
|
||||
InterruptDebugging(true, 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;
|
||||
HidOutputReport(_channelID, sr);
|
||||
|
||||
/* This is the 0x22 answer to all Inputs. In most games it didn't matter
|
||||
if it was written before or after HidOutputReport(), but Wii Sports
|
||||
and Mario Galaxy would stop working if it was placed before
|
||||
HidOutputReport(). Zelda - TP is even more sensitive and require
|
||||
a delay after the Input for the Nunchuck to work. It seemed to be
|
||||
enough to delay only the Nunchuck registry reads and writes but
|
||||
for now I'm delaying all inputs. Both for status changes and Eeprom
|
||||
and registry reads and writes. */
|
||||
/* This is the 0x22 answer to all Inputs. In most games it
|
||||
didn't matter if it was written before or after
|
||||
HidOutputReport(), but Wii Sports and Mario Galaxy would
|
||||
stop working if it was placed before
|
||||
HidOutputReport(). Zelda - TP is even more sensitive and
|
||||
require a delay after the Input for the Nunchuck to
|
||||
work. It seemed to be enough to delay only the Nunchuck
|
||||
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
|
||||
// Report 0x10 that seems to be only used for rumble, and we don't need to answer 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
|
||||
// There are no 0x22 replys to these report from the real
|
||||
// wiimote from what I could see Report 0x10 that seems to
|
||||
// be only used for rumble, and we don't need to answer
|
||||
// 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)
|
||||
&& !(data[1] == WM_REQUEST_STATUS)
|
||||
&& !(data[1] == WM_WRITE_SPEAKER_DATA)
|
||||
|
@ -639,7 +608,6 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
|||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
@ -647,11 +615,9 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
|||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, "=============================================================");
|
||||
}
|
||||
|
||||
|
||||
|
@ -676,12 +642,10 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
|||
case HID_TYPE_HANDSHAKE:
|
||||
if (hidp->param == HID_PARAM_INPUT)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_HANDSHAKE - HID_PARAM_INPUT");
|
||||
PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_INPUT");
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT");
|
||||
PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT");
|
||||
}
|
||||
break;
|
||||
|
@ -689,7 +653,6 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
|||
case HID_TYPE_SET_REPORT:
|
||||
if (hidp->param == HID_PARAM_INPUT)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HID_TYPE_SET_REPORT input");
|
||||
PanicAlert("HID_TYPE_SET_REPORT input");
|
||||
}
|
||||
else
|
||||
|
@ -703,12 +666,10 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
|||
break;
|
||||
|
||||
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");
|
||||
break;
|
||||
|
||||
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);
|
||||
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 documentation. I'm
|
||||
not sure exactly how often this function is called but I think it's tied to the frame
|
||||
rate of the game rather than a certain amount of times per second. */
|
||||
// ----------------
|
||||
/* This is called from Wiimote_Update(). See SystemTimers.cpp for a
|
||||
documentation. I'm not sure exactly how often this function is called but I
|
||||
think it's tied to the frame rate of the game rather than a certain amount
|
||||
of times per second. */
|
||||
void Update()
|
||||
{
|
||||
//LOG(WII_IPC_WIIMOTE, "Wiimote_Update");
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -36,18 +33,14 @@
|
|||
#include "EmuSubroutines.h"
|
||||
#include "EmuMain.h"
|
||||
#include "Encryption.h" // for extension encryption
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
////////////////////////////////////
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
namespace WiiMoteEmu
|
||||
{
|
||||
|
||||
// ===================================================
|
||||
// Fill joyinfo with the current connected devices
|
||||
// ----------------
|
||||
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
||||
{
|
||||
bool Success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
|
||||
|
@ -72,11 +65,8 @@ bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_N
|
|||
|
||||
return Success;
|
||||
}
|
||||
// ===========================
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Return adjusted input values
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr)
|
||||
{
|
||||
// This has to be changed if multiple Wiimotes are to be supported later
|
||||
|
@ -126,16 +116,11 @@ void PadStateAdjustments(int &Lx, int &Ly, int &Rx, int &Ry, int &Tl, int &Tr)
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Request joystick state
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Called from: PAD_GetStatus()
|
||||
Input: The virtual device 0, 1, 2 or 3
|
||||
Function: Updates the PadState struct with the current pad status. The input value "controller" is
|
||||
for a virtual controller 0 to 3. */
|
||||
/* Called from: PAD_GetStatus() Input: The virtual device 0, 1, 2 or 3
|
||||
Function: Updates the PadState struct with the current pad status. The input
|
||||
value "controller" is for a virtual controller 0 to 3. */
|
||||
|
||||
void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONTROLLER_MAPPING_NEW _PadMapping, int controller, int NumButtons)
|
||||
{
|
||||
|
@ -188,7 +173,6 @@ void GetJoyState(InputCommon::CONTROLLER_STATE_NEW &_PadState, InputCommon::CONT
|
|||
_PadState.Axis.Lx, _PadState.Axis.Ly
|
||||
);*/
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
} // end of namespace WiiMoteEmu
|
||||
|
|
|
@ -16,11 +16,7 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* HID reports access guide. */
|
||||
// ----------------
|
||||
|
||||
/* 0x10 - 0x1a Output EmuMain.cpp: HidOutputReport()
|
||||
0x10 - 0x14: General
|
||||
|
@ -33,12 +29,6 @@
|
|||
0x10 - 0x1a leads to a 0x22 Input report
|
||||
0x30 - 0x3f Input This file: Update() */
|
||||
|
||||
// ================
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
@ -48,9 +38,7 @@
|
|||
|
||||
#include "EmuMain.h" // Local
|
||||
#include "EmuSubroutines.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // for g_Config
|
||||
/////////////////////////////////
|
||||
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
@ -63,10 +51,10 @@ namespace WiiMoteEmu
|
|||
//******************************************************************************
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Here we process the Output Reports that the Wii sends. Our response will be an Input Report
|
||||
back to the Wii. Input and Output is from the Wii's perspective, Output means data to
|
||||
the Wiimote (from the Wii), Input means data from the Wiimote.
|
||||
/* Here we process the Output Reports that the Wii sends. Our response will be
|
||||
an Input Report back to the Wii. Input and Output is from the Wii's
|
||||
perspective, Output means data to the Wiimote (from the Wii), Input means
|
||||
data from the Wiimote.
|
||||
|
||||
The call browser:
|
||||
|
||||
|
@ -75,10 +63,9 @@ namespace WiiMoteEmu
|
|||
|
||||
The IR lights and speaker enable/disable and mute/unmute values are
|
||||
0x2 = Disable
|
||||
0x6 = Enable */
|
||||
// ----------------
|
||||
0x6 = Enable
|
||||
*/
|
||||
void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "HidOutputReport (0x%02x)", sr->channel);
|
||||
std::string Temp;
|
||||
|
||||
|
@ -102,8 +89,8 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
|
|||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmReadData(_channelID, (wm_read_data*)sr->data);
|
||||
break;
|
||||
|
||||
/* This enables or disables the IR lights, we update the global variable g_IR
|
||||
so that WmRequestStatus() knows about it */
|
||||
/* This enables or disables the IR lights, we update the global variable
|
||||
g_IR so that WmRequestStatus() knows about it */
|
||||
case WM_IR_PIXEL_CLOCK: // 0x13
|
||||
case WM_IR_LOGIC: // 0x1a
|
||||
WARN_LOG(WII_IPC_WIIMOTE, " IR Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
||||
|
@ -132,18 +119,15 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
|
|||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "HidOutputReport: Unknown channel 0x%02x", sr->channel);
|
||||
PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->channel);
|
||||
return;
|
||||
}
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Generate the right header for wm reports. The returned values is the length of the header before
|
||||
the data begins. It's always two for all reports 0x20 - 0x22, 0x30 - 0x37 */
|
||||
// ----------------
|
||||
/* Generate the right header for wm reports. The returned values is the length
|
||||
of the header before the data begins. It's always two for all reports 0x20 -
|
||||
0x22, 0x30 - 0x37 */
|
||||
int WriteWmReport(u8* dst, u8 channel)
|
||||
{
|
||||
// Update the first byte to 0xa1
|
||||
|
@ -161,26 +145,18 @@ int WriteWmReport(u8* dst, u8 channel)
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* LED (blue lights) report. */
|
||||
// ----------------
|
||||
void WmLeds(u16 _channelID, wm_leds* leds) {
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Set LEDs");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Leds: %x", leds->leds);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", leds->rumble);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Set LEDs Leds: %x Rumble: %x", leds->leds, leds->rumble);
|
||||
|
||||
g_Leds = leds->leds;
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* This will generate the 0x22 acknowledgment after all Input reports. It will
|
||||
have the form a1 22 00 00 _reportID 00. The first two bytes are the core buttons data,
|
||||
they are 00 00 when nothing is pressed. The last byte is the success code 00. */
|
||||
// ----------------
|
||||
have the form a1 22 00 00 _reportID 00. The first two bytes are the core
|
||||
buttons data, they are 00 00 when nothing is pressed. The last byte is the
|
||||
success code 00. */
|
||||
void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
|
||||
{
|
||||
u8 DataFrame[1024];
|
||||
|
@ -220,26 +196,22 @@ void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Read data from Wiimote and Extensions registers. */
|
||||
// ----------------
|
||||
void WmReadData(u16 _channelID, wm_read_data* rd)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
u32 address = convert24bit(rd->address);
|
||||
u16 size = convert16bit(rd->size);
|
||||
std::string Temp;
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Address space: %x", rd->space);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Size: 0x%04x", size);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", rd->rumble);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Address space: %x", rd->space);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Address: 0x%06x", address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Size: 0x%04x", size);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Read data Rumble: %x", rd->rumble);
|
||||
|
||||
//u32 _address = address;
|
||||
std::string Tmp; // Debugging
|
||||
|
||||
/* Now we determine what address space we are reading from. Space 0 is Eeprom and
|
||||
space 1 and 2 is the registers. */
|
||||
/* Now we determine what address space we are reading from. Space 0 is
|
||||
Eeprom and space 1 and 2 is the registers. */
|
||||
if(rd->space == WM_SPACE_EEPROM)
|
||||
{
|
||||
if (address + size > WIIMOTE_EEPROM_SIZE)
|
||||
|
@ -286,14 +258,11 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
|
|||
break;
|
||||
default:
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: bad register block!");
|
||||
PanicAlert("WmWriteData: bad register block!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
// Encrypt data that is read from the Wiimote Extension Register
|
||||
// -------------
|
||||
if(((address >> 16) & 0xfe) == 0xa4)
|
||||
{
|
||||
/* 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);
|
||||
}
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "===========================================================");
|
||||
}
|
||||
// ===================================================
|
||||
/* Here we produce the actual 0x21 Input report that we send to the Wii. The message
|
||||
is divided into 16 bytes pieces and sent piece by piece. There will be five formatting
|
||||
bytes at the begging of all reports. A common format is 00 00 f0 00 20, the 00 00
|
||||
means that no buttons are pressed, the f means 16 bytes in the message, the 0
|
||||
means no error, the 00 20 means that the message is at the 00 20 offest in the
|
||||
registry that was read.
|
||||
|
||||
/* Here we produce the actual 0x21 Input report that we send to the Wii. The
|
||||
message is divided into 16 bytes pieces and sent piece by piece. There will
|
||||
be five formatting bytes at the begging of all reports. A common format is
|
||||
00 00 f0 00 20, the 00 00 means that no buttons are pressed, the f means 16
|
||||
bytes in the message, the 0 means no error, the 00 20 means that the message
|
||||
is at the 00 20 offest in the registry that was read.
|
||||
|
||||
_Base: The data beginning at _Base[0]
|
||||
_Address: The starting address inside the registry, this is used to check for out of bounds reading
|
||||
_Size: The total size to send
|
||||
_Base: The data beginning at _Base[0] _Address: The starting address inside
|
||||
the registry, this is used to check for out of bounds reading _Size: The
|
||||
total size to send
|
||||
*/
|
||||
// ----------------
|
||||
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "=========================================");
|
||||
int dataOffset = 0;
|
||||
const u8* data = (const u8*)_Base;
|
||||
|
||||
|
@ -389,10 +355,11 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
|
|||
// Update DataOffset for the next loop
|
||||
dataOffset += copySize;
|
||||
|
||||
/* Out of bounds. The real Wiimote generate an error for the first request to 0x1770
|
||||
if we dont't replicate that the game will never read the capibration data at the
|
||||
beginning of Eeprom. I think this error is supposed to occur when we try to read above
|
||||
the freely usable space that ends at 0x16ff. */
|
||||
/* Out of bounds. The real Wiimote generate an error for the first
|
||||
request to 0x1770 if we dont't replicate that the game will never
|
||||
read the capibration data at the beginning of Eeprom. I think this
|
||||
error is supposed to occur when we try to read above the freely
|
||||
usable space that ends at 0x16ff. */
|
||||
if (Common::swap16(pReply->address + pReply->size) > WIIMOTE_EEPROM_FREE_SIZE)
|
||||
{
|
||||
pReply->size = 0x0f;
|
||||
|
@ -424,20 +391,14 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
|
|||
}
|
||||
|
||||
if (_Size != 0) {
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WiiMote-Plugin: SendReadDataReply() failed");
|
||||
PanicAlert("WiiMote-Plugin: SendReadDataReply() failed");
|
||||
}
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "==========================================");
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Write data to Wiimote and Extensions registers. */
|
||||
// ----------------
|
||||
void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
{
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "========================================================");
|
||||
u32 address = convert24bit(wd->address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Write data");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Address space: %x", wd->space);
|
||||
|
@ -477,9 +438,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
|||
case 0xA4:
|
||||
block = g_RegExt; // Extension Controller register
|
||||
blockSize = WIIMOTE_REG_EXT_SIZE;
|
||||
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Case 0xa4: ExtReg");
|
||||
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
|
||||
/*INFO_LOG(CONSOLE, "Write RegExt Size: %i Address: %08x Offset: %08x \n",
|
||||
wd->size, address, (address & 0xffff));
|
||||
INFO_LOG(CONSOLE, "Data: %s\n", Temp.c_str());*/
|
||||
|
@ -503,7 +462,6 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
|||
|
||||
// Check if the address is within bounds
|
||||
if(address + wd->size > blockSize) {
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: address + size out of bounds!");
|
||||
PanicAlert("WmWriteData: address + size out of bounds!");
|
||||
return;
|
||||
}
|
||||
|
@ -512,9 +470,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
|||
memcpy(block + address, wd->data, wd->size);
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
// Generate key for the Wiimote Extension
|
||||
// -------------
|
||||
if(blockSize == WIIMOTE_REG_EXT_SIZE)
|
||||
{
|
||||
/* Debugging. Write the data.
|
||||
|
@ -531,29 +487,23 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
|||
|
||||
|
||||
} else {
|
||||
ERROR_LOG(WII_IPC_WIIMOTE, "WmWriteData: unimplemented parameters!");
|
||||
PanicAlert("WmWriteData: unimplemented parameters!");
|
||||
}
|
||||
|
||||
/* Just added for home brew... Isn't it enough that we call this from
|
||||
InterruptChannel()? Or is there a separate route here that don't pass though
|
||||
InterruptChannel()? */
|
||||
InterruptChannel()? Or is there a separate route here that don't pass
|
||||
though InterruptChannel()? */
|
||||
//WmSendAck(_channelID, WM_WRITE_DATA, _address);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "==========================================================");
|
||||
}
|
||||
|
||||
// ===================================================
|
||||
/* Here we produce a 0x20 status report to send to the Wii. We currently ignore the status
|
||||
request rs and all its eventual instructions it may include (for example turn off
|
||||
rumble or something else) and just send the status report. */
|
||||
// ----------------
|
||||
/* Here we produce a 0x20 status report to send to the Wii. We currently ignore
|
||||
the status request rs and all its eventual instructions it may include (for
|
||||
example turn off rumble or something else) and just send the status
|
||||
report. */
|
||||
void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
|
||||
{
|
||||
//PanicAlert("WmRequestStatus");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "================================================");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Request Status");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Rumble: %x", rs->rumble);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Channel: %04x", _channelID);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " Request Status: Rumble: %x Channel: %04x",
|
||||
rs->rumble, _channelID);
|
||||
|
||||
//SendStatusReport();
|
||||
u8 DataFrame[1024];
|
||||
|
@ -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, " SendStatusReport()");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%02x", pStatus->padding1[2]);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Battery: %d", pStatus->battery);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendStatusReport() Flags: 0x%02x Battery: %d"
|
||||
pStatus->padding1[2], pStatus->battery);
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "=================================================");
|
||||
|
||||
|
||||
// Debugging
|
||||
ReadDebugging(true, DataFrame, Offset);
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
#ifndef _EMU_SUBFUNCTIONS_
|
||||
#define _EMU_SUBFUNCTIONS_
|
||||
|
||||
|
@ -32,13 +29,8 @@
|
|||
#include "wiimote_hid.h" // Local
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Encryption.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations and definitions
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "Common.h"
|
||||
#include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#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 */
|
||||
// ----------------
|
||||
void wiimote_gen_key(wiimote_key *key, u8 *keydata)
|
||||
{
|
||||
u8 rand[10];
|
||||
|
@ -283,9 +280,7 @@ void wiimote_gen_key(wiimote_key *key, u8 *keydata)
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Encrypt data */
|
||||
// ----------------
|
||||
void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
{
|
||||
for(int i = 0; i < len; i++, addr++)
|
||||
|
@ -293,11 +288,9 @@ void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
|||
}
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Decrypt data */
|
||||
// ----------------
|
||||
void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
{
|
||||
for(int i = 0; i < len; i++, addr++)
|
||||
data[i] = (data[i] ^ key->sb[addr%8]) + key->ft[addr%8];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include <vector>
|
||||
|
@ -33,9 +30,7 @@
|
|||
#include "EmuMain.h"
|
||||
#include "EmuSubroutines.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Logging.h" // For startConsoleWin, Console::Print, GetConsoleHwnd
|
||||
#include "Config.h" // For g_Config
|
||||
//////////////////////////////////
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
|
||||
|
@ -43,24 +38,19 @@ namespace WiiMoteEmu
|
|||
{
|
||||
|
||||
|
||||
//**************************************************************************************
|
||||
//****************************************************************************
|
||||
// Recorded movements
|
||||
//**************************************************************************************
|
||||
//****************************************************************************
|
||||
|
||||
// ------------------------------------------
|
||||
// Variables: 0 = Wiimote, 1 = Nunchuck
|
||||
// ----------------
|
||||
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_RecordingPoint[3]; //g_RecordingPoint[0] = 0; g_RecordingPoint[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;
|
||||
// --------------------------
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/* 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. */
|
||||
// ---------------
|
||||
int G2Accelerometer(int _G, int XYZ, int Wm)
|
||||
{
|
||||
float G = (float)_G / 100.0;
|
||||
|
@ -384,12 +374,9 @@ int IsKey(int Key)
|
|||
return false;
|
||||
#endif
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Wiimote core buttons
|
||||
// ---------------
|
||||
void FillReportInfo(wm_core& _core)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
//////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Wiimote accelerometer
|
||||
// ---------------
|
||||
/* The accelerometer x, y and z values range from 0x00 to 0xff with the default netural values
|
||||
being [y = 0x84, x = 0x84, z = 0x9f] according to a source. The extremes are 0x00 for (-)
|
||||
and 0xff for (+). It's important that all values are not 0x80, the mouse pointer can disappear
|
||||
from the screen permanently then, until z is adjusted back. This is because the game detects
|
||||
/* The accelerometer x, y and z values range from 0x00 to 0xff with the default
|
||||
netural values being [y = 0x84, x = 0x84, z = 0x9f] according to a
|
||||
source. The extremes are 0x00 for (-) and 0xff for (+). It's important that
|
||||
all values are not 0x80, the mouse pointer can disappear from the screen
|
||||
permanently then, until z is adjusted back. This is because the game detects
|
||||
a steep pitch of the Wiimote then. */
|
||||
|
||||
|
||||
// ----------
|
||||
// Global declarations for FillReportAcc: These variables are global so they can be changed during debugging
|
||||
//int A = 0, B = 128, C = 64; // for debugging
|
||||
//int a = 1, b = 1, c = 2, d = -2; // for debugging
|
||||
//int consoleDisplay = 0;
|
||||
// Global declarations for FillReportAcc: These variables are global so they
|
||||
//can be changed during debugging int A = 0, B = 128, C = 64; // for debugging
|
||||
//int a = 1, b = 1, c = 2, d = -2; // for debugging int consoleDisplay = 0;
|
||||
|
||||
// For all functions
|
||||
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;
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
// Single shake of Wiimote while holding it sideways (Wario Land pound ground)
|
||||
// ---------------
|
||||
void SingleShake(u8 &_y, u8 &_z, int i)
|
||||
{
|
||||
#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 Wiimote pitch and use it as a
|
||||
measure of the tilting of the Wiimote. We are interested in this tilting range
|
||||
90° to -90° */
|
||||
// ---------------
|
||||
/* Tilting Wiimote with gamepad. We can guess that the game will calculate a
|
||||
Wiimote pitch and use it as a measure of the tilting of the Wiimote. We are
|
||||
interested in this tilting range 90° to -90° */
|
||||
void TiltWiimoteGamepad(float &Roll, float &Pitch)
|
||||
{
|
||||
// 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
|
||||
const int Page = 0;
|
||||
|
||||
/* Adjust the pad state values, including a downscaling from the original 0x8000 size values
|
||||
to 0x80. The only reason we do this is that the code below crrently assume that the range
|
||||
is 0 to 255 for all axes. If we 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. */
|
||||
/* Adjust the pad state values, including a downscaling from the original
|
||||
0x8000 size values to 0x80. The only reason we do this is that the code
|
||||
below crrently assume that the range is 0 to 255 for all axes. If we
|
||||
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;
|
||||
PadStateAdjustments(_Lx, _Ly, _Rx, _Ry, _Tl, _Tr);
|
||||
float Lx = (float)_Lx;
|
||||
|
@ -532,8 +513,9 @@ void TiltWiimoteGamepad(float &Roll, float &Pitch)
|
|||
- 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.
|
||||
By changing the axis mapping and the invert options this can be altered in any way */
|
||||
/* For the analog stick roll us by default set to the X-axis, pitch is by
|
||||
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)
|
||||
{
|
||||
// Adjust the trigger to go between negative and positive values
|
||||
|
@ -566,9 +548,7 @@ void TiltWiimoteGamepad(float &Roll, float &Pitch)
|
|||
}
|
||||
|
||||
|
||||
// ------------------------------------------
|
||||
// Tilting Wiimote with keyboard
|
||||
// ---------------
|
||||
void TiltWiimoteKeyboard(float &Roll, float &Pitch)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -585,9 +565,7 @@ void TiltWiimoteKeyboard(float &Roll, float &Pitch)
|
|||
KbDegree -= 3; // aim right
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
// Check for inactivity in the tilting, the Y value will be reset after ten inactive updates
|
||||
// ----------
|
||||
// Check for activity
|
||||
yhist[yhist.size() - 1] = (
|
||||
IsKey(g_Wm.PITCH_L)
|
||||
|
@ -611,13 +589,10 @@ void TiltWiimoteKeyboard(float &Roll, float &Pitch)
|
|||
Pitch = KbDegree;
|
||||
//INFO_LOG(CONSOLE, "Degree: %2.1f\n", KbDegree);
|
||||
}
|
||||
// --------------------
|
||||
#endif
|
||||
}
|
||||
|
||||
// ------------------------------------------
|
||||
// Tilting Wiimote (Wario Land aiming, Mario Kart steering and other things)
|
||||
// ---------------
|
||||
void Tilt(u8 &_x, u8 &_y, u8 &_z)
|
||||
{
|
||||
// Ceck if it's on
|
||||
|
@ -641,7 +616,6 @@ void Tilt(u8 &_x, u8 &_y, u8 &_z)
|
|||
|
||||
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",
|
||||
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);*/
|
||||
|
@ -650,9 +624,7 @@ void Tilt(u8 &_x, u8 &_y, u8 &_z)
|
|||
|
||||
void FillReportAcc(wm_accel& _acc)
|
||||
{
|
||||
// ------------------------------------
|
||||
// Recorded movements
|
||||
// --------------
|
||||
// Check for a playback command
|
||||
if(g_RecordingPlaying[0] < 0)
|
||||
{
|
||||
|
@ -664,7 +636,6 @@ void FillReportAcc(wm_accel& _acc)
|
|||
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);
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
// The default values can change so we need to update them all the time
|
||||
g_X = g_wm.cal_zero.x;
|
||||
|
@ -681,9 +652,7 @@ void FillReportAcc(wm_accel& _acc)
|
|||
return;
|
||||
}
|
||||
|
||||
// ------------------------------------------------
|
||||
// Wiimote to Gamepad translations
|
||||
// ------------
|
||||
|
||||
// The following functions may or may not update these values
|
||||
g_x = g_X;
|
||||
|
@ -702,9 +671,7 @@ void FillReportAcc(wm_accel& _acc)
|
|||
_acc.z = g_z;
|
||||
|
||||
|
||||
// ----------------------------
|
||||
// Debugging for translating Wiimote to Keyboard (or Gamepad)
|
||||
// ----------
|
||||
/*
|
||||
|
||||
// Toogle console display
|
||||
|
@ -779,7 +746,6 @@ void FillReportAcc(wm_accel& _acc)
|
|||
AX, AY, AZ
|
||||
);*/
|
||||
}
|
||||
/////////////////////////
|
||||
|
||||
|
||||
|
||||
|
@ -789,14 +755,10 @@ void FillReportAcc(wm_accel& _acc)
|
|||
Bottom = BOTTOM, SensorBarRadius = SENSOR_BAR_RADIUS;
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// The extended 12 byte (3 byte per object) reporting
|
||||
// ---------------
|
||||
void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
|
||||
{
|
||||
// ------------------------------------
|
||||
// Recorded movements
|
||||
// --------------
|
||||
// Check for a playback command
|
||||
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);
|
||||
if (RecordingPlayIR(_ir0)) return;
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
/* Fill with 0xff if empty. The real Wiimote seems to use 0xff when it doesn't see a certain point,
|
||||
at least from how WiiMoteReal::SendEvent() works. */
|
||||
/* Fill with 0xff if empty. The real Wiimote seems to use 0xff when it
|
||||
doesn't see a certain point, at least from how WiiMoteReal::SendEvent()
|
||||
works. */
|
||||
memset(&_ir0, 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(MouseX > 1 || MouseX < 0 || MouseY > 1 || MouseY < 0) return;
|
||||
|
||||
// --------------------------------------
|
||||
// Position calculation
|
||||
// ----------
|
||||
int y0 = g_Config.iIRTop + (MouseY * g_Config.iIRHeight);
|
||||
int y1 = y0;
|
||||
// The distance between the x positions are two sensor bar radii
|
||||
int x0 = 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
|
||||
// ----------
|
||||
/*
|
||||
if(!GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_RIGHT))
|
||||
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",
|
||||
x0, x1, y0, y1, Top, Left, Right, Bottom, SensorBarRadius
|
||||
);*/
|
||||
// ------------------
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// Converted to IR data
|
||||
// ----------
|
||||
// The width is 0 to 1023
|
||||
// The height is 0 to 767
|
||||
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.y = y1 & 0xff; _ir1.yHi = y1 >> 8;
|
||||
_ir1.size = 10;
|
||||
// ------------------
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// The 10 byte reporting used when an extension is connected
|
||||
// ---------------
|
||||
void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
|
||||
{
|
||||
|
||||
// ------------------------------------
|
||||
// Recorded movements
|
||||
// --------------
|
||||
// Check for a playback command
|
||||
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);
|
||||
if (RecordingPlayIR(_ir0)) return;
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
// Fill with 0xff if empty
|
||||
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 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
|
||||
the only difference is that we don't report any size of the tracked object here */
|
||||
/* As with the extented report we settle with emulating two out of four
|
||||
possible objects the only difference is that we don't report any size of
|
||||
the tracked object here */
|
||||
x1 = 1023 - x1;
|
||||
_ir0.x1 = x1 & 0xff; _ir0.x1Hi = (x1 >> 8); // we are dealing with 2 bit values here
|
||||
_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);
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// Debugging for calibration
|
||||
// ----------
|
||||
/*
|
||||
if(GetAsyncKeyState(VK_NUMPAD1))
|
||||
Right +=1;
|
||||
|
@ -972,19 +918,16 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
|
|||
}
|
||||
|
||||
|
||||
//**************************************************************************************
|
||||
//*****************************************************************************
|
||||
// Extensions
|
||||
//**************************************************************************************
|
||||
//*****************************************************************************
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Generate the 6 byte extension report for the Nunchuck, encrypted. The bytes are JX JY AX AY AZ BT. */
|
||||
// ----------------
|
||||
/* Generate the 6 byte extension report for the Nunchuck, encrypted. The bytes
|
||||
are JX JY AX AY AZ BT. */
|
||||
void FillReportExtension(wm_extension& _ext)
|
||||
{
|
||||
// ------------------------------------------
|
||||
// Recorded movements
|
||||
// --------------
|
||||
// Check for a playback command
|
||||
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.az = g_nu.cal_zero.z + g_nu.cal_g.z;
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
// Shake the Wiimote
|
||||
SingleShake(_ext.ay, _ext.az, 1);
|
||||
|
||||
// ------------------------------------
|
||||
// The default joystick and button values unless we use them
|
||||
// --------------
|
||||
_ext.jx = g_nu.jx.center;
|
||||
_ext.jy = g_nu.jy.center;
|
||||
_ext.bt = 0x03; // 0x03 means no button pressed, the button is zero active
|
||||
// ---------------------
|
||||
|
||||
// Update the analog stick
|
||||
if (g_Config.Nunchuck.Type == g_Config.Nunchuck.KEYBOARD)
|
||||
|
@ -1032,9 +971,10 @@ void FillReportExtension(wm_extension& _ext)
|
|||
_Ly = 0xff - _Ly;
|
||||
_Ry = 0xff - _Ry;
|
||||
|
||||
/* This is if we are also using a real Nunchuck that we are sharing the calibration with. It's not
|
||||
needed if we are using our default values. We adjust the values to the configured range, we even
|
||||
allow the center to not be 0x80. */
|
||||
/* This is if we are also using a real Nunchuck that we are sharing the
|
||||
calibration with. It's not needed if we are using our default
|
||||
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
|
||||
|| g_nu.jx.min != 0 || g_nu.jy.min != 0
|
||||
|| g_nu.jx.center != 0x80 || g_nu.jy.center != 0x80)
|
||||
|
@ -1043,8 +983,8 @@ void FillReportExtension(wm_extension& _ext)
|
|||
float Ly = (float)_Ly;
|
||||
float Rx = (float)_Rx;
|
||||
float Ry = (float)_Ry;
|
||||
float Tl = (float)_Tl;
|
||||
float Tr = (float)_Tr;
|
||||
// float Tl = (float)_Tl;
|
||||
// float Tr = (float)_Tr;
|
||||
|
||||
float XRangePos = (float) (g_nu.jx.max - g_nu.jx.center);
|
||||
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
|
||||
memcpy(&_ext, Tmp, sizeof(_ext));
|
||||
}
|
||||
// =======================
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Generate the 6 byte extension report for the Classic Controller, encrypted.
|
||||
The bytes are ... */
|
||||
// ----------------
|
||||
void FillReportClassicExtension(wm_classic_extension& _ext)
|
||||
{
|
||||
/* 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.bZL = 0x01;
|
||||
|
||||
// --------------------------------------
|
||||
// Check that Dolphin is in focus
|
||||
if (IsFocus())
|
||||
{
|
||||
// --------------------------------------
|
||||
/* Left and right analog sticks and analog triggers
|
||||
|
||||
u8 Lx : 6; // byte 0
|
||||
|
@ -1175,10 +1110,13 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||
_Ly = 0xff - _Ly;
|
||||
_Ry = 0xff - _Ry;
|
||||
|
||||
/* This is if we are also using a real Classic Controller that we are sharing the calibration with.
|
||||
It's not needed if we are using our default values. We adjust the values to the configured range.
|
||||
/* This is if we are also using a real Classic Controller that we
|
||||
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)
|
||||
|
@ -1214,10 +1152,13 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||
_Ly = 0xff - _Ly;
|
||||
_Ry = 0xff - _Ry;
|
||||
|
||||
/* This is if we are also using a real Classic Controller that we are sharing the calibration with.
|
||||
It's not needed if we are using our default values. We adjust the values to the configured range.
|
||||
/* This is if we are also using a real Classic Controller that we
|
||||
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)
|
||||
|
@ -1246,25 +1187,28 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||
int _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.
|
||||
It's not needed if we are using our default values. We adjust the values to the configured range.
|
||||
/* This is if we are also using a real Classic Controller that we
|
||||
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 (_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;
|
||||
rT = _Tr;
|
||||
}
|
||||
|
||||
|
||||
// --------------
|
||||
|
||||
// --------------------------------------
|
||||
/* D-Pad
|
||||
|
||||
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.Dr)) _ext.b1.bdR = 0x00; // Right
|
||||
if(IsKey(g_Cc.Dd)) _ext.b1.bdD = 0x00; // Down
|
||||
// --------------
|
||||
|
||||
// --------------------------------------
|
||||
/* Buttons
|
||||
u8 b1;
|
||||
0:
|
||||
|
@ -1329,14 +1271,10 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||
// All buttons pressed
|
||||
//if(GetAsyncKeyState('C') && GetAsyncKeyState('Z'))
|
||||
// { _ext.b2.bA = 0x01; _ext.b2.bB = 0x01; }
|
||||
// --------------
|
||||
}
|
||||
// --------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------
|
||||
// Convert data for reporting
|
||||
// --------------
|
||||
_ext.Lx = (Lx >> 2);
|
||||
_ext.Ly = (Ly >> 2);
|
||||
// 5 bit to 1 bit
|
||||
|
@ -1352,7 +1290,6 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||
// 5 bit to the highest two bits
|
||||
_ext.lT2 = (lT >> 3) >> 3;
|
||||
_ext.rT = (rT >> 3);
|
||||
// --------------
|
||||
|
||||
|
||||
/* Here we encrypt the report */
|
||||
|
@ -1368,7 +1305,4 @@ void FillReportClassicExtension(wm_classic_extension& _ext)
|
|||
// Write it back to the struct
|
||||
memcpy(&_ext, Tmp, sizeof(_ext));
|
||||
}
|
||||
// =======================
|
||||
|
||||
|
||||
} // end of namespace
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
Import('env')
|
||||
import sys
|
||||
|
||||
wmenv = env.Clone()
|
||||
name = "Plugin_Wiimote"
|
||||
wiienv = env.Clone()
|
||||
name = "Plugin_Wiimote-testing"
|
||||
|
||||
files = [
|
||||
"Config.cpp",
|
||||
|
@ -17,12 +17,11 @@ files = [
|
|||
"Encryption.cpp",
|
||||
"main.cpp",
|
||||
]
|
||||
if wmenv['HAVE_WX']:
|
||||
if wiienv['HAVE_WX']:
|
||||
files += [
|
||||
"ConfigDlg.cpp",
|
||||
"ConfigGamepad.cpp",
|
||||
"ConfigRecording.cpp",
|
||||
"Logging.cpp",
|
||||
"FillReport.cpp",
|
||||
]
|
||||
|
||||
|
@ -31,23 +30,23 @@ libs = [ 'common', 'inputcommon' ]
|
|||
|
||||
cxxflags = [ '-fPIC' ]
|
||||
|
||||
if wmenv['HAVE_WIIUSE']:
|
||||
if wiienv['HAVE_WIIUSE']:
|
||||
libs += [ 'wiiuse' ]
|
||||
files += [ "wiimote_real.cpp" ]
|
||||
files += [ "ReadWiimote.cpp" ]
|
||||
cxxflags += ['-DHAVE_WIIUSE']
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
wmenv.Append(
|
||||
wiienv.Append(
|
||||
CXXFLAGS = cxxflags,
|
||||
LINKFLAGS = ['-framework' ,'IOBluetooth'],
|
||||
LIBS = libs,
|
||||
)
|
||||
else:
|
||||
wmenv.Append(
|
||||
wiienv.Append(
|
||||
CXXFLAGS = cxxflags,
|
||||
LIBS = libs,
|
||||
)
|
||||
LIBS = libs,
|
||||
)
|
||||
|
||||
|
||||
wmenv.SharedLibrary(env['plugin_dir']+name, files)
|
||||
wiienv.SharedLibrary(env['plugin_dir']+name, files)
|
||||
|
|
|
@ -16,34 +16,31 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Current issues
|
||||
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/*
|
||||
The real Wiimote fails to answer the core correctly sometmes. Leading to an
|
||||
unwanted disconnection. And there is currenty no functions to reconnect with
|
||||
the game. There are two ways to solve this:
|
||||
|
||||
The real Wiimote fails to answer the core correctly sometmes. Leading to an unwanted disconnection. And
|
||||
there is currenty no functions to reconnect with the game. There are two ways to solve this:
|
||||
1. Make a reconnect function in the IOS emulation
|
||||
2. Detect failed answers in this plugin and solve it by replacing them with emulated answers.
|
||||
1. Make a reconnect function in the IOS emulation
|
||||
|
||||
The first solution seems easier, if I knew a little better how the /dev/usb/oh1 and Wiimote functions
|
||||
worked.
|
||||
2. Detect failed answers in this plugin and solve it by replacing them with
|
||||
emulated answers.
|
||||
|
||||
/////////////////////////////////////////////*/
|
||||
The first solution seems easier, if I knew a little better how the /dev/usb/oh1
|
||||
and Wiimote functions worked.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include "Common.h" // Common
|
||||
#include "StringUtil.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#define EXCLUDEMAIN_H // Avoid certain declarations in main.h
|
||||
#include "EmuDefinitions.h" // Local
|
||||
#include "wiimote_hid.h"
|
||||
#include "main.h"
|
||||
#include "Logging.h"
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include "ConfigDlg.h"
|
||||
#endif
|
||||
|
@ -53,12 +50,8 @@ worked.
|
|||
#if HAVE_WIIUSE
|
||||
#include "wiimote_real.h"
|
||||
#endif
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations and definitions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
SWiimoteInitialize g_WiimoteInitialize;
|
||||
PLUGIN_GLOBALS* globals = NULL;
|
||||
|
||||
|
@ -114,12 +107,9 @@ HWND g_ParentHWND = NULL;
|
|||
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
||||
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
||||
#endif
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Main function and WxWidgets initialization
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#ifdef _WIN32
|
||||
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
||||
DWORD dwReason, // reason called
|
||||
|
@ -149,7 +139,6 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
|||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
/////////////////////////////////////
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
|
@ -536,9 +525,7 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
|||
// data[4]: Size and error
|
||||
// data[5, 6]: The registry offset
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Show the extension ID
|
||||
// --------------------------
|
||||
if ((data[4] == 0x10 || data[4] == 0x20 || data[4] == 0x50) && data[5] == 0x00 && (data[6] == 0xfa || data[6] == 0xfe))
|
||||
{
|
||||
if(data[4] == 0x10)
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Show the Wiimote neutral values
|
||||
// --------------------------
|
||||
/* The only difference between the Nunchuck and Wiimote that we go after is calibration here is
|
||||
the offset in memory. If needed we can check the preceding 0x17 request to. */
|
||||
/* The only difference between the Nunchuck and Wiimote that we go
|
||||
after is calibration here is the offset in memory. If needed we can
|
||||
check the preceding 0x17 request to. */
|
||||
if(data[4] == 0xf0 && data[5] == 0x00 && data[6] == 0x10)
|
||||
{
|
||||
if(data[6] == 0x10)
|
||||
|
@ -604,11 +589,8 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
|||
INFO_LOG(CONSOLE, "Cal_g.z: %i\n", data[7 +12]);
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Show the Nunchuck neutral values
|
||||
// --------------------------
|
||||
if(data[4] == 0xf0 && data[5] == 0x00 && (data[6] == 0x20 || data[6] == 0x30))
|
||||
{
|
||||
// Save the encrypted data
|
||||
|
@ -680,7 +662,6 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
|||
// Show the encrypted data
|
||||
INFO_LOG(CONSOLE, "%s", TmpData.c_str());
|
||||
}
|
||||
// ---------------------------------------------
|
||||
|
||||
break;
|
||||
case WM_WRITE_DATA_REPLY: // 0x22
|
||||
|
@ -727,9 +708,9 @@ void ReadDebugging(bool Emu, const void* _pData, int Size)
|
|||
|
||||
if (!DataReport && g_DebugComm)
|
||||
{
|
||||
std::string TmpData = ArrayToString(data, size + 2, 0, 30);
|
||||
std::string tmpData = ArrayToString(data, size + 2, 0, 30);
|
||||
//LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
INFO_LOG(CONSOLE, "Read[%s] %s: %s\n", (Emu ? "Emu" : "Real"), Name.c_str(), TmpData.c_str()); // No timestamp
|
||||
INFO_LOG(CONSOLE, "Read[%s] %s: %s\n", (Emu ? "Emu" : "Real"), Name.c_str(), tmpData.c_str()); // No timestamp
|
||||
//INFO_LOG(CONSOLE, " (%s): %s\n", Tm(true).c_str(), Temp.c_str()); // Timestamp
|
||||
}
|
||||
|
||||
|
@ -1083,18 +1064,16 @@ int GetUpdateRate()
|
|||
|
||||
void DoInitialize()
|
||||
{
|
||||
// Open console
|
||||
//OpenConsole(true);
|
||||
|
||||
// Run this first so that WiiMoteReal::Initialize() overwrites g_Eeprom
|
||||
WiiMoteEmu::Initialize();
|
||||
|
||||
/* We will run WiiMoteReal::Initialize() even if we are not using a real wiimote,
|
||||
to check if there is a real wiimote connected. We will initiate wiiuse.dll, but
|
||||
we will return before creating a new thread for it if we find no real Wiimotes.
|
||||
Then g_RealWiiMotePresent will also be false. This function call will be done
|
||||
instantly whether there is a real Wiimote connected or not. It takes no time for
|
||||
Wiiuse to check for connected Wiimotes. */
|
||||
/* We will run WiiMoteReal::Initialize() even if we are not using a real
|
||||
wiimote, to check if there is a real wiimote connected. We will initiate
|
||||
wiiuse.dll, but we will return before creating a new thread for it if we
|
||||
find no real Wiimotes. Then g_RealWiiMotePresent will also be
|
||||
false. This function call will be done instantly whether there is a real
|
||||
Wiimote connected or not. It takes no time for Wiiuse to check for
|
||||
connected Wiimotes. */
|
||||
#if HAVE_WIIUSE
|
||||
if (g_Config.bConnectRealWiimote) WiiMoteReal::Initialize();
|
||||
#endif
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <iostream> // System
|
||||
#include <queue>
|
||||
|
||||
|
@ -35,15 +33,13 @@
|
|||
#include "Config.h"
|
||||
#include "EmuMain.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#define EXCLUDE_H // Avoid certain declarations in wiimote_real.h
|
||||
#include "Thread.h"
|
||||
#include "wiimote_real.h"
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include "ConfigDlg.h"
|
||||
#endif
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
////////////////////////////////////////
|
||||
|
||||
|
||||
namespace WiiMoteReal
|
||||
{
|
||||
|
@ -54,11 +50,8 @@ namespace WiiMoteReal
|
|||
|
||||
class CWiiMote;
|
||||
|
||||
#ifdef _WIN32
|
||||
DWORD WINAPI ReadWiimote_ThreadFunc(void* arg);
|
||||
#else
|
||||
void* ReadWiimote_ThreadFunc(void* arg);
|
||||
#endif
|
||||
THREAD_RETURN ReadWiimote_ThreadFunc(void* arg);
|
||||
|
||||
//******************************************************************************
|
||||
// Variable declarations
|
||||
//******************************************************************************
|
||||
|
@ -86,15 +79,12 @@ class CWiiMote
|
|||
{
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////
|
||||
// On create and on uncreate
|
||||
// ---------------
|
||||
CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
|
||||
: m_WiimoteNumber(_WiimoteNumber)
|
||||
, m_channelID(0)
|
||||
, m_pWiiMote(_pWiimote)
|
||||
, m_pCriticalSection(NULL)
|
||||
, m_LastReportValid(false)
|
||||
, m_pWiiMote(_pWiimote)
|
||||
{
|
||||
m_pCriticalSection = new Common::CriticalSection();
|
||||
|
||||
|
@ -110,12 +100,9 @@ virtual ~CWiiMote()
|
|||
{
|
||||
delete m_pCriticalSection;
|
||||
};
|
||||
//////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Queue raw HID data from the core to the wiimote
|
||||
// ---------------
|
||||
void SendData(u16 _channelID, const u8* _pData, u32 _Size)
|
||||
{
|
||||
m_channelID = _channelID;
|
||||
|
@ -132,12 +119,9 @@ void SendData(u16 _channelID, const u8* _pData, u32 _Size)
|
|||
}
|
||||
m_pCriticalSection->Leave();
|
||||
}
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
/* Read and write data to the Wiimote */
|
||||
// ---------------
|
||||
void ReadData()
|
||||
{
|
||||
m_pCriticalSection->Enter();
|
||||
|
@ -193,12 +177,9 @@ void ReadData()
|
|||
}
|
||||
}
|
||||
};
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Send queued data to the core
|
||||
// ---------------
|
||||
void Update()
|
||||
{
|
||||
// Thread function
|
||||
|
@ -218,12 +199,9 @@ void Update()
|
|||
|
||||
m_pCriticalSection->Leave();
|
||||
};
|
||||
/////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Clear events
|
||||
// ---------------
|
||||
void ClearEvents()
|
||||
{
|
||||
while (!m_EventReadQueue.empty())
|
||||
|
@ -231,7 +209,6 @@ void ClearEvents()
|
|||
while (!m_EventWriteQueue.empty())
|
||||
m_EventWriteQueue.pop();
|
||||
}
|
||||
/////////////////////
|
||||
|
||||
private:
|
||||
|
||||
|
@ -254,9 +231,7 @@ private:
|
|||
SEvent m_LastReport;
|
||||
wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[]
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Send queued data to the core
|
||||
// ---------------
|
||||
void SendEvent(SEvent& _rEvent)
|
||||
{
|
||||
// We don't have an answer channel
|
||||
|
@ -272,8 +247,9 @@ void SendEvent(SEvent& _rEvent)
|
|||
|
||||
// Create the buffer
|
||||
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, MAX_PAYLOAD);
|
||||
/* This Offset value is not exactly correct like it is for the emulated Wiimote reports. It's
|
||||
often to big, but I guess that's okay. The game will know how big the actual data is. */
|
||||
/* This Offset value is not exactly correct like it is for the emulated
|
||||
Wiimote reports. It's often to big, but I guess that's okay. The game
|
||||
will know how big the actual data is. */
|
||||
Offset += MAX_PAYLOAD;
|
||||
|
||||
// Send it
|
||||
|
@ -282,7 +258,6 @@ void SendEvent(SEvent& _rEvent)
|
|||
// Debugging
|
||||
// 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(g_Config.bUseRealWiimote) g_RunTemporary = true;
|
||||
|
||||
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values to g_Eeprom. Unlike with
|
||||
and extension we have to do this here, because this data is only read once when the Wiimote
|
||||
is connected. Also, we can't change the neutral values the wiimote will report, I think, unless
|
||||
we update its eeprom? In any case it's probably better to let the current calibration be where it
|
||||
is and adjust the global values after that to avoid overwriting critical data on any Wiimote. */
|
||||
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values
|
||||
to g_Eeprom. Unlike with and extension we have to do this here, because
|
||||
this data is only read once when the Wiimote is connected. Also, we
|
||||
can't change the neutral values the wiimote will report, I think, unless
|
||||
we update its eeprom? In any case it's probably better to let the
|
||||
current calibration be where it is and adjust the global values after
|
||||
that to avoid overwriting critical data on any Wiimote. */
|
||||
// TODO: Update for multiple wiimotes?
|
||||
byte *data = (byte*)malloc(sizeof(byte) * sizeof(WiiMoteEmu::EepromData_0));
|
||||
wiiuse_read_data(g_WiiMotesFromWiiUse[0], data, 0, sizeof(WiiMoteEmu::EepromData_0));
|
||||
|
@ -450,9 +427,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
|||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
// Read the Wiimote once
|
||||
// ---------------
|
||||
void Update()
|
||||
{
|
||||
//INFO_LOG(CONSOLE, "Real Update\n");
|
||||
|
@ -462,16 +437,11 @@ void Update()
|
|||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
/* Continuously read the Wiimote status. However, the actual sending of data occurs in Update(). If we are
|
||||
not currently using the real Wiimote we allow the separate ReadWiimote() function to run. Wo don't use
|
||||
them at the same time to avoid a potential collision. */
|
||||
// ---------------
|
||||
#ifdef _WIN32
|
||||
DWORD WINAPI ReadWiimote_ThreadFunc(void* arg)
|
||||
#else
|
||||
void *ReadWiimote_ThreadFunc(void* arg)
|
||||
#endif
|
||||
/* Continuously read the Wiimote status. However, the actual sending of data
|
||||
occurs in Update(). If we are not currently using the real Wiimote we allow
|
||||
the separate ReadWiimote() function to run. Wo don't use them at the same
|
||||
time to avoid a potential collision. */
|
||||
THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
|
||||
{
|
||||
while (!g_Shutdown)
|
||||
{
|
||||
|
|
|
@ -20,12 +20,7 @@
|
|||
#define WIIMOTE_REAL_H
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include "wiiuse.h"
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
namespace WiiMoteReal
|
||||
{
|
||||
|
@ -47,20 +42,18 @@ void ClearEvents();
|
|||
void ReadWiimote();
|
||||
bool IRDataOK(struct wiimote_t* wm);
|
||||
|
||||
#ifndef EXCLUDE_H
|
||||
extern wiimote_t** g_WiiMotesFromWiiUse;
|
||||
extern bool g_Shutdown;
|
||||
extern bool g_ThreadGoing;
|
||||
extern int g_NumberOfWiiMotes;
|
||||
extern bool g_MotionSensing;
|
||||
extern bool g_IRSensing;
|
||||
extern u64 g_UpdateTime;
|
||||
extern int g_UpdateCounter;
|
||||
extern bool g_RunTemporary;
|
||||
extern int g_RunTemporaryCountdown;
|
||||
extern u8 g_EventBuffer[32];
|
||||
#endif
|
||||
|
||||
extern wiimote_t** g_WiiMotesFromWiiUse;
|
||||
extern bool g_Shutdown;
|
||||
extern bool g_ThreadGoing;
|
||||
extern int g_NumberOfWiiMotes;
|
||||
extern bool g_MotionSensing;
|
||||
extern bool g_IRSensing;
|
||||
extern u64 g_UpdateTime;
|
||||
extern int g_UpdateCounter;
|
||||
extern bool g_RunTemporary;
|
||||
extern int g_RunTemporaryCountdown;
|
||||
extern u8 g_EventBuffer[32];
|
||||
|
||||
}; // WiiMoteReal
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue