diff --git a/SConstruct b/SConstruct
index 2ca4d5a804..a6e816aa44 100644
--- a/SConstruct
+++ b/SConstruct
@@ -373,8 +373,6 @@ dirs = [
#'Source/Plugins/Plugin_VideoDX9/Src',
'Source/Plugins/Plugin_VideoOGL/Src',
'Source/Plugins/Plugin_VideoSoftware/Src',
- 'Source/Plugins/Plugin_Wiimote/Src',
- 'Source/Plugins/Plugin_WiimoteNew/Src',
'Source/UnitTests',
]
diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj
index 0e63a8359c..0e478e686a 100644
--- a/Source/Core/Common/Common.vcproj
+++ b/Source/Core/Common/Common.vcproj
@@ -480,14 +480,6 @@
RelativePath=".\Src\PluginVideo.h"
>
-
-
-
-
@@ -511,10 +503,6 @@
RelativePath="..\..\PluginSpecs\pluginspecs_video.h"
>
-
-
- (LoadSymbol("Wiimote_ControlChannel"));
- Wiimote_Input = reinterpret_cast
- (LoadSymbol("Wiimote_Input"));
- Wiimote_InterruptChannel = reinterpret_cast
- (LoadSymbol("Wiimote_InterruptChannel"));
- Wiimote_Update = reinterpret_cast
- (LoadSymbol("Wiimote_Update"));
- Wiimote_GetAttachedControllers = reinterpret_cast
- (LoadSymbol("Wiimote_GetAttachedControllers"));
- Wiimote_UnPairWiimotes = reinterpret_cast
- (LoadSymbol("Wiimote_UnPairWiimotes"));
-
- if ((Wiimote_ControlChannel != 0) &&
- (Wiimote_Input != 0) &&
- (Wiimote_InterruptChannel != 0) &&
- (Wiimote_Update != 0) &&
- (Wiimote_GetAttachedControllers != 0))
- validWiimote = true;
-}
-
-PluginWiimote::~PluginWiimote() { }
-
-} // Namespace
diff --git a/Source/Core/Common/Src/PluginWiimote.h b/Source/Core/Common/Src/PluginWiimote.h
deleted file mode 100644
index a2761a9fc3..0000000000
--- a/Source/Core/Common/Src/PluginWiimote.h
+++ /dev/null
@@ -1,53 +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 _PLUGINWIIMOTE_H_
-#define _PLUGINWIIMOTE_H_
-
-#include "pluginspecs_wiimote.h"
-#include "Plugin.h"
-
-namespace Common {
-
-typedef unsigned int (__cdecl* TPAD_GetAttachedPads)();
-typedef void (__cdecl* TWiimote_Update)(int _number);
-typedef void (__cdecl* TWiimote_Input)(u16 _Key, u8 _UpDown);
-typedef void (__cdecl* TWiimote_ControlChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
-typedef void (__cdecl* TWiimote_InterruptChannel)(int _number, u16 _channelID, const void* _pData, u32 _Size);
-typedef unsigned int (__cdecl* TWiimote_UnPairWiimotes)();
-typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)();
-
-class PluginWiimote : public CPlugin {
-public:
- PluginWiimote(const char *_Filename);
- virtual ~PluginWiimote();
- virtual bool IsValid() {return validWiimote;};
-
- TWiimote_ControlChannel Wiimote_ControlChannel;
- TWiimote_Input Wiimote_Input;
- TWiimote_InterruptChannel Wiimote_InterruptChannel;
- TWiimote_Update Wiimote_Update;
- TWiimote_UnPairWiimotes Wiimote_UnPairWiimotes;
- TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers;
-
-private:
- bool validWiimote;
-};
-
-} // namespace
-
-#endif // _PLUGINWIIMOTE_H_
diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj
index 194ed12876..b83700dcc3 100644
--- a/Source/Core/Core/Core.vcproj
+++ b/Source/Core/Core/Core.vcproj
@@ -45,7 +45,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Save();
@@ -187,7 +186,6 @@ void SConfig::LoadSettings()
// Hard coded defaults
m_DefaultGFXPlugin = DEFAULT_GFX_PLUGIN;
m_DefaultDSPPlugin = DEFAULT_DSP_PLUGIN;
- m_DefaultWiiMotePlugin = DEFAULT_WIIMOTE_PLUGIN;
// General
{
@@ -302,7 +300,6 @@ void SConfig::LoadSettings()
// Plugins
ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str());
ini.Get("Core", "DSPPlugin", &m_LocalCoreStartupParameter.m_strDSPPlugin, m_DefaultDSPPlugin.c_str());
- ini.Get("Core", "WiiMotePlugin", &m_LocalCoreStartupParameter.m_strWiimotePlugin, m_DefaultWiiMotePlugin.c_str());
}
m_SYSCONF = new SysConf();
diff --git a/Source/Core/Core/Src/ConfigManager.h b/Source/Core/Core/Src/ConfigManager.h
index 6a1839b07b..70cc5dc5c9 100644
--- a/Source/Core/Core/Src/ConfigManager.h
+++ b/Source/Core/Core/Src/ConfigManager.h
@@ -50,7 +50,6 @@ struct SConfig
// hard coded default plugins ...
std::string m_DefaultGFXPlugin;
std::string m_DefaultDSPPlugin;
- std::string m_DefaultWiiMotePlugin;
// name of the last used filename
std::string m_LastFilename;
diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp
index 3dba513079..746e6ffed4 100644
--- a/Source/Core/Core/Src/Core.cpp
+++ b/Source/Core/Core/Src/Core.cpp
@@ -45,6 +45,7 @@
#include "HW/GPFifo.h"
#include "HW/CPU.h"
#include "HW/GCPad.h"
+#include "HW/Wiimote.h"
#include "HW/HW.h"
#include "HW/DSP.h"
#include "HW/GPFifo.h"
@@ -382,20 +383,11 @@ THREAD_RETURN EmuThread(void *pArg)
Plugins.GetDSP()->Initialize((void *)&dspInit);
- GCPad_Init(g_pWindowHandle);
+ Pad::Initialize(g_pWindowHandle);
- // Load and Init WiimotePlugin - only if we are booting in wii mode
+ // Load and Init Wiimotes - only if we are booting in wii mode
if (_CoreParameter.bWii)
- {
- SWiimoteInitialize WiimoteInitialize;
- WiimoteInitialize.hWnd = g_pWindowHandle;
- WiimoteInitialize.ISOId = Ascii2Hex(_CoreParameter.m_strUniqueID);
- WiimoteInitialize.pLog = Callback_WiimoteLog;
- WiimoteInitialize.pWiimoteInterruptChannel = Callback_WiimoteInterruptChannel;
- WiimoteInitialize.pRendererHasFocus = Callback_RendererHasFocus;
- // Wait for Wiiuse to find the number of connected Wiimotes
- Plugins.GetWiimote()->Initialize((void *)&WiimoteInitialize);
- }
+ Wiimote::Initialize(g_pWindowHandle);
// The hardware is initialized.
g_bHwInit = true;
@@ -508,7 +500,8 @@ THREAD_RETURN EmuThread(void *pArg)
if (_CoreParameter.bCPUThread)
Plugins.ShutdownVideoPlugin();
- GCPad_Deinit();
+ Pad::Shutdown();
+ Wiimote::Shutdown();
Plugins.ShutdownPlugins();
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Plugins shutdown").c_str());
diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h
index 44e78a31af..3fe1d15d27 100644
--- a/Source/Core/Core/Src/CoreParameter.h
+++ b/Source/Core/Core/Src/CoreParameter.h
@@ -126,7 +126,6 @@ struct SCoreStartupParameter
// files
std::string m_strVideoPlugin;
std::string m_strDSPPlugin;
- std::string m_strWiimotePlugin;
std::string m_strFilename;
std::string m_strBootROM;
diff --git a/Source/Core/Core/Src/HW/GCPad.cpp b/Source/Core/Core/Src/HW/GCPad.cpp
index 74cac8e3c8..62704fff6c 100644
--- a/Source/Core/Core/Src/HW/GCPad.cpp
+++ b/Source/Core/Core/Src/HW/GCPad.cpp
@@ -23,47 +23,42 @@
#include "../../InputCommon/Src/InputConfig.h"
-static InputPlugin g_plugin("GCPadNew", "Pad", "GCPad");
+namespace Pad
+{
-InputPlugin *PAD_GetPlugin() {
+static InputPlugin g_plugin("GCPadNew", "Pad", "GCPad");
+InputPlugin *GetPlugin()
+{
return &g_plugin;
}
-void GCPad_Deinit()
+void Shutdown()
{
- if ( g_plugin.controller_interface.IsInit() )
- {
- std::vector::const_iterator
- i = g_plugin.controllers.begin(),
- e = g_plugin.controllers.end();
- for ( ; i!=e; ++i )
- delete *i;
- g_plugin.controllers.clear();
+ std::vector::const_iterator
+ i = g_plugin.controllers.begin(),
+ e = g_plugin.controllers.end();
+ for ( ; i!=e; ++i )
+ delete *i;
+ g_plugin.controllers.clear();
- g_plugin.controller_interface.DeInit();
- }
+ g_controller_interface.Shutdown();
}
// if plugin isn't initialized, init and load config
-void GCPad_Init( void* const hwnd )
+void Initialize(void* const hwnd)
{
- // i realize i am checking IsInit() twice, just too lazy to change it
- if ( false == g_plugin.controller_interface.IsInit() )
- {
- // add 4 gcpads
- for (unsigned int i=0; i<4; ++i)
- g_plugin.controllers.push_back(new GCPad(i));
-
- // needed for Xlib
- g_plugin.controller_interface.SetHwnd(hwnd);
- g_plugin.controller_interface.Init();
+ // add 4 gcpads
+ for (unsigned int i=0; i<4; ++i)
+ g_plugin.controllers.push_back(new GCPad(i));
- // load the saved controller config
- g_plugin.LoadConfig();
- }
+ g_controller_interface.SetHwnd(hwnd);
+ g_controller_interface.Initialize();
+
+ // load the saved controller config
+ g_plugin.LoadConfig();
}
-void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
+void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{
memset(_pPADStatus, 0, sizeof(*_pPADStatus));
_pPADStatus->err = PAD_ERR_NONE;
@@ -84,8 +79,8 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
static int _last_numPAD = 4;
if (_numPAD <= _last_numPAD)
{
- g_plugin.controller_interface.UpdateOutput();
- g_plugin.controller_interface.UpdateInput();
+ g_controller_interface.UpdateOutput();
+ g_controller_interface.UpdateInput();
}
_last_numPAD = _numPAD;
@@ -102,7 +97,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
// input: PAD number, Command type (Stop=0, Rumble=1, Stop Hard=2) and strength of Rumble
// output: none
//
-void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
+void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
{
// enter
if ( g_plugin.controls_crit.TryEnter() )
@@ -115,3 +110,5 @@ void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
g_plugin.controls_crit.Leave();
}
}
+
+}
diff --git a/Source/Core/Core/Src/HW/GCPad.h b/Source/Core/Core/Src/HW/GCPad.h
index 78f748e807..c3e1ace61e 100644
--- a/Source/Core/Core/Src/HW/GCPad.h
+++ b/Source/Core/Core/Src/HW/GCPad.h
@@ -19,10 +19,20 @@
#include "GCPadStatus.h"
#include "../../InputCommon/Src/InputConfig.h"
-void GCPad_Init( void* const hwnd );
-void GCPad_Deinit();
+#ifndef _GCPAD_H_
+#define _GCPAD_H_
-void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus);
-void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
+namespace Pad
+{
-InputPlugin *PAD_GetPlugin();
+void Shutdown();
+void Initialize(void* const hwnd);
+
+InputPlugin *GetPlugin();
+
+void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus);
+void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
+
+}
+
+#endif
diff --git a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp
index 158fba404a..e17dcdc897 100644
--- a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp
+++ b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp
@@ -148,7 +148,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
DEBUG_LOG(AMBASEBOARDDEBUG, "GC-AM: CMD 10, %02x (READ STATUS&SWITCHES)", ptr(1));
SPADStatus PadStatus;
memset(&PadStatus, 0 ,sizeof(PadStatus));
- PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
+ Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
res[resp++] = 0x10;
res[resp++] = 0x2;
int d10_0 = 0xdf;
@@ -313,7 +313,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength)
for (i=0; i::const_iterator
+ i = g_plugin.controllers.begin(),
+ e = g_plugin.controllers.end();
+ for ( ; i!=e; ++i )
+ delete *i;
+ g_plugin.controllers.clear();
+
+ // WiimoteReal is shutdown on app exit
+ //WiimoteReal::Shutdown();
+
+ g_controller_interface.Shutdown();
+}
+
+// if plugin isn't initialized, init and load config
+void Initialize(void* const hwnd)
+{
+ // add 4 wiimotes
+ for (unsigned int i = 0; i<4; ++i)
+ g_plugin.controllers.push_back(new WiimoteEmu::Wiimote(i));
+
+ g_controller_interface.SetHwnd(hwnd);
+ g_controller_interface.Initialize();
+
+ g_plugin.LoadConfig();
+
+ WiimoteReal::Initialize();
+}
+
+// __________________________________________________________________________________________________
+// Function: Wiimote_Output
+// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
+// on the HID CONTROL channel.
+// input: Da pakket.
+// output: none
+//
+void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
+{
+ if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
+ ((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->ControlChannel(_channelID, _pData, _Size);
+
+ if (WIIMOTE_SRC_REAL & g_wiimote_sources[_number])
+ WiimoteReal::ControlChannel(_number, _channelID, _pData, _Size);
+}
+
+// __________________________________________________________________________________________________
+// Function: Wiimote_InterruptChannel
+// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
+// on the HID INTERRUPT channel.
+// input: Da pakket.
+// output: none
+//
+void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
+{
+ if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
+ ((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->InterruptChannel(_channelID, _pData, _Size);
+ else
+ WiimoteReal::InterruptChannel(_number, _channelID, _pData, _Size);
+}
+
+// __________________________________________________________________________________________________
+// Function: Wiimote_Update
+// Purpose: This function is called periodically by the Core.
+// input: none
+// output: none
+//
+void Update(int _number)
+{
+ //PanicAlert( "Wiimote_Update" );
+
+ // TODO: change this to a TryEnter, and make it give empty input on failure
+ g_plugin.controls_crit.Enter();
+
+ static int _last_number = 4;
+ if (_number <= _last_number)
+ {
+ g_controller_interface.UpdateOutput();
+ g_controller_interface.UpdateInput();
+ }
+ _last_number = _number;
+
+ if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
+ ((WiimoteEmu::Wiimote*)g_plugin.controllers[_number])->Update();
+ else
+ WiimoteReal::Update(_number);
+
+ g_plugin.controls_crit.Leave();
+}
+
+// __________________________________________________________________________________________________
+// Function: PAD_GetAttachedPads
+// Purpose: Get mask of attached pads (eg: controller 1 & 4 -> 0x9)
+// input: none
+// output: number of pads
+//
+unsigned int GetAttached()
+{
+ unsigned int attached = 0;
+ for (unsigned int i=0; i<4; ++i)
+ if (g_wiimote_sources[i])
+ attached |= (1 << i);
+ return attached;
+}
+
+// ___________________________________________________________________________
+// Function: DoState
+// Purpose: Saves/load state
+// input/output: ptr
+// input: mode
+//
+void DoState(unsigned char **ptr, int mode)
+{
+ // TODO:
+
+ //PointerWrap p(ptr, mode);
+ //for (unsigned int i=0; i<4; ++i)
+ // ((WiimoteEmu::Wiimote*)g_plugin.controllers[i])->DoState(p);
+}
+
+// ___________________________________________________________________________
+// Function: EmuStateChange
+// Purpose: Notifies the plugin of a change in emulation state
+// input: newState
+// output: none
+//
+void EmuStateChange(PLUGIN_EMUSTATE newState)
+{
+ // TODO
+ WiimoteReal::StateChange(newState);
+}
+
+}
diff --git a/Source/Core/Core/Src/HW/Wiimote.h b/Source/Core/Core/Src/HW/Wiimote.h
new file mode 100644
index 0000000000..3908fc4246
--- /dev/null
+++ b/Source/Core/Core/Src/HW/Wiimote.h
@@ -0,0 +1,50 @@
+
+#ifndef _WIIMOTE_H_
+#define _WIIMOTE_H_
+
+#include "PluginSpecs.h"
+#include "../../InputCommon/Src/InputConfig.h"
+
+#define MAX_WIIMOTES 4
+
+#define WIIMOTE_INI_NAME "WiimoteNew"
+
+//extern InputPlugin g_plugin;
+extern unsigned int g_wiimote_sources[MAX_WIIMOTES];
+
+//extern SWiimoteInitialize g_WiimoteInitialize;
+
+namespace Wiimote
+{
+
+void Shutdown();
+void Initialize(void* const hwnd);
+
+unsigned int GetAttached();
+void DoState(unsigned char **ptr, int mode);
+void EmuStateChange(PLUGIN_EMUSTATE newState);
+InputPlugin *GetPlugin();
+
+void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
+void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
+void Update(int _number);
+
+}
+
+namespace WiimoteReal
+{
+
+unsigned int Initialize();
+void Shutdown();
+void Refresh();
+
+void LoadSettings();
+
+#ifdef _WIN32
+int PairUp(bool unpair = false);
+int UnPair();
+#endif
+
+}
+
+#endif
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.cpp
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.cpp
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.h b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.h
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Attachment.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Attachment.h
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.cpp
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.cpp
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.h b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.h
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Classic.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Classic.h
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.cpp
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.cpp
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.h b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.h
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Drums.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Drums.h
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.cpp
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.cpp
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.h b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.h
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Guitar.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Guitar.h
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp
similarity index 96%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp
index 446fdecb86..7cf36efb85 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.cpp
@@ -27,7 +27,11 @@ static const u8 nunchuk_button_bitmasks[] =
Nunchuk::BUTTON_Z,
};
+#ifdef USE_UDP_WIIMOTE
Nunchuk::Nunchuk(UDPWrapper *wrp) : Attachment("Nunchuk") , m_udpWrap(wrp)
+#else
+Nunchuk::Nunchuk() : Attachment("Nunchuk")
+#endif
{
// buttons
groups.push_back(m_buttons = new Buttons("Buttons"));
@@ -85,7 +89,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
// flip the button bits :/
ncdata->bt ^= 0x03;
- //UDPNunchuk stuff
+#ifdef USE_UDP_WIIMOTE
if (m_udpWrap->inst)
{
if (m_udpWrap->updNun)
@@ -114,7 +118,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
accel.z=z;
}
}
- //End UDPNunchuck
+#endif
wm_accel* dt = (wm_accel*)&ncdata->ax;
accel_cal* calib = (accel_cal*)®[0x20];
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.h
similarity index 85%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.h
index fefeee4796..59eea0b5e3 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Nunchuk.h
+++ b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Nunchuk.h
@@ -11,7 +11,13 @@ namespace WiimoteEmu
class Nunchuk : public Attachment
{
public:
+
+#ifdef USE_UDP_WIIMOTE
Nunchuk(UDPWrapper * wrp);
+#else
+ Nunchuk();
+#endif
+
virtual void GetState( u8* const data, const bool focus );
enum
@@ -31,7 +37,9 @@ private:
unsigned int m_shake_step[3];
+#ifdef USE_UDP_WIIMOTE
UDPWrapper* const m_udpWrap;
+#endif
};
}
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Turntable.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.cpp
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Turntable.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.cpp
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Turntable.h b/Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.h
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Turntable.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/Attachment/Turntable.h
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/EmuSubroutines.cpp
similarity index 97%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/EmuSubroutines.cpp
index 6f89016c09..ccc840450a 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/EmuSubroutines.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteEmu/EmuSubroutines.cpp
@@ -33,9 +33,8 @@
#include
#include
-#include "Common.h" // Common
+#include "Common.h"
#include "FileUtil.h"
-#include "pluginspecs_wiimote.h"
#include "WiimoteEmu.h"
#include "WiimoteHid.h"
@@ -200,7 +199,7 @@ void Wiimote::SendAck(u8 _reportID)
ack->reportID = _reportID;
ack->errorID = 0;
- g_WiimoteInitialize.pWiimoteInterruptChannel( m_index, m_reporting_channel, data, sizeof(data));
+ Core::Callback_WiimoteInterruptChannel( m_index, m_reporting_channel, data, sizeof(data));
}
void Wiimote::HandleExtensionSwap()
@@ -259,7 +258,7 @@ void Wiimote::RequestStatus(const wm_request_status* const rs)
}
// send report
- g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
+ Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
}
/* Write data to Wiimote and Extensions registers. */
@@ -526,7 +525,7 @@ void Wiimote::SendReadDataReply(ReadRequest& _request)
}
// Send a piece
- g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
+ Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, sizeof(data));
}
void Wiimote::DoState(PointerWrap& p)
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Encryption.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Encryption.cpp
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Encryption.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Encryption.cpp
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Encryption.h b/Source/Core/Core/Src/HW/WiimoteEmu/Encryption.h
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Encryption.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/Encryption.h
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/MatrixMath.h b/Source/Core/Core/Src/HW/WiimoteEmu/MatrixMath.h
similarity index 96%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/MatrixMath.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/MatrixMath.h
index d1072fefa6..3f6348cb1b 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/MatrixMath.h
+++ b/Source/Core/Core/Src/HW/WiimoteEmu/MatrixMath.h
@@ -3,6 +3,10 @@
#include
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
typedef double Matrix[4][4];
typedef struct
{
@@ -24,9 +28,10 @@ inline void MatrixFrustum(Matrix &m, double l, double r, double b, double t, dou
m[2][0]=(r+l)/(r-l); m[2][1]=(t+b)/(t-b); m[2][2]=(f+n)/(f-n); m[2][3]=-1;
m[3][0]=0; m[3][1]=0; m[3][2]=2*f*n/(f-n); m[3][3]=0;
}
+
inline void MatrixPerspective(Matrix & m, double fovy, double aspect, double nplane, double fplane)
{
- double xmin,xmax,ymin,ymax;
+ double xmin, xmax, ymin, ymax;
ymax = nplane * tan(fovy * M_PI / 360.0);
ymin = -ymax;
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Speaker.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/Speaker.cpp
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Speaker.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/Speaker.cpp
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/UDPTLayer.h b/Source/Core/Core/Src/HW/WiimoteEmu/UDPTLayer.h
similarity index 96%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/UDPTLayer.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/UDPTLayer.h
index f800f6fbf0..44ae0605e0 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/UDPTLayer.h
+++ b/Source/Core/Core/Src/HW/WiimoteEmu/UDPTLayer.h
@@ -1,6 +1,6 @@
//UDP Wiimote Translation Layer
-#ifndef UDPTLAYER_H
+#if (defined(USE_UDP_WIIMOTE) && !defined(UDPTLAYER_H))
#define UDPTLAYER_H
#include "UDPWiimote.h"
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp
similarity index 98%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp
rename to Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp
index 9f2851ed02..f97ad986bb 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.cpp
@@ -12,6 +12,7 @@
#include "Timer.h"
#include "Common.h"
+#include "../../Host.h"
#include "UDPTLayer.h"
@@ -242,7 +243,7 @@ Wiimote::Wiimote( const unsigned int index )
m_buttons->controls.push_back(new ControlGroup::Input( named_buttons[i]));
// ir
- groups.push_back(m_ir = new Cursor("IR", &g_WiimoteInitialize));
+ groups.push_back(m_ir = new Cursor("IR"));
// swing
groups.push_back(m_swing = new Force("Swing"));
@@ -250,8 +251,10 @@ Wiimote::Wiimote( const unsigned int index )
// tilt
groups.push_back(m_tilt = new Tilt("Tilt"));
+#ifdef USE_UDP_WIIMOTE
// udp
groups.push_back(m_udp = new UDPWrapper(m_index, "UDP Wiimote"));
+#endif
// shake
groups.push_back(m_shake = new Buttons("Shake"));
@@ -262,7 +265,11 @@ Wiimote::Wiimote( const unsigned int index )
// extension
groups.push_back(m_extension = new Extension("Extension"));
m_extension->attachments.push_back(new WiimoteEmu::None());
+#ifdef USE_UDP_WIIMOTE
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk(m_udp));
+#else
+ m_extension->attachments.push_back(new WiimoteEmu::Nunchuk());
+#endif
m_extension->attachments.push_back(new WiimoteEmu::Classic());
m_extension->attachments.push_back(new WiimoteEmu::Guitar());
m_extension->attachments.push_back(new WiimoteEmu::Drums());
@@ -319,7 +326,7 @@ std::string Wiimote::GetName() const
}
// if windows is focused or background input is enabled
-#define HAS_FOCUS (g_WiimoteInitialize.pRendererHasFocus() || (m_options->settings[0]->value != 0))
+#define HAS_FOCUS (Host_RendererHasFocus() || (m_options->settings[0]->value != 0))
bool Wiimote::Step()
{
@@ -338,7 +345,9 @@ bool Wiimote::Step()
{
m_buttons->GetState(&m_status.buttons, button_bitmasks);
m_dpad->GetState(&m_status.buttons, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks);
+#ifdef USE_UDP_WIIMOTE
UDPTLayer::GetButtons(m_udp, &m_status.buttons);
+#endif
}
// check if there is a read data request
@@ -398,8 +407,9 @@ void Wiimote::GetAccelData(u8* const data, u8* const buttons)
{
EmulateSwing(&m_accel, m_swing, is_sideways, is_upright);
EmulateShake(&m_accel, m_shake, m_shake_step);
- // UDP Wiimote
+#ifdef USE_UDP_WIIMOTE
UDPTLayer::GetAcceleration(m_udp, &m_accel);
+#endif
}
wm_accel* dt = (wm_accel*)data;
accel_cal* calib = (accel_cal*)&m_eeprom[0x16];
@@ -466,7 +476,9 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
LowPassFilter(ir_cos,ncos,1.0f/60);
m_ir->GetState(&xx, &yy, &zz, true);
+#ifdef USE_UDP_WIIMOTE
UDPTLayer::GetIR(m_udp, &xx, &yy, &zz);
+#endif
Vertex v[4];
@@ -737,7 +749,7 @@ void Wiimote::Update()
// send data report
if (rptf_size)
- g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_reporting_channel, data, rptf_size);
+ Core::Callback_WiimoteInterruptChannel(m_index, m_reporting_channel, data, rptf_size);
}
void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size)
@@ -778,7 +790,7 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
HidOutputReport((wm_report*)hidp->data);
u8 handshake = HID_HANDSHAKE_SUCCESS;
- g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, _channelID, &handshake, 1);
+ Core::Callback_WiimoteInterruptChannel(m_index, _channelID, &handshake, 1);
}
break;
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h
similarity index 98%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h
index 114fa9bddd..eecbbc4c07 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.h
+++ b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteEmu.h
@@ -8,6 +8,8 @@
// just used to get the OpenAL includes :p
//#include
+#include "../../Core.h"
+
#include "ControllerEmu.h"
#include "ChunkFile.h"
@@ -27,8 +29,6 @@
#define WIIMOTE_REG_EXT_SIZE 0x100
#define WIIMOTE_REG_IR_SIZE 0x34
-extern SWiimoteInitialize g_WiimoteInitialize;
-
namespace WiimoteEmu
{
@@ -146,8 +146,9 @@ private:
double ir_sin,ir_cos; //for the low pass filter
- //UDPWiimote
+#ifdef USE_UDP_WIIMOTE
UDPWrapper* m_udp;
+#endif
bool m_rumble_on;
bool m_speaker_mute;
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteHid.h b/Source/Core/Core/Src/HW/WiimoteEmu/WiimoteHid.h
similarity index 100%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteHid.h
rename to Source/Core/Core/Src/HW/WiimoteEmu/WiimoteHid.h
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
similarity index 97%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp
rename to Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
index 5046f6f54e..abf1d1f0b9 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
@@ -21,7 +21,6 @@
#include "IniFile.h"
#include "StringUtil.h"
#include "Timer.h"
-#include "pluginspecs_wiimote.h"
#include "wiiuse.h"
#include "WiimoteReal.h"
@@ -30,6 +29,8 @@
// used for pair up
#ifdef _WIN32
+#undef NTDDI_VERSION
+#define NTDDI_VERSION NTDDI_WINXPSP2
#include
#include
#pragma comment(lib, "Bthprops.lib")
@@ -131,7 +132,7 @@ void Wiimote::ControlChannel(const u16 channel, const void* const data, const u3
if (hidp->type == HID_TYPE_SET_REPORT)
{
u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
- g_WiimoteInitialize.pWiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok));
+ Core::Callback_WiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok));
}
}
}
@@ -233,7 +234,7 @@ void Wiimote::Update()
// send the report
if (rpt && m_channel)
- g_WiimoteInitialize.pWiimoteInterruptChannel(index, m_channel, rpt, MAX_PAYLOAD);
+ Core::Callback_WiimoteInterruptChannel(index, m_channel, rpt, MAX_PAYLOAD);
// delete the data if it isn't also the last data rpt
if (rpt != m_last_data_report)
@@ -250,7 +251,7 @@ void Wiimote::Disconnect()
void LoadSettings()
{
- std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + g_plugin.ini_name + ".ini" );
+ std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini" );
IniFile inifile;
inifile.Load(ini_filename);
@@ -495,6 +496,12 @@ THREAD_RETURN WiimoteThreadFunc(void* arg)
}
#ifdef _WIN32
+int UnPair()
+{
+ // TODO:
+ return 0;
+}
+
// WiiMote Pair-Up, function will return amount of either new paired or unpaired devices
// negative number on failure
int PairUp(bool unpair)
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.h b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
similarity index 88%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.h
rename to Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
index c772ed06fa..3908a8e6ea 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.h
+++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
@@ -23,16 +23,12 @@
#include "ChunkFile.h"
#include "Thread.h"
#include "FifoQueue.h"
+
+#include "../Wiimote.h"
#include "../WiimoteEmu/WiimoteEmu.h"
#include "../../InputCommon/Src/InputConfig.h"
-#define MAX_WIIMOTES 4
-
-extern unsigned int g_wiimote_sources[MAX_WIIMOTES];
-extern InputPlugin g_plugin;
-extern SWiimoteInitialize g_WiimoteInitialize;
-
enum
{
WIIMOTE_SRC_NONE = 0,
@@ -84,11 +80,6 @@ private:
extern Common::CriticalSection g_refresh_critsec;
extern Wiimote *g_wiimotes[4];
-unsigned int Initialize();
-void Shutdown();
-void Refresh();
-void LoadSettings();
-
void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size);
void ControlChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size);
void Update(int _WiimoteNumber);
@@ -96,10 +87,6 @@ void Update(int _WiimoteNumber);
void DoState(PointerWrap &p);
void StateChange(PLUGIN_EMUSTATE newState);
-#ifdef _WIN32
-int PairUp(bool unpair = false);
-#endif
-
}; // WiiMoteReal
#endif
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
index e5a512ce5b..b8ae5032e3 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
@@ -18,7 +18,7 @@
#include "../Core.h"
#include "../Debugger/Debugger_SymbolMap.h"
#include "../Host.h"
-#include "../PluginManager.h"
+#include "../HW/Wiimote.h"
#include "../HW/WII_IPC.h"
#include "WII_IPC_HLE.h"
#include "WII_IPC_HLE_Device_usb.h"
@@ -439,7 +439,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
#if defined(HAVE_WX) && HAVE_WX
NetPlay_WiimoteUpdate(i);
#endif
- CPluginManager::GetInstance().GetWiimote()->Wiimote_Update(i);
+ Wiimote::Update(i);
//return true;
}
}
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
index 752ea3f3f7..3c4c01b8a2 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
@@ -24,6 +24,7 @@
#include "../ConfigManager.h"
#include "../Host.h"
#include "../Core.h"
+#include "../HW/Wiimote.h"
#include "l2cap.h" // Local
#include "WiiMote_HID_Attr.h"
@@ -183,7 +184,7 @@ void CWII_IPC_HLE_WiiMote::EventDisconnect()
{
// Send disconnect message to plugin
u8 Message = WIIMOTE_DISCONNECT;
- CPluginManager::GetInstance().GetWiimote()->Wiimote_ControlChannel(m_ConnectionHandle & 0xFF, 99, &Message, 0);
+ Wiimote::ControlChannel(m_ConnectionHandle & 0xFF, 99, &Message, 0);
m_ConnectionState = CONN_INACTIVE;
// Clear channel flags
@@ -256,7 +257,6 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size)
const int number = 0;
#endif
- Common::PluginWiimote* mote = CPluginManager::GetInstance().GetWiimote();
if (itr != m_Channel.end())
{
SChannel& rChannel = itr->second;
@@ -268,7 +268,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size)
case L2CAP_PSM_HID_CNTL:
if (number < 4)
- mote->Wiimote_ControlChannel(number, pHeader->dcid, pData, DataSize);
+ Wiimote::ControlChannel(number, pHeader->dcid, pData, DataSize);
break;
case L2CAP_PSM_HID_INTR:
@@ -280,7 +280,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size)
std::string Temp = ArrayToString((const u8*)pData, DataSize);
DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str());
- mote->Wiimote_InterruptChannel(number, pHeader->dcid, pData, DataSize);
+ Wiimote::InterruptChannel(number, pHeader->dcid, pData, DataSize);
}
}
break;
diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp
index 4a29ea12bc..d1216a3fe4 100644
--- a/Source/Core/Core/Src/PluginManager.cpp
+++ b/Source/Core/Core/Src/PluginManager.cpp
@@ -71,7 +71,6 @@ CPluginManager::CPluginManager()
// Set initial values to NULL.
m_video = NULL;
m_dsp = NULL;
- m_wiimote = NULL;
}
// This will call FreeLibrary() for all plugins
@@ -81,14 +80,6 @@ CPluginManager::~CPluginManager()
delete m_PluginGlobals;
delete m_dsp;
-
- if (m_wiimote)
- {
- m_wiimote->Shutdown();
- delete m_wiimote;
- m_wiimote = NULL;
- }
-
delete m_video;
}
@@ -118,18 +109,6 @@ bool CPluginManager::InitPlugins()
return false;
}
- // Init wiimote
- if (m_params->bWii)
- {
- if (!m_params->m_strWiimotePlugin.empty())
- GetWiimote();
- if (!m_wiimote)
- {
- PanicAlert("Can't init Wiimote Plugin");
- return false;
- }
- }
-
return true;
}
@@ -138,12 +117,6 @@ bool CPluginManager::InitPlugins()
// for an explanation about the current LoadLibrary() and FreeLibrary() behavior.
void CPluginManager::ShutdownPlugins()
{
- if (m_wiimote)
- {
- m_wiimote->Shutdown();
- FreeWiimote();
- }
-
if (m_dsp)
{
m_dsp->Shutdown();
@@ -247,10 +220,6 @@ void *CPluginManager::LoadPlugin(const char *_rFilename)
plugin = new Common::PluginDSP(_rFilename);
break;
- case PLUGIN_TYPE_WIIMOTE:
- plugin = new Common::PluginWiimote(_rFilename);
- break;
-
default:
PanicAlert("Trying to load unsupported type %d", type);
return NULL;
@@ -319,27 +288,12 @@ void CPluginManager::ScanForPlugins()
/* Create or return the already created plugin pointers. This will be called
- often for Wiimote. And often for the DSP from the DSP files.
+ often for the DSP from the DSP files.
We don't need to check if [Plugin]->IsValid() here because it will not be set by LoadPlugin()
if it's not valid.
*/
-Common::PluginWiimote *CPluginManager::GetWiimote()
-{
- if (m_wiimote != NULL)
- {
- if (m_wiimote->GetFilename() == m_params->m_strWiimotePlugin)
- return m_wiimote;
- else
- FreeWiimote();
- }
-
- // Else load a new plugin
- m_wiimote = (Common::PluginWiimote*)LoadPlugin(m_params->m_strWiimotePlugin.c_str());
- return m_wiimote;
-}
-
Common::PluginDSP *CPluginManager::GetDSP()
{
if (m_dsp != NULL)
@@ -384,17 +338,10 @@ void CPluginManager::FreeDSP()
m_dsp = NULL;
}
-void CPluginManager::FreeWiimote()
-{
- delete m_wiimote;
- m_wiimote = NULL;
-}
-
void CPluginManager::EmuStateChange(PLUGIN_EMUSTATE newState)
{
GetVideo()->EmuStateChange(newState);
GetDSP()->EmuStateChange(newState);
- GetWiimote()->EmuStateChange(newState);
}
@@ -417,16 +364,15 @@ void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TY
if (GetVideo() != NULL)
GetVideo()->Config(_Parent);
break;
+
case PLUGIN_TYPE_DSP:
if (GetDSP() != NULL)
GetDSP()->Config(_Parent);
break;
- case PLUGIN_TYPE_WIIMOTE:
- if (GetWiimote() != NULL)
- GetWiimote()->Config(_Parent);
- break;
+
default:
PanicAlert("Type %d config not supported in plugin %s", Type, _rFilename);
+ break;
}
}
@@ -444,11 +390,14 @@ void *CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TY
case PLUGIN_TYPE_VIDEO:
return GetVideo()->Debug(_Parent, Show);
break;
+
case PLUGIN_TYPE_DSP:
return GetDSP()->Debug(_Parent, Show);
break;
+
default:
PanicAlert("Type %d debug not supported in plugin %s", Type, _rFilename);
return NULL;
+ break;
}
}
diff --git a/Source/Core/Core/Src/PluginManager.h b/Source/Core/Core/Src/PluginManager.h
index d1a94655be..8262f40753 100644
--- a/Source/Core/Core/Src/PluginManager.h
+++ b/Source/Core/Core/Src/PluginManager.h
@@ -21,7 +21,6 @@
#include "Plugin.h"
#include "PluginDSP.h"
#include "PluginVideo.h"
-#include "PluginWiimote.h"
#include "CoreParameter.h"
class CPluginInfo
@@ -51,11 +50,9 @@ public:
Common::PluginVideo *GetVideo();
Common::PluginDSP *GetDSP();
- Common::PluginWiimote *GetWiimote();
void FreeVideo();
void FreeDSP();
- void FreeWiimote();
void EmuStateChange(PLUGIN_EMUSTATE newState);
@@ -75,7 +72,6 @@ private:
PLUGIN_GLOBALS *m_PluginGlobals;
Common::PluginVideo *m_video;
Common::PluginDSP *m_dsp;
- Common::PluginWiimote *m_wiimote;
SCoreStartupParameter * m_params;
CPluginManager();
diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript
index 493f3c5cbc..5b6ebce6b6 100644
--- a/Source/Core/Core/Src/SConscript
+++ b/Source/Core/Core/Src/SConscript
@@ -49,6 +49,17 @@ files = [
"HW/EXI_DeviceEthernet.cpp",
"HW/GPFifo.cpp",
"HW/GCPad.cpp",
+ "HW/Wiimote.cpp",
+ "HW/WiimoteEmu/WiimoteEmu.cpp",
+ "HW/WiimoteEmu/Attachment/Classic.cpp",
+ "HW/WiimoteEmu/Attachment/Attachment.cpp",
+ "HW/WiimoteEmu/Attachment/Nunchuk.cpp",
+ "HW/WiimoteEmu/Attachment/Drums.cpp",
+ "HW/WiimoteEmu/Attachment/Guitar.cpp",
+ "HW/WiimoteEmu/Attachment/Turntable.cpp",
+ "HW/WiimoteEmu/EmuSubroutines.cpp",
+ "HW/WiimoteEmu/Encryption.cpp",
+ "HW/WiimoteEmu/Speaker.cpp",
"HW/GCPadEmu.cpp",
"HW/HW.cpp",
"HW/Memmap.cpp",
@@ -132,6 +143,10 @@ elif sys.platform == 'darwin':
else:
files += [ "HW/BBA-TAP/TAP_Unix.cpp" ]
+if env['HAVE_WIIUSE']:
+ files += [ 'HW/WiimoteReal/WiimoteReal.cpp' ]
+ libs += [ 'wiiuse' ]
+
libs = [
'bdisasm',
'inputcommon',
diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp
index 938228e783..8033a4661e 100644
--- a/Source/Core/Core/Src/State.cpp
+++ b/Source/Core/Core/Src/State.cpp
@@ -24,6 +24,7 @@
#include "Thread.h"
#include "CoreTiming.h"
#include "OnFrame.h"
+#include "HW/Wiimote.h"
#include "HW/HW.h"
#include "PowerPC/PowerPC.h"
#include "PowerPC/JitCommon/JitBase.h"
@@ -90,7 +91,7 @@ void DoState(PointerWrap &p)
pm.GetVideo()->DoState(p.GetPPtr(), p.GetMode());
pm.GetDSP()->DoState(p.GetPPtr(), p.GetMode());
if (Core::g_CoreStartupParameter.bWii)
- pm.GetWiimote()->DoState(p.GetPPtr(), p.GetMode());
+ Wiimote::DoState(p.GetPPtr(), p.GetMode());
PowerPC::DoState(p);
HW::DoState(p);
CoreTiming::DoState(p);
diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj
index d11c530ed6..f3af012580 100644
--- a/Source/Core/DolphinWX/DolphinWX.vcproj
+++ b/Source/Core/DolphinWX/DolphinWX.vcproj
@@ -90,11 +90,11 @@
/>
+
+
+
+
@@ -1054,6 +1062,22 @@
>
+
+
+
+
+
+
+
+
Disable();
DSPSelection->Disable();
- WiimoteSelection->Disable();
}
}
@@ -329,7 +325,6 @@ void CConfigMain::InitializeGUIValues()
// Plugins
FillChoiceBox(GraphicSelection, PLUGIN_TYPE_VIDEO, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin);
FillChoiceBox(DSPSelection, PLUGIN_TYPE_DSP, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin);
- FillChoiceBox(WiimoteSelection, PLUGIN_TYPE_WIIMOTE, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin);
}
void CConfigMain::InitializeGUITooltips()
@@ -743,10 +738,6 @@ void CConfigMain::CreateGUIControls()
DSPSelection = new wxChoice(PluginsPage, ID_DSP_CB, wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator);
DSPConfig = new wxButton(PluginsPage, ID_DSP_CONFIG, wxT("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
- sbWiimotePlugin = new wxStaticBoxSizer(wxHORIZONTAL, PluginsPage, wxT("Wiimote"));
- WiimoteSelection = new wxChoice(PluginsPage, ID_WIIMOTE_CB, wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator);
- WiimoteConfig = new wxButton(PluginsPage, ID_WIIMOTE_CONFIG, wxT("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
-
// Populate the settings
sbGraphicsPlugin->Add(GraphicSelection, 1, wxEXPAND|wxALL, 5);
sbGraphicsPlugin->Add(GraphicConfig, 0, wxALL, 5);
@@ -754,14 +745,10 @@ void CConfigMain::CreateGUIControls()
sbDSPPlugin->Add(DSPSelection, 1, wxEXPAND|wxALL, 5);
sbDSPPlugin->Add(DSPConfig, 0, wxALL, 5);
- sbWiimotePlugin->Add(WiimoteSelection, 1, wxEXPAND|wxALL, 5);
- sbWiimotePlugin->Add(WiimoteConfig, 0, wxALL, 5);
-
// Populate the Plugins page
sPluginsPage = new wxBoxSizer(wxVERTICAL);
sPluginsPage->Add(sbGraphicsPlugin, 0, wxEXPAND|wxALL, 5);
sPluginsPage->Add(sbDSPPlugin, 0, wxEXPAND|wxALL, 5);
- sPluginsPage->Add(sbWiimotePlugin, 0, wxEXPAND|wxALL, 5);
PluginsPage->SetSizer(sPluginsPage);
sPluginsPage->Layout();
@@ -1155,8 +1142,6 @@ void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event))
CPluginManager::GetInstance().FreeVideo();
if (GetFilename(DSPSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin))
CPluginManager::GetInstance().FreeDSP();
- if (GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin))
- CPluginManager::GetInstance().FreeWiimote();
}
void CConfigMain::OnConfig(wxCommandEvent& event)
@@ -1169,9 +1154,6 @@ void CConfigMain::OnConfig(wxCommandEvent& event)
case ID_DSP_CONFIG:
CallConfig(DSPSelection);
break;
- case ID_WIIMOTE_CONFIG:
- CallConfig(WiimoteSelection);
- break;
}
}
diff --git a/Source/Core/DolphinWX/Src/ConfigMain.h b/Source/Core/DolphinWX/Src/ConfigMain.h
index 192f4c0db0..b947b732d4 100644
--- a/Source/Core/DolphinWX/Src/ConfigMain.h
+++ b/Source/Core/DolphinWX/Src/ConfigMain.h
@@ -140,7 +140,7 @@ private:
wxBoxSizer* sPluginsPage; // Plugins settings
- wxStaticBoxSizer* sbGraphicsPlugin, *sbDSPPlugin, *sbWiimotePlugin; // Graphics, DSP, Wiimote sections
+ wxStaticBoxSizer* sbGraphicsPlugin, *sbDSPPlugin; // Graphics, DSP sections
// Graphics
wxChoice* GraphicSelection;
@@ -150,10 +150,6 @@ private:
wxChoice* DSPSelection;
wxButton* DSPConfig;
- // Wiimote
- wxChoice* WiimoteSelection;
- wxButton* WiimoteConfig;
-
wxButton* m_Ok;
FILE* pStream;
@@ -262,11 +258,6 @@ private:
ID_DSP_CB,
ID_DSP_CONFIG,
ID_DSP_ABOUT,
-
- ID_WIIMOTE_TEXT,
- ID_WIIMOTE_CB,
- ID_WIIMOTE_CONFIG,
- ID_WIIMOTE_ABOUT
};
void InitializeGUILists();
diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp
index 3b5c66136d..4e17e6ca74 100644
--- a/Source/Core/DolphinWX/Src/Frame.cpp
+++ b/Source/Core/DolphinWX/Src/Frame.cpp
@@ -817,9 +817,6 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
&& event.GetModifiers() == wxMOD_SHIFT)
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
#endif
-
- // Send the keyboard status to the Input plugins
- CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 1); // 1 = Down
}
else
event.Skip();
@@ -828,10 +825,6 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
void CFrame::OnKeyUp(wxKeyEvent& event)
{
event.Skip();
-
- if(Core::GetState() != Core::CORE_UNINITIALIZED) {
- CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 0); // 0 = Up
- }
}
void CFrame::DoFullscreen(bool bF)
diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp
index 4494d02b72..a7639456fe 100644
--- a/Source/Core/DolphinWX/Src/FrameTools.cpp
+++ b/Source/Core/DolphinWX/Src/FrameTools.cpp
@@ -57,12 +57,14 @@ Core::GetWindowHandle().
#include "HW/DVDInterface.h"
#include "HW/ProcessorInterface.h"
#include "HW/GCPad.h"
+#include "HW/Wiimote.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "State.h"
#include "VolumeHandler.h"
#include "NANDContentLoader.h"
#include "WXInputBase.h"
-#include "../../InputUICommon/Src/ConfigDiag.h"
+#include "WiimoteConfigDiag.h"
+#include "InputConfigDiag.h"
#include // wxWidgets
@@ -1024,42 +1026,50 @@ void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event))
void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event))
{
- InputPlugin *pad_plugin = PAD_GetPlugin();
+ InputPlugin *const pad_plugin = Pad::GetPlugin();
bool was_init = false;
- if ( pad_plugin->controller_interface.IsInit() ) // check if game is running
+ if (g_controller_interface.IsInit()) // check if game is running
was_init = true;
else
{
#if defined(HAVE_X11) && HAVE_X11
Window win = X11Utils::XWindowFromHandle(GetHandle());
- GCPad_Init((void *)win);
+ Pad::Initialize((void *)win);
#else
- GCPad_Init(GetHandle());
+ Pad::Initialize(GetHandle());
#endif
}
- InputConfigDialog* m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "Dolphin GCPad Configuration");
+ InputConfigDialog *const m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "Dolphin GCPad Configuration");
m_ConfigFrame->ShowModal();
m_ConfigFrame->Destroy();
if (!was_init) // if game isn't running
{
- GCPad_Deinit();
+ Pad::Shutdown();
}
}
void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event))
{
- #ifdef _WIN32
- Disable(); // Fake a modal dialog
- #endif
- CPluginManager::GetInstance().OpenConfig(
- this,
- SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin.c_str(),
- PLUGIN_TYPE_WIIMOTE
- );
- #ifdef _WIN32
- Enable();
- Raise();
- #endif
+ InputPlugin *const wiimote_plugin = Wiimote::GetPlugin();
+ bool was_init = false;
+ if (g_controller_interface.IsInit()) // check if game is running
+ was_init = true;
+ else
+ {
+#if defined(HAVE_X11) && HAVE_X11
+ Window win = X11Utils::XWindowFromHandle(GetHandle());
+ Wiimote::Initialize((void *)win);
+#else
+ Wiimote::Initialize(GetHandle());
+#endif
+ }
+ WiimoteConfigDiag *const m_ConfigFrame = new WiimoteConfigDiag(this, *wiimote_plugin);
+ m_ConfigFrame->ShowModal();
+ m_ConfigFrame->Destroy();
+ if (!was_init) // if game isn't running
+ {
+ Wiimote::Shutdown();
+ }
}
void CFrame::OnHelp(wxCommandEvent& event)
diff --git a/Source/Core/InputUICommon/Src/ConfigDiag.cpp b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp
similarity index 93%
rename from Source/Core/InputUICommon/Src/ConfigDiag.cpp
rename to Source/Core/DolphinWX/Src/InputConfigDiag.cpp
index 473cc96520..354a3bacac 100644
--- a/Source/Core/InputUICommon/Src/ConfigDiag.cpp
+++ b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp
@@ -15,18 +15,20 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-#include "ConfigDiag.h"
+#include "InputConfigDiag.h"
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
#define WXSTR_FROM_STR(s) (wxString::From8BitData((s).c_str()))
// ToAscii was causing probs with some extended ascii characters, To8BitData seems to work
#define STR_FROM_WXSTR(w) (std::string((w).To8BitData()))
+#ifdef USE_UDP_WIIMOTE
void GamepadPage::ConfigUDPWii(wxCommandEvent &event)
{
UDPWrapper* const wrp = ((UDPConfigButton*)event.GetEventObject())->wrapper;
wrp->Configure(this);
}
+#endif
void GamepadPage::ConfigExtension( wxCommandEvent& event )
{
@@ -184,10 +186,10 @@ void InputConfigDialog::UpdateControlReferences()
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
e = m_padpages.end();
for ( ; i != e; ++i )
- (*i)->controller->UpdateReferences( m_plugin.controller_interface );
+ (*i)->controller->UpdateReferences(g_controller_interface);
}
-void InputConfigDialog::ClickSave( wxCommandEvent& event )
+void InputConfigDialog::ClickSave(wxCommandEvent&)
{
m_plugin.SaveConfig();
Close();
@@ -197,7 +199,7 @@ void ControlDialog::UpdateListContents()
{
control_lbox->Clear();
- ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(m_devq);
+ ControllerInterface::Device* const dev = g_controller_interface.FindDevice(m_devq);
if (dev)
{
if (control_reference->is_input)
@@ -268,7 +270,7 @@ void GamepadPage::UpdateGUI()
}
}
-void GamepadPage::ClearAll( wxCommandEvent& event )
+void GamepadPage::ClearAll(wxCommandEvent&)
{
// just load an empty ini section to clear everything :P
IniFile::Section section;
@@ -284,29 +286,29 @@ void GamepadPage::ClearAll( wxCommandEvent& event )
UpdateGUI();
}
-void GamepadPage::LoadDefaults( wxCommandEvent& event )
+void GamepadPage::LoadDefaults(wxCommandEvent&)
{
- controller->LoadDefaults(m_plugin.controller_interface);
+ controller->LoadDefaults(g_controller_interface);
m_plugin.controls_crit.Enter(); // enter
- controller->UpdateReferences(m_plugin.controller_interface);
+ controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
-void ControlDialog::SetControl( wxCommandEvent& event )
+void ControlDialog::SetControl(wxCommandEvent&)
{
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
m_plugin.controls_crit.Enter(); // enter
- m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
+ g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
-void GamepadPage::SetDevice( wxCommandEvent& event )
+void GamepadPage::SetDevice(wxCommandEvent&)
{
controller->default_device.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
@@ -318,11 +320,11 @@ void GamepadPage::SetDevice( wxCommandEvent& event )
// update references
m_plugin.controls_crit.Enter(); // enter
- controller->UpdateReferences( m_plugin.controller_interface );
+ controller->UpdateReferences( g_controller_interface );
m_plugin.controls_crit.Leave(); // leave
}
-void ControlDialog::SetDevice( wxCommandEvent& event )
+void ControlDialog::SetDevice(wxCommandEvent&)
{
m_devq.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
@@ -333,18 +335,18 @@ void ControlDialog::SetDevice( wxCommandEvent& event )
UpdateListContents();
}
-void ControlDialog::ClearControl(wxCommandEvent& event)
+void ControlDialog::ClearControl(wxCommandEvent&)
{
control_reference->expression.clear();
m_plugin.controls_crit.Enter(); // enter
- m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
+ g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
}
-void ControlDialog::SetSelectedControl(wxCommandEvent& event)
+void ControlDialog::SetSelectedControl(wxCommandEvent&)
{
const int num = control_lbox->GetSelection();
@@ -363,7 +365,7 @@ void ControlDialog::SetSelectedControl(wxCommandEvent& event)
control_reference->expression = STR_FROM_WXSTR(expr);
m_plugin.controls_crit.Enter(); // enter
- m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
+ g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
@@ -395,7 +397,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
control_reference->expression = STR_FROM_WXSTR(expr);
m_plugin.controls_crit.Enter(); // enter
- m_plugin.controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
+ g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
m_plugin.controls_crit.Leave(); // leave
UpdateGUI();
@@ -408,7 +410,7 @@ void GamepadPage::AdjustSetting( wxCommandEvent& event )
m_plugin.controls_crit.Leave(); // leave
}
-void GamepadPage::AdjustControlOption( wxCommandEvent& event )
+void GamepadPage::AdjustControlOption(wxCommandEvent&)
{
m_plugin.controls_crit.Enter(); // enter / prolly fine not being here
m_control_dialog->control_reference->range = (ControlState)(m_control_dialog->range_slider->GetValue()) / SLIDER_TICK_COUNT;
@@ -432,7 +434,7 @@ void GamepadPage::ClearControl( wxCommandEvent& event )
btn->control_reference->range = 1.0f;
m_plugin.controls_crit.Enter(); // enter
- controller->UpdateReferences( m_plugin.controller_interface );
+ controller->UpdateReferences( g_controller_interface );
m_plugin.controls_crit.Leave(); // leave
// update changes
@@ -444,7 +446,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
wxButton* const btn = (wxButton*)event.GetEventObject();
const wxString lbl = btn->GetLabel();
- ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(m_devq);
+ ControllerInterface::Device* const dev = g_controller_interface.FindDevice(m_devq);
if (dev)
{
btn->SetLabel(wxT("[ waiting ]"));
@@ -469,7 +471,7 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
ControlButton* btn = (ControlButton*)event.GetEventObject();
// find device :/
- ControllerInterface::Device* const dev = m_plugin.controller_interface.FindDevice(controller->default_device);
+ ControllerInterface::Device* const dev = g_controller_interface.FindDevice(controller->default_device);
if (dev)
{
btn->SetLabel(wxT("[ waiting ]"));
@@ -484,7 +486,7 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
if (ctrl)
{
btn->control_reference->expression = ctrl->GetName();
- m_plugin.controller_interface.UpdateReference(btn->control_reference, controller->default_device);
+ g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
}
m_plugin.controls_crit.Leave(); // leave
@@ -585,7 +587,7 @@ void GamepadPage::GetProfilePath(std::string& path)
}
}
-void GamepadPage::LoadProfile(wxCommandEvent& event)
+void GamepadPage::LoadProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
@@ -598,13 +600,13 @@ void GamepadPage::LoadProfile(wxCommandEvent& event)
m_plugin.controls_crit.Enter();
controller->LoadConfig(inifile.GetOrCreateSection("Profile"));
- controller->UpdateReferences(m_plugin.controller_interface);
+ controller->UpdateReferences(g_controller_interface);
m_plugin.controls_crit.Leave();
UpdateGUI();
}
-void GamepadPage::SaveProfile(wxCommandEvent& event)
+void GamepadPage::SaveProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
@@ -622,7 +624,7 @@ void GamepadPage::SaveProfile(wxCommandEvent& event)
PanicAlert("You must enter a valid profile name.");
}
-void GamepadPage::DeleteProfile(wxCommandEvent& event)
+void GamepadPage::DeleteProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
@@ -647,8 +649,8 @@ void InputConfigDialog::UpdateDeviceComboBox()
{
(*i)->device_cbox->Clear();
std::vector::const_iterator
- di = m_plugin.controller_interface.Devices().begin(),
- de = m_plugin.controller_interface.Devices().end();
+ di = g_controller_interface.Devices().begin(),
+ de = g_controller_interface.Devices().end();
for ( ; di!=de; ++di )
{
dq.FromDevice( *di );
@@ -658,14 +660,13 @@ void InputConfigDialog::UpdateDeviceComboBox()
}
}
-void GamepadPage::RefreshDevices( wxCommandEvent& event )
+void GamepadPage::RefreshDevices(wxCommandEvent&)
{
m_plugin.controls_crit.Enter(); // enter
// refresh devices
- // TODO: remove hackery of not deinting SDL
- m_plugin.controller_interface.DeInit(true);
- m_plugin.controller_interface.Init();
+ g_controller_interface.Shutdown();
+ g_controller_interface.Initialize();
// update all control references
m_config_dialog->UpdateControlReferences();
@@ -835,6 +836,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(configure_btn, 0, wxALL|wxEXPAND, 3 );
}
break;
+#ifdef USE_UDP_WIIMOTE
case GROUP_TYPE_UDPWII:
{
wxButton* const btn = new UDPConfigButton( parent, (UDPWrapper*)group );
@@ -842,6 +844,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(btn, 0, wxALL|wxEXPAND, 3);
}
break;
+#endif
default:
{
//options
diff --git a/Source/Core/InputUICommon/Src/ConfigDiag.h b/Source/Core/DolphinWX/Src/InputConfigDiag.h
similarity index 99%
rename from Source/Core/InputUICommon/Src/ConfigDiag.h
rename to Source/Core/DolphinWX/Src/InputConfigDiag.h
index ae236bc56a..7745c29794 100644
--- a/Source/Core/InputUICommon/Src/ConfigDiag.h
+++ b/Source/Core/DolphinWX/Src/InputConfigDiag.h
@@ -146,6 +146,7 @@ public:
ControllerInterface::ControlReference* const control_reference;
};
+#ifdef USE_UDP_WIIMOTE
class UDPConfigButton : public wxButton
{
@@ -157,6 +158,8 @@ public:
{}
};
+#endif
+
class ControlGroupBox : public wxStaticBoxSizer
{
public:
diff --git a/Source/Core/InputUICommon/Src/ConfigDiagBitmaps.cpp b/Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp
similarity index 98%
rename from Source/Core/InputUICommon/Src/ConfigDiagBitmaps.cpp
rename to Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp
index 4d6a339e47..18718948ac 100644
--- a/Source/Core/InputUICommon/Src/ConfigDiagBitmaps.cpp
+++ b/Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp
@@ -15,15 +15,15 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-#include "ConfigDiag.h"
+#include "InputConfigDiag.h"
void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
- m_plugin.controller_interface.UpdateInput();
+ g_controller_interface.UpdateInput();
// don't want game thread updating input when we are using it here
- if (false == m_plugin.controller_interface.update_lock.TryEnter())
+ if (false == g_controller_interface.update_lock.TryEnter())
return;
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());
@@ -345,5 +345,5 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
}
}
- m_plugin.controller_interface.update_lock.Leave();
+ g_controller_interface.update_lock.Leave();
}
diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp
index ccf8063b59..fa4ccc6c37 100644
--- a/Source/Core/DolphinWX/Src/Main.cpp
+++ b/Source/Core/DolphinWX/Src/Main.cpp
@@ -32,6 +32,7 @@
#include "Host.h" // Core
#include "PluginManager.h"
+#include "HW/Wiimote.h"
#include "Globals.h" // Local
#include "Main.h"
@@ -336,6 +337,7 @@ bool DolphinApp::OnInit()
LogManager::Init();
SConfig::Init();
CPluginManager::Init();
+ WiimoteReal::LoadSettings();
if (selectVideoPlugin && videoPluginFilename != wxEmptyString)
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin =
@@ -345,10 +347,6 @@ bool DolphinApp::OnInit()
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin =
std::string(audioPluginFilename.mb_str());
- if (selectWiimotePlugin && wiimotePluginFilename != wxEmptyString)
- SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin =
- std::string(wiimotePluginFilename.mb_str());
-
// Enable the PNG image handler for screenshots
wxImage::AddHandler(new wxPNGHandler);
@@ -432,12 +430,10 @@ void DolphinApp::OnEndSession()
int DolphinApp::OnExit()
{
+ WiimoteReal::Shutdown();
#ifdef _WIN32
if (SConfig::GetInstance().m_WiiAutoUnpair)
- {
- if (CPluginManager::GetInstance().GetWiimote())
- CPluginManager::GetInstance().GetWiimote()->Wiimote_UnPairWiimotes();
- }
+ WiimoteReal::UnPair();
#endif
CPluginManager::Shutdown();
SConfig::Shutdown();
diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp
index 8043b30b16..171fc2281d 100644
--- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp
+++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp
@@ -392,6 +392,7 @@ int main(int argc, char* argv[])
}
updateMainFrameEvent.Shutdown();
+ WiimoteReal::Shutdown();
CPluginManager::Shutdown();
SConfig::Shutdown();
LogManager::Shutdown();
diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript
index e6800a142d..08891e2fa0 100644
--- a/Source/Core/DolphinWX/Src/SConscript
+++ b/Source/Core/DolphinWX/Src/SConscript
@@ -33,6 +33,8 @@ if env['HAVE_WX']:
'LogWindow.cpp',
'GameListCtrl.cpp',
'HotkeyDlg.cpp',
+ 'InputConfigDiag.cpp',
+ 'InputConfigDiagBitmaps.cpp',
'ISOFile.cpp',
'ISOProperties.cpp',
'PatchAddEdit.cpp',
@@ -43,6 +45,7 @@ if env['HAVE_WX']:
'NetPlayClient.cpp',
'NetPlayServer.cpp',
'NetWindow.cpp',
+ 'WiimoteConfigDiag.cpp',
]
wxlibs = [ 'debwx', 'debugger_ui_util', 'inputuicommon', 'memcard' ]
@@ -96,8 +99,6 @@ elif sys.platform == 'darwin' and env['HAVE_WX']:
env.Depends(exeGUIdist, env['plugin_dir'])
env.Fixup(exeGUIdist, exeGUI)
else:
- files += [ 'X11Utils.cpp' ]
- libs += [ 'SDL' ]
exeGUI = env['binary_dir'] + '/dolphin-emu'
exeNoGUI = env['binary_dir'] + '/dolphin-emu-nogui'
env.InstallAs(env['data_dir'] + '/sys', '#Data/Sys')
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteConfigDiag.cpp b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp
similarity index 94%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteConfigDiag.cpp
rename to Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp
index 5ac1e9ee33..91da36c6f1 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteConfigDiag.cpp
+++ b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp
@@ -1,6 +1,6 @@
#include "WiimoteConfigDiag.h"
-#include "WiimoteReal/WiimoteReal.h"
+#include "HW/Wiimote.h"
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
@@ -87,7 +87,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
Center();
}
-void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent& event)
+void WiimoteConfigDiag::ConfigEmulatedWiimote(wxCommandEvent&)
{
InputConfigDialog* const m_emu_config_diag = new InputConfigDialog(this, m_plugin, "Dolphin Emulated Wiimote Configuration", m_pad_notebook->GetSelection());
m_emu_config_diag->ShowModal();
@@ -102,7 +102,7 @@ void WiimoteConfigDiag::UpdateGUI()
}
#ifdef _WIN32
-void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent& event)
+void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent&)
{
const int paired = WiimoteReal::PairUp();
@@ -119,7 +119,7 @@ void WiimoteConfigDiag::PairUpRealWiimotes(wxCommandEvent& event)
}
#endif
-void WiimoteConfigDiag::RefreshRealWiimotes(wxCommandEvent& event)
+void WiimoteConfigDiag::RefreshRealWiimotes(wxCommandEvent&)
{
WiimoteReal::Refresh();
UpdateGUI();
@@ -131,9 +131,9 @@ void WiimoteConfigPage::SelectSource(wxCommandEvent& event)
g_wiimote_sources[m_index] = event.GetInt();
}
-void WiimoteConfigDiag::Save(wxCommandEvent& event)
+void WiimoteConfigDiag::Save(wxCommandEvent&)
{
- std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + g_plugin.ini_name + ".ini" );
+ std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + WIIMOTE_INI_NAME ".ini" );
IniFile inifile;
inifile.Load(ini_filename);
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteConfigDiag.h b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.h
similarity index 97%
rename from Source/Plugins/Plugin_WiimoteNew/Src/WiimoteConfigDiag.h
rename to Source/Core/DolphinWX/Src/WiimoteConfigDiag.h
index cc17bc2c34..4a46f019b2 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteConfigDiag.h
+++ b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.h
@@ -13,7 +13,7 @@
#include
#include
-#include "ConfigDiag.h"
+#include "InputConfigDiag.h"
class WiimoteConfigPage : public wxNotebookPage
{
diff --git a/Source/Core/InputCommon/InputCommon.vcproj b/Source/Core/InputCommon/InputCommon.vcproj
index 970138916e..42c1407223 100644
--- a/Source/Core/InputCommon/InputCommon.vcproj
+++ b/Source/Core/InputCommon/InputCommon.vcproj
@@ -66,6 +66,8 @@
/>
-
-
@@ -489,22 +497,10 @@
RelativePath=".\Src\ControllerEmu.h"
>
-
-
-
-
-
-
@@ -517,14 +513,6 @@
RelativePath=".\Src\SConscript"
>
-
-
-
-
@@ -541,14 +529,6 @@
RelativePath=".\Src\UDPWrapper.h"
>
-
-
-
-
diff --git a/Source/Core/InputCommon/Src/Configuration.cpp b/Source/Core/InputCommon/Src/Configuration.cpp
deleted file mode 100644
index f48d6519c8..0000000000
--- a/Source/Core/InputCommon/Src/Configuration.cpp
+++ /dev/null
@@ -1,253 +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 // System
-#include
-#include
-#include "Common.h" // Common
-
-#if defined HAVE_WX && HAVE_WX
- #include
-#endif
-
-#ifdef _WIN32
-#define NOMINMAX
-#include
-#endif
-
-namespace InputCommon
-{
-
-// Degree to radian and back
-float Deg2Rad(float Deg)
-{
- return Deg * (float)M_PI / 180.0f;
-}
-float Rad2Deg(float Rad)
-{
- return Rad * 180.0f / (float)M_PI;
-}
-
-// Check if the pad is within the dead zone, we assume the range is 0x8000
-float CoordinatesToRadius(int x, int y)
-{
- return sqrt(pow((float)x, 2) + pow((float)y, 2));
-}
-
-bool IsDeadZone(float DeadZone, int x, int y)
-{
- // Get the distance from the center
- float Distance = CoordinatesToRadius(x, y) / 32767.0f;
-
- //Console::Print("%f\n", Distance);
-
- // Check if it's within the dead zone
- if (Distance <= DeadZone)
- return true;
- else
- return false;
-}
-
-// Scale down stick values from 0x8000 to 0x80
-/*
- The value returned by SDL_JoystickGetAxis is a signed integer s16 (-32768 to
- 32767). The value used for the gamecube controller is an unsigned char u8 (0
- to 255) with neutral at 0x80 (128), so that it's equivalent to a signed -128
- to 127. */
-//
-int Pad_Convert(int _val)
-{
-
- /* If the limits on PadState[].axis[] actually is a u16 then we don't need
- this but if it's not actually limited to that we need to apply these
- limits */
- if(_val > 32767) _val = 32767; // upper limit
- if(_val < -32768) _val = -32768; // lower limit
-
- // Convert the range (-0x8000 to 0x7fff) to (0 to 0xffff)
- _val = 0x8000 +_val;
-
- // Convert the range (0 to 0xffff) to (0 to 0xff)
- _val = _val >> 8;
-
- //Console::Print("0x%04x %06i\n\n", _val, _val);
-
- return _val;
-}
-
-// Adjust the radius
-void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius)
-{
- // Get the radius setting
- float RadiusSetting = (float)_Radius / 100.0f;
- float x = (float)_x * RadiusSetting;
- float y = (float)_y * RadiusSetting;
- // Update values
- _x = (s8)x;
- _y = (s8)y;
-}
-
-/* Convert the stick raidus from a square or rounded box to a circular
- radius. I don't know what input values the actual GC controller produce for
- the GC, it may be a square, a circle or something in between. But one thing
- that is certain is that PC pads differ in their output (as shown in the list
- below), so it may be beneficiary to convert whatever radius they produce to
- the radius the GC games expect. This is the first implementation of this
- that convert a square radius to a circual radius. Use the advanced settings
- to enable and calibrate it.
-
- Observed diagonals:
- Perfect circle: 71% = sin(45)
- Logitech Dual Action: 100%
- PS2 Dual Shock 2 (Original) with Super Dual Box Pro: 90%
- XBox 360 Wireless: 85%
- GameCube Controller (Third Party) with EMS Trio Linker Plus II: 60%
-*/
-
-/* Calculate the distance from the outer edges of the box to the outer edges of
- the circle inside the box at any angle from 0 to 360. The returned value is
- 1 + Distance, for example at most sqrt(2) in the corners and at least 1.0 at
- the horizontal and vertical angles. */
-float Square2CircleDistance(float deg)
-{
- // See if we have to adjust the angle
- deg = fabsf(deg);
- if( (deg > 45 && deg < 135) ) deg = deg - 90;
-
- // Calculate distance from center
- float val = fabsf(cos(Deg2Rad(deg)));
- float Distance = 1 / val;
-
- //m_frame->m_pStatusBar2->SetLabel(wxString::Format("Deg:%f Val:%f Dist:%f", deg, val, dist));
-
- return Distance;
-}
-
-// Produce a perfect circle from an original square or rounded box
-void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square)
-{
- // Do we need to do this check?
- if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit
- if(_x < -32768) _x = -32768; if(_y < -32768) _y = -32768; // lower limit
-
- // Convert to circle
- // Get the manually configured diagonal distance
- float Diagonal = (float)_Diagonal / 100.0f;
-
- // First make a perfect square in case we don't have one already
- float OrigDist = sqrt( pow((float)_y, 2) + pow((float)_x, 2) ); // Get current distance
- float deg = Rad2Deg(atan2((float)_y, (float)_x)); // Get current angle
-
- /* Calculate the actual distance between the maxium diagonal values, and
- the outer edges of the square. A diagonal of 85% means a maximum
- distance of 0.85 * sqrt(2) ~1.2 in the diagonals. */
- float corner_circle_dist = ( Diagonal / sin(Deg2Rad(45.0f)) );
- float SquareDist = Square2CircleDistance(deg);
- // The original-to-square distance adjustment
- float adj_ratio1;
- // The circle-to-square distance adjustment
- float adj_ratio2 = SquareDist;
- // The resulting distance
- float result_dist;
-
- // Calculate the corner-to-square adjustment ratio
- if(corner_circle_dist < SquareDist) adj_ratio1 = SquareDist / corner_circle_dist;
- else adj_ratio1 = 1;
-
- // Calculate the resulting distance
- if(Circle2Square)
- result_dist = OrigDist * adj_ratio1;
- else
- result_dist = OrigDist * adj_ratio1 / adj_ratio2;
-
- // Calculate x and y and return it
- float x = result_dist * cos(Deg2Rad(deg));
- float y = result_dist * sin(Deg2Rad(deg));
- // Update coordinates
- _x = (int)floor(x);
- _y = (int)floor(y);
- // Boundaries
- if (_x < -32768) _x = -32768; if (_x > 32767) _x = 32767;
- if (_y < -32768) _y = -32768; if (_y > 32767) _y = 32767;
-
- // Debugging
- //Console::Print("%f %f %i", corner_circle_dist, Diagonal, Tmp));
-}
-
-// Windows Virtual Key Codes Names
-#ifdef _WIN32
-std::string VKToString(int keycode)
-{
- // Default value
- char KeyStr[64] = {0};
- std::string KeyString;
-
- switch(keycode)
- {
- // Give it some help with a few keys
- case VK_END: return "END";
- case VK_INSERT: return "INS";
- case VK_DELETE: return "DEL";
- case VK_HOME: return "HOME";
- case VK_PRIOR: return "PGUP";
- case VK_NEXT: return "PGDN";
-
- case VK_UP: return "UP";
- case VK_DOWN: return "DOWN";
- case VK_LEFT: return "LEFT";
- case VK_RIGHT: return "RIGHT";
-
- case VK_LSHIFT: return "Left Shift";
- case VK_RSHIFT: return "Right Shift";
- case VK_LCONTROL: return "Left Ctrl";
- case VK_RCONTROL: return "Right Ctrl";
- case VK_LMENU: return "Left Alt";
- case VK_RMENU: return "Right Alt";
-
- case VK_NUMLOCK: return "Num Lock";
- case VK_MULTIPLY: return "Num *";
- case VK_ADD: return "Num +";
- case VK_SEPARATOR: case 0xC2: return "Num Separator";
- case VK_SUBTRACT: return "Num -";
- case VK_DECIMAL: return "Num Decimal";
- case VK_DIVIDE: return "Num /";
-
- case VK_OEM_PLUS: return "=";
- case VK_OEM_MINUS: return "-";
- case VK_OEM_COMMA: return ",";
- case VK_OEM_PERIOD: return ".";
-
- case VK_BROWSER_BACK: return "Nav Bwd";
- case VK_BROWSER_FORWARD: return "Nav Fwd";
-
- //default: return KeyString = KeyStr;
- }
-
- // TODO: Switch to unicode GetKeyNameText?
- if (keycode < 256) // Keyboard
- GetKeyNameTextA(MapVirtualKey(keycode, MAPVK_VK_TO_VSC) << 16, KeyStr, 64);
- else // Pad
- sprintf(KeyStr, "PAD: %d", keycode - 0x1000);
-
- return KeyString = KeyStr;
-}
-#endif
-
-
-}
-
diff --git a/Source/Core/InputCommon/Src/ControllerEmu.cpp b/Source/Core/InputCommon/Src/ControllerEmu.cpp
index a2c8630d22..dcd3fec981 100644
--- a/Source/Core/InputCommon/Src/ControllerEmu.cpp
+++ b/Source/Core/InputCommon/Src/ControllerEmu.cpp
@@ -298,9 +298,8 @@ ControllerEmu::Tilt::Tilt( const char* const _name )
settings.push_back( new Setting("Circle Stick", 0 ) );
}
-ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize )
- : ControlGroup( _name, GROUP_TYPE_CURSOR )
- , wiimote_initialize(_wiimote_initialize)
+ControllerEmu::Cursor::Cursor(const char* const _name)
+ : ControlGroup(_name, GROUP_TYPE_CURSOR)
, m_z(0)
{
for ( unsigned int i = 0; i < 4; ++i )
diff --git a/Source/Core/InputCommon/Src/ControllerEmu.h b/Source/Core/InputCommon/Src/ControllerEmu.h
index 635befa53e..af770079f7 100644
--- a/Source/Core/InputCommon/Src/ControllerEmu.h
+++ b/Source/Core/InputCommon/Src/ControllerEmu.h
@@ -27,7 +27,6 @@
#include
#include "GCPadStatus.h"
-#include "pluginspecs_wiimote.h"
#include "ControllerInterface/ControllerInterface.h"
#include "IniFile.h"
@@ -374,7 +373,7 @@ public:
class Cursor : public ControlGroup
{
public:
- Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize );
+ Cursor(const char* const _name);
template
void GetState( C* const x, C* const y, C* const z, const bool adjusted = false )
@@ -412,9 +411,6 @@ public:
}
}
- private:
- const SWiimoteInitialize* const wiimote_initialize;
-
float m_z;
};
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp
index 235985704a..e29c9d53e3 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp
@@ -20,14 +20,16 @@
#define INPUT_DETECT_THRESHOLD 0.85
+ControllerInterface g_controller_interface;
+
//
// Init
//
// detect devices and inputs outputs / will make refresh function later
//
-void ControllerInterface::Init()
+void ControllerInterface::Initialize()
{
- if ( m_is_init )
+ if (m_is_init)
return;
#ifdef CIFACE_USE_DINPUT
@@ -54,9 +56,9 @@ void ControllerInterface::Init()
//
// remove all devices/ call library cleanup functions
//
-void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
+void ControllerInterface::Shutdown()
{
- if ( false == m_is_init )
+ if (false == m_is_init)
return;
std::vector::const_iterator
@@ -73,12 +75,6 @@ void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
// update output
(*d)->UpdateOutput();
- // TODO: remove this
- // major hacks/memleaks to prevent gcpad/wiimote new from crashing eachother
- if (hacks_no_sdl_quit)
- if ((*d)->GetSource() == "SDL")
- continue;
-
//delete device
delete *d;
}
@@ -99,8 +95,7 @@ void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
#endif
#ifdef CIFACE_USE_SDL
// TODO: there seems to be some sort of memory leak with SDL, quit isn't freeing everything up
- if (false == hacks_no_sdl_quit)
- SDL_Quit();
+ SDL_Quit();
#endif
m_is_init = false;
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h
index af07b1ac69..d0bff0a271 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h
+++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.h
@@ -210,9 +210,9 @@ public:
ControllerInterface() : m_is_init(false), m_hwnd(NULL) {}
void SetHwnd(void* const hwnd);
- void Init();
+ void Initialize();
// TODO: remove this hack param
- void DeInit(const bool hacks_no_sdl_quit = false);
+ void Shutdown();
bool IsInit() const { return m_is_init; }
void UpdateReference(ControlReference* control, const DeviceQualifier& default_device) const;
@@ -230,4 +230,6 @@ private:
void* m_hwnd;
};
+extern ControllerInterface g_controller_interface;
+
#endif
diff --git a/Source/Core/InputCommon/Src/DirectInputBase.cpp b/Source/Core/InputCommon/Src/DirectInputBase.cpp
deleted file mode 100644
index b9a7fee33d..0000000000
--- a/Source/Core/InputCommon/Src/DirectInputBase.cpp
+++ /dev/null
@@ -1,229 +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
-// -------------------
-#include "DirectInputBase.h"
-
-
-
-DInput::DInput()
- : g_pDI(NULL),
- g_pKeyboard(NULL)
-{}
-
-
-DInput::~DInput()
-{
- Free();
-}
-
-void DInput::DIKToString(unsigned int keycode, char *keyStr)
-{
- switch(keycode) {
- case DIK_RETURN:
- sprintf(keyStr, "Enter");
- break;
- case DIK_LCONTROL:
- sprintf(keyStr, "Left Ctrl");
- break;
- case DIK_RCONTROL:
- strcpy(keyStr, "Right Ctrl");
- break;
- case DIK_LSHIFT:
- sprintf(keyStr, "Left Shift");
- break;
- case DIK_RSHIFT:
- sprintf(keyStr, "Right Shift");
- break;
- case DIK_LMENU:
- sprintf(keyStr, "Left Alt");
- break;
- case DIK_RMENU:
- strcpy(keyStr, "Right Alt");
- break;
- case DIK_UP:
- sprintf(keyStr, "Up");
- break;
- case DIK_DOWN:
- sprintf(keyStr, "Down");
- break;
- case DIK_LEFT:
- sprintf(keyStr, "Left");
- break;
- case DIK_RIGHT:
- sprintf(keyStr, "Right");
- break;
- case DIK_HOME:
- strcpy(keyStr, "Home");
- break;
- case DIK_END:
- strcpy(keyStr, "End");
- break;
- case DIK_INSERT:
- strcpy(keyStr, "Ins");
- break;
- case DIK_DELETE:
- strcpy(keyStr, "Del");
- break;
- case DIK_PGUP:
- strcpy(keyStr, "PgUp");
- break;
- case DIK_PGDN:
- strcpy(keyStr, "PgDn");
- break;
- case DIK_NUMLOCK:
- strcpy(keyStr, "Num Lock");
- break;
- case DIK_NUMPAD0:
- strcpy(keyStr, "Num 0");
- break;
- case DIK_NUMPAD1:
- strcpy(keyStr, "Num 1");
- break;
- case DIK_NUMPAD2:
- strcpy(keyStr, "Num 2");
- break;
- case DIK_NUMPAD3:
- strcpy(keyStr, "Num 3");
- break;
- case DIK_NUMPAD4:
- strcpy(keyStr, "Num 4");
- break;
- case DIK_NUMPAD5:
- strcpy(keyStr, "Num 5");
- break;
- case DIK_NUMPAD6:
- strcpy(keyStr, "Num 6");
- break;
- case DIK_NUMPAD7:
- strcpy(keyStr, "Num 7");
- break;
- case DIK_NUMPAD8:
- strcpy(keyStr, "Num 8");
- break;
- case DIK_NUMPAD9:
- strcpy(keyStr, "Num 9");
- break;
- case DIK_DIVIDE:
- strcpy(keyStr, "Num /");
- break;
- case DIK_NUMPADENTER:
- strcpy(keyStr, "Num Enter");
- break;
- case DIK_DECIMAL:
- strcpy(keyStr, "Num Decimal");
- break;
- case DIK_NUMPADCOMMA:
- case DIK_ABNT_C2:
- strcpy(keyStr, "Num Separator");
- break;
- case DIK_NUMPADEQUALS:
- strcpy(keyStr, "Num =");
- break;
- default:
- // TODO: Switch to unicode GetKeyNameText?
- GetKeyNameTextA(keycode << 16, keyStr, 64);
- break;
- }
-}
-
-HRESULT DInput::Init(HWND hWnd)
-{
- HRESULT hr;
- DWORD dwCoopFlags;
- dwCoopFlags = DISCL_FOREGROUND | DISCL_NOWINKEY;
-
- // Create a DInput object
- if (FAILED(hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION,
- IID_IDirectInput8, (VOID* *)&g_pDI, NULL)))
- {
- MessageBox(0, L"Direct Input Create Failed", 0, MB_ICONERROR);
- return(hr);
- }
-
- if (FAILED(hr = g_pDI->CreateDevice(GUID_SysKeyboard, &g_pKeyboard, NULL)))
- {
- MessageBox(0, L"Couldn't access keyboard", 0, MB_ICONERROR);
- Free();
- return(hr);
- }
-
- g_pKeyboard->SetDataFormat(&c_dfDIKeyboard);
- g_pKeyboard->SetCooperativeLevel(hWnd, dwCoopFlags);
- g_pKeyboard->Acquire();
-
- return(S_OK);
-}
-
-void DInput::Free()
-{
- if (g_pKeyboard)
- {
- g_pKeyboard->Unacquire();
- g_pKeyboard->Release();
- g_pKeyboard = 0;
- }
-
- if (g_pDI)
- {
- g_pDI->Release();
- g_pDI = 0;
- }
-}
-
-// Desc: Read the input device's state when in immediate mode and display it.
-HRESULT DInput::Read()
-{
- HRESULT hr;
-
- if (NULL == g_pKeyboard)
- {
- return(S_OK);
- }
-
- // Get the input's device state, and put the state in dims
- ZeroMemory(diks, sizeof(diks));
- hr = g_pKeyboard->GetDeviceState(sizeof(diks), diks);
-
- //for (int i=0; i<256; i++)
- // if (diks[i]) MessageBox(0,"DSFJDKSF|",0,0);
- if (FAILED(hr))
- {
- // DirectInput may be telling us that the input stream has been
- // interrupted. We aren't tracking any state between polls, so
- // we don't have any special reset that needs to be done.
- // We just re-acquire and try again.
-
- // If input is lost then acquire and keep trying
- hr = g_pKeyboard->Acquire();
-
- while (hr == DIERR_INPUTLOST)
- {
- hr = g_pKeyboard->Acquire();
- }
-
- // hr may be DIERR_OTHERAPPHASPRIO or other errors. This
- // may occur when the app is minimized or in the process of
- // switching, so just try again later
- return(S_OK);
- }
-
- return(S_OK);
-}
diff --git a/Source/Core/InputCommon/Src/DirectInputBase.h b/Source/Core/InputCommon/Src/DirectInputBase.h
deleted file mode 100644
index 22f7fb5d2e..0000000000
--- a/Source/Core/InputCommon/Src/DirectInputBase.h
+++ /dev/null
@@ -1,53 +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 _DIRECTINPUTBASE_H
-#define _DIRECTINPUTBASE_H
-
-
-#include // System
-#include
-
-#define DIRECTINPUT_VERSION 0x0800 // DirectInput
-#include
-
-
-
-class DInput
-{
- public:
-
- DInput();
- ~DInput();
-
- static void DInput::DIKToString(unsigned int keycode, char *keyStr);
-
- HRESULT Init(HWND hWnd);
- void Free();
- HRESULT Read();
-
-
- BYTE diks[256]; // DirectInput keyboard state buffer
-
- private:
-
- LPDIRECTINPUT8 g_pDI; // The DirectInput object
- LPDIRECTINPUTDEVICE8 g_pKeyboard; // The keyboard device
-};
-
-#endif
-
diff --git a/Source/Core/InputCommon/Src/InputCommon.h b/Source/Core/InputCommon/Src/InputCommon.h
deleted file mode 100644
index 52b75e0f0f..0000000000
--- a/Source/Core/InputCommon/Src/InputCommon.h
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace InputCommon
-{
-enum EButtonType
-{
- CTL_AXIS = 0,
- CTL_HAT,
- CTL_BUTTON,
- CTL_KEY,
-};
-
-enum ETriggerType
-{
- CTL_TRIGGER_SDL = 0,
- CTL_TRIGGER_XINPUT,
-};
-
-enum EXInputTrigger
-{
- XI_TRIGGER_L = 0,
- XI_TRIGGER_R,
-};
-
-}
diff --git a/Source/Core/InputCommon/Src/InputConfig.cpp b/Source/Core/InputCommon/Src/InputConfig.cpp
index 73d52aae84..c8813b532c 100644
--- a/Source/Core/InputCommon/Src/InputConfig.cpp
+++ b/Source/Core/InputCommon/Src/InputConfig.cpp
@@ -17,19 +17,6 @@
#include "InputConfig.h"
-InputPlugin::InputPlugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name )
- : ini_name(_ini_name)
- , gui_name(_gui_name)
- , profile_name(_profile_name)
-{
- // GCPads
- //for ( unsigned int i = 0; i<4; ++i )
- //controllers.push_back( new GCPad( i ) );
- // Wiimotes / disabled, cause it only the GUI half is done
- //for ( unsigned int i = 0; i<4; ++i )
- // controllers.push_back( new Wiimote( i ) );
-};
-
InputPlugin::~InputPlugin()
{
// delete pads
@@ -52,14 +39,14 @@ bool InputPlugin::LoadConfig()
// load settings from ini
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
// update refs
- (*i)->UpdateReferences(controller_interface);
+ (*i)->UpdateReferences(g_controller_interface);
}
return true;
}
else
{
- controllers[0]->LoadDefaults(controller_interface);
- controllers[0]->UpdateReferences(controller_interface);
+ controllers[0]->LoadDefaults(g_controller_interface);
+ controllers[0]->UpdateReferences(g_controller_interface);
return false;
}
}
diff --git a/Source/Core/InputCommon/Src/InputConfig.h b/Source/Core/InputCommon/Src/InputConfig.h
index 2d1e3b6411..f405b7bfa1 100644
--- a/Source/Core/InputCommon/Src/InputConfig.h
+++ b/Source/Core/InputCommon/Src/InputConfig.h
@@ -30,13 +30,16 @@
#include