Wiimote: Fixed the switch during gameplay option. The only issue left seems to be that the real wiimote sometimes doesn't get the correct reporting mode
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2013 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
3c4a73d5a6
commit
b0736a1508
|
@ -993,6 +993,11 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng
|
||||||
// Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->Length + sizeof(SL2CAP_Header), "m_pHost->SendACLFrame: ");
|
// Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->Length + sizeof(SL2CAP_Header), "m_pHost->SendACLFrame: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ===================================================
|
||||||
|
/* On a second boot the _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(scid)) makes a report. However
|
||||||
|
the game eventually starts and the Wiimote connects, but it takes at least ten seconds. */
|
||||||
|
// ----------------
|
||||||
void CWII_IPC_HLE_WiiMote::SendL2capData(u16 scid, const void* _pData, u32 _Size)
|
void CWII_IPC_HLE_WiiMote::SendL2capData(u16 scid, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
//allocate
|
//allocate
|
||||||
|
@ -1019,6 +1024,7 @@ void CWII_IPC_HLE_WiiMote::SendL2capData(u16 scid, const void* _pData, u32 _Size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
/* This is called continously from the Wiimote plugin as soon as it has received
|
/* This is called continously from the Wiimote plugin as soon as it has received
|
||||||
|
|
|
@ -231,7 +231,6 @@ Global
|
||||||
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|Win32.ActiveCfg = Debug|Win32
|
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|x64.ActiveCfg = Debug|x64
|
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
||||||
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|Win32.Build.0 = DebugFast|Win32
|
|
||||||
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
||||||
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|Win32.ActiveCfg = Release|Win32
|
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|x64.ActiveCfg = Release|x64
|
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
@ -306,7 +305,6 @@ Global
|
||||||
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Debug|x64.ActiveCfg = Debug|x64
|
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Debug|x64.Build.0 = Debug|x64
|
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Debug|x64.Build.0 = Debug|x64
|
||||||
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
||||||
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|Win32.Build.0 = DebugFast|Win32
|
|
||||||
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
||||||
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|x64.Build.0 = DebugFast|x64
|
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|x64.Build.0 = DebugFast|x64
|
||||||
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|Win32.ActiveCfg = Release|Win32
|
{33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
@ -315,6 +313,7 @@ Global
|
||||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|Win32.ActiveCfg = Debug|Win32
|
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|x64.ActiveCfg = Debug|x64
|
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
||||||
|
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.Build.0 = DebugFast|Win32
|
||||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
||||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.ActiveCfg = Release|Win32
|
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32
|
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
@ -371,7 +370,6 @@ Global
|
||||||
{DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.ActiveCfg = Debug|x64
|
{DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.Build.0 = Debug|x64
|
{DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.Build.0 = Debug|x64
|
||||||
{DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
{DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
||||||
{DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.Build.0 = DebugFast|Win32
|
|
||||||
{DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
{DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
||||||
{DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.Build.0 = DebugFast|x64
|
{DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.Build.0 = DebugFast|x64
|
||||||
{DE7C596C-CBC4-4278-8909-146D63990803}.Release|Win32.ActiveCfg = Release|Win32
|
{DE7C596C-CBC4-4278-8909-146D63990803}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
|
|
@ -49,15 +49,25 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
|
||||||
EVT_CHECKBOX(ID_CONNECT_REAL, ConfigDialog::GeneralSettingsChanged)
|
EVT_CHECKBOX(ID_CONNECT_REAL, ConfigDialog::GeneralSettingsChanged)
|
||||||
EVT_CHECKBOX(ID_USE_REAL, ConfigDialog::GeneralSettingsChanged)
|
EVT_CHECKBOX(ID_USE_REAL, ConfigDialog::GeneralSettingsChanged)
|
||||||
|
|
||||||
|
EVT_TIMER(IDTM_EXIT, ConfigDialog::FlashLights)
|
||||||
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
|
ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title,
|
||||||
|
const wxPoint &position, const wxSize& size, long style)
|
||||||
: wxDialog(parent, id, title, position, size, style)
|
: wxDialog(parent, id, title, position, size, style)
|
||||||
{
|
{
|
||||||
|
#if wxUSE_TIMER
|
||||||
|
m_ExitTimer = new wxTimer(this, IDTM_EXIT);
|
||||||
|
// Reset values
|
||||||
|
ShutDown = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
g_Config.Load();
|
g_Config.Load();
|
||||||
CreateGUIControls();
|
CreateGUIControls();
|
||||||
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigDialog::~ConfigDialog()
|
ConfigDialog::~ConfigDialog()
|
||||||
|
@ -184,6 +194,71 @@ void ConfigDialog::AboutClick(wxCommandEvent& WXUNUSED (event))
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
/* Flash lights and rumble (for Connect and Disconnect) in its own thread like this
|
||||||
|
to avoid a delay when the Connect checkbox is pressed (that would occur if we use
|
||||||
|
Sleep() instead). */
|
||||||
|
// ------------
|
||||||
|
void ConfigDialog::StartTimer()
|
||||||
|
{
|
||||||
|
TimerCounter = 0;
|
||||||
|
|
||||||
|
// Start the constant timer
|
||||||
|
int TimesPerSecond = 10;
|
||||||
|
m_ExitTimer->Start( floor((double)(1000 / TimesPerSecond)) );
|
||||||
|
|
||||||
|
// Run it immedeately for the first time
|
||||||
|
DoFlashLights();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigDialog::DoFlashLights()
|
||||||
|
{
|
||||||
|
TimerCounter++;
|
||||||
|
|
||||||
|
if(TimerCounter == 1) wiiuse_rumble(WiiMoteReal::g_WiiMotesFromWiiUse[0], 1);
|
||||||
|
|
||||||
|
if(TimerCounter == 1)
|
||||||
|
{
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_1);
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_2);
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_3);
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the rumble period equal on both Init and Shutdown
|
||||||
|
if (TimerCounter == 1 && ShutDown) TimerCounter++;
|
||||||
|
|
||||||
|
if (TimerCounter >= 3 || TimerCounter <= 5)
|
||||||
|
{
|
||||||
|
wiiuse_rumble(WiiMoteReal::g_WiiMotesFromWiiUse[0], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TimerCounter == 3)
|
||||||
|
{
|
||||||
|
if(ShutDown)
|
||||||
|
{
|
||||||
|
// Set led 4
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_NONE);
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4);
|
||||||
|
|
||||||
|
// Clean up wiiuse
|
||||||
|
wiiuse_cleanup(WiiMoteReal::g_WiiMotesFromWiiUse, WiiMoteReal::g_NumberOfWiiMotes);
|
||||||
|
|
||||||
|
ShutDown = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_NONE);
|
||||||
|
wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop timer
|
||||||
|
m_ExitTimer->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console::Print("TimerCounter == %i\n", TimerCounter);
|
||||||
|
}
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
// ===================================================
|
// ===================================================
|
||||||
|
@ -288,6 +363,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
||||||
break;
|
break;
|
||||||
/////////////////
|
/////////////////
|
||||||
}
|
}
|
||||||
|
g_Config.Save();
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +374,12 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
|
||||||
// -------------
|
// -------------
|
||||||
void ConfigDialog::UpdateGUI()
|
void ConfigDialog::UpdateGUI()
|
||||||
{
|
{
|
||||||
// Save status
|
/* I have disabled this option during a running game because it's enough to be able to switch
|
||||||
m_ConnectRealWiimote->Enable(g_RealWiiMotePresent);
|
between using and not using then. To also use the connect option during a running game would
|
||||||
|
mean that the wiimote must be sent the current reporting mode and the channel ID after it
|
||||||
|
has been initialized. If you know how to set that manually please feel free to make functions
|
||||||
|
for that so that this option can be enabled during gameplay. */
|
||||||
|
m_ConnectRealWiimote->Enable(!g_EmulatorRunning);
|
||||||
m_UseRealWiimote->Enable(g_RealWiiMotePresent && g_Config.bConnectRealWiimote);
|
m_UseRealWiimote->Enable(g_RealWiiMotePresent && g_Config.bConnectRealWiimote);
|
||||||
|
Console::Print("Present: %i, Connect: %i\n", g_RealWiiMotePresent, g_Config.bConnectRealWiimote);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,15 @@ class ConfigDialog : public wxDialog
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
long style = wxDEFAULT_DIALOG_STYLE);
|
long style = wxDEFAULT_DIALOG_STYLE);
|
||||||
virtual ~ConfigDialog();
|
virtual ~ConfigDialog();
|
||||||
|
|
||||||
void CloseClick(wxCommandEvent& event);
|
void CloseClick(wxCommandEvent& event);
|
||||||
|
void UpdateGUI();
|
||||||
|
|
||||||
|
wxTimer * m_ExitTimer;
|
||||||
|
void DoFlashLights();
|
||||||
|
void StartTimer();
|
||||||
|
void FlashLights(wxTimerEvent& WXUNUSED(event)) { DoFlashLights(); }
|
||||||
|
bool ShutDown; int TimerCounter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
@ -59,6 +67,7 @@ class ConfigDialog : public wxDialog
|
||||||
{
|
{
|
||||||
ID_CLOSE = 1000,
|
ID_CLOSE = 1000,
|
||||||
ID_ABOUTOGL,
|
ID_ABOUTOGL,
|
||||||
|
IDTM_EXIT, // Timer
|
||||||
|
|
||||||
ID_NOTEBOOK,
|
ID_NOTEBOOK,
|
||||||
ID_PAGEEMU,
|
ID_PAGEEMU,
|
||||||
|
@ -82,7 +91,6 @@ class ConfigDialog : public wxDialog
|
||||||
void DoExtensionConnectedDisconnected(); // Emulated
|
void DoExtensionConnectedDisconnected(); // Emulated
|
||||||
|
|
||||||
void GeneralSettingsChanged(wxCommandEvent& event);
|
void GeneralSettingsChanged(wxCommandEvent& event);
|
||||||
void UpdateGUI();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "StringUtil.h" // for ArrayToString
|
#include "StringUtil.h" // for ArrayToString()
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
#include "wiimote_hid.h"
|
#include "wiimote_hid.h"
|
||||||
#include "EmuSubroutines.h"
|
#include "EmuSubroutines.h"
|
||||||
#include "EmuDefinitions.h"
|
#include "EmuDefinitions.h"
|
||||||
|
@ -108,6 +109,8 @@ void WriteCrypted16(u8* _baseBlock, u16 _address, u16 _value)
|
||||||
// ----------------
|
// ----------------
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
|
if (g_EmulatedWiiMoteInitialized) return;
|
||||||
|
|
||||||
memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE);
|
memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE);
|
||||||
memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0));
|
memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0));
|
||||||
memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0));
|
memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0));
|
||||||
|
@ -132,9 +135,11 @@ void Initialize()
|
||||||
memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id));
|
memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_EmulatedWiiMoteInitialized = true;
|
||||||
|
|
||||||
// g_RegExt[0xfd] = 0x1e;
|
// I forgot what these were for?
|
||||||
// g_RegExt[0xfc] = 0x9a;
|
// g_RegExt[0xfd] = 0x1e;
|
||||||
|
// g_RegExt[0xfc] = 0x9a;
|
||||||
}
|
}
|
||||||
// ================
|
// ================
|
||||||
|
|
||||||
|
@ -197,6 +202,8 @@ void CheckAckDelay()
|
||||||
// ----------------
|
// ----------------
|
||||||
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
|
//Console::Print("Emu InterruptChannel\n");
|
||||||
|
|
||||||
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
|
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
|
||||||
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input");
|
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input");
|
||||||
const u8* data = (const u8*)_pData;
|
const u8* data = (const u8*)_pData;
|
||||||
|
@ -267,7 +274,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
//if((data[1] == WM_WRITE_DATA || data[1] == WM_READ_DATA)
|
//if((data[1] == WM_WRITE_DATA || data[1] == WM_READ_DATA)
|
||||||
// && data[3] == 0xa4)
|
// && data[3] == 0xa4)
|
||||||
//{
|
//{
|
||||||
if (!g_Config.bUseRealWiimote) CreateAckDelay((u8)_channelID, (u16)sr->channel);
|
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) CreateAckDelay((u8)_channelID, (u16)sr->channel);
|
||||||
//}
|
//}
|
||||||
//else
|
//else
|
||||||
//{
|
//{
|
||||||
|
@ -295,8 +302,10 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
|
|
||||||
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
|
//Console::Print("Emu ControlChannel\n");
|
||||||
|
|
||||||
const u8* data = (const u8*)_pData;
|
const u8* data = (const u8*)_pData;
|
||||||
// dump raw data
|
// Dump raw data
|
||||||
{
|
{
|
||||||
LOG(WII_IPC_WIIMOTE, "Wiimote_ControlChannel");
|
LOG(WII_IPC_WIIMOTE, "Wiimote_ControlChannel");
|
||||||
std::string Temp = ArrayToString(data, 0, _Size);
|
std::string Temp = ArrayToString(data, 0, _Size);
|
||||||
|
@ -353,7 +362,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
//LOG(WII_IPC_WIIMOTE, "Wiimote_Update");
|
//LOG(WII_IPC_WIIMOTE, "Wiimote_Update");
|
||||||
Console::Print("g_ReportingMode %i\n", g_ReportingMode);
|
//Console::Print("Emu Update: %i\n", g_ReportingMode);
|
||||||
|
|
||||||
switch(g_ReportingMode)
|
switch(g_ReportingMode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,14 +39,14 @@
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Includes
|
// Includes
|
||||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
// ¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
#include "pluginspecs_wiimote.h"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "StringUtil.h"
|
#include "StringUtil.h"
|
||||||
|
#include "pluginspecs_wiimote.h"
|
||||||
|
|
||||||
|
#include "main.h" // Local
|
||||||
#include "wiimote_hid.h"
|
#include "wiimote_hid.h"
|
||||||
#include "EmuMain.h"
|
#include "EmuMain.h"
|
||||||
#include "EmuSubroutines.h"
|
#include "EmuSubroutines.h"
|
||||||
|
@ -97,12 +97,12 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||||
WmDataReporting(_channelID, (wm_data_reporting*)sr->data);
|
WmDataReporting(_channelID, (wm_data_reporting*)sr->data);
|
||||||
break;
|
break;
|
||||||
case WM_REQUEST_STATUS: // 0x15
|
case WM_REQUEST_STATUS: // 0x15
|
||||||
if (!g_Config.bUseRealWiimote) WmRequestStatus(_channelID, (wm_request_status*)sr->data);
|
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmRequestStatus(_channelID, (wm_request_status*)sr->data);
|
||||||
//Temp = ArrayToString(sr->data, sizeof(wm_request_status), 0);
|
//Temp = ArrayToString(sr->data, sizeof(wm_request_status), 0);
|
||||||
//Console::Print("\n%s: InterruptChannel: %s\n", Tm().c_str(), Temp.c_str());
|
//Console::Print("\n%s: InterruptChannel: %s\n", Tm().c_str(), Temp.c_str());
|
||||||
break;
|
break;
|
||||||
case WM_READ_DATA: // 0x17
|
case WM_READ_DATA: // 0x17
|
||||||
if (!g_Config.bUseRealWiimote) WmReadData(_channelID, (wm_read_data*)sr->data);
|
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmReadData(_channelID, (wm_read_data*)sr->data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* This enables or disables the IR lights, we update the global variable g_IR
|
/* This enables or disables the IR lights, we update the global variable g_IR
|
||||||
|
@ -116,17 +116,17 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_WRITE_DATA: // 0x16
|
case WM_WRITE_DATA: // 0x16
|
||||||
if (!g_Config.bUseRealWiimote) WmWriteData(_channelID, (wm_write_data*)sr->data);
|
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmWriteData(_channelID, (wm_write_data*)sr->data);
|
||||||
break;
|
break;
|
||||||
case WM_SPEAKER_ENABLE: // 0x14
|
case WM_SPEAKER_ENABLE: // 0x14
|
||||||
LOGV(WII_IPC_WIIMOTE, 1, " WM Speaker Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
LOGV(WII_IPC_WIIMOTE, 1, " WM Speaker Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
||||||
Console::Print("Speaker Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
|
//Console::Print("Speaker Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
|
||||||
if(sr->data[0] == 0x02) g_Speaker = 0;
|
if(sr->data[0] == 0x02) g_Speaker = 0;
|
||||||
else if(sr->data[0] == 0x06) g_Speaker = 1;
|
else if(sr->data[0] == 0x06) g_Speaker = 1;
|
||||||
break;
|
break;
|
||||||
case WM_SPEAKER_MUTE:
|
case WM_SPEAKER_MUTE:
|
||||||
LOGV(WII_IPC_WIIMOTE, 1, " WM Mute Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
LOGV(WII_IPC_WIIMOTE, 1, " WM Mute Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
||||||
Console::Print("Speaker Mute/Unmute 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
|
//Console::Print("Speaker Mute/Unmute 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
|
||||||
if(sr->data[0] == 0x02) g_SpeakerVoice = 0; // g_SpeakerVoice
|
if(sr->data[0] == 0x02) g_SpeakerVoice = 0; // g_SpeakerVoice
|
||||||
else if(sr->data[0] == 0x06) g_SpeakerVoice = 1;
|
else if(sr->data[0] == 0x06) g_SpeakerVoice = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -196,9 +196,9 @@ void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
|
||||||
|
|
||||||
LOGV(WII_IPC_WIIMOTE, 2, " WMSendAck()");
|
LOGV(WII_IPC_WIIMOTE, 2, " WMSendAck()");
|
||||||
LOGV(WII_IPC_WIIMOTE, 2, " Report ID: %02x", _reportID);
|
LOGV(WII_IPC_WIIMOTE, 2, " Report ID: %02x", _reportID);
|
||||||
//std::string Temp = ArrayToString(DataFrame, Offset, 0);
|
std::string Temp = ArrayToString(DataFrame, Offset, 0);
|
||||||
//LOGV(WII_IPC_WIIMOTE, 2, " Data: %s", Temp.c_str());
|
//LOGV(WII_IPC_WIIMOTE, 2, " Data: %s", Temp.c_str());
|
||||||
//Console::Print("%s: WMSendAck: %s\n", Tm(true).c_str(), Temp.c_str());
|
Console::Print("%s: WMSendAck: %s\n", Tm(true).c_str(), Temp.c_str());
|
||||||
|
|
||||||
/* Debug. Write the report for extension registry writes.
|
/* Debug. Write the report for extension registry writes.
|
||||||
if((_reportID == 0x16 || _reportID == 0x17) && ((address >> 16) & 0xfe) == 0xa4)
|
if((_reportID == 0x16 || _reportID == 0x17) && ((address >> 16) & 0xfe) == 0xa4)
|
||||||
|
|
|
@ -48,20 +48,23 @@ bool g_EmulatorRunning = false;
|
||||||
bool g_FrameOpen = false;
|
bool g_FrameOpen = false;
|
||||||
bool g_RealWiiMotePresent = false;
|
bool g_RealWiiMotePresent = false;
|
||||||
bool g_RealWiiMoteInitialized = false;
|
bool g_RealWiiMoteInitialized = false;
|
||||||
|
bool g_EmulatedWiiMoteInitialized = false;
|
||||||
|
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
|
|
||||||
#if defined(HAVE_WX) && HAVE_WX
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
class wxDLLApp : public wxApp
|
wxWindow win;
|
||||||
{
|
ConfigDialog *frame;
|
||||||
|
|
||||||
|
class wxDLLApp : public wxApp
|
||||||
|
{
|
||||||
bool OnInit()
|
bool OnInit()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
||||||
|
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
||||||
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
||||||
|
@ -127,16 +130,16 @@ void DllConfig(HWND _hParent)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_WX) && HAVE_WX
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
|
|
||||||
wxWindow win;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
win.SetHWND(_hParent);
|
win.SetHWND(_hParent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DoInitialize();
|
|
||||||
g_FrameOpen = true;
|
g_FrameOpen = true;
|
||||||
ConfigDialog frame(&win);
|
frame = new ConfigDialog(&win);
|
||||||
frame.ShowModal();
|
|
||||||
|
DoInitialize();
|
||||||
|
|
||||||
|
frame->ShowModal();
|
||||||
//frame.Show();
|
//frame.Show();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -154,18 +157,33 @@ extern "C" void Initialize(void *init)
|
||||||
|
|
||||||
g_EmulatorRunning = true;
|
g_EmulatorRunning = true;
|
||||||
|
|
||||||
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
|
if(g_FrameOpen) if(frame) frame->UpdateGUI();
|
||||||
|
#endif
|
||||||
|
|
||||||
DoInitialize();
|
DoInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void Shutdown(void)
|
extern "C" void Shutdown(void)
|
||||||
{
|
{
|
||||||
// We will only shutdown when both a game and the frame is closed
|
// We will only shutdown when both a game and the frame is closed
|
||||||
if (g_FrameOpen) { g_EmulatorRunning = false; return; }
|
if (g_FrameOpen)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
|
if(frame) frame->UpdateGUI();
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not running
|
||||||
|
g_EmulatorRunning = false;
|
||||||
|
|
||||||
#if HAVE_WIIUSE
|
#if HAVE_WIIUSE
|
||||||
if(g_RealWiiMoteInitialized) WiiMoteReal::Shutdown();
|
if(g_RealWiiMoteInitialized) WiiMoteReal::Shutdown();
|
||||||
#endif
|
#endif
|
||||||
WiiMoteEmu::Shutdown();
|
WiiMoteEmu::Shutdown();
|
||||||
|
|
||||||
|
Console::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,7 +198,11 @@ extern "C" void DoState(unsigned char **ptr, int mode)
|
||||||
|
|
||||||
// ===================================================
|
// ===================================================
|
||||||
/* This function produce Wiimote Input (reports from the Wiimote) in response
|
/* This function produce Wiimote Input (reports from the Wiimote) in response
|
||||||
to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp. */
|
to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp.
|
||||||
|
|
||||||
|
Switch between real and emulated wiimote: We send all this Input to WiiMoteEmu::InterruptChannel()
|
||||||
|
so that it knows the channel ID and the data reporting mode at all times.
|
||||||
|
*/
|
||||||
// ----------------
|
// ----------------
|
||||||
extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
|
@ -196,10 +218,10 @@ extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decice where to send the message
|
// Decice where to send the message
|
||||||
//if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
|
//if (!g_RealWiiMotePresent)
|
||||||
WiiMoteEmu::InterruptChannel(_channelID, _pData, _Size);
|
WiiMoteEmu::InterruptChannel(_channelID, _pData, _Size);
|
||||||
#if HAVE_WIIUSE
|
#if HAVE_WIIUSE
|
||||||
//else if (g_RealWiiMotePresent)
|
if (g_RealWiiMotePresent)
|
||||||
WiiMoteReal::InterruptChannel(_channelID, _pData, _Size);
|
WiiMoteReal::InterruptChannel(_channelID, _pData, _Size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -223,10 +245,10 @@ extern "C" void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _
|
||||||
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
|
if (!g_RealWiiMotePresent)
|
||||||
WiiMoteEmu::ControlChannel(_channelID, _pData, _Size);
|
WiiMoteEmu::ControlChannel(_channelID, _pData, _Size);
|
||||||
#if HAVE_WIIUSE
|
#if HAVE_WIIUSE
|
||||||
else if (g_RealWiiMotePresent)
|
else
|
||||||
WiiMoteReal::ControlChannel(_channelID, _pData, _Size);
|
WiiMoteReal::ControlChannel(_channelID, _pData, _Size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
// Includes
|
// Includes
|
||||||
// ¯¯¯¯¯¯¯¯¯¯
|
// ¯¯¯¯¯¯¯¯¯¯
|
||||||
#include <iostream> // System
|
#include <iostream> // System
|
||||||
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
|
#include "ConfigDlg.h"
|
||||||
|
#endif
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +47,11 @@ void DoInitialize();
|
||||||
extern bool g_FrameOpen;
|
extern bool g_FrameOpen;
|
||||||
extern bool g_RealWiiMotePresent;
|
extern bool g_RealWiiMotePresent;
|
||||||
extern bool g_RealWiiMoteInitialized;
|
extern bool g_RealWiiMoteInitialized;
|
||||||
|
extern bool g_EmulatedWiiMoteInitialized;
|
||||||
|
|
||||||
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
|
extern ConfigDialog *frame;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
#include "EmuMain.h"
|
#include "EmuMain.h"
|
||||||
#define EXCLUDE_H // Avoid certain declarations in main.h
|
#define EXCLUDE_H // Avoid certain declarations in main.h
|
||||||
#include "wiimote_real.h"
|
#include "wiimote_real.h"
|
||||||
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
|
#include "ConfigDlg.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
@ -241,7 +244,6 @@ void SendEvent(SEvent& _rEvent)
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
// Function Definitions
|
// Function Definitions
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
|
|
||||||
int Initialize()
|
int Initialize()
|
||||||
{
|
{
|
||||||
if (g_RealWiiMoteInitialized) return g_NumberOfWiiMotes;
|
if (g_RealWiiMoteInitialized) return g_NumberOfWiiMotes;
|
||||||
|
@ -263,14 +265,7 @@ int Initialize()
|
||||||
//int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES);
|
//int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES);
|
||||||
//Console::Print("Connected: %i\n", Connect);
|
//Console::Print("Connected: %i\n", Connect);
|
||||||
|
|
||||||
wiiuse_rumble(g_WiiMotesFromWiiUse[0], 1);
|
if(frame) frame->StartTimer();
|
||||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4);
|
|
||||||
Sleep(40);
|
|
||||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[0], WIIMOTE_LED_NONE);
|
|
||||||
Sleep(40);
|
|
||||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4);
|
|
||||||
Sleep(120);
|
|
||||||
wiiuse_rumble(g_WiiMotesFromWiiUse[0], 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -312,20 +307,31 @@ void Shutdown(void)
|
||||||
g_WiiMotes[i] = NULL;
|
g_WiiMotes[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
|
if(frame) frame->ShutDown = true;
|
||||||
|
if(frame) frame->StartTimer();
|
||||||
|
#else
|
||||||
// Clean up wiiuse
|
// Clean up wiiuse
|
||||||
wiiuse_cleanup(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes);
|
wiiuse_cleanup(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes);
|
||||||
|
|
||||||
// Uninitialized
|
// Uninitialized
|
||||||
g_RealWiiMoteInitialized = false;
|
g_RealWiiMoteInitialized = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Uninitialized
|
||||||
|
g_RealWiiMoteInitialized = false;
|
||||||
|
g_RealWiiMotePresent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
|
//Console::Print("Real InterruptChannel\n");
|
||||||
g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size);
|
g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
{
|
{
|
||||||
|
//Console::Print("Real ControlChannel\n");
|
||||||
g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size);
|
g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,6 +341,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||||
// ---------------
|
// ---------------
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
//Console::Print("Real Update\n");
|
||||||
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||||
{
|
{
|
||||||
g_WiiMotes[i]->Update();
|
g_WiiMotes[i]->Update();
|
||||||
|
|
|
@ -42,6 +42,7 @@ void ReadWiimote();
|
||||||
|
|
||||||
#ifndef EXCLUDE_H
|
#ifndef EXCLUDE_H
|
||||||
extern wiimote_t** g_WiiMotesFromWiiUse;
|
extern wiimote_t** g_WiiMotesFromWiiUse;
|
||||||
|
extern int g_NumberOfWiiMotes;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}; // WiiMoteReal
|
}; // WiiMoteReal
|
||||||
|
|
Loading…
Reference in New Issue