Wiimote: Added option to record adjusted wiimote accelerometer values
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2089 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
2b8d2134e5
commit
4660943322
|
@ -43,6 +43,12 @@ void Config::Load()
|
|||
iniFile.Get("Real", "Connect", &bConnectRealWiimote, true);
|
||||
iniFile.Get("Real", "Use", &bUseRealWiimote, true);
|
||||
iniFile.Get("Real", "UpdateStatus", &bUpdateRealWiimote, true);
|
||||
iniFile.Get("Real", "AccNeutralX", &iAccNeutralX, 0);
|
||||
iniFile.Get("Real", "AccNeutralY", &iAccNeutralY, 0);
|
||||
iniFile.Get("Real", "AccNeutralZ", &iAccNeutralZ, 0);
|
||||
iniFile.Get("Real", "AccNunNeutralX", &iAccNunNeutralX, 0);
|
||||
iniFile.Get("Real", "AccNunNeutralY", &iAccNunNeutralY, 0);
|
||||
iniFile.Get("Real", "AccNunNeutralZ", &iAccNunNeutralZ, 0);
|
||||
}
|
||||
|
||||
void Config::Save()
|
||||
|
@ -57,6 +63,12 @@ void Config::Save()
|
|||
iniFile.Set("Real", "Connect", bConnectRealWiimote);
|
||||
iniFile.Set("Real", "Use", bUseRealWiimote);
|
||||
iniFile.Set("Real", "UpdateStatus", bUpdateRealWiimote);
|
||||
iniFile.Set("Real", "AccNeutralX", iAccNeutralX);
|
||||
iniFile.Set("Real", "AccNeutralY", iAccNeutralY);
|
||||
iniFile.Set("Real", "AccNeutralZ", iAccNeutralZ);
|
||||
iniFile.Set("Real", "AccNunNeutralX", iAccNunNeutralX);
|
||||
iniFile.Set("Real", "AccNunNeutralY", iAccNunNeutralY);
|
||||
iniFile.Set("Real", "AccNunNeutralZ", iAccNunNeutralZ);
|
||||
|
||||
iniFile.Save(FULL_CONFIG_DIR "Wiimote.ini");
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ struct Config
|
|||
|
||||
// Real Wiimote
|
||||
bool bConnectRealWiimote, bUseRealWiimote, bUpdateRealWiimote;
|
||||
int iAccNeutralX, iAccNeutralY, iAccNeutralZ;
|
||||
int iAccNunNeutralX, iAccNunNeutralY, iAccNunNeutralZ;
|
||||
};
|
||||
|
||||
extern Config g_Config;
|
||||
|
|
|
@ -57,6 +57,7 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
|
|||
EVT_CHECKBOX(ID_CONNECT_REAL, ConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_USE_REAL, ConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHECKBOX(ID_UPDATE_REAL, ConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHOICE(ID_NEUTRAL_CHOICE, ConfigDialog::GeneralSettingsChanged)
|
||||
|
||||
EVT_CHOICE(IDC_RECORD + 1, ConfigDialog::GeneralSettingsChanged)
|
||||
EVT_CHOICE(IDC_RECORD + 2, ConfigDialog::GeneralSettingsChanged)
|
||||
|
@ -348,7 +349,9 @@ void ConfigDialog::CreateGUIControls()
|
|||
m_ConnectRealWiimote->SetValue(g_Config.bConnectRealWiimote);
|
||||
m_UseRealWiimote->SetValue(g_Config.bUseRealWiimote);
|
||||
|
||||
// ---------------------------------------------
|
||||
// Status
|
||||
// ----------------
|
||||
wxStaticBoxSizer * sbRealStatus = new wxStaticBoxSizer(wxVERTICAL, m_PageReal, wxT("Status"));
|
||||
m_TextUpdateRate = new wxStaticText(m_PageReal, wxID_ANY, wxT("Update rate: 000 times/s"));
|
||||
m_UpdateMeters = new wxCheckBox(m_PageReal, ID_UPDATE_REAL, wxT("Update gauges"));
|
||||
|
@ -362,6 +365,66 @@ void ConfigDialog::CreateGUIControls()
|
|||
|
||||
sbRealStatus->Add(m_TextUpdateRate, 0, wxEXPAND | (wxALL), 5);
|
||||
sbRealStatus->Add(m_UpdateMeters, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxUP), 5);
|
||||
// -----------------------
|
||||
|
||||
// ---------------------------------------------
|
||||
// Wiimote accelerometer neutral values
|
||||
// ----------------
|
||||
wxStaticBoxSizer * sbRealNeutral = new wxStaticBoxSizer(wxVERTICAL, m_PageReal, wxT("Wiimote neutral"));
|
||||
wxStaticText * m_TextAccNeutralTarget = new wxStaticText(m_PageReal, wxID_ANY, wxT("Target: 132 132 159"));
|
||||
m_TextAccNeutralCurrent = new wxStaticText(m_PageReal, wxID_ANY, wxT("Current: 000 000 000"));
|
||||
wxArrayString StrAccNeutral;
|
||||
for(int i = 0; i < 31; i++) StrAccNeutral.Add(wxString::Format(wxT("%i"), i));
|
||||
for(int i = 0; i < 3; i++) m_AccNeutralChoice[i] = new wxChoice(m_PageReal, ID_NEUTRAL_CHOICE, wxDefaultPosition, wxDefaultSize, StrAccNeutral);
|
||||
m_AccNeutralChoice[0]->SetSelection(g_Config.iAccNeutralX);
|
||||
m_AccNeutralChoice[1]->SetSelection(g_Config.iAccNeutralY);
|
||||
m_AccNeutralChoice[2]->SetSelection(g_Config.iAccNeutralZ);
|
||||
|
||||
wxBoxSizer * sbRealWiimoteNeutralChoices = new wxBoxSizer(wxHORIZONTAL);
|
||||
sbRealWiimoteNeutralChoices->Add(m_AccNeutralChoice[0], 0, wxEXPAND | (wxALL), 0);
|
||||
sbRealWiimoteNeutralChoices->Add(m_AccNeutralChoice[1], 0, wxEXPAND | (wxLEFT), 2);
|
||||
sbRealWiimoteNeutralChoices->Add(m_AccNeutralChoice[2], 0, wxEXPAND | (wxLEFT), 2);
|
||||
|
||||
sbRealNeutral->Add(m_TextAccNeutralTarget, 0, wxEXPAND | (wxALL), 5);
|
||||
sbRealNeutral->Add(m_TextAccNeutralCurrent, 0, wxEXPAND | (wxLEFT | wxRIGHT), 5);
|
||||
sbRealNeutral->Add(sbRealWiimoteNeutralChoices, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxUP), 5);
|
||||
|
||||
m_TextAccNeutralTarget->SetToolTip(wxT(
|
||||
"To produce compatible accelerometer recordings that can be shared with other users without problems"
|
||||
" you have to adjust the Current value to the Target value before you make a recording."
|
||||
));
|
||||
// -----------------------
|
||||
|
||||
// ---------------------------------------------
|
||||
// Nunchuck accelerometer neutral values
|
||||
// ----------------
|
||||
/*
|
||||
wxStaticBoxSizer * sbRealNNeutral = new wxStaticBoxSizer(wxVERTICAL, m_PageReal, wxT("Nunchuck neutrals"));
|
||||
wxStaticText * m_TextAccNeutralTarget = new wxStaticText(m_PageReal, wxID_ANY, wxT("Target: 132 132 159"));
|
||||
m_TextAccNeutralCurrent = new wxStaticText(m_PageReal, wxID_ANY, wxT("Current: 000 000 000"));
|
||||
wxArrayString StrAccNeutral;
|
||||
for(int i = 0; i < 31; i++) StrAccNeutral.Add(wxString::Format(wxT("%i"), i));
|
||||
for(int i = 0; i < 3; i++) m_AccNeutralChoice[i] = new wxChoice(m_PageReal, ID_NEUTRAL_CHOICE, wxDefaultPosition, wxDefaultSize, StrAccNeutral);
|
||||
m_AccNeutralChoice[0]->SetSelection(g_Config.iAccNeutralX);
|
||||
m_AccNeutralChoice[1]->SetSelection(g_Config.iAccNeutralY);
|
||||
m_AccNeutralChoice[2]->SetSelection(g_Config.iAccNeutralZ);
|
||||
|
||||
wxBoxSizer * sbRealWiimoteNeutralChoices = new wxBoxSizer(wxHORIZONTAL);
|
||||
sbRealWiimoteNeutralChoices->Add(m_AccNeutralChoice[0], 0, wxEXPAND | (wxALL), 0);
|
||||
sbRealWiimoteNeutralChoices->Add(m_AccNeutralChoice[1], 0, wxEXPAND | (wxLEFT), 2);
|
||||
sbRealWiimoteNeutralChoices->Add(m_AccNeutralChoice[2], 0, wxEXPAND | (wxLEFT), 2);
|
||||
|
||||
sbRealNeutral->Add(m_TextAccNeutralTarget, 0, wxEXPAND | (wxALL), 5);
|
||||
sbRealNeutral->Add(m_TextAccNeutralCurrent, 0, wxEXPAND | (wxLEFT | wxRIGHT), 5);
|
||||
sbRealNeutral->Add(sbRealWiimoteNeutralChoices, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxUP), 5);
|
||||
|
||||
m_TextAccNeutralTarget->SetToolTip(wxT(
|
||||
"To produce compatible accelerometer recordings that can be shared with other users without problems"
|
||||
" you have to adjust the Current value to the Target value before you make a recording."
|
||||
));
|
||||
*/
|
||||
// -----------------------
|
||||
|
||||
|
||||
// ==================================================
|
||||
// Wiimote Status
|
||||
|
@ -532,6 +595,7 @@ void ConfigDialog::CreateGUIControls()
|
|||
wxBoxSizer * sRealBasicStatus = new wxBoxSizer(wxHORIZONTAL);
|
||||
sRealBasicStatus->Add(sbRealBasic, 0, wxEXPAND | (wxLEFT), 0);
|
||||
sRealBasicStatus->Add(sbRealStatus, 0, wxEXPAND | (wxLEFT), 5);
|
||||
sRealBasicStatus->Add(sbRealNeutral, 0, wxEXPAND | (wxLEFT), 5);
|
||||
|
||||
wxBoxSizer * sRealMain = new wxBoxSizer(wxVERTICAL);
|
||||
sRealMain->Add(sRealBasicStatus, 0, wxEXPAND | (wxALL), 5);
|
||||
|
@ -853,6 +917,14 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
|||
case ID_UPDATE_REAL:
|
||||
g_Config.bUpdateRealWiimote = m_UpdateMeters->IsChecked();
|
||||
break;
|
||||
case ID_NEUTRAL_CHOICE:
|
||||
g_Config.iAccNeutralX = m_AccNeutralChoice[0]->GetSelection();
|
||||
g_Config.iAccNeutralY = m_AccNeutralChoice[1]->GetSelection();
|
||||
g_Config.iAccNeutralZ = m_AccNeutralChoice[2]->GetSelection();
|
||||
//g_Config.iAccNunNeutralX = m_AccNunNeutralChoice[0]->GetSelection();
|
||||
//g_Config.iAccNunNeutralY = m_AccNunNeutralChoice[1]->GetSelection();
|
||||
//g_Config.iAccNunNeutralZ = m_AccNunNeutralChoice[2]->GetSelection();
|
||||
break;
|
||||
|
||||
case IDC_RECORD + 1:
|
||||
case IDC_RECORD + 2:
|
||||
|
|
|
@ -53,7 +53,7 @@ class ConfigDialog : public wxDialog
|
|||
|
||||
// Wiimote status
|
||||
wxGauge *m_GaugeBattery, *m_GaugeRoll[2], *m_GaugeGForce[3], *m_GaugeAccel[3];
|
||||
wxStaticText * m_TextIR;
|
||||
wxStaticText *m_TextIR, *m_TextAccNeutralCurrent;
|
||||
bool m_bWaitForRecording, m_bRecording, m_bAllowA;
|
||||
int m_iRecordTo;
|
||||
void RecordMovement(wxCommandEvent& event);
|
||||
|
@ -79,6 +79,7 @@ class ConfigDialog : public wxDialog
|
|||
wxCheckBox *m_NunchuckConnected, *m_ClassicControllerConnected;
|
||||
|
||||
wxCheckBox *m_ConnectRealWiimote, *m_UseRealWiimote, *m_UpdateMeters; // Real Wiimote settings
|
||||
wxChoice *m_AccNeutralChoice[3], *m_AccNunNeutralChoice[3];
|
||||
|
||||
//static const int RECORDING_ROWS = 15;
|
||||
wxButton * m_RecordButton[RECORDING_ROWS + 1];
|
||||
|
@ -117,7 +118,7 @@ class ConfigDialog : public wxDialog
|
|||
ID_NUNCHUCKCONNECTED, ID_CLASSICCONTROLLERCONNECTED,
|
||||
|
||||
// Real
|
||||
ID_CONNECT_REAL, ID_USE_REAL, ID_UPDATE_REAL, IDT_STATUS,
|
||||
ID_CONNECT_REAL, ID_USE_REAL, ID_UPDATE_REAL, IDT_STATUS, ID_NEUTRAL_CHOICE,
|
||||
IDB_RECORD = 2000,
|
||||
IDC_RECORD = 3000,
|
||||
IDT_RECORD_TEXT, IDT_RECORD_GAMETEXT, IDT_RECORD_IRBYTESTEXT, IDT_RECORD_SPEED, IDT_RECORD_PLAYSPEED
|
||||
|
|
|
@ -114,6 +114,11 @@ void handle_event(struct wiimote_t* wm)
|
|||
if(frame && g_Config.bUpdateRealWiimote)
|
||||
frame->m_GaugeBattery->SetValue((int)floor((wm->battery_level * 100) + 0.5));
|
||||
|
||||
/* Create shortcut to the nunchuck */
|
||||
struct nunchuk_t* nc = NULL;
|
||||
if (wm->exp.type == EXP_NUNCHUK)
|
||||
nc = (nunchuk_t*)&wm->exp.nunchuk;
|
||||
|
||||
/* If the accelerometer is turned on then print angles */
|
||||
if (WIIUSE_USING_ACC(wm) && WIIUSE_USING_IR(wm))
|
||||
{
|
||||
|
@ -146,19 +151,31 @@ void handle_event(struct wiimote_t* wm)
|
|||
|
||||
Tmp += StringFromFormat("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
|
||||
Tmp += StringFromFormat("IR z distance: %f\n", wm->ir.z);
|
||||
std::string TmpData = ArrayToString(g_EventBuffer, ReportSize, 0, 30);
|
||||
Tmp += "Data: " + TmpData;
|
||||
//std::string TmpData = ArrayToString(g_EventBuffer, ReportSize, 0, 30);
|
||||
//Tmp += "Data: " + TmpData;
|
||||
|
||||
Console::ClearScreen();
|
||||
Console::Print("%s\n\n", Tmp.c_str());
|
||||
//Console::ClearScreen();
|
||||
//Console::Print("%s\n\n", Tmp.c_str());
|
||||
|
||||
if(frame)
|
||||
{
|
||||
if(g_Config.bUpdateRealWiimote)
|
||||
{
|
||||
// Produce adjussted accelerometer values
|
||||
u8 AccelX = 0, AccelY = 0, AccelZ = 0;
|
||||
if((wm->accel.x + g_Config.iAccNunNeutralX) <= 255) AccelX = wm->accel.x + g_Config.iAccNeutralX;
|
||||
if((wm->accel.y + g_Config.iAccNunNeutralY) <= 255) AccelY = wm->accel.y + g_Config.iAccNeutralY;
|
||||
if((wm->accel.z + g_Config.iAccNunNeutralZ) <= 255) AccelZ = wm->accel.z + g_Config.iAccNeutralZ;
|
||||
// And for the Nunchuck
|
||||
u8 AccelNX = 0, AccelNY = 0, AccelNZ = 0;
|
||||
if(wm->exp.type == EXP_NUNCHUK)
|
||||
{
|
||||
if((nc->accel.x + g_Config.iAccNunNeutralX) <= 255) AccelNX = nc->accel.x + g_Config.iAccNunNeutralX;
|
||||
if((nc->accel.y + g_Config.iAccNunNeutralY) <= 255) AccelNY = nc->accel.y + g_Config.iAccNunNeutralY;
|
||||
if((nc->accel.z + g_Config.iAccNunNeutralZ) <= 255) AccelNZ = nc->accel.z + g_Config.iAccNunNeutralZ;
|
||||
}
|
||||
|
||||
// Disabled for now, they serve a limited purpose anyway. Enabled again.
|
||||
/**/
|
||||
if(g_Config.bUpdateRealWiimote)
|
||||
{
|
||||
// Update gauges
|
||||
frame->m_GaugeRoll[0]->SetValue(wm->orient.roll + 180);
|
||||
frame->m_GaugeRoll[1]->SetValue(wm->orient.pitch + 180);
|
||||
|
||||
|
@ -166,20 +183,23 @@ void handle_event(struct wiimote_t* wm)
|
|||
frame->m_GaugeGForce[1]->SetValue((int)floor((wm->gforce.y * 100) + 300.5));
|
||||
frame->m_GaugeGForce[2]->SetValue((int)floor((wm->gforce.z * 100) + 300.5));
|
||||
|
||||
frame->m_GaugeAccel[0]->SetValue(wm->accel.x);
|
||||
frame->m_GaugeAccel[1]->SetValue(wm->accel.y);
|
||||
frame->m_GaugeAccel[2]->SetValue(wm->accel.z);
|
||||
frame->m_GaugeAccel[0]->SetValue(AccelX);
|
||||
frame->m_GaugeAccel[1]->SetValue(AccelY);
|
||||
frame->m_GaugeAccel[2]->SetValue(AccelZ);
|
||||
|
||||
frame->m_TextIR->SetLabel(wxString::Format(
|
||||
"Cursor: %03u %03u\nDistance:%4.0f", wm->ir.x, wm->ir.y, wm->ir.z));
|
||||
|
||||
frame->m_TextAccNeutralCurrent->SetLabel(wxString::Format(
|
||||
"Current: %03u %03u %03u", AccelX, AccelY, AccelZ));
|
||||
|
||||
if(frame->m_bRecording)
|
||||
Console::Print("Wiiuse Recorded accel x, y, z: %03i %03i %03i\n", wm->accel.x, wm->accel.y, wm->accel.z);
|
||||
}
|
||||
|
||||
// Send the data to be saved
|
||||
//const u8* data = (const u8*)wm->event_buf;
|
||||
frame->DoRecordMovement(wm->accel.x, wm->accel.y, wm->accel.z, (g_EventBuffer + 6),
|
||||
frame->DoRecordMovement(AccelX, AccelY, AccelZ, (g_EventBuffer + 6),
|
||||
(WIIUSE_USING_EXP(wm) ? 10 : 12));
|
||||
|
||||
// Turn recording on and off
|
||||
|
@ -192,6 +212,9 @@ void handle_event(struct wiimote_t* wm)
|
|||
{
|
||||
if (frame)
|
||||
{
|
||||
|
||||
frame->m_TextAccNeutralCurrent->SetLabel(wxT("Current: 000 000 000"));
|
||||
|
||||
frame->m_GaugeRoll[0]->SetValue(0);
|
||||
frame->m_GaugeRoll[1]->SetValue(0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue