MAJOR and long ago overdue wiiuse and real wiimote sourcecode cleanup. Removed "recording" in old wiimote plugin and other not necessary functions(EEPROM reading, we 'll just do a reconnect instead to use default accel calibration data etc). Recording is not needed anymore(playback of recorded moves should be still working). Everything the recording feature offered, the new wiimote plugin does as well and even more. The cleanup will ease the port of the real wiimote feature into new wiimote plugin, which is still only offering emulated wiimote support. Billiard said he's now on it.:)

Wiimotes are now slighty more responsive and multiple wiimotes should harmonize now slighty better. This clean up was requested/inevitable and should have be done way more earlier. This "might" break osx/linux builds, so please test. If your aware of any "real wiimote" issues please post it in the comments as well(dont forget to state your OS).

Known wiimote issues:
1.) Possible wiimote disconnect on pressing the home button
2.) 1-2 Possible wiimote disconnects directly after starting a game
3.) Rumble causes lag. I don't think this is a wiimote plugin issue itself, I'm not sure tho. It would be interesting to know whether the lag still happens on emulated wiimotes as well, when the game tries to rumble.
4.) Connecting(pairing up and refreshing) a 2nd/3rd/4th real wiimote while having a game running/paused, might swap player slots and cause disconnects at that moment.
If u have more issues, feel free to post them, to have them all here collected once more to get a brief overview.
Apart from that, increase the wiimote read timeout @settings(20-200). If your  expecting frequent disconnects, restart dolphin, and don't open the wiimote gui before playing instead directly start games.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5788 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
snzgoo
2010-06-26 02:08:30 +00:00
parent 434e6b1198
commit f6d844dac1
37 changed files with 72 additions and 4503 deletions

View File

@ -20,7 +20,6 @@
#include "main.h"
#include "ConfigBasicDlg.h"
#include "ConfigPadDlg.h"
#include "ConfigRecordingDlg.h"
#include "Config.h"
#include "EmuMain.h" // for SetDefaultExtensionRegistry
#include "EmuSubroutines.h" // for WmRequestStatus
@ -112,12 +111,6 @@ void WiimoteBasicConfigDialog::ButtonClick(wxCommandEvent& event)
m_Notebook->ChangeSelection(g_Config.CurrentPage);
UpdateGUI();
break;
case ID_BUTTONRECORDING:
m_RecordingConfigFrame = new WiimoteRecordingConfigDialog(this);
m_RecordingConfigFrame->ShowModal();
m_RecordingConfigFrame->Destroy();
m_RecordingConfigFrame = NULL;
break;
#ifdef _WIN32
case IDB_PAIRUP_REAL:
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY)
@ -327,7 +320,6 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
}
m_ButtonMapping = new wxButton(this, ID_BUTTONMAPPING, wxT("Button Mapping"));
m_Recording = new wxButton(this, ID_BUTTONRECORDING, wxT("Recording"));
m_OK = new wxButton(this, wxID_OK, wxT("OK"));
m_OK->SetToolTip(wxT("Save changes and close"));
@ -336,7 +328,6 @@ void WiimoteBasicConfigDialog::CreateGUIControls()
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->Add(m_ButtonMapping, 0, (wxALL), 0);
sButtons->Add(m_Recording, 0, (wxALL), 0);
sButtons->AddStretchSpacer();
sButtons->Add(m_OK, 0, (wxALL), 0);
sButtons->Add(m_Cancel, 0, (wxLEFT), 5);

View File

@ -1,541 +0,0 @@
// Copyright (C) 2003 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/
#include "IniFile.h"
#include "Timer.h"
#include "wiimote_real.h" // Local
#include "wiimote_hid.h"
#include "main.h"
#include "ConfigRecordingDlg.h"
#include "ConfigBasicDlg.h"
#include "Config.h"
#include "EmuMain.h" // for LoadRecordedMovements()
#include "EmuSubroutines.h" // for WmRequestStatus
void WiimoteRecordingConfigDialog::LoadFile()
{
DEBUG_LOG(WIIMOTE, "LoadFile()");
IniFile file;
file.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "WiimoteMovement.ini").c_str());
for (int i = 1; i < (RECORDING_ROWS + 1); i++)
{
// Temporary storage
int iTmp;
std::string STmp;
// Get row name
std::string SaveName = StringFromFormat("Recording%i", i);
// HotKey
file.Get(SaveName.c_str(), "HotKeySwitch", &iTmp, 3); m_RecordHotKeySwitch[i]->SetSelection(iTmp);
file.Get(SaveName.c_str(), "HotKeyWiimote", &iTmp, 10); m_RecordHotKeyWiimote[i]->SetSelection(iTmp);
file.Get(SaveName.c_str(), "HotKeyNunchuck", &iTmp, 10); m_RecordHotKeyNunchuck[i]->SetSelection(iTmp);
file.Get(SaveName.c_str(), "HotKeyIR", &iTmp, 10); m_RecordHotKeyIR[i]->SetSelection(iTmp);
// Movement name
file.Get(SaveName.c_str(), "MovementName", &STmp, ""); m_RecordText[i]->SetValue(wxString::FromAscii(STmp.c_str()));
// Game name
file.Get(SaveName.c_str(), "GameName", &STmp, ""); m_RecordGameText[i]->SetValue(wxString::FromAscii(STmp.c_str()));
// IR Bytes
file.Get(SaveName.c_str(), "IRBytes", &STmp, ""); m_RecordIRBytesText[i]->SetValue(wxString::FromAscii(STmp.c_str()));
// Recording speed
file.Get(SaveName.c_str(), "RecordingSpeed", &iTmp, -1);
if(iTmp != -1)
m_RecordSpeed[i]->SetValue(wxString::Format(wxT("%i"), iTmp));
else
m_RecordSpeed[i]->SetValue(wxT(""));
// Playback speed (currently always saved directly after a recording)
file.Get(SaveName.c_str(), "PlaybackSpeed", &iTmp, -1); m_RecordPlayBackSpeed[i]->SetSelection(iTmp);
}
}
void WiimoteRecordingConfigDialog::SaveFile()
{
DEBUG_LOG(WIIMOTE, "SaveFile");
IniFile file;
file.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "WiimoteMovement.ini").c_str());
for(int i = 1; i < (RECORDING_ROWS + 1); i++)
{
// Get row name
std::string SaveName = StringFromFormat("Recording%i", i);
// HotKey
file.Set(SaveName.c_str(), "HotKeySwitch", m_RecordHotKeySwitch[i]->GetSelection());
file.Set(SaveName.c_str(), "HotKeyWiimote", m_RecordHotKeyWiimote[i]->GetSelection());
file.Set(SaveName.c_str(), "HotKeyNunchuck", m_RecordHotKeyNunchuck[i]->GetSelection());
file.Set(SaveName.c_str(), "HotKeyIR", m_RecordHotKeyIR[i]->GetSelection());
// Movement name
file.Set(SaveName.c_str(), "MovementName", (const char*)m_RecordText[i]->GetValue().mb_str(wxConvUTF8));
// Game name
file.Set(SaveName.c_str(), "GameName", (const char*)m_RecordGameText[i]->GetValue().mb_str(wxConvUTF8));
// Recording speed (currently always saved directly after a recording)
/*
wxString TmpRecordSpeed = m_RecordSpeed[i]->GetValue();
if(TmpRecordSpeed.length() > 0)
int TmpRecordSpeed; file.Set(SaveName.c_str(), "RecordingSpeed", TmpRecordSpeed);
else
int TmpRecordSpeed; file.Set(SaveName.c_str(), "RecordingSpeed", "-1");
*/
// Playback speed (currently always saved directly after a recording)
file.Set(SaveName.c_str(), "PlaybackSpeed", m_RecordPlayBackSpeed[i]->GetSelection());
}
file.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "WiimoteMovement.ini").c_str());
DEBUG_LOG(WIIMOTE, "SaveFile()");
}
void WiimoteRecordingConfigDialog::CreateGUIControlsRecording()
{
m_PageRecording = new wxPanel(this, ID_RECORDINGPAGE, wxDefaultPosition, wxDefaultSize);
m_TextUpdateRate = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Update rate: 000 times/s"));
m_UpdateMeters = new wxCheckBox(m_PageRecording, ID_UPDATE_REAL, wxT("Update gauges"));
m_UpdateMeters->SetValue(g_Config.bUpdateRealWiimote);
m_UpdateMeters->SetToolTip(
wxT("You can turn this off when a game is running to avoid a potential slowdown that may come from redrawing the\n")
wxT("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; //ugly
m_GaugeBattery = new wxGauge( m_PageRecording, wxID_ANY, 100, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeRoll[0] = new wxGauge( m_PageRecording, wxID_ANY, 360, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeRoll[1] = new wxGauge( m_PageRecording, wxID_ANY, 360, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeGForce[0] = new wxGauge( m_PageRecording, wxID_ANY, 600, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeGForce[1] = new wxGauge( m_PageRecording, wxID_ANY, 600, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeGForce[2] = new wxGauge( m_PageRecording, wxID_ANY, 600, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeAccel[0] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeAccel[1] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeAccel[2] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeAccelNunchuk[0] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeAccelNunchuk[1] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeAccelNunchuk[2] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeGForceNunchuk[0] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeGForceNunchuk[1] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
m_GaugeGForceNunchuk[2] = new wxGauge( m_PageRecording, wxID_ANY, 255, wxDefaultPosition, wxSize(Gw, Gh), wxGA_VERTICAL | wxNO_BORDER | wxGA_SMOOTH);
// The text controls
m_TextIR = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Cursor: 000 000\nDistance: 0000"));
wxBoxSizer * sBoxBattery = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * sBoxRoll[2];
sBoxRoll[0] = new wxBoxSizer(wxVERTICAL);
sBoxRoll[1] = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * sBoxGForce[3];
sBoxGForce[0] = new wxBoxSizer(wxVERTICAL);
sBoxGForce[1] = new wxBoxSizer(wxVERTICAL);
sBoxGForce[2] = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * sBoxAccel[3];
sBoxAccel[0] = new wxBoxSizer(wxVERTICAL);
sBoxAccel[1] = new wxBoxSizer(wxVERTICAL);
sBoxAccel[2] = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * sBoxAccelNunchuk[3];
sBoxAccelNunchuk[0] = new wxBoxSizer(wxVERTICAL);
sBoxAccelNunchuk[1] = new wxBoxSizer(wxVERTICAL);
sBoxAccelNunchuk[2] = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * sBoxGForceNunchuk[3];
sBoxGForceNunchuk[0] = new wxBoxSizer(wxVERTICAL);
sBoxGForceNunchuk[1] = new wxBoxSizer(wxVERTICAL);
sBoxGForceNunchuk[2] = new wxBoxSizer(wxVERTICAL);
wxStaticText * m_TextBattery = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Batt."), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
wxStaticText * m_TextRoll = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Roll"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
wxStaticText * m_TextPitch = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Pitch"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
wxStaticText *m_TextX[4], *m_TextY[4], *m_TextZ[4];
m_TextX[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextX[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextX[2] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextX[3] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("X"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
m_TextY[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextY[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextY[2] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextY[3] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Y"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
m_TextZ[0] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextZ[1] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextZ[2] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); m_TextZ[3] = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Z"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
sBoxBattery->Add(m_GaugeBattery, 0, wxEXPAND | (wxALL), 0); sBoxBattery->Add(m_TextBattery, 0, wxEXPAND | (wxUP), 5);
sBoxRoll[0]->Add(m_GaugeRoll[0], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 0); sBoxRoll[0]->Add(m_TextRoll, 0, wxEXPAND | (wxUP), 5);
sBoxRoll[1]->Add(m_GaugeRoll[1], 0, wxEXPAND | (wxUP | wxDOWN | wxRIGHT), 0); sBoxRoll[1]->Add(m_TextPitch, 0, wxEXPAND | (wxUP), 5);
sBoxGForce[0]->Add(m_GaugeGForce[0], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 0); sBoxGForce[0]->Add(m_TextX[0], 0, wxEXPAND | (wxUP), 5);
sBoxGForce[1]->Add(m_GaugeGForce[1], 0, wxEXPAND | (wxUP | wxDOWN), 0); sBoxGForce[1]->Add(m_TextY[0], 0, wxEXPAND | (wxUP), 5);
sBoxGForce[2]->Add(m_GaugeGForce[2], 0, wxEXPAND | (wxUP | wxDOWN | wxRIGHT), 0); sBoxGForce[2]->Add(m_TextZ[0], 0, wxEXPAND | (wxUP), 5);
sBoxAccel[0]->Add(m_GaugeAccel[0], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 0); sBoxAccel[0]->Add(m_TextX[1], 0, wxEXPAND | (wxUP), 5);
sBoxAccel[1]->Add(m_GaugeAccel[1], 0, wxEXPAND | (wxUP | wxDOWN), 0); sBoxAccel[1]->Add(m_TextY[1], 0, wxEXPAND | (wxUP), 5);
sBoxAccel[2]->Add(m_GaugeAccel[2], 0, wxEXPAND | (wxUP | wxDOWN | wxRIGHT), 0); sBoxAccel[2]->Add(m_TextZ[1], 0, wxEXPAND | (wxUP), 5);
sBoxGForceNunchuk[0]->Add(m_GaugeGForceNunchuk[0], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 0); sBoxGForceNunchuk[0]->Add(m_TextX[2], 0, wxEXPAND | (wxUP), 5);
sBoxGForceNunchuk[1]->Add(m_GaugeGForceNunchuk[1], 0, wxEXPAND | (wxUP | wxDOWN), 0); sBoxGForceNunchuk[1]->Add(m_TextY[2], 0, wxEXPAND | (wxUP), 5);
sBoxGForceNunchuk[2]->Add(m_GaugeGForceNunchuk[2], 0, wxEXPAND | (wxUP | wxDOWN | wxRIGHT), 0); sBoxGForceNunchuk[2]->Add(m_TextZ[2], 0, wxEXPAND | (wxUP), 5);
sBoxAccelNunchuk[0]->Add(m_GaugeAccelNunchuk[0], 0, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 0); sBoxAccelNunchuk[0]->Add(m_TextX[3], 0, wxEXPAND | (wxUP), 5);
sBoxAccelNunchuk[1]->Add(m_GaugeAccelNunchuk[1], 0, wxEXPAND | (wxUP | wxDOWN), 0); sBoxAccelNunchuk[1]->Add(m_TextY[3], 0, wxEXPAND | (wxUP), 5);
sBoxAccelNunchuk[2]->Add(m_GaugeAccelNunchuk[2], 0, wxEXPAND | (wxUP | wxDOWN | wxRIGHT), 0); sBoxAccelNunchuk[2]->Add(m_TextZ[3], 0, wxEXPAND | (wxUP), 5);
wxStaticBoxSizer * sbRealStatus = new wxStaticBoxSizer(wxVERTICAL, m_PageRecording, wxT("Status"));
wxStaticBoxSizer * sbRealIR = new wxStaticBoxSizer(wxHORIZONTAL, m_PageRecording, wxT("IR"));
wxStaticBoxSizer * sbRealBattery = new wxStaticBoxSizer(wxVERTICAL, m_PageRecording, wxT("Battery"));
wxStaticBoxSizer * sbRealRoll = new wxStaticBoxSizer(wxHORIZONTAL, m_PageRecording, wxT("Roll and Pitch"));
wxStaticBoxSizer * sbRealGForce = new wxStaticBoxSizer(wxHORIZONTAL, m_PageRecording, wxT("G-Force"));
wxStaticBoxSizer * sbRealAccel = new wxStaticBoxSizer(wxHORIZONTAL, m_PageRecording, wxT("Accelerometer"));
wxStaticBoxSizer * sbRealGForceNunchuk = new wxStaticBoxSizer(wxHORIZONTAL, m_PageRecording, wxT("G-Force NC"));
wxStaticBoxSizer * sbRealAccelNunchuk = new wxStaticBoxSizer(wxHORIZONTAL, m_PageRecording, wxT("Accelerometer NC"));
// Status
sbRealStatus->Add(m_TextUpdateRate, 0, wxEXPAND | (wxALL), 5);
sbRealStatus->Add(m_UpdateMeters, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
sbRealIR->Add(m_TextIR, 0, wxEXPAND | (wxALL), 5);
sbRealBattery->Add(sBoxBattery, 0, wxEXPAND | (wxALL), 5);
sbRealRoll->Add(sBoxRoll[0], 0, wxEXPAND | (wxALL), 5); sbRealRoll->Add(sBoxRoll[1], 0, wxEXPAND | (wxALL), 5);
sbRealGForce->Add(sBoxGForce[0], 0, wxEXPAND | (wxALL), 5); sbRealGForce->Add(sBoxGForce[1], 0, wxEXPAND | (wxALL), 5); sbRealGForce->Add(sBoxGForce[2], 0, wxEXPAND | (wxALL), 5);
sbRealAccel->Add(sBoxAccel[0], 0, wxEXPAND | (wxALL), 5); sbRealAccel->Add(sBoxAccel[1], 0, wxEXPAND | (wxALL), 5); sbRealAccel->Add(sBoxAccel[2], 0, wxEXPAND | (wxALL), 5);
sbRealAccelNunchuk->Add(sBoxAccelNunchuk[0], 0, wxEXPAND | (wxALL), 5); sbRealAccelNunchuk->Add(sBoxAccelNunchuk[1], 0, wxEXPAND | (wxALL), 5); sbRealAccelNunchuk->Add(sBoxAccelNunchuk[2], 0, wxEXPAND | (wxALL), 5);
sbRealGForceNunchuk->Add(sBoxGForceNunchuk[0], 0, wxEXPAND | (wxALL), 5); sbRealGForceNunchuk->Add(sBoxGForceNunchuk[1], 0, wxEXPAND | (wxALL), 5); sbRealGForceNunchuk->Add(sBoxGForceNunchuk[2], 0, wxEXPAND | (wxALL), 5);
// Vertical leftmost status
wxBoxSizer * sbStatusLeft = new wxBoxSizer(wxVERTICAL);
sbStatusLeft->Add(sbRealStatus, 0, wxEXPAND | (wxLEFT), 0);
sbStatusLeft->Add(sbRealIR, 0, wxEXPAND | (wxLEFT), 0);
wxBoxSizer * sbRealWiimoteStatus = new wxBoxSizer(wxHORIZONTAL);
sbRealWiimoteStatus->Add(sbStatusLeft, 0, wxEXPAND | (wxLEFT), 0);
sbRealWiimoteStatus->Add(sbRealBattery, 0, wxEXPAND | (wxLEFT), 5);
sbRealWiimoteStatus->Add(sbRealRoll, 0, wxEXPAND | (wxLEFT), 5);
sbRealWiimoteStatus->Add(sbRealGForce, 0, wxEXPAND | (wxLEFT), 5);
sbRealWiimoteStatus->Add(sbRealAccel, 0, wxEXPAND | (wxLEFT), 5);
sbRealWiimoteStatus->Add(sbRealAccelNunchuk, 0, wxEXPAND | (wxLEFT), 5);
sbRealWiimoteStatus->Add(sbRealGForceNunchuk, 0, wxEXPAND | (wxLEFT), 5);
m_GaugeBattery->SetToolTip(wxT("Press '+' to show the current status. Press '-' to stop recording the status."));
wxStaticBoxSizer * sbRealRecord = new wxStaticBoxSizer(wxVERTICAL, m_PageRecording, wxT("Record movements"));
wxArrayString StrHotKeySwitch;
StrHotKeySwitch.Add(wxT("Shift"));
StrHotKeySwitch.Add(wxT("Ctrl"));
StrHotKeySwitch.Add(wxT("Alt"));
StrHotKeySwitch.Add(wxT(" "));
wxArrayString StrHotKey;
for(int i = 0; i < 10; i++) StrHotKey.Add(wxString::Format(wxT("%i"), i));
StrHotKey.Add(wxT(" "));
wxArrayString StrPlayBackSpeed;
for(int i = 1; i <= 20; i++) StrPlayBackSpeed.Add(wxString::Format(wxT("%i"), i*25));
wxBoxSizer * sRealRecord[RECORDING_ROWS + 1];
wxStaticText * m_TextRec = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Rec."), wxDefaultPosition, wxSize(80, -1), wxALIGN_CENTRE);
wxStaticText * m_TextHotKeyWm = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Wiim."), wxDefaultPosition, wxSize(32, -1), wxALIGN_CENTRE);
wxStaticText * m_TextHotKeyNc = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Nunc."), wxDefaultPosition, wxSize(32, -1), wxALIGN_CENTRE);
wxStaticText * m_TextHotKeyIR = new wxStaticText(m_PageRecording, wxID_ANY, wxT("IR"), wxDefaultPosition, wxSize(32, -1), wxALIGN_CENTRE);
wxStaticText * m_TextMovement = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Movement name"), wxDefaultPosition, wxSize(200, -1), wxALIGN_CENTRE);
wxStaticText * m_TextGame = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Game name"), wxDefaultPosition, wxSize(200, -1), wxALIGN_CENTRE);
wxStaticText * m_TextIRBytes = new wxStaticText(m_PageRecording, wxID_ANY, wxT("IR"), wxDefaultPosition, wxSize(20, -1), wxALIGN_CENTRE);
wxStaticText * m_TextRecSpeed = new wxStaticText(m_PageRecording, wxID_ANY, wxT("R. s."), wxDefaultPosition, wxSize(33, -1), wxALIGN_CENTRE);
wxStaticText * m_TextPlaySpeed = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Pl. s."), wxDefaultPosition, wxSize(40, -1), wxALIGN_CENTRE);
// Tool tips
m_TextRec->SetToolTip(
wxT("To record a movement first press this button, then start the recording by pressing 'A' on the Wiimote and stop the recording\n")
wxT("by letting go of 'A'"));
m_TextHotKeyWm->SetToolTip(
wxT("Select a hotkey for playback of Wiimote movements. You can combine it with an")
wxT(" optional Shift, Ctrl, or Alt switch."));
m_TextHotKeyNc->SetToolTip(wxT(
"Select a hotkey for playback of Nunchuck movements"));
m_TextHotKeyIR->SetToolTip(wxT(
"Select a hotkey for playback of Nunchuck movements"));
m_TextRecSpeed->SetToolTip(wxT(
"Recording speed in average measurements per second"));
m_TextPlaySpeed->SetToolTip(
wxT("Playback speed: A playback speed of 100 means that the playback occurs at the same rate as it was recorded. (You can see the\n")
wxT("current update rate in the Status window above when a game is running.) However, if your framerate is only at 50% of full speed\n")
wxT("you may want to select a playback rate of 50, because then the game might perceive the playback as a full speed playback. (This\n")
wxT("holds if Wiimote_Update() is tied to the framerate, I'm not sure that this is the case. It seemed to vary somewhat with different\n")
wxT("framerates but perhaps not enough to say that it was exactly tied to the framerate.) So until this is better understood you'll have\n")
wxT("to try different playback rates and see which one that works."));
sRealRecord[0] = new wxBoxSizer(wxHORIZONTAL);
sRealRecord[0]->Add(m_TextRec, 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[0]->Add(m_TextHotKeyWm, 0, wxEXPAND | (wxLEFT), 62);
sRealRecord[0]->Add(m_TextHotKeyNc, 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[0]->Add(m_TextHotKeyIR, 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[0]->Add(m_TextMovement, 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[0]->Add(m_TextGame, 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[0]->Add(m_TextIRBytes, 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[0]->Add(m_TextRecSpeed, 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[0]->Add(m_TextPlaySpeed, 0, wxEXPAND | (wxLEFT), 5);
sbRealRecord->Add(sRealRecord[0], 0, wxEXPAND | (wxALL), 0);
for(int i = 1; i < (RECORDING_ROWS + 1); i++)
{
sRealRecord[i] = new wxBoxSizer(wxHORIZONTAL);
m_RecordButton[i] = new wxButton(m_PageRecording, IDB_RECORD + i, wxEmptyString, wxDefaultPosition, wxSize(80, 20), 0, wxDefaultValidator, wxEmptyString);
m_RecordHotKeySwitch[i] = new wxChoice(m_PageRecording, IDC_RECORD + i, wxDefaultPosition, wxDefaultSize, StrHotKeySwitch);
m_RecordHotKeyWiimote[i] = new wxChoice(m_PageRecording, IDC_RECORD + i, wxDefaultPosition, wxDefaultSize, StrHotKey);
m_RecordHotKeyNunchuck[i] = new wxChoice(m_PageRecording, IDC_RECORD + i, wxDefaultPosition, wxDefaultSize, StrHotKey);
m_RecordHotKeyIR[i] = new wxChoice(m_PageRecording, IDC_RECORD + i, wxDefaultPosition, wxDefaultSize, StrHotKey);
m_RecordText[i] = new wxTextCtrl(m_PageRecording, IDT_RECORD_TEXT, wxT(""), wxDefaultPosition, wxSize(200, 19));
m_RecordGameText[i] = new wxTextCtrl(m_PageRecording, IDT_RECORD_GAMETEXT, wxT(""), wxDefaultPosition, wxSize(200, 19));
m_RecordIRBytesText[i] = new wxTextCtrl(m_PageRecording, IDT_RECORD_IRBYTESTEXT, wxT(""), wxDefaultPosition, wxSize(25, 19));
m_RecordSpeed[i] = new wxTextCtrl(m_PageRecording, IDT_RECORD_SPEED, wxT(""), wxDefaultPosition, wxSize(30, 19), wxTE_READONLY | wxTE_CENTRE);
m_RecordPlayBackSpeed[i] = new wxChoice(m_PageRecording, IDT_RECORD_PLAYSPEED, wxDefaultPosition, wxDefaultSize, StrPlayBackSpeed);
m_RecordText[i]->SetMaxLength(35);
m_RecordGameText[i]->SetMaxLength(35);
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);
sRealRecord[i]->Add(m_RecordHotKeyNunchuck[i], 0, wxEXPAND | (wxLEFT), 2);
sRealRecord[i]->Add(m_RecordHotKeyIR[i], 0, wxEXPAND | (wxLEFT), 2);
sRealRecord[i]->Add(m_RecordText[i], 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[i]->Add(m_RecordGameText[i], 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[i]->Add(m_RecordIRBytesText[i], 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[i]->Add(m_RecordSpeed[i], 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[i]->Add(m_RecordPlayBackSpeed[i], 0, wxEXPAND | (wxLEFT), 5);
sbRealRecord->Add(sRealRecord[i], 0, wxEXPAND | (wxTOP), 2);
}
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);
m_Apply = new wxButton(this, wxID_APPLY, wxT("Apply"));
m_Close = new wxButton(this, wxID_CLOSE, wxT("Close"));
m_Close->SetToolTip(wxT("Apply and Close"));
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->AddStretchSpacer();
sButtons->Add(m_Apply, 0, (wxALL), 0);
sButtons->Add(m_Close, 0, (wxLEFT), 5);
m_MainSizer = new wxBoxSizer(wxVERTICAL);
m_MainSizer->Add(m_PageRecording, 1, wxEXPAND | wxALL, 5);
m_MainSizer->Add(sButtons, 0, wxEXPAND | (wxLEFT | wxRIGHT | wxDOWN), 5);
this->SetSizer(m_MainSizer);
this->Layout();
Fit();
// Center the window if there is room for it
#ifdef _WIN32
if (GetSystemMetrics(SM_CYFULLSCREEN) > 800)
Center();
#endif
ControlsCreated = true;
}
void WiimoteRecordingConfigDialog::ConvertToString()
{
IniFile file;
file.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "WiimoteMovement.ini").c_str());
std::string TmpStr = "", TmpIR = "", TmpTime = "";
for (int i = 0; i < (int)m_vRecording.size(); i++)
{
// Write the movement data
TmpStr += StringFromFormat("%s", m_vRecording.at(i).x >= 0 ? StringFromFormat("+%03i", m_vRecording.at(i).x).c_str() : StringFromFormat("%04i", m_vRecording.at(i).x).c_str());
TmpStr += StringFromFormat("%s", m_vRecording.at(i).y >= 0 ? StringFromFormat("+%03i", m_vRecording.at(i).y).c_str() : StringFromFormat("%04i", m_vRecording.at(i).y).c_str());
TmpStr += StringFromFormat("%s", m_vRecording.at(i).z >= 0 ? StringFromFormat("+%03i", m_vRecording.at(i).z).c_str() : StringFromFormat("%04i", m_vRecording.at(i).z).c_str());
if (i < ((int)m_vRecording.size() - 1)) TmpStr += ",";
DEBUG_LOG(WIIMOTE, "%s", TmpStr.c_str());
// Write the IR data
TmpIR += ArrayToString(m_vRecording.at(i).IR, IRBytes, 0, 30, false);
if (i < ((int)m_vRecording.size() - 1)) TmpIR += ",";
// Write the timestamps. The upper limit is 99 seconds.
int Time = (int)((m_vRecording.at(i).Time - m_vRecording.at(0).Time) * 1000);
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. */
if(TmpStr.length() > (1024*10 - 10) || TmpIR.length() > (1024*10 - 10) || TmpTime.length() > (1024*10 - 10))
{
break;
PanicAlert("Your recording was to long, the entire recording was not saved.");
}
// Debug
DEBUG_LOG(WIIMOTE, "Saved: [%i / %i] %03i %03i %03i", i, m_vRecording.size(), m_vRecording.at(i).x, m_vRecording.at(i).y, m_vRecording.at(i).z);
}
// Recordings per second
double Recordings = (double)m_vRecording.size();
double Time = m_vRecording.at(m_vRecording.size() - 1).Time - m_vRecording.at(0).Time;
int Rate = (int)(Recordings / Time);
// If time or the number of recordings are zero we set the Rate to zero
if (Time == 0 || m_vRecording.size() == 0) Rate = 0;
// Update GUI
m_RecordIRBytesText[m_iRecordTo]->SetValue(wxString::Format(wxT("%i"), IRBytes));
m_RecordSpeed[m_iRecordTo]->SetValue(wxString::Format(wxT("%i"), Rate));
// Save file
std::string SaveName = StringFromFormat("Recording%i", m_iRecordTo);
file.Set(SaveName.c_str(), "Movement", TmpStr.c_str());
file.Set(SaveName.c_str(), "IR", TmpIR.c_str());
file.Set(SaveName.c_str(), "Time", TmpTime.c_str());
file.Set(SaveName.c_str(), "IRBytes", IRBytes);
file.Set(SaveName.c_str(), "RecordingSpeed", Rate);
// Set a default playback speed if none is set already
int TmpPlaySpeed; file.Get(SaveName.c_str(), "PlaybackSpeed", &TmpPlaySpeed, -1);
if (TmpPlaySpeed == -1)
{
file.Set(SaveName.c_str(), "PlaybackSpeed", 3);
m_RecordPlayBackSpeed[m_iRecordTo]->SetSelection(3);
}
file.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "WiimoteMovement.ini").c_str());
DEBUG_LOG(WIIMOTE, "Save recording to WiimoteMovement.ini");
}
// Timeout the recording
void WiimoteRecordingConfigDialog::Update(wxTimerEvent& WXUNUSED(event))
{
m_bWaitForRecording = false;
m_bRecording = false;
m_RecordButton[m_iRecordTo]->SetLabel(wxT(""));
UpdateRecordingGUI();
}
void WiimoteRecordingConfigDialog::RecordMovement(wxCommandEvent& event)
{
m_iRecordTo = event.GetId() - 2000;
if(WiiMoteReal::g_MotionSensing)
{
// Check if there already is a recording here
if(m_RecordSpeed[m_iRecordTo]->GetLineLength(0) > 0)
{
if(!AskYesNo("Do you want to replace the current recording?")) return;
}
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Hold A"));
}
else
{
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Press +"));
return;
}
m_bWaitForRecording = true;
m_bRecording = false;
UpdateRecordingGUI();
m_TimeoutTimer->Start(5000, true);
}
void WiimoteRecordingConfigDialog::DoRecordA(bool Pressed)
{
// Return if we are not waiting or recording
if (! (m_bWaitForRecording || m_bRecording)) return;
// Return if we are waiting but have not pressed A
if (m_bWaitForRecording && !Pressed) return;
// Return if we are recording but are still pressing A
if (m_bRecording && Pressed) return;
//m_bAllowA = false;
m_bRecording = Pressed;
// Start recording, only run this once
if(m_bRecording && m_bWaitForRecording)
{
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Recording..."));
m_vRecording.clear(); // Clear the list
m_TimeoutTimer->Stop();
m_bWaitForRecording = false;
}
// The recording is done
else
{
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Done"));
DEBUG_LOG(WIIMOTE, "Done: %i %i", m_bWaitForRecording, m_bRecording);
//m_bAllowA = true;
ConvertToString();
}
UpdateRecordingGUI();
}
void WiimoteRecordingConfigDialog::DoRecordMovement(int _x, int _y, int _z, const u8 *_IR, int _IRBytes)
{
//std::string Tmp1 = ArrayToString(_IR, 20, 0, 30);
//DEBUG_LOG(WIIMOTE, "DoRecordMovement: %s", Tmp1.c_str());
if (!m_bRecording) return;
//DEBUG_LOG(WIIMOTE, "DoRecordMovement: %03i %03i %03i", _x, _y, _z);
SRecording Tmp;
Tmp.x = _x;
Tmp.y = _y;
Tmp.z = _z;
Tmp.Time = Common::Timer::GetDoubleTime();
memcpy(Tmp.IR, _IR, _IRBytes);
m_vRecording.push_back(Tmp);
// Save the number of IR bytes
IRBytes = _IRBytes;
// The upper limit of a recording coincides with the IniFile.cpp limit, each list element
// is 7 bytes, therefore be divide by 7
if (m_vRecording.size() > (10*1024 / 7 - 2) )
{
m_bRecording = false;
m_RecordButton[m_iRecordTo]->SetLabel(wxT("Done"));
ConvertToString();
UpdateRecordingGUI();
}
}

View File

@ -1,147 +0,0 @@
// Copyright (C) 2003 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/
#include "wiimote_hid.h"
#include "main.h"
#include "ConfigRecordingDlg.h"
#include "ConfigBasicDlg.h"
#include "Config.h"
#include "EmuMain.h" // for LoadRecordedMovements()
#include "wiimote_real.h"
BEGIN_EVENT_TABLE(WiimoteRecordingConfigDialog,wxDialog)
EVT_CLOSE(WiimoteRecordingConfigDialog::OnClose)
EVT_BUTTON(wxID_CLOSE, WiimoteRecordingConfigDialog::CloseClick)
EVT_BUTTON(wxID_APPLY, WiimoteRecordingConfigDialog::CloseClick)
EVT_CHOICE(IDC_RECORD + 1, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 2, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 3, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 4, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 5, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 6, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 7, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 8, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 9, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 10, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 11, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 12, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 13, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 14, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_CHOICE(IDC_RECORD + 15, WiimoteRecordingConfigDialog::RecordingChanged)
EVT_BUTTON(IDB_RECORD + 1, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 2, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 3, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 4, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 5, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 6, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 7, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 8, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 9, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 10, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 11, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 12, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 13, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 14, WiimoteRecordingConfigDialog::RecordMovement)
EVT_BUTTON(IDB_RECORD + 15, WiimoteRecordingConfigDialog::RecordMovement)
EVT_TIMER(IDTM_UPDATE, WiimoteRecordingConfigDialog::Update)
END_EVENT_TABLE()
WiimoteRecordingConfigDialog::WiimoteRecordingConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
#if wxUSE_TIMER
m_TimeoutTimer = new wxTimer(this, IDTM_UPDATE);
#endif
m_bWaitForRecording = false;
m_bRecording = false;
m_vRecording.resize(RECORDING_ROWS + 1);
g_Config.Load();
CreateGUIControlsRecording();
SetBackgroundColour(m_PageRecording->GetBackgroundColour());
LoadFile();
// Set control values
UpdateRecordingGUI();
}
void WiimoteRecordingConfigDialog::OnClose(wxCloseEvent& event)
{
SaveFile();
EndModal(wxID_CLOSE);
}
void WiimoteRecordingConfigDialog::CloseClick(wxCommandEvent& event)
{
switch(event.GetId())
{
case wxID_CLOSE:
#if HAVE_WIIUSE
if (!WiiMoteReal::SafeClose())
#endif
Close();
break;
case wxID_APPLY:
SaveFile();
WiiMoteEmu::LoadRecordedMovements();
break;
}
}
void WiimoteRecordingConfigDialog::RecordingChanged(wxCommandEvent& event)
{
switch (event.GetId())
{
case ID_UPDATE_REAL:
g_Config.bUpdateRealWiimote = m_UpdateMeters->IsChecked();
break;
default:
// Check if any of the other choice boxes has the same hotkey
for (int i = 1; i < (RECORDING_ROWS + 1); i++)
{
int CurrentChoiceBox = (event.GetId() - IDC_RECORD);
if (i == CurrentChoiceBox) continue;
if (m_RecordHotKeyWiimote[i]->GetSelection() == m_RecordHotKeyWiimote[CurrentChoiceBox]->GetSelection()) m_RecordHotKeyWiimote[i]->SetSelection(10);
if (m_RecordHotKeyNunchuck[i]->GetSelection() == m_RecordHotKeyNunchuck[CurrentChoiceBox]->GetSelection()) m_RecordHotKeyNunchuck[i]->SetSelection(10);
if (m_RecordHotKeyIR[i]->GetSelection() == m_RecordHotKeyIR[CurrentChoiceBox]->GetSelection()) m_RecordHotKeyIR[i]->SetSelection(10);
//DEBUG_LOG(WIIMOTE, "HotKey: %i %i",
// m_RecordHotKey[i]->GetSelection(), m_RecordHotKey[CurrentChoiceBox]->GetSelection());
}
break;
}
g_Config.Save();
UpdateRecordingGUI();
}
void WiimoteRecordingConfigDialog::UpdateRecordingGUI(int Slot)
{
// Disable all recording buttons
#ifdef _WIN32
bool ActiveRecording = !(m_bWaitForRecording || m_bRecording);
for(int i = IDB_RECORD + 1; i < (IDB_RECORD + RECORDING_ROWS + 1); i++)
if(ControlsCreated) m_PageRecording->FindItem(i)->Enable(ActiveRecording);
#endif
}

View File

@ -1,129 +0,0 @@
// Copyright (C) 2003 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 __CONFIGDIALOG_h__
#define __CONFIGDIALOG_h__
#include <iostream>
#include <vector>
#include <wx/wx.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/stattext.h>
#include <wx/combobox.h>
#include <wx/checkbox.h>
#include <wx/panel.h>
#include "Thread.h"
class WiimoteRecordingConfigDialog : public wxDialog
{
public:
WiimoteRecordingConfigDialog(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString &title = wxT("Wii Remote Plugin Configuration"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS);
virtual ~WiimoteRecordingConfigDialog(){;}
void UpdateRecordingGUI(int Slot = 0);
void LoadFile();
void SaveFile();
void DoRecordMovement(int _x, int _y, int _z, const u8 *_IR, int IRBytes);
void DoRecordA(bool Pressed);
void ConvertToString();
void CloseClick(wxCommandEvent& event);
void RecordMovement(wxCommandEvent& event);
void Update(wxTimerEvent& WXUNUSED(event));
bool m_bWaitForRecording,
m_bRecording;
int m_iRecordTo;
wxTimer *m_TimeoutTimer;
// General status
wxStaticText * m_TextUpdateRate,
*m_TextIR;
// Wiimote status
wxGauge *m_GaugeBattery,
*m_GaugeRoll[2],
*m_GaugeGForce[3],
*m_GaugeAccel[3],
*m_GaugeAccelNunchuk[3],
*m_GaugeGForceNunchuk[3];
private:
DECLARE_EVENT_TABLE();
bool ControlsCreated;
THREAD_RETURN SafeCloseReadWiimote_ThreadFunc2(void* arg);
Common::Thread* g_pReadThread2;
wxPanel *m_PageRecording;
wxButton *m_Close,
*m_Apply;
wxBoxSizer *m_MainSizer,
*m_sRecordingMain;
wxCheckBox *m_UpdateMeters;
wxButton * m_RecordButton[RECORDING_ROWS + 1];
wxChoice * m_RecordHotKeySwitch[RECORDING_ROWS + 1];
wxChoice * m_RecordHotKeyWiimote[RECORDING_ROWS + 1];
wxChoice * m_RecordHotKeyNunchuck[RECORDING_ROWS + 1];
wxChoice * m_RecordHotKeyIR[RECORDING_ROWS + 1];
wxTextCtrl * m_RecordText[RECORDING_ROWS + 1];
wxTextCtrl * m_RecordGameText[RECORDING_ROWS + 1];
wxTextCtrl * m_RecordIRBytesText[RECORDING_ROWS + 1];
wxTextCtrl * m_RecordSpeed[RECORDING_ROWS + 1];
wxChoice * m_RecordPlayBackSpeed[RECORDING_ROWS + 1];
std::vector<SRecording> m_vRecording;
int IRBytes;
enum
{
ID_RECORDINGPAGE = 1000,
IDTM_UPDATE,
// Real
ID_UPDATE_REAL,
IDB_RECORD = 2000,
IDC_RECORD = 3000,
IDC_PLAY_WIIMOTE,
IDC_PLAY_NUNCHUCK,
IDC_PLAY_IR,
IDT_RECORD_TEXT,
IDT_RECORD_GAMETEXT,
IDT_RECORD_IRBYTESTEXT,
IDT_RECORD_SPEED,
IDT_RECORD_PLAYSPEED
};
void OnClose(wxCloseEvent& event);
void CreateGUIControlsRecording();
void RecordingChanged(wxCommandEvent& event);
};
extern WiimoteRecordingConfigDialog *m_RecordingConfigFrame;
#endif

View File

@ -1,417 +0,0 @@
// Copyright (C) 2003 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/
#include <iostream> // System
#include "wiiuse.h" // Externals
#include "StringUtil.h"
#include "Timer.h"
#include "pluginspecs_wiimote.h"
#include "wiimote_real.h" // Local
#include "wiimote_hid.h"
#include "EmuDefinitions.h"
#include "EmuMain.h"
#include "main.h"
#if defined(HAVE_WX) && HAVE_WX
#include "ConfigBasicDlg.h"
#include "ConfigRecordingDlg.h"
#include "ConfigPadDlg.h"
#endif
#include "Config.h"
namespace WiiMoteReal
{
int GetIRDataSize(struct wiimote_t* wm)
{
if (WIIUSE_USING_EXP(wm))
return 10;
else
return 12;
}
void handle_ctrl_status(struct wiimote_t* wm)
{
DEBUG_LOG(WIIMOTE, "--- CONTROLLER STATUS [wiimote id %i] ---", wm->unid);
DEBUG_LOG(WIIMOTE, "attachment: %i", wm->expansion.type);
DEBUG_LOG(WIIMOTE, "speaker: %i", WIIUSE_USING_SPEAKER(wm));
DEBUG_LOG(WIIMOTE, "ir: %i", WIIUSE_USING_IR(wm));
DEBUG_LOG(WIIMOTE, "leds: %i %i %i %i", WIIUSE_IS_LED_SET(wm, 1), WIIUSE_IS_LED_SET(wm, 2), WIIUSE_IS_LED_SET(wm, 3), WIIUSE_IS_LED_SET(wm, 4));
DEBUG_LOG(WIIMOTE, "battery: %f %%", wm->battery_level);
}
bool IRDataOK(struct wiimote_t* wm)
{
// This check is valid because 0 should only be returned if the data
// hasn't been filled in by wiiuse
int IRDataSize = GetIRDataSize(wm);
for (int i = 7; i < IRDataSize; i++)
if (wm->event_buf[i] == 0)
return false;
return true;
}
void handle_event(struct wiimote_t* wm)
{
//DEBUG_LOG(WIIMOTE, "--- EVENT [id %i] ---", wm->unid);
// if a button is pressed, report it
if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) DEBUG_LOG(WIIMOTE, "A pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_B)) DEBUG_LOG(WIIMOTE, "B pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_UP)) DEBUG_LOG(WIIMOTE, "UP pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) DEBUG_LOG(WIIMOTE, "DOWN pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT)) DEBUG_LOG(WIIMOTE, "LEFT pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT)) DEBUG_LOG(WIIMOTE, "RIGHT pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) DEBUG_LOG(WIIMOTE, "MINUS pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) DEBUG_LOG(WIIMOTE, "PLUS pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) DEBUG_LOG(WIIMOTE, "ONE pressed");
//if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) g_Run = false;
if (IS_PRESSED(wm, WIIMOTE_BUTTON_TWO)) DEBUG_LOG(WIIMOTE, "TWO pressed");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) DEBUG_LOG(WIIMOTE, "HOME pressed");
// Create shortcut to the nunchuck
struct nunchuk_t* nc = NULL;
if (wm->expansion.type == EXP_NUNCHUK) {
nc = (nunchuk_t*)&wm->expansion.nunchuk;
if (IS_PRESSED(nc, NUNCHUK_BUTTON_C))
DEBUG_LOG(WIIMOTE, "C pressed");
if (IS_PRESSED(nc, NUNCHUK_BUTTON_Z))
DEBUG_LOG(WIIMOTE, "Z pressed");
}
// Pressing minus will tell the wiimote we are no longer interested in movement.
// This is useful because it saves battery power.
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_MINUS))
{
wiiuse_motion_sensing(wm, 0);
wiiuse_set_ir(wm, 0);
g_MotionSensing = false;
}
// Turn aceelerometer and IR reporting on, there is some kind of bug that prevents us from turing these on
// directly after each other, so we have to wait for another wiiuse_poll() this way
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_PLUS))
{
wiiuse_motion_sensing(wm, 1);
g_MotionSensing = true;
}
// Turn IR reporting on
if (g_MotionSensing && !WIIUSE_USING_IR(wm))
wiiuse_set_ir(wm, 1);
#if defined(HAVE_WX) && HAVE_WX
if (!m_RecordingConfigFrame) return;
// Print battery status
if(m_RecordingConfigFrame && g_Config.bUpdateRealWiimote)
m_RecordingConfigFrame->m_GaugeBattery->SetValue((int)floor((wm->battery_level * 100) + 0.5));
#endif
// If the accelerometer is turned on then print angles
if (WIIUSE_USING_ACC(wm) && WIIUSE_USING_IR(wm))
{
/*
std::string Tmp;
Tmp += StringFromFormat("Roll: %2.1f ", wm->orient.roll);
Tmp += StringFromFormat("Pitch: %2.1f ", wm->orient.pitch);
Tmp += StringFromFormat("Battery: %1.2f\n", wm->battery_level);
Tmp += StringFromFormat("G-Force x, y, z: %1.2f %1.2f %1.2f\n", wm->gforce.x, wm->gforce.y, wm->gforce.z);
Tmp += StringFromFormat("Accel x, y, z: %03i %03i %03i\n", wm->accel.x, wm->accel.y, wm->accel.z); */
// wm->event_buf is cleared at the end of all wiiuse_poll(), so wm->event_buf will always be zero
// after that. To get the raw IR data we need to read the wiimote again. This seems to work most of the time,
// it seems to fails with a regular interval about each tenth read.
if (wiiuse_io_read(wm))
if (IRDataOK(wm))
memcpy(g_EventBuffer, wm->event_buf, GetIRDataSize(wm));
/*
// Go through each of the 4 possible IR sources
for (int i = 0; i < 4; ++i)
{
// Check if the source is visible
if (wm->ir.dot[i].visible)
Tmp += StringFromFormat("IR source %i: (%u, %u)\n", i, wm->ir.dot[i].x, wm->ir.dot[i].y);
}
Tmp += "\n";
Tmp += StringFromFormat("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
Tmp += StringFromFormat("IR z distance: %f\n", wm->ir.z);
if(wm->expansion.type == EXP_NUNCHUK)
{
Tmp += "\n";
Tmp += StringFromFormat("Nunchuck accel x, y, z: %03i %03i %03i\n", nc->accel.x, nc->accel.y, nc->accel.z);
} */
//Tmp += "\n";
//std::string TmpData = ArrayToString(g_EventBuffer, ReportSize, 0, 30);
//Tmp += "Data: " + TmpData;
//DEBUG_LOG(WIIMOTE, "%s", Tmp.c_str());
#if defined(HAVE_WX) && HAVE_WX
if(m_RecordingConfigFrame && g_Config.bUpdateRealWiimote)
{
// Produce adjusted accelerometer values
float _Gx = (float)(wm->accel.x - wm->accel_calib.cal_zero.x) / (float)wm->accel_calib.cal_g.x;
float _Gy = (float)(wm->accel.y - wm->accel_calib.cal_zero.y) / (float)wm->accel_calib.cal_g.y;
float _Gz = (float)(wm->accel.z - wm->accel_calib.cal_zero.z) / (float)wm->accel_calib.cal_g.z;
// Conver the data to integers
int Gx = (int)(_Gx * 100);
int Gy = (int)(_Gy * 100);
int Gz = (int)(_Gz * 100);
{ //Updating Wiimote Gauges.
m_RecordingConfigFrame->m_GaugeRoll[0]->SetValue(wm->orient.roll + 180);
m_RecordingConfigFrame->m_GaugeRoll[1]->SetValue(wm->orient.pitch + 180);
// Show g. forces between -3 and 3
m_RecordingConfigFrame->m_GaugeGForce[0]->SetValue((int)floor((wm->gforce.x * 100) + 300.5));
m_RecordingConfigFrame->m_GaugeGForce[1]->SetValue((int)floor((wm->gforce.y * 100) + 300.5));
m_RecordingConfigFrame->m_GaugeGForce[2]->SetValue((int)floor((wm->gforce.z * 100) + 300.5));
m_RecordingConfigFrame->m_GaugeAccel[0]->SetValue(wm->accel.x);
m_RecordingConfigFrame->m_GaugeAccel[1]->SetValue(wm->accel.y);
m_RecordingConfigFrame->m_GaugeAccel[2]->SetValue(wm->accel.z);
int GNCx, GNCy, GNCz;
if(wm->expansion.type == EXP_NUNCHUK) // Updating Nunchuck Gauges
{
m_RecordingConfigFrame->m_GaugeGForceNunchuk[0]->SetValue((int)floor((nc->gforce.x * 300) + 100.5));
m_RecordingConfigFrame->m_GaugeGForceNunchuk[1]->SetValue((int)floor((nc->gforce.y * 300) + 100.5));
m_RecordingConfigFrame->m_GaugeGForceNunchuk[2]->SetValue((int)floor((nc->gforce.z * 300) + 100.5));
m_RecordingConfigFrame->m_GaugeAccelNunchuk[0]->SetValue(nc->accel.x);
m_RecordingConfigFrame->m_GaugeAccelNunchuk[1]->SetValue(nc->accel.y);
m_RecordingConfigFrame->m_GaugeAccelNunchuk[2]->SetValue(nc->accel.z);
//Produce valid data for recording
float _GNCx = (float)(nc->accel.x - nc->accel_calib.cal_zero.x) / (float)nc->accel_calib.cal_g.x;
float _GNCy = (float)(nc->accel.y - nc->accel_calib.cal_zero.y) / (float)nc->accel_calib.cal_g.y;
float _GNCz = (float)(nc->accel.z - nc->accel_calib.cal_zero.z) / (float)nc->accel_calib.cal_g.z;
// Conver the data to integers
GNCx = (int)(_GNCx * 100);
GNCy = (int)(_GNCy * 100);
GNCz = (int)(_GNCz * 100);
}
m_RecordingConfigFrame->m_TextIR->SetLabel(wxString::Format(
wxT("Cursor: %03u %03u\nDistance:%4.0f"), wm->ir.x, wm->ir.y, wm->ir.z));
//m_RecordingConfigFrame->m_TextAccNeutralCurrent->SetLabel(wxString::Format(
// wxT("Current: %03u %03u %03u"), Gx, Gy, Gz));
if(m_RecordingConfigFrame->m_bRecording) {
if(wm->expansion.type != EXP_NUNCHUK) {
DEBUG_LOG(WIIMOTE, "Wiiuse Recorded accel x, y, z: %03i %03i %03i", Gx, Gy, Gz);
}
else {
DEBUG_LOG(WIIMOTE, "Wiiuse Recorded accel x, y, z: %03i %03i %03i; NCx, NCy, NCz: %03i %03i %03i",Gx,Gy,Gz, GNCx, GNCy, GNCz);
}
}
}
// Send the data to be saved //todo: passing nunchuck x,y,z vars as well
m_RecordingConfigFrame->DoRecordMovement(Gx, Gy, Gz, g_EventBuffer + 6, GetIRDataSize(wm));
// Turn recording on and off
if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) m_RecordingConfigFrame->DoRecordA(true);
else m_RecordingConfigFrame->DoRecordA(false);
// ------------------------------------
// Show roll and pitch in the status box
// --------------
if(!g_DebugData)
{
DEBUG_LOG(WIIMOTE, "Roll:%03i Pitch:%03i", (int)wm->orient.roll, (int)wm->orient.pitch);
}
if(m_PadConfigFrame)
{
// Convert Roll and Pitch from 180 to 0x8000
int Roll = (int)wm->orient.roll * (0x8000 / 180);
int Pitch = (int)wm->orient.pitch * (0x8000 / 180);
// Convert it to the box
m_PadConfigFrame->Convert2Box(Roll);
m_PadConfigFrame->Convert2Box(Pitch);
// Show roll and pitch in the axis boxes
m_PadConfigFrame->m_bmpDotRightOut[0]->SetPosition(wxPoint(Roll, Pitch));
}
}
#endif
}
// Otherwise remove the values
else
{
#if defined(HAVE_WX) && HAVE_WX
if (m_RecordingConfigFrame)
{
NOTICE_LOG(BOOT, "readwiimote, reset bars to zero");
m_RecordingConfigFrame->m_GaugeRoll[0]->SetValue(0);
m_RecordingConfigFrame->m_GaugeRoll[1]->SetValue(0);
m_RecordingConfigFrame->m_GaugeGForce[0]->SetValue(0);
m_RecordingConfigFrame->m_GaugeGForce[1]->SetValue(0);
m_RecordingConfigFrame->m_GaugeGForce[2]->SetValue(0);
m_RecordingConfigFrame->m_GaugeAccel[0]->SetValue(0);
m_RecordingConfigFrame->m_GaugeAccel[1]->SetValue(0);
m_RecordingConfigFrame->m_GaugeAccel[2]->SetValue(0);
m_RecordingConfigFrame->m_GaugeAccelNunchuk[0]->SetValue(0);
m_RecordingConfigFrame->m_GaugeAccelNunchuk[1]->SetValue(0);
m_RecordingConfigFrame->m_GaugeAccelNunchuk[2]->SetValue(0);
m_RecordingConfigFrame->m_GaugeGForceNunchuk[0]->SetValue(0);
m_RecordingConfigFrame->m_GaugeGForceNunchuk[1]->SetValue(0);
m_RecordingConfigFrame->m_GaugeGForceNunchuk[2]->SetValue(0);
m_RecordingConfigFrame->m_TextIR->SetLabel(wxT("Cursor:\nDistance:"));
}
#endif
}
}
void ReadWiimote()
{
/* I place this outside wiiuse_poll() to produce a continous recording regardless of the status
change of the Wiimote, wiiuse_poll() is only true if the status has changed. However, this the
timing functions for recording playback that checks the time of the recording this should not
be needed. But I still use it becase it seemed like state_changed() or the threshold values or
something else might fail so that only huge status changed were reported. */
for (int i = 0; i < g_NumberOfWiiMotes; i++)
{
handle_event(g_WiiMotesFromWiiUse[i]);
}
// Declaration
std::string Temp;
/* Timeout for data reading. This is used in Initialize() to read the Eeprom, if we have not gotten
what we wanted in the WIIUSE_READ_DATA case we stop this loop and enable the regular
wiiuse_io_read() and wiiuse_io_write() loop again. */
if (g_RunTemporary)
{
// The SecondsToWait holds if the update rate of wiiuse_poll() is kept at the default value of 10 ms
static const int SecondsToWait = 2;
g_RunTemporaryCountdown++;
if(g_RunTemporaryCountdown > (SecondsToWait * 100))
{
g_RunTemporaryCountdown = 0;
g_RunTemporary = false;
}
}
// Read formatted Wiimote data
if (wiiuse_poll(g_WiiMotesFromWiiUse, MAX_WIIMOTES))
{
/*
* This happens if something happened on any wiimote.
* So go through each one and check if anything happened.
*/
int i = 0;
for (; i < MAX_WIIMOTES; ++i)
{
switch (g_WiiMotesFromWiiUse[i]->event)
{
case WIIUSE_EVENT:
/* a generic event occured */
//handle_event(g_WiiMotesFromWiiUse[i]);
break;
case WIIUSE_STATUS:
/* a status event occured */
//handle_ctrl_status(g_WiiMotesFromWiiUse[i]);
break;
case WIIUSE_DISCONNECT:
case WIIUSE_UNEXPECTED_DISCONNECT:
/* the wiimote disconnected */
//handle_disconnect(wiimotes[i]);
break;
case WIIUSE_READ_DATA:
/*
* Data we requested to read was returned.
* Take a look at wiimotes[i]->read_req
* for the data.
*/
if(g_WiiMotesFromWiiUse[i]->read_req->size == sizeof(WiiMoteEmu::EepromData_0)
&& g_WiiMotesFromWiiUse[i]->read_req->addr == 0)
{
Temp = ArrayToString(g_WiiMotesFromWiiUse[i]->read_req->buf, sizeof(WiiMoteEmu::EepromData_0), 0, 30);
//memcpy(WiiMoteEmu::g_Eeprom[i], g_WiiMotesFromWiiUse[i]->read_req->buf, sizeof(WiiMoteEmu::EepromData_0));
DEBUG_LOG(WIIMOTE, "EEPROM: %s", Temp.c_str());
g_RunTemporary = false;
}
break;
case WIIUSE_NUNCHUK_INSERTED:
/*
* a nunchuk was inserted
* This is a good place to set any nunchuk specific
* threshold values. By default they are the same
* as the wiimote.
*/
//wiiuse_set_nunchuk_orient_threshold(g_WiiMotesFromWiiUse[i], 90.0f);
//wiiuse_set_nunchuk_accel_threshold(g_WiiMotesFromWiiUse[i], 100);
break;
case WIIUSE_CLASSIC_CTRL_INSERTED:
DEBUG_LOG(WIIMOTE, "Classic controller inserted.");
break;
case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED:
// some expansion was inserted
//handle_ctrl_status(wiimotes[i]);
DEBUG_LOG(WIIMOTE, "Guitar Hero 3 controller inserted.");
break;
case WIIUSE_NUNCHUK_REMOVED:
DEBUG_LOG(WIIMOTE, "Nunchuck was removed.");
break;
case WIIUSE_CLASSIC_CTRL_REMOVED:
case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED:
// some expansion was removed
//handle_ctrl_status(wiimotes[i]);
DEBUG_LOG(WIIMOTE, "An expansion was removed.");
break;
default:
break;
}
}
}
}
}; // end of namespace

View File

@ -27,11 +27,9 @@
#include "main.h"
#if defined(HAVE_WX) && HAVE_WX
#include "ConfigPadDlg.h"
#include "ConfigRecordingDlg.h"
#include "ConfigBasicDlg.h"
WiimotePadConfigDialog *m_PadConfigFrame = NULL;
WiimoteRecordingConfigDialog *m_RecordingConfigFrame = NULL;
WiimoteBasicConfigDialog *m_BasicConfigFrame = NULL;
#endif
#include "Config.h"
@ -358,20 +356,6 @@ void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32
// This sends a Data Report from the Wiimote. See SystemTimers.cpp for the documentation of this update.
void Wiimote_Update(int _number)
{
// Tell us about the update rate, but only about once every second to avoid a major slowdown
#if defined(HAVE_WX) && HAVE_WX
if (m_RecordingConfigFrame)
{
GetUpdateRate();
if (g_UpdateWriteScreen > g_UpdateRate)
{
m_RecordingConfigFrame->m_TextUpdateRate->SetLabel(wxString::Format(wxT("Update rate: %03i times/s"), g_UpdateRate));
g_UpdateWriteScreen = 0;
}
g_UpdateWriteScreen++;
}
#endif
// This functions will send:
// Emulated Wiimote: Only data reports 0x30-0x37
// Real Wiimote: Both data reports 0x30-0x37 and all other read reports
@ -437,40 +421,3 @@ bool IsFocus()
of the form seconds.milleseconds for example 1234.123. The leding seconds have no particular meaning
but are just there to enable use to tell if we have entered a new second or now. */
// -----------------
/* Calculate the current update frequency. Calculate the time between ten updates, and average
five such rates. If we assume there are 60 updates per second if the game is running at full
speed then we get this measure on average once every second. The reason to have a few updates
between each measurement is becase the milliseconds may not be perfectly accurate and may return
the same time even when a milliseconds has actually passed, for example.*/
int GetUpdateRate()
{
#if defined(HAVE_WX) && HAVE_WX
if(g_UpdateCounter == 10)
{
// Erase the old ones
if(g_UpdateTimeList.size() == 5) g_UpdateTimeList.erase(g_UpdateTimeList.begin() + 0);
// Calculate the time and save it
int Time = (int)(10 / (Common::Timer::GetDoubleTime() - g_UpdateTime));
g_UpdateTimeList.push_back(Time);
//DEBUG_LOG(WIIMOTE, "Time: %i %f", Time, Common::Timer::GetDoubleTime());
int TotalTime = 0;
for (int i = 0; i < (int)g_UpdateTimeList.size(); i++)
TotalTime += g_UpdateTimeList.at(i);
g_UpdateRate = TotalTime / 5;
// Write the new update time
g_UpdateTime = Common::Timer::GetDoubleTime();
g_UpdateCounter = 0;
}
g_UpdateCounter++;
return g_UpdateRate;
#else
return 0;
#endif
}

View File

@ -32,7 +32,6 @@
#endif
// Definitions and declarations
bool IsFocus();
int GetUpdateRate();
//void InterruptDebugging(bool Emu, const void* _pData);
//void ReadDebugging(bool Emu, const void* _pData, int Size);

View File

@ -35,7 +35,6 @@
#define EXCLUDE_H // Avoid certain declarations in wiimote_real.h
#include "wiimote_real.h"
#if defined(HAVE_WX) && HAVE_WX
#include "ConfigRecordingDlg.h"
#include "ConfigBasicDlg.h"
#endif
@ -64,16 +63,6 @@ Common::Thread* g_pReadThread = NULL;
int g_NumberOfWiiMotes;
CWiiMote* g_WiiMotes[MAX_WIIMOTES];
volatile bool g_Shutdown = false;
Common::Event g_StartThread;
Common::Event g_StopThreadTemporary;
bool g_LocalThread = true;
bool g_IRSensing = false;
bool g_MotionSensing = false;
u64 g_UpdateTime = 0;
int g_UpdateCounter = 0;
bool g_RunTemporary = false;
int g_RunTemporaryCountdown = 0;
u8 g_EventBuffer[32];
bool g_WiimoteInUse[MAX_WIIMOTES];
Common::Event NeedsConnect;
Common::Event Connected;
@ -94,7 +83,6 @@ THREAD_RETURN RunInvisibleMessageWindow_ThreadFunc(void* arg);
#endif
THREAD_RETURN ReadWiimote_ThreadFunc(void* arg);
THREAD_RETURN SafeCloseReadWiimote_ThreadFunc(void* arg);
// Probably this class should be in its own file
@ -377,6 +365,13 @@ int Initialize()
DEBUG_LOG(WIIMOTE, "Found No of Wiimotes: %i", g_NumberOfWiiMotes);
if (g_NumberOfWiiMotes > 0)
{
/*
//TODO: We need here to re-order the wiimote structure, after we shutdown() and re-init().
// If we don't do this Wiimotes will change slots on addition of a new real wiimote during a game,
// causing a disconnect as well.
if (g_EmulatorState == PLUGIN_EMUSTATE_PAUSE)
SortWiimotes();
*/
g_RealWiiMotePresent = true;
// Create a new thread for listening for Wiimote data
// and also connecting in Linux/OSX.
@ -384,6 +379,8 @@ int Initialize()
g_pReadThread = new Common::Thread(ReadWiimote_ThreadFunc, NULL);
// Don't run the Wiimote thread if no wiimotes were found
g_Shutdown = false;
//Hack for OSX
NeedsConnect.Set();
Connected.Wait();
}
@ -391,10 +388,7 @@ int Initialize()
return 0;
for (i = 0; i < g_NumberOfWiiMotes; i++)
{
// Remove the wiiuse_poll() threshold
wiiuse_set_accel_threshold(g_WiiMotesFromWiiUse[i], 0);
{
// Set the ir sensor sensitivity.
if (g_Config.iIRLevel) {
wiiuse_set_ir_sensitivity(g_WiiMotesFromWiiUse[i], g_Config.iIRLevel);
@ -402,33 +396,13 @@ int Initialize()
// Set the sensor bar position, this should only affect the internal wiiuse api functions
wiiuse_set_ir_position(g_WiiMotesFromWiiUse[i], WIIUSE_IR_ABOVE);
// Set flags
//wiiuse_set_flags(g_WiiMotesFromWiiUse[i], NULL, WIIUSE_SMOOTHING);
}
// psyjoe reports this allows majority of lost packets to be transferred.
// Will test soon
if (g_Config.bWiiReadTimeout != 10)
if (g_Config.bWiiReadTimeout != 10)
wiiuse_set_timeout(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes, g_Config.bWiiReadTimeout, g_Config.bWiiReadTimeout);
// If we are connecting from the config window without a game running we set the LEDs
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY && g_RealWiiMotePresent)
FlashLights(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. */
for (i = 0; i < g_NumberOfWiiMotes; i++)
{
byte *data = (byte*)malloc(sizeof(byte) * sizeof(WiiMoteEmu::EepromData_0));
wiiuse_read_data(g_WiiMotesFromWiiUse[i], data, 0, sizeof(WiiMoteEmu::EepromData_0));
}
// Initialized, even if we didn't find a Wiimote
g_RealWiiMoteInitialized = true;
@ -508,10 +482,6 @@ void Allocate()
DEBUG_LOG(WIIMOTE, "Using %i Real Wiimote(s) and %i Emu Wiimote(s)", g_Config.bNumberRealWiimotes, g_Config.bNumberEmuWiimotes);
// If we are not using any emulated wiimotes we can run the thread temporary until the data has beeen copied
if (g_Config.bNumberEmuWiimotes == 0)
g_RunTemporary = true;
g_RealWiiMoteAllocated = true;
}
@ -546,6 +516,11 @@ void Shutdown(void)
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY && g_RealWiiMotePresent)
FlashLights(false);
// TODOE: Save Wiimote-order here to restore it after an Init()
// we should best use the btaddress for this purpose, unfortunately it is a bit of a work to make wiiuse_find()
// get the btaddress of a bt device on windows with only a createfile() handle etc., but it wiiuse_find() is already doing that on linux
// Clean up wiiuse
wiiuse_cleanup(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes);
@ -580,8 +555,6 @@ void Update(int _WiimoteNumber)
time to avoid a potential collision. */
THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
{
g_StopThreadTemporary.Init();
g_StartThread.Init();
NeedsConnect.Wait();
#ifndef _WIN32
int Connect;
@ -594,58 +567,18 @@ THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
while (!g_Shutdown)
{
// There is at least one Real Wiimote in use
if (g_Config.bNumberRealWiimotes > 0 && !g_RunTemporary)
// Usually, there is at least one Real Wiimote in use,
// except a wiimote gets disconnected unexpectly ingame or wiimote input type gets changed from real to none
if (g_Config.bNumberRealWiimotes > 0)
{
for (int i = 0; i < MAX_WIIMOTES; i++)
if (g_WiimoteInUse[i])
g_WiiMotes[i]->ReadData();
}
else {
if (!g_StopThreadTemporary.Wait(0))
{
// Event object was signaled, exiting thread to close ConfigRecordingDlg
new Common::Thread(SafeCloseReadWiimote_ThreadFunc, NULL);
g_StartThread.Set(); //tell the new thread to get going
return 0;
}
else
ReadWiimote();
}
}
//else { idle }
}
return 0;
}
// Returns whether SafeClose_ThreadFunc will take over closing of Recording dialog.
// FIXME: this whole threading stuff is bad, and should be removed.
// OSX is having problems with the threading anyways, since WiiUse is used
// from multiple threads, and not just the one where it was created on.
bool SafeClose()
{
if (!g_RealWiiMoteInitialized)
return false;
g_StopThreadTemporary.Set();
return true;
}
// Thread to avoid racing conditions by directly closing of ReadWiimote_ThreadFunc() resp. ReadWiimote()
// shutting down the Dlg while still beeing @ReadWiimote will result in a crash;
THREAD_RETURN SafeCloseReadWiimote_ThreadFunc(void* arg)
{
g_Shutdown = true;
g_StartThread.Wait(); //Ready to start cleaning
if (g_RealWiiMoteInitialized)
Shutdown();
#if defined(HAVE_WX) && HAVE_WX
m_RecordingConfigFrame->Close(true);
#endif
if (!g_RealWiiMoteInitialized)
Initialize();
return 0;
}

View File

@ -44,28 +44,13 @@ void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32
void Update(int _WiimoteNumber);
void SendAcc(u8 _ReportID);
void SetDataReportingMode(u8 ReportingMode = 0);
void ClearEvents();
bool SafeClose();
// The alternative Wiimote loop
void ReadWiimote();
bool IRDataOK(struct wiimote_t* wm);
#ifndef EXCLUDE_H
extern wiimote_t** g_WiiMotesFromWiiUse;
extern bool g_Shutdown;
extern Common::Event g_StartThread;
extern Common::Event g_StopThreadTemporary;
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];
#ifdef _WIN32
extern Common::Thread* g_AutoPairUpInvisibleWindow;
extern Common::Thread* g_AutoPairUpMonitoring;