Emulated Wiimote: Fixed the concurrent playback of Wiimote and Nunchuck movements

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2242 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-02-14 19:36:25 +00:00
parent 5e80ca1526
commit ae9bb905bf
6 changed files with 151 additions and 128 deletions

View File

@ -555,7 +555,7 @@ void ConfigDialog::CreateGUIControls()
// Dead zone
m_ComboDeadZoneLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Dead Zone"));
wxArrayString TextDeadZone;
for (int i = 0; i <= 50; i++) TextDeadZone.Add(wxString::Format(wxT("%i%%"), i));
for (int j = 0; j <= 50; j++) TextDeadZone.Add(wxString::Format(wxT("%i%%"), j));
m_ComboDeadZoneLeft[i] = new wxComboBox(m_Controller[i], IDCB_DEAD_ZONE_LEFT, TextDeadZone[0], wxDefaultPosition, wxDefaultSize, TextDeadZone, wxCB_READONLY);
m_ComboDeadZoneRight[i] = new wxComboBox(m_Controller[i], IDCB_DEAD_ZONE_RIGHT, TextDeadZone[0], wxDefaultPosition, wxDefaultSize, TextDeadZone, wxCB_READONLY);
@ -1235,9 +1235,12 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
{
int CurrentChoiceBox = (event.GetId() - IDC_RECORD);
if (i == CurrentChoiceBox) continue;
if (m_RecordHotKey[i]->GetSelection() == m_RecordHotKey[CurrentChoiceBox]->GetSelection()) m_RecordHotKey[i]->SetSelection(10);
Console::Print("HotKey: %i %i\n",
m_RecordHotKey[i]->GetSelection(), m_RecordHotKey[CurrentChoiceBox]->GetSelection());
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);
//Console::Print("HotKey: %i %i\n",
// m_RecordHotKey[i]->GetSelection(), m_RecordHotKey[CurrentChoiceBox]->GetSelection());
}
break;
/////////////////

View File

@ -118,7 +118,10 @@ class ConfigDialog : public wxDialog
wxBitmap CreateBitmapDot(), CreateBitmap(), CreateBitmapDeadZone(int Radius), CreateBitmapClear();
wxButton * m_RecordButton[RECORDING_ROWS + 1];
wxChoice * m_RecordHotKey[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];
@ -169,7 +172,7 @@ class ConfigDialog : public wxDialog
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
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);

View File

@ -37,42 +37,45 @@
void ConfigDialog::LoadFile()
{
Console::Print("LoadFile\n");
Console::Print("LoadFile()\n");
IniFile file;
file.Load("WiimoteMovement.ini");
for(int i = 1; i < (RECORDING_ROWS + 1); i++)
{
// Temporary storage
bool bTmp;
int iTmp;
std::string STmp;
// Get row name
std::string SaveName = StringFromFormat("Recording%i", i);
// HotKey
int TmpRecordHotKey; file.Get(SaveName.c_str(), "HotKey", &TmpRecordHotKey, -1);
m_RecordHotKey[i]->SetSelection(TmpRecordHotKey);
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
std::string TmpMovementName; file.Get(SaveName.c_str(), "MovementName", &TmpMovementName, "");
m_RecordText[i]->SetValue(wxString::FromAscii(TmpMovementName.c_str()));
file.Get(SaveName.c_str(), "MovementName", &STmp, ""); m_RecordText[i]->SetValue(wxString::FromAscii(STmp.c_str()));
// Game name
std::string TmpGameName; file.Get(SaveName.c_str(), "GameName", &TmpGameName, "");
m_RecordGameText[i]->SetValue(wxString::FromAscii(TmpGameName.c_str()));
file.Get(SaveName.c_str(), "GameName", &STmp, ""); m_RecordGameText[i]->SetValue(wxString::FromAscii(STmp.c_str()));
// IR Bytes
std::string TmpIRBytes; file.Get(SaveName.c_str(), "IRBytes", &TmpIRBytes, "");
m_RecordIRBytesText[i]->SetValue(wxString::FromAscii(TmpIRBytes.c_str()));
file.Get(SaveName.c_str(), "IRBytes", &STmp, ""); m_RecordIRBytesText[i]->SetValue(wxString::FromAscii(STmp.c_str()));
// Recording speed
int TmpRecordSpeed; file.Get(SaveName.c_str(), "RecordingSpeed", &TmpRecordSpeed, -1);
if(TmpRecordSpeed != -1)
m_RecordSpeed[i]->SetValue(wxString::Format(wxT("%i"), TmpRecordSpeed));
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)
int TmpPlaybackSpeed; file.Get(SaveName.c_str(), "PlaybackSpeed", &TmpPlaybackSpeed, -1);
m_RecordPlayBackSpeed[i]->SetSelection(TmpPlaybackSpeed);
file.Get(SaveName.c_str(), "PlaybackSpeed", &iTmp, -1); m_RecordPlayBackSpeed[i]->SetSelection(iTmp);
}
}
void ConfigDialog::SaveFile()
@ -88,7 +91,10 @@ void ConfigDialog::SaveFile()
std::string SaveName = StringFromFormat("Recording%i", i);
// HotKey
file.Set(SaveName.c_str(), "HotKey", m_RecordHotKey[i]->GetSelection());
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", m_RecordText[i]->GetValue().c_str());
@ -110,7 +116,7 @@ void ConfigDialog::SaveFile()
}
file.Save("WiimoteMovement.ini");
Console::Print("Wrote WiimoteMovement.ini\n");
Console::Print("SaveFile()\n");
}
/////////////////////////////
@ -261,6 +267,12 @@ void ConfigDialog::CreateGUIControlsRecording()
// ----------------
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(""));
@ -270,18 +282,23 @@ void ConfigDialog::CreateGUIControlsRecording()
wxBoxSizer * sRealRecord[RECORDING_ROWS + 1];
wxStaticText * m_TextRec = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Rec."), wxDefaultPosition, wxSize(80, 15), wxALIGN_CENTRE);
wxStaticText * m_TextHotKey = new wxStaticText(m_PageRecording, wxID_ANY, wxT("HotKey"), wxDefaultPosition, wxSize(40, 15), wxALIGN_CENTRE);
wxStaticText * m_TextMovement = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Movement name"), wxDefaultPosition, wxSize(200, 15), wxALIGN_CENTRE);
wxStaticText * m_TextGame = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Game name"), wxDefaultPosition, wxSize(200, 15), wxALIGN_CENTRE);
wxStaticText * m_TextIRBytes = new wxStaticText(m_PageRecording, wxID_ANY, wxT("IR"), wxDefaultPosition, wxSize(20, 15), wxALIGN_CENTRE);
wxStaticText * m_TextRecSped = new wxStaticText(m_PageRecording, wxID_ANY, wxT("R. s."), wxDefaultPosition, wxSize(33, 15), wxALIGN_CENTRE);
wxStaticText * m_TextPlaySpeed = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Pl. s."), wxDefaultPosition, wxSize(40, 15), wxALIGN_CENTRE);
wxStaticText * m_TextRec = new wxStaticText(m_PageRecording, wxID_ANY, wxT("Rec."), wxDefaultPosition, wxSize(80, -1), wxALIGN_CENTRE);
wxStaticText * m_TextHotKey = new wxStaticText(m_PageRecording, wxID_ANY, wxT("HotKey"), wxDefaultPosition, wxSize(170, -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"
"by letting go of 'A'"));
m_TextHotKey->SetToolTip(wxT("The HotKey is Shift + [Number] for Wiimote movements and Ctrl + [Number] for Nunchuck movements"));
m_TextRecSped->SetToolTip(wxT("Recording speed in average measurements per second"));
m_TextHotKey->SetToolTip(
wxT("Select a hotkey for playback of 1. Wiimote movements, 2. Nunchuck movements, 3. IR data. You can combine it with an"
" option Shift, Ctrl, or Alt switch."
));
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"
"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"
@ -297,7 +314,7 @@ void ConfigDialog::CreateGUIControlsRecording()
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_TextRecSped, 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);
@ -305,7 +322,10 @@ void ConfigDialog::CreateGUIControlsRecording()
{
sRealRecord[i] = new wxBoxSizer(wxHORIZONTAL);
m_RecordButton[i] = new wxButton(m_PageRecording, IDB_RECORD + i, wxEmptyString, wxDefaultPosition, wxSize(80, 20), 0, wxDefaultValidator, wxEmptyString);
m_RecordHotKey[i] = new wxChoice(m_PageRecording, IDC_RECORD + i, wxDefaultPosition, wxDefaultSize, StrHotKey);
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));
@ -318,7 +338,10 @@ void ConfigDialog::CreateGUIControlsRecording()
m_RecordSpeed[i]->Enable(false);
sRealRecord[i]->Add(m_RecordButton[i], 0, wxEXPAND | (wxLEFT), 5);
sRealRecord[i]->Add(m_RecordHotKey[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);

View File

@ -132,6 +132,11 @@ void LoadRecordedMovements()
// Logging
//Console::Print("Recording%i ", i + 1);
// Temporary storage
bool bTmp;
int iTmp;
std::string STmp;
// First clear the list
VRecording.at(i).Recording.clear();
@ -203,8 +208,10 @@ void LoadRecordedMovements()
}
// Get HotKey
int TmpRecordHotKey; file.Get(SaveName.c_str(), "HotKey", &TmpRecordHotKey, -1);
VRecording.at(i).HotKey = TmpRecordHotKey;
file.Get(SaveName.c_str(), "HotKeySwitch", &iTmp, 3); VRecording.at(i).HotKeySwitch = iTmp;
file.Get(SaveName.c_str(), "HotKeyWiimote", &iTmp, 10); VRecording.at(i).HotKeyWiimote = iTmp;
file.Get(SaveName.c_str(), "HotKeyNunchuck", &iTmp, 10); VRecording.at(i).HotKeyNunchuck = iTmp;
file.Get(SaveName.c_str(), "HotKeyIR", &iTmp, 10); VRecording.at(i).HotKeyIR = iTmp;
// Get Recording speed
int TmpPlaybackSpeed; file.Get(SaveName.c_str(), "PlaybackSpeed", &TmpPlaybackSpeed, -1);
@ -254,7 +261,7 @@ void UpdateEeprom()
Console::Print("UpdateExtension: %i %i %i %i %i\n\n",
WiiMoteEmu::g_RegExt[0x2a], WiiMoteEmu::g_RegExt[0x2d],
WiiMoteEmu::g_RegExt[20], WiiMoteEmu::g_RegExt[21], WiiMoteEmu::g_RegExt[26]);
WiiMoteEmu::g_RegExt[0x20], WiiMoteEmu::g_RegExt[0x21], WiiMoteEmu::g_RegExt[0x26]);
}
// Calculate checksum for the nunchuck calibration. The last two bytes.
@ -270,7 +277,7 @@ void ExtensionChecksum(u8 * Calibration)
Byte16 = sum + 0xaa; // Byte 16
}
// Set initial values
// Set initial valuesm this done both in Init and Shutdown
void ResetVariables()
{
u8 g_Leds = 0x0; // 4 bits
@ -282,6 +289,16 @@ void ResetVariables()
g_ReportingChannel = 0;
g_Encryption = false;
// Set default recording values
for (int i = 0; i < 3; i++)
{
g_RecordingPlaying[i] = -1;
g_RecordingCounter[i] = 0;
g_RecordingPoint[i] = 0;
g_RecordingStart[i] = 0;
g_RecordingCurrentTime[i] = 0;
}
g_EmulatedWiiMoteInitialized = false;
}
@ -302,6 +319,8 @@ void SetDefaultExtensionRegistry()
memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id));
}
Console::Print("\nSetDefaultExtensionRegistry()\n\n");
UpdateEeprom();
}
@ -316,36 +335,27 @@ void Initialize()
// Reset variables
ResetVariables();
// Write default Eeprom data
// Write default Eeprom data to g_Eeprom[]
memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE);
memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0));
memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0));
// Copy extension id and calibration to its register
SetDefaultExtensionRegistry();
g_ReportingMode = 0;
g_EmulatedWiiMoteInitialized = true;
// Load pre-recorded movements
LoadRecordedMovements();
// Set default recording values
for (int i = 0; i < 3; i++)
{
g_RecordingPlaying[i] = -1;
g_RecordingCounter[i] = 0;
g_RecordingPoint[i] = 0;
g_RecordingStart[i] = 0;
g_RecordingCurrentTime[i] = 0;
}
// Populate joyinfo for all attached devices if the configuration window is not already open
/* 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);
}
// Copy extension id and calibration to its register, g_Config.Load() is needed before this
SetDefaultExtensionRegistry();
// The emulated Wiimote is initialized
g_EmulatedWiiMoteInitialized = true;
// 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. */
//WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk

View File

@ -60,6 +60,9 @@ double g_RecordingCurrentTime[3]; //g_RecordingCurrentTime[0] = 0; g_RecordingCu
template<class IRReportType>
bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm)
{
// Check if the recording is on
if (g_RecordingPlaying[Wm] == -1) return false;
// Return if the list is empty
if(VRecording.at(g_RecordingPlaying[Wm]).Recording.size() == 0)
{
@ -94,7 +97,7 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm)
// Get starting time
if(g_RecordingCounter[Wm] == 0)
{
Console::Print("\n\nBegin\n");
Console::Print("\n\nBegin: %i\n", Wm);
g_RecordingStart[Wm] = GetDoubleTime();
}
@ -124,7 +127,7 @@ bool RecordingPlayAccIR(u8 &_x, u8 &_y, u8 &_z, IRReportType &_IR, int Wm)
g_RecordingPlaying[Wm] = -1;
g_RecordingStart[Wm] = 0;
g_RecordingCurrentTime[Wm] = 0;
Console::Print("End\n\n");
Console::Print("End: %i\n\n", Wm);
return false;
}
@ -164,89 +167,73 @@ bool RecordingPlayIR(IRReportType &_IR)
return RecordingPlayAccIR(x, y, z, _IR, 2);
}
// Check if we should start the playback of a recording. Once it has been started it can not currently
// be stopped, it will always run to the end of the recording.
int RecordingCheckKeys(int Wiimote)
// Return true if this particual numerical key is pressed
bool IsNumericalKeyPressed(int _Key)
{
// Check which key it is
std::string TmpKey = StringFromFormat("%i", _Key);
if(GetAsyncKeyState(TmpKey[0]))
return true;
else
// That numerical key is pressed
return false;
}
// Check if a switch is pressed
bool IsSwitchPressed(int _Key)
{
// Check if that switch is pressed
switch (_Key)
{
case 0: if (GetAsyncKeyState(VK_SHIFT)) return true;
case 1: if (GetAsyncKeyState(VK_CONTROL)) return true;
case 2: if (GetAsyncKeyState(VK_MENU)) return true;
}
// That switch was not pressed
return false;
}
// Check if we should start the playback of a recording. Once it has been started it can currently
// not be stopped, it will always run to the end of the recording.
int RecordingCheckKeys(int WmNuIr)
{
#ifdef _WIN32
//Console::Print("RecordingCheckKeys: %i\n", Wiimote);
// ------------------------------------
// Don't allow multiple action keys
// --------------
// Return if we have both a Shift, Ctrl, and Alt
if ( GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU) ) return -1;
// Return if we have both a Shift and Ctrl
if ( (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_CONTROL)) ) return -1;
// Return if we have both a Ctrl and Alt
if ( (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU)) ) return -1;
// Return if we have both a Shift and Alt
if ( (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_MENU)) ) return -1;
// ---------------------
// Return if we don't have both a Wiimote and Shift
if ( Wiimote == 0 && !GetAsyncKeyState(VK_SHIFT) ) return -1;
// Return if we don't have both a Nunchuck and Ctrl
if ( Wiimote == 1 && !GetAsyncKeyState(VK_CONTROL) ) return -1;
// Return if we don't have both a IR call and Alt
if ( Wiimote == 2 && !GetAsyncKeyState(VK_MENU) ) return -1;
// Check if we have exactly one numerical key
int Keys = 0;
for(int i = 0; i < 10; i++)
{
std::string Key = StringFromFormat("%i", i);
if(GetAsyncKeyState(Key[0])) Keys++;
}
//Console::Print("RecordingCheckKeys: %i\n", Keys);
// Return if we have less than or more than one
if (Keys != 1) return -1;
// Check which key it is
int Key;
for(int i = 0; i < 10; i++)
{
std::string TmpKey = StringFromFormat("%i", i);
if(GetAsyncKeyState(TmpKey[0])) { Key = i; break; }
}
// Check if we have a HotKey match
bool Match = false;
int Recording = -1;
for(int i = 0; i < RECORDING_ROWS; i++)
{
if (VRecording.at(i).HotKey == Key)
// Check all ten numerical keys
for(int j = 0; j < 10; j++)
{
//Console::Print("Match: %i %i\n", i, Key);
Match = true;
Key = i;
break;
if ((VRecording.at(i).HotKeyWiimote == j && WmNuIr == 0 && IsNumericalKeyPressed(j)
|| VRecording.at(i).HotKeyNunchuck == j && WmNuIr == 1 && IsNumericalKeyPressed(j)
|| VRecording.at(i).HotKeyIR == j && WmNuIr == 2 && IsNumericalKeyPressed(j))
&& (IsSwitchPressed(VRecording.at(i).HotKeySwitch) || VRecording.at(i).HotKeySwitch == 3))
{
//Console::Print("Match: %i %i\n", i, Key);
Match = true;
Recording = i;
break;
}
}
}
// Return nothing if we don't have a match
if (!Match) return -1;
// Return the match
return Key;
return Recording;
#else
return -1;
#endif
}
// check if we have any recording playback key combination
bool CheckKeyCombination()
{
if (RecordingCheckKeys(0) == -1 && RecordingCheckKeys(1) == -1 && RecordingCheckKeys(2) == -1)
return false;
else
return true; // This will also start a recording
}
//******************************************************************************
// Subroutines
@ -266,9 +253,6 @@ void FillReportInfo(wm_core& _core)
// Check that Dolphin is in focus
if (!IsFocus()) return;
// Don't interrupt a recording
if (CheckKeyCombination()) return;
// Check the mouse position. Don't allow mouse clicks from outside the window.
float x, y; GetMousePos(x, y);
bool InsideScreen = !(x < 0 || x > 1 || y < 0 || y > 1);
@ -919,7 +903,7 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
// ----------------
void FillReportExtension(wm_extension& _ext)
{
// ------------------------------------
// ------------------------------------------
// Recorded movements
// --------------
// Check for a playback command

View File

@ -59,7 +59,7 @@ struct SRecording
struct SRecordingAll
{
std::vector<SRecording> Recording;
int HotKey;
int HotKeySwitch, HotKeyWiimote, HotKeyNunchuck, HotKeyIR;
int PlaybackSpeed;
int IRBytes;
};