From 8cae2fee56c56fdd87c8b3c11aa6614c6aec7651 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 13 Jun 2010 09:14:40 +0000 Subject: [PATCH] Merge the pad plugin into Dolphin. Since there's only one plugin left under active development, and it's awesome, we no longer have a need for a pad plugin mechanism. In the future if we merge wiimote too, this will bring the advantage that the two will be able to cooperate, to no longer fight over control of input devices which can sometimes cause problems. Thanks shuffle2 for the patience. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5670 8ced0084-cf51-0410-be5f-012b33b47a6e --- SConstruct | 1 - Source/Core/Common/Common.vcproj | 10 +- Source/Core/Common/Src/CommonPaths.h | 1 - Source/Core/Common/Src/PluginPAD.cpp | 40 -- Source/Core/Common/Src/PluginPAD.h | 47 --- Source/Core/Common/Src/SConscript | 1 - Source/Core/Core/Core.vcproj | 22 +- Source/Core/Core/Src/ConfigManager.cpp | 5 - Source/Core/Core/Src/ConfigManager.h | 1 - Source/Core/Core/Src/Core.cpp | 15 +- Source/Core/Core/Src/CoreParameter.h | 1 - Source/Core/Core/Src/HW/GCPad.cpp | 159 ++++++++ .../Src => Core/Core/Src/HW}/GCPadEmu.cpp | 5 +- .../Src => Core/Core/Src/HW}/GCPadEmu.h | 5 +- .../Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp | 13 +- .../Core/Src/HW/SI_DeviceGCController.cpp | 10 +- .../Core/Core/Src/HW/SI_DeviceGCController.h | 3 +- Source/Core/Core/Src/OnFrame.cpp | 1 - Source/Core/Core/Src/OnFrame.h | 1 - Source/Core/Core/Src/PluginManager.cpp | 63 +-- Source/Core/Core/Src/PluginManager.h | 5 +- Source/Core/Core/Src/SConscript | 7 +- Source/Core/Core/Src/State.cpp | 1 - Source/Core/DolphinWX/DolphinWX.vcproj | 24 +- Source/Core/DolphinWX/Src/ConfigMain.cpp | 19 - Source/Core/DolphinWX/Src/ConfigMain.h | 12 +- Source/Core/DolphinWX/Src/Frame.cpp | 5 +- Source/Core/DolphinWX/Src/FrameTools.cpp | 23 +- Source/Core/DolphinWX/Src/Main.cpp | 8 - Source/Dolphin.sln | 23 -- Source/PluginSpecs/PluginSpecs.h | 2 +- Source/PluginSpecs/pluginspecs_pad.h | 48 +-- .../Plugins/Plugin_GCPadNew/Src/GCPadNew.cpp | 378 ------------------ 33 files changed, 247 insertions(+), 712 deletions(-) delete mode 100644 Source/Core/Common/Src/PluginPAD.cpp delete mode 100644 Source/Core/Common/Src/PluginPAD.h create mode 100644 Source/Core/Core/Src/HW/GCPad.cpp rename Source/{Plugins/Plugin_GCPadNew/Src => Core/Core/Src/HW}/GCPadEmu.cpp (96%) rename Source/{Plugins/Plugin_GCPadNew/Src => Core/Core/Src/HW}/GCPadEmu.h (94%) delete mode 100644 Source/Plugins/Plugin_GCPadNew/Src/GCPadNew.cpp diff --git a/SConstruct b/SConstruct index d7e6fd37f8..ac316a4664 100644 --- a/SConstruct +++ b/SConstruct @@ -71,7 +71,6 @@ dirs = [ 'Source/Plugins/Plugin_VideoSoftware/Src', 'Source/Plugins/Plugin_DSP_HLE/Src', 'Source/Plugins/Plugin_DSP_LLE/Src', - 'Source/Plugins/Plugin_GCPadNew/Src', 'Source/Plugins/Plugin_Wiimote/Src', 'Source/Plugins/Plugin_WiimoteNew/Src/', 'Source/Core/DolphinWX/Src', diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index 2c8893258b..bed1f25dbb 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -1,7 +1,7 @@ - - - - diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index 1a3b5168d1..5adff7038e 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -132,7 +132,6 @@ // Plugin files #define DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX #define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX -#define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_GCPadNew" PLUGIN_SUFFIX #define DEFAULT_WIIMOTE_PLUGIN PLUGIN_PREFIX "Plugin_Wiimote" PLUGIN_SUFFIX // Sys files diff --git a/Source/Core/Common/Src/PluginPAD.cpp b/Source/Core/Common/Src/PluginPAD.cpp deleted file mode 100644 index 2fbc6d1a0f..0000000000 --- a/Source/Core/Common/Src/PluginPAD.cpp +++ /dev/null @@ -1,40 +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 "PluginPAD.h" - -namespace Common -{ - -PluginPAD::PluginPAD(const char *_Filename) : CPlugin(_Filename), validPAD(false) -{ - PAD_GetStatus = reinterpret_cast - (LoadSymbol("PAD_GetStatus")); - PAD_Input = reinterpret_cast - (LoadSymbol("PAD_Input")); - PAD_Rumble = reinterpret_cast - (LoadSymbol("PAD_Rumble")); - - if ((PAD_GetStatus != 0) && - (PAD_Input != 0) && - (PAD_Rumble != 0)) - validPAD = true; -} - -PluginPAD::~PluginPAD() {} - -} // Namespace diff --git a/Source/Core/Common/Src/PluginPAD.h b/Source/Core/Common/Src/PluginPAD.h deleted file mode 100644 index 07417ec807..0000000000 --- a/Source/Core/Common/Src/PluginPAD.h +++ /dev/null @@ -1,47 +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 _PLUGINPAD_H_ -#define _PLUGINPAD_H_ - -#include "pluginspecs_pad.h" -#include "Plugin.h" - -namespace Common { - -typedef void (__cdecl* TPAD_GetStatus)(u8, SPADStatus*); -typedef void (__cdecl* TPAD_Input)(u16, u8); -typedef void (__cdecl* TPAD_Rumble)(u8, unsigned int, unsigned int); - -class PluginPAD : public CPlugin { -public: - PluginPAD(const char *_Filename); - virtual ~PluginPAD(); - virtual bool IsValid() {return validPAD;}; - - TPAD_GetStatus PAD_GetStatus; - TPAD_Input PAD_Input; - TPAD_Rumble PAD_Rumble; - -private: - bool validPAD; - -}; - -} // namespace - -#endif // _PLUGINPAD_H_ diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index ef087b8d63..7493db335a 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -26,7 +26,6 @@ files = [ "PluginDSP.cpp", "PluginWiimote.cpp", "PluginVideo.cpp", - "PluginPAD.cpp", "SDCardUtil.cpp", "StringUtil.cpp", "SymbolDB.cpp", diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 4c890cf6a4..fb11bab094 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + Initialize((void *)&dspInit); - // Load and init GCPadPlugin - SPADInitialize PADInitialize; - PADInitialize.hWnd = g_pWindowHandle; -#if defined(HAVE_X11) && HAVE_X11 - PADInitialize.pXWindow = g_pXWindow; -#endif - PADInitialize.pLog = Callback_PADLog; - PADInitialize.pRendererHasFocus = Callback_RendererHasFocus; - // This is may be needed to avoid a SDL problem - //Plugins.FreeWiimote(); - Plugins.GetPad()->Initialize(&PADInitialize); + GCPad_Init(g_pWindowHandle); // Load and Init WiimotePlugin - only if we are booting in wii mode if (_CoreParameter.bWii) @@ -521,7 +512,9 @@ THREAD_RETURN EmuThread(void *pArg) if (_CoreParameter.bCPUThread) Plugins.ShutdownVideoPlugin(); + GCPad_Deinit(); Plugins.ShutdownPlugins(); + NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Plugins shutdown").c_str()); NOTICE_LOG(CONSOLE, "%s", StopMessage(true, "Main thread stopped").c_str()); diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 1432665108..74930873ca 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -118,7 +118,6 @@ struct SCoreStartupParameter // files std::string m_strVideoPlugin; - std::string m_strPadPlugin; std::string m_strDSPPlugin; std::string m_strWiimotePlugin; diff --git a/Source/Core/Core/Src/HW/GCPad.cpp b/Source/Core/Core/Src/HW/GCPad.cpp new file mode 100644 index 0000000000..c17fb37517 --- /dev/null +++ b/Source/Core/Core/Src/HW/GCPad.cpp @@ -0,0 +1,159 @@ +// Copyright (C) 2010 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 "Common.h" +#include "pluginspecs_pad.h" + +#include "ControllerInterface/ControllerInterface.h" +#include "GCPadEmu.h" + +#include "../../InputCommon/Src/InputConfig.h" + +InputPlugin g_plugin("GCPadNew", "Pad", "GCPad"); + +InputPlugin *PAD_GetPlugin() { + return &g_plugin; +} + +void GCPad_Deinit() +{ + // i realize i am checking IsInit() twice, just too lazy to change it + 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(); + + g_plugin.controller_interface.DeInit(); + } +} + +// if plugin isn't initialized, init and load config +void GCPad_Init( 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(); + + // load the saved controller config + if (false == g_plugin.LoadConfig()) + { + // load default config for pad 1 + g_plugin.controllers[0]->LoadDefaults(); + + // kinda silly, set default device(all controls) to first one found in ControllerInterface + // should be the keyboard device + if (g_plugin.controller_interface.Devices().size()) + { + g_plugin.controllers[0]->default_device.FromDevice(g_plugin.controller_interface.Devices()[0]); + g_plugin.controllers[0]->UpdateDefaultDevice(); + } + } + + // update control refs + std::vector::const_iterator + i = g_plugin.controllers.begin(), + e = g_plugin.controllers.end(); + for ( ; i!=e; ++i ) + (*i)->UpdateReferences( g_plugin.controller_interface ); + + } +} + +// I N T E R F A C E + +// __________________________________________________________________________________________________ +// Function: +// Purpose: +// input: +// output: +// +void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) +{ + memset( _pPADStatus, 0, sizeof(*_pPADStatus) ); + _pPADStatus->err = PAD_ERR_NONE; + // wtf is this? + _pPADStatus->button |= PAD_USE_ORIGIN; + + // try lock + if ( false == g_plugin.controls_crit.TryEnter() ) + { + // if gui has lock (messing with controls), skip this input cycle + // center axes and return + memset( &_pPADStatus->stickX, 0x80, 4 ); + return; + } + + // if we are on the next input cycle, update output and input + // if we can get a lock + static int _last_numPAD = 4; + if ( _numPAD <= _last_numPAD && g_plugin.interface_crit.TryEnter() ) + { + g_plugin.controller_interface.UpdateOutput(); + g_plugin.controller_interface.UpdateInput(); + g_plugin.interface_crit.Leave(); + } + _last_numPAD = _numPAD; + + // get input + ((GCPad*)g_plugin.controllers[ _numPAD ])->GetInput( _pPADStatus ); + + // leave + g_plugin.controls_crit.Leave(); + +} + +// __________________________________________________________________________________________________ +// Function: Send keyboard input to the plugin +// Purpose: +// input: The key and if it's pressed or released +// output: None +// +void PAD_Input(u16 _Key, u8 _UpDown) +{ + // nofin +} + +// __________________________________________________________________________________________________ +// Function: PAD_Rumble +// Purpose: Pad rumble! +// 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) +{ + // enter + if ( g_plugin.controls_crit.TryEnter() ) + { + // TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time + // set rumble + ((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput( 1 == _uType && _uStrength > 2 ); + + // leave + g_plugin.controls_crit.Leave(); + } +} diff --git a/Source/Plugins/Plugin_GCPadNew/Src/GCPadEmu.cpp b/Source/Core/Core/Src/HW/GCPadEmu.cpp similarity index 96% rename from Source/Plugins/Plugin_GCPadNew/Src/GCPadEmu.cpp rename to Source/Core/Core/Src/HW/GCPadEmu.cpp index e5f3a1fa42..482291f0bc 100644 --- a/Source/Plugins/Plugin_GCPadNew/Src/GCPadEmu.cpp +++ b/Source/Core/Core/Src/HW/GCPadEmu.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "GCPadEmu.h" +#include "../Host.h" const u16 button_bitmasks[] = { @@ -93,7 +94,7 @@ std::string GCPad::GetName() const void GCPad::GetInput( SPADStatus* const pad ) { // if window has focus or background input enabled - if (g_PADInitialize->pRendererHasFocus() || m_options[0].settings[0]->value ) + if (Host_RendererHasFocus() || m_options[0].settings[0]->value ) { // buttons m_buttons->GetState( &pad->button, button_bitmasks ); @@ -120,7 +121,7 @@ void GCPad::GetInput( SPADStatus* const pad ) void GCPad::SetOutput( const bool on ) { // only rumble if window has focus or background input is enabled - m_rumble->controls[0]->control_ref->State( on && (g_PADInitialize->pRendererHasFocus() || m_options[0].settings[0]->value) ); + m_rumble->controls[0]->control_ref->State( on && (Host_RendererHasFocus() || m_options[0].settings[0]->value) ); } void GCPad::LoadDefaults() diff --git a/Source/Plugins/Plugin_GCPadNew/Src/GCPadEmu.h b/Source/Core/Core/Src/HW/GCPadEmu.h similarity index 94% rename from Source/Plugins/Plugin_GCPadNew/Src/GCPadEmu.h rename to Source/Core/Core/Src/HW/GCPadEmu.h index a1ac83d95c..e744c92315 100644 --- a/Source/Plugins/Plugin_GCPadNew/Src/GCPadEmu.h +++ b/Source/Core/Core/Src/HW/GCPadEmu.h @@ -18,9 +18,9 @@ #ifndef _CONEMU_GCPAD_H_ #define _CONEMU_GCPAD_H_ -#include +#include -extern SPADInitialize *g_PADInitialize; +#include "ControllerEmu.h" class GCPad : public ControllerEmu { @@ -48,5 +48,4 @@ private: }; - #endif diff --git a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp index cea97ac82b..c9ea0f3b5f 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp @@ -15,10 +15,14 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include "pluginspecs_pad.h" + #include "SI.h" #include "SI_Device.h" #include "SI_DeviceAMBaseboard.h" +#include "GCPad.h" + #include "../PluginManager.h" // for pad state // where to put baseboard debug @@ -144,8 +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)); - CPluginManager::GetInstance().GetPad() - ->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); + PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); res[resp++] = 0x10; res[resp++] = 0x2; int d10_0 = 0xdf; @@ -310,8 +313,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength) for (i=0; iPAD_GetStatus(i, &PadStatus); + PAD_GetStatus(i, &PadStatus); unsigned char player_data[2] = {0,0}; if (PadStatus.button & PAD_BUTTON_START) player_data[0] |= 0x80; @@ -348,8 +350,7 @@ int CSIDevice_AMBaseboard::RunBuffer(u8* _pBuffer, int _iLength) int slots = *jvs_io++; msg.addData(1); SPADStatus PadStatus; - CPluginManager::GetInstance().GetPad() - ->PAD_GetStatus(0, &PadStatus); + PAD_GetStatus(0, &PadStatus); while (slots--) { msg.addData(0); diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index 16839a63dd..fd95ecd97c 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -25,6 +25,8 @@ #include "EXI_Device.h" #include "EXI_DeviceMic.h" +#include "GCPad.h" + #include "../OnFrame.h" #include "Timer.h" @@ -128,8 +130,8 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) { SPADStatus PadStatus; memset(&PadStatus, 0, sizeof(PadStatus)); - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(); - pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); + + PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); u32 netValues[2] = {0}; int NetPlay = 2; @@ -258,7 +260,6 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) // SendCommand void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll) { - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPad(); UCommand command(_Cmd); switch (command.Command) @@ -280,8 +281,7 @@ void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll) #endif if (numPAD < 4) - if (pad->PAD_Rumble) - pad->PAD_Rumble(numPAD, uType, uStrength); + PAD_Rumble(numPAD, uType, uStrength); if (!_Poll) { diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.h b/Source/Core/Core/Src/HW/SI_DeviceGCController.h index 8a8dd0efb7..2a2db1f6f5 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.h +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.h @@ -20,6 +20,7 @@ #include "../PluginManager.h" #include "SI_Device.h" +#include "pluginspecs_pad.h" // standard gamecube controller @@ -102,7 +103,7 @@ public: virtual int RunBuffer(u8* _pBuffer, int _iLength); // Send and Receive pad input from network - static int NetPlay_GetInput(u8 numPAD, SPADStatus, u32 *PADStatus); + static int NetPlay_GetInput(u8 numPAD, SPADStatus status, u32 *PADStatus); static u8 NetPlay_GetPadNum(u8 numPAD); // Return true on new data diff --git a/Source/Core/Core/Src/OnFrame.cpp b/Source/Core/Core/Src/OnFrame.cpp index 0b58abd844..17a61446a6 100644 --- a/Source/Core/Core/Src/OnFrame.cpp +++ b/Source/Core/Core/Src/OnFrame.cpp @@ -250,7 +250,6 @@ void EndRecordingInput() // header.author; // header.videoPlugin; // header.audioPlugin; - // header.padPlugin; fwrite(&header, sizeof(DTMHeader), 1, g_recordfd); diff --git a/Source/Core/Core/Src/OnFrame.h b/Source/Core/Core/Src/OnFrame.h index f197921478..4b6da0859e 100644 --- a/Source/Core/Core/Src/OnFrame.h +++ b/Source/Core/Core/Src/OnFrame.h @@ -80,7 +80,6 @@ typedef struct { u8 videoPlugin[16]; // UTF-8 representation of the video plugin u8 audioPlugin[16]; // UTF-8 representation of the audio plugin u8 padPlugin[16]; // UTF-8 representation of the input plugin - bool padding[102]; // Padding to align the header to 1024 bits diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index f349eb6d05..ac5b09e6b8 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -70,7 +70,6 @@ CPluginManager::CPluginManager() // Set initial values to NULL. m_video = NULL; m_dsp = NULL; - m_pad = NULL; m_wiimote = NULL; } @@ -82,12 +81,6 @@ CPluginManager::~CPluginManager() delete m_PluginGlobals; delete m_dsp; - if (m_pad) - { - delete m_pad; - m_pad = NULL; - } - if (m_wiimote) { m_wiimote->Shutdown(); @@ -124,18 +117,6 @@ bool CPluginManager::InitPlugins() return false; } - // Init pad - // Check that the plugin has a name - if (!m_params->m_strPadPlugin.empty()) - GetPad(); - - // Check that GetPad succeeded - if (!m_pad) - { - PanicAlert("Can't init PAD Plugin"); - return false; - } - // Init wiimote if (m_params->bWii) { @@ -156,12 +137,6 @@ bool CPluginManager::InitPlugins() // for an explanation about the current LoadLibrary() and FreeLibrary() behavior. void CPluginManager::ShutdownPlugins() { - if (m_pad) - { - m_pad->Shutdown(); - FreePad(); - } - if (m_wiimote) { m_wiimote->Shutdown(); @@ -246,7 +221,7 @@ void CPluginManager::GetPluginInfo(CPluginInfo *&info, std::string Filename) void *CPluginManager::LoadPlugin(const char *_rFilename) { if (!File::Exists((File::GetPluginsDirectory() + _rFilename).c_str())) { - PanicAlert("Error loading %s: can't find file", _rFilename); + PanicAlert("Error loading plugin %s: can't find file. Please re-select your plugins.", _rFilename); return NULL; } /* Avoid calling LoadLibrary() again and instead point to the plugin info that we found when @@ -271,10 +246,6 @@ void *CPluginManager::LoadPlugin(const char *_rFilename) plugin = new Common::PluginDSP(_rFilename); break; - case PLUGIN_TYPE_PAD: - plugin = new Common::PluginPAD(_rFilename); - break; - case PLUGIN_TYPE_WIIMOTE: plugin = new Common::PluginWiimote(_rFilename); break; @@ -347,27 +318,11 @@ void CPluginManager::ScanForPlugins() /* Create or return the already created plugin pointers. This will be called - often for the Pad and Wiimote from the SI_.cpp files. And often for the DSP - from the DSP files. + often for Wiimote. And 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::PluginPAD *CPluginManager::GetPad() -{ - if (m_pad != NULL) - { - if (m_pad->GetFilename() == m_params->m_strPadPlugin) - return m_pad; - else - FreePad(); - } - - // Else load a new plugin - m_pad = (Common::PluginPAD*)LoadPlugin(m_params->m_strPadPlugin.c_str()); - return m_pad; -} Common::PluginWiimote *CPluginManager::GetWiimote() { @@ -435,12 +390,6 @@ void CPluginManager::FreeDSP() m_dsp = NULL; } -void CPluginManager::FreePad() -{ - delete m_pad; - m_pad = NULL; -} - void CPluginManager::FreeWiimote() { delete m_wiimote; @@ -451,11 +400,6 @@ void CPluginManager::EmuStateChange(PLUGIN_EMUSTATE newState) { GetVideo()->EmuStateChange(newState); GetDSP()->EmuStateChange(newState); - //TODO: OpenConfig below only uses GetXxx(0) aswell - // Would we need to call all plugins? - // If yes, how would one check if the plugin was not - // just created by GetXxx(idx) because there was none? - GetPad()->EmuStateChange(newState); GetWiimote()->EmuStateChange(newState); } @@ -481,9 +425,6 @@ void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TY case PLUGIN_TYPE_DSP: GetDSP()->Config((HWND)_Parent); break; - case PLUGIN_TYPE_PAD: - GetPad()->Config((HWND)_Parent); - break; case PLUGIN_TYPE_WIIMOTE: GetWiimote()->Config((HWND)_Parent); break; diff --git a/Source/Core/Core/Src/PluginManager.h b/Source/Core/Core/Src/PluginManager.h index 0652c98337..0f491e3777 100644 --- a/Source/Core/Core/Src/PluginManager.h +++ b/Source/Core/Core/Src/PluginManager.h @@ -20,7 +20,6 @@ #include "Plugin.h" #include "PluginDSP.h" -#include "PluginPAD.h" #include "PluginVideo.h" #include "PluginWiimote.h" #include "CoreParameter.h" @@ -46,17 +45,16 @@ class CPluginManager { public: static CPluginManager& GetInstance() {return(*m_Instance);} + static void Init(); static void Shutdown(); Common::PluginVideo *GetVideo(); Common::PluginDSP *GetDSP(); - Common::PluginPAD *GetPad(); Common::PluginWiimote *GetWiimote(); void FreeVideo(); void FreeDSP(); - void FreePad(); void FreeWiimote(); void EmuStateChange(PLUGIN_EMUSTATE newState); @@ -77,7 +75,6 @@ private: PLUGIN_GLOBALS *m_PluginGlobals; Common::PluginVideo *m_video; Common::PluginDSP *m_dsp; - Common::PluginPAD *m_pad; Common::PluginWiimote *m_wiimote; SCoreStartupParameter * m_params; diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index d90a40efc7..a958db934b 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -15,8 +15,8 @@ files = ["ActionReplay.cpp", "MemTools.cpp", "PatchEngine.cpp", "PluginManager.cpp", - "LuaInterface.cpp", - "State.cpp", + "LuaInterface.cpp", + "State.cpp",1 "Tracer.cpp", "VolumeHandler.cpp", "Boot/Boot.cpp", @@ -41,7 +41,8 @@ files = ["ActionReplay.cpp", "HW/EXI_DeviceMemoryCard.cpp", "HW/EXI_DeviceMic.cpp", "HW/EXI_DeviceEthernet.cpp", - "HW/GPFifo.cpp", + "HW/GCPad.cpp", + "HW/GCPadEmu.cpp", "HW/HW.cpp", "HW/Memmap.cpp", "HW/MemmapFunctions.cpp", diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index dfeb3a3417..ee110d5171 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -92,7 +92,6 @@ void DoState(PointerWrap &p) CPluginManager &pm = CPluginManager::GetInstance(); pm.GetVideo()->DoState(p.GetPPtr(), p.GetMode()); pm.GetDSP()->DoState(p.GetPPtr(), p.GetMode()); - pm.GetPad()->DoState(p.GetPPtr(), p.GetMode()); if (Core::g_CoreStartupParameter.bWii) pm.GetWiimote()->DoState(p.GetPPtr(), p.GetMode()); PowerPC::DoState(p); diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index f5384ad86e..16231b448c 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -90,11 +90,11 @@ /> Disable(); DSPSelection->Disable(); - PADSelection->Disable(); WiimoteSelection->Disable(); } } @@ -319,7 +315,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(PADSelection, PLUGIN_TYPE_PAD, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin); FillChoiceBox(WiimoteSelection, PLUGIN_TYPE_WIIMOTE, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin); } @@ -727,10 +722,6 @@ void CConfigMain::CreateGUIControls() DSPSelection = new wxChoice(PluginsPage, ID_DSP_CB, wxDefaultPosition, wxDefaultSize, NULL, 0, wxDefaultValidator); DSPConfig = new wxButton(PluginsPage, ID_DSP_CONFIG, wxT("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - sbPadPlugin = new wxStaticBoxSizer(wxHORIZONTAL, PluginsPage, wxT("Gamecube Pad")); - PADSelection = new wxChoice(PluginsPage, ID_PAD_CB, wxDefaultPosition, wxDefaultSize, NULL, 0, wxDefaultValidator); - PADConfig = new wxButton(PluginsPage, ID_PAD_CONFIG, wxT("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - sbWiimotePlugin = new wxStaticBoxSizer(wxHORIZONTAL, PluginsPage, wxT("Wiimote")); WiimoteSelection = new wxChoice(PluginsPage, ID_WIIMOTE_CB, wxDefaultPosition, wxDefaultSize, NULL, 0, wxDefaultValidator); WiimoteConfig = new wxButton(PluginsPage, ID_WIIMOTE_CONFIG, wxT("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); @@ -742,9 +733,6 @@ void CConfigMain::CreateGUIControls() sbDSPPlugin->Add(DSPSelection, 1, wxEXPAND|wxALL, 5); sbDSPPlugin->Add(DSPConfig, 0, wxALL, 5); - sbPadPlugin->Add(PADSelection, 1, wxEXPAND|wxALL, 5); - sbPadPlugin->Add(PADConfig, 0, wxALL, 5); - sbWiimotePlugin->Add(WiimoteSelection, 1, wxEXPAND|wxALL, 5); sbWiimotePlugin->Add(WiimoteConfig, 0, wxALL, 5); @@ -752,14 +740,11 @@ void CConfigMain::CreateGUIControls() sPluginsPage = new wxBoxSizer(wxVERTICAL); sPluginsPage->Add(sbGraphicsPlugin, 0, wxEXPAND|wxALL, 5); sPluginsPage->Add(sbDSPPlugin, 0, wxEXPAND|wxALL, 5); - sPluginsPage->Add(sbPadPlugin, 0, wxEXPAND|wxALL, 5); sPluginsPage->Add(sbWiimotePlugin, 0, wxEXPAND|wxALL, 5); PluginsPage->SetSizer(sPluginsPage); sPluginsPage->Layout(); - - m_Ok = new wxButton(this, wxID_OK); wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL); @@ -1142,7 +1127,6 @@ void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event)) // Update plugin filenames GetFilename(GraphicSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin); GetFilename(DSPSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin); - GetFilename(PADSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin); GetFilename(WiimoteSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin); } @@ -1156,9 +1140,6 @@ void CConfigMain::OnConfig(wxCommandEvent& event) case ID_DSP_CONFIG: CallConfig(DSPSelection); break; - case ID_PAD_CONFIG: - CallConfig(PADSelection); - 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 3e64b9a406..649403effe 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.h +++ b/Source/Core/DolphinWX/Src/ConfigMain.h @@ -139,7 +139,7 @@ private: wxBoxSizer* sPluginsPage; // Plugins settings - wxStaticBoxSizer* sbGraphicsPlugin, *sbDSPPlugin, *sbPadPlugin, *sbWiimotePlugin; // Graphics, DSP, Pad and Wiimote sections + wxStaticBoxSizer* sbGraphicsPlugin, *sbDSPPlugin, *sbWiimotePlugin; // Graphics, DSP, Wiimote sections // Graphics wxChoice* GraphicSelection; @@ -149,15 +149,10 @@ private: wxChoice* DSPSelection; wxButton* DSPConfig; - // Pad - wxChoice* PADSelection; - wxButton* PADConfig; - // Wiimote wxChoice* WiimoteSelection; wxButton* WiimoteConfig; - wxButton* m_Ok; FILE* pStream; @@ -266,11 +261,6 @@ private: ID_DSP_CONFIG, ID_DSP_ABOUT, - ID_PAD_TEXT, - ID_PAD_CB, - ID_PAD_CONFIG, - ID_PAD_ABOUT, - ID_WIIMOTE_TEXT, ID_WIIMOTE_CB, ID_WIIMOTE_CONFIG, diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index bbc7c640ea..5110fa2518 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -42,6 +42,7 @@ #include "ConfigManager.h" // Core #include "Core.h" #include "HW/DVDInterface.h" +#include "HW/GCPad.h" #include "IPC_HLE/WII_IPC_HLE_Device_usb.h" #include "State.h" #include "VolumeHandler.h" @@ -882,7 +883,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) #endif // Send the keyboard status to the Input plugins - CPluginManager::GetInstance().GetPad()->PAD_Input(event.GetKeyCode(), 1); // 1 = Down + PAD_Input(event.GetKeyCode(), 1); // 1 = Down CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 1); // 1 = Down } else @@ -894,7 +895,7 @@ void CFrame::OnKeyUp(wxKeyEvent& event) event.Skip(); if(Core::GetState() != Core::CORE_UNINITIALIZED) { - CPluginManager::GetInstance().GetPad()->PAD_Input(event.GetKeyCode(), 0); // 0 = Up + PAD_Input(event.GetKeyCode(), 0); // 0 = Up CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event.GetKeyCode(), 0); // 0 = Up } } diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 3d4a41b88d..0fb8239ea6 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -56,11 +56,13 @@ Core::GetWindowHandle(). #include "PowerPC/PowerPC.h" #include "HW/DVDInterface.h" #include "HW/ProcessorInterface.h" +#include "HW/GCPad.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 // wxWidgets @@ -942,12 +944,23 @@ void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event)) void CFrame::OnPluginPAD(wxCommandEvent& WXUNUSED (event)) { - CPluginManager::GetInstance().OpenConfig( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin.c_str(), - PLUGIN_TYPE_PAD - ); + InputPlugin *pad_plugin = PAD_GetPlugin(); + bool was_init = false; + if ( pad_plugin->controller_interface.IsInit() ) // check if game is running + was_init = true; + else + { + GCPad_Init(GetHandle()); + } + InputConfigDialog* m_ConfigFrame = new InputConfigDialog(this, *pad_plugin, "GCPadNew", was_init ); + m_ConfigFrame->ShowModal(); + m_ConfigFrame->Destroy(); + if ( !was_init ) // if game is running + { + GCPad_Deinit(); + } } + void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event)) { CPluginManager::GetInstance().OpenConfig( diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index b46a802fe3..e26f398a80 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -95,13 +95,11 @@ bool DolphinApp::OnInit() bool LoadElf = false; bool selectVideoPlugin = false; bool selectAudioPlugin = false; - bool selectPadPlugin = false; bool selectWiimotePlugin = false; wxString ElfFile; wxString videoPluginFilename; wxString audioPluginFilename; - wxString padPluginFilename; wxString wiimotePluginFilename; #if wxUSE_CMDLINE_PARSER // Parse command lines @@ -201,12 +199,10 @@ bool DolphinApp::OnInit() #if wxCHECK_VERSION(2, 9, 0) selectVideoPlugin = parser.Found("video_plugin", &videoPluginFilename); selectAudioPlugin = parser.Found("audio_plugin", &audioPluginFilename); - selectPadPlugin = parser.Found("pad_plugin", &padPluginFilename); selectWiimotePlugin = parser.Found("wiimote_plugin", &wiimotePluginFilename); #else selectVideoPlugin = parser.Found(wxT("video_plugin"), &videoPluginFilename); selectAudioPlugin = parser.Found(wxT("audio_plugin"), &audioPluginFilename); - selectPadPlugin = parser.Found(_T("pad_plugin"), &padPluginFilename); selectWiimotePlugin = parser.Found(wxT("wiimote_plugin"), &wiimotePluginFilename); #endif #endif // wxUSE_CMDLINE_PARSER @@ -353,10 +349,6 @@ bool DolphinApp::OnInit() SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin = std::string(audioPluginFilename.mb_str()); - if (selectPadPlugin && padPluginFilename != wxEmptyString) - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strPadPlugin = - std::string(padPluginFilename.mb_str()); - if (selectWiimotePlugin && wiimotePluginFilename != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strWiimotePlugin = std::string(wiimotePluginFilename.mb_str()); diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index 418364859d..0e37aca610 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -185,17 +185,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoSoftware", "Plu {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_GCPadNew", "Plugins\Plugin_GCPadNew\Plugin_GCPadNew.vcproj", "{1C3A7A91-A97F-4C7C-B45D-26F2242904D7}" - ProjectSection(ProjectDependencies) = postProject - {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} - {05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75} - {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} - {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} - {374E2DB7-42DF-4E59-8474-62B6687F4978} = {374E2DB7-42DF-4E59-8474-62B6687F4978} - {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} - {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_WiimoteNew", "Plugins\Plugin_WiimoteNew\Plugin_WiimoteNew.vcproj", "{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}" ProjectSection(ProjectDependencies) = postProject {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} @@ -557,18 +546,6 @@ Global {66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|Win32.Build.0 = Release|Win32 {66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|x64.ActiveCfg = Release|x64 {66A4E7BD-E2E8-4373-9B75-8750EB5AE683}.Release|x64.Build.0 = Release|x64 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Debug|Win32.ActiveCfg = Debug|Win32 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Debug|Win32.Build.0 = Debug|Win32 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Debug|x64.ActiveCfg = Debug|x64 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Debug|x64.Build.0 = Debug|x64 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.DebugFast|Win32.Build.0 = DebugFast|Win32 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.DebugFast|x64.ActiveCfg = DebugFast|x64 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.DebugFast|x64.Build.0 = DebugFast|x64 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Release|Win32.ActiveCfg = Release|Win32 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Release|Win32.Build.0 = Release|Win32 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Release|x64.ActiveCfg = Release|x64 - {1C3A7A91-A97F-4C7C-B45D-26F2242904D7}.Release|x64.Build.0 = Release|x64 {BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Debug|Win32.ActiveCfg = Debug|Win32 {BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Debug|Win32.Build.0 = Debug|Win32 {BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/Source/PluginSpecs/PluginSpecs.h b/Source/PluginSpecs/PluginSpecs.h index c52674a4ab..d1ef22fc12 100644 --- a/Source/PluginSpecs/PluginSpecs.h +++ b/Source/PluginSpecs/PluginSpecs.h @@ -63,7 +63,7 @@ enum PLUGIN_COMM enum PLUGIN_TYPE { PLUGIN_TYPE_VIDEO = 1, PLUGIN_TYPE_DVD, - PLUGIN_TYPE_PAD, + PLUGIN_TYPE_PAD_REMOVED, PLUGIN_TYPE_AUDIO, PLUGIN_TYPE_COMPILER, PLUGIN_TYPE_DSP, diff --git a/Source/PluginSpecs/pluginspecs_pad.h b/Source/PluginSpecs/pluginspecs_pad.h index 45237b7dc7..e2998808c1 100644 --- a/Source/PluginSpecs/pluginspecs_pad.h +++ b/Source/PluginSpecs/pluginspecs_pad.h @@ -1,14 +1,8 @@ -//__________________________________________________________________________________________________ -// Common pad plugin spec, version #1.0 maintained by F|RES -// +// TODO: Move these defines somewhere else and delete this file. #ifndef _PAD_H_INCLUDED__ #define _PAD_H_INCLUDED__ -#include "PluginSpecs.h" - -#include "ExportProlog.h" - #define PAD_ERR_NONE 0 #define PAD_ERR_NO_CONTROLLER -1 #define PAD_ERR_NOT_READY -2 @@ -29,19 +23,6 @@ #define PAD_BUTTON_Y 0x0800 #define PAD_BUTTON_START 0x1000 -typedef void (*TLog)(const char* _pMessage); -typedef bool (*TRendererHasFocus)(void); - -typedef struct -{ - HWND hWnd; -#if defined HAVE_X11 && HAVE_X11 - void *pXWindow; -#endif - TLog pLog; - TRendererHasFocus pRendererHasFocus; -} SPADInitialize; - typedef struct { unsigned short button; // Or-ed PAD_BUTTON_* and PAD_TRIGGER_* bits @@ -58,31 +39,4 @@ typedef struct } SPADStatus; -// I N T E R F A C E - -// __________________________________________________________________________________________________ -// Function: -// Purpose: -// input: -// output: -// -EXPORT void CALL PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus); - -// __________________________________________________________________________________________________ -// Function: Send keyboard input to the plugin -// Purpose: -// input: The key and if it's pressed or released -// output: None -// -EXPORT void CALL PAD_Input(u16 _Key, u8 _UpDown); - -// __________________________________________________________________________________________________ -// Function: PAD_Rumble -// Purpose: Pad rumble! -// input: PAD number, Command type (Stop=0, Rumble=1, Stop Hard=2) and strength of Rumble -// output: none -// -EXPORT void CALL PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength); - -#include "ExportEpilog.h" #endif diff --git a/Source/Plugins/Plugin_GCPadNew/Src/GCPadNew.cpp b/Source/Plugins/Plugin_GCPadNew/Src/GCPadNew.cpp deleted file mode 100644 index ccfa53953c..0000000000 --- a/Source/Plugins/Plugin_GCPadNew/Src/GCPadNew.cpp +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright (C) 2010 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 "Common.h" -#include "pluginspecs_pad.h" - -#include "ControllerInterface/ControllerInterface.h" -#include "GCPadEmu.h" - -#if defined(HAVE_WX) && HAVE_WX -#include "../../InputUICommon/Src/ConfigDiag.h" -#endif -#include "../../InputCommon/Src/InputConfig.h" - -#if defined(HAVE_X11) && HAVE_X11 -#include -#endif - -#define PLUGIN_VERSION 0x0100 - -#define PLUGIN_NAME "Dolphin GCPad New" -#ifdef DEBUGFAST -#define PLUGIN_FULL_NAME PLUGIN_NAME" (DebugFast)" -#else -#ifdef _DEBUG -#define PLUGIN_FULL_NAME PLUGIN_NAME" (Debug)" -#else -#define PLUGIN_FULL_NAME PLUGIN_NAME -#endif -#endif - -// plugin globals -static InputPlugin g_plugin( "GCPadNew", "Pad", "GCPad" ); -SPADInitialize *g_PADInitialize = NULL; - -#ifdef _WIN32 -class wxDLLApp : public wxApp -{ - bool OnInit() - { - return true; - }; -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); -#endif - -// copied from GCPad -HINSTANCE g_hInstance; - -// copied from GCPad -#if defined(HAVE_WX) && HAVE_WX -wxWindow* GetParentedWxWindow(HWND Parent) -{ -#ifdef _WIN32 - wxSetInstance((HINSTANCE)g_hInstance); -#endif - wxWindow *win = new wxWindow(); -#ifdef _WIN32 - win->SetHWND((WXHWND)Parent); - win->AdoptAttributesFromHWND(); -#endif - return win; -} -#endif -// / - -#ifdef _WIN32 -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) -{ - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - wxSetInstance(hinstDLL); - wxInitialize(); - break; - case DLL_PROCESS_DETACH: - wxUninitialize(); - break; - default: - break; - } - - g_hInstance = hinstDLL; - return TRUE; -} -#endif - -void DeInitPlugin() -{ - // i realize i am checking IsInit() twice, just too lazy to change it - 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(); - - g_plugin.controller_interface.DeInit(); - } -} - -// if plugin isn't initialized, init and load config -void InitPlugin( 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(); - - // load the saved controller config - if (false == g_plugin.LoadConfig()) - { - // load default config for pad 1 - g_plugin.controllers[0]->LoadDefaults(); - - // kinda silly, set default device(all controls) to first one found in ControllerInterface - // should be the keyboard device - if (g_plugin.controller_interface.Devices().size()) - { - g_plugin.controllers[0]->default_device.FromDevice(g_plugin.controller_interface.Devices()[0]); - g_plugin.controllers[0]->UpdateDefaultDevice(); - } - } - - // update control refs - std::vector::const_iterator - i = g_plugin.controllers.begin(), - e = g_plugin.controllers.end(); - for ( ; i!=e; ++i ) - (*i)->UpdateReferences( g_plugin.controller_interface ); - - } -} - -// I N T E R F A C E - -// __________________________________________________________________________________________________ -// Function: -// Purpose: -// input: -// output: -// -void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) -{ - memset( _pPADStatus, 0, sizeof(*_pPADStatus) ); - _pPADStatus->err = PAD_ERR_NONE; - // wtf is this? - _pPADStatus->button |= PAD_USE_ORIGIN; - - // try lock - if ( false == g_plugin.controls_crit.TryEnter() ) - { - // if gui has lock (messing with controls), skip this input cycle - // center axes and return - memset( &_pPADStatus->stickX, 0x80, 4 ); - return; - } - - // if we are on the next input cycle, update output and input - // if we can get a lock - static int _last_numPAD = 4; - if ( _numPAD <= _last_numPAD && g_plugin.interface_crit.TryEnter() ) - { - g_plugin.controller_interface.UpdateOutput(); - g_plugin.controller_interface.UpdateInput(); - g_plugin.interface_crit.Leave(); - } - _last_numPAD = _numPAD; - - // get input - ((GCPad*)g_plugin.controllers[ _numPAD ])->GetInput( _pPADStatus ); - - // leave - g_plugin.controls_crit.Leave(); - -} - -// __________________________________________________________________________________________________ -// Function: Send keyboard input to the plugin -// Purpose: -// input: The key and if it's pressed or released -// output: None -// -void PAD_Input(u16 _Key, u8 _UpDown) -{ - // nofin -} - -// __________________________________________________________________________________________________ -// Function: PAD_Rumble -// Purpose: Pad rumble! -// 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) -{ - // enter - if ( g_plugin.controls_crit.TryEnter() ) - { - // TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time - // set rumble - ((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput( 1 == _uType && _uStrength > 2 ); - - // leave - g_plugin.controls_crit.Leave(); - } -} - - -// GLOBAL I N T E R F A C E -// Function: GetDllInfo -// Purpose: This function allows the emulator to gather information -// about the DLL by filling in the PluginInfo structure. -// input: A pointer to a PLUGIN_INFO structure that needs to be -// filled by the function. (see def above) -// output: none -// -void GetDllInfo(PLUGIN_INFO* _pPluginInfo) -{ - // don't feel like messing around with all those strcpy functions and warnings - //char *s1 = CIFACE_PLUGIN_FULL_NAME, *s2 = _pPluginInfo->Name; - //while ( *s2++ = *s1++ ); - memcpy( _pPluginInfo->Name, PLUGIN_FULL_NAME, sizeof(PLUGIN_FULL_NAME) ); - _pPluginInfo->Type = PLUGIN_TYPE_PAD; - _pPluginInfo->Version = PLUGIN_VERSION; -} - -// ___________________________________________________________________________ -// Function: DllConfig -// Purpose: This function is optional function that is provided -// to allow the user to configure the DLL -// input: A handle to the window that calls this function -// output: none -// -void DllConfig(HWND _hParent) -{ - bool was_init = false; -#if defined(HAVE_X11) && HAVE_X11 - Display *dpy = NULL; -#endif - if ( g_plugin.controller_interface.IsInit() ) // check if game is running - was_init = true; - else - { -#if defined(HAVE_X11) && HAVE_X11 - dpy = XOpenDisplay(0); - InitPlugin(dpy); -#else - InitPlugin(_hParent); -#endif - } - - // copied from GCPad -#if defined(HAVE_WX) && HAVE_WX - wxWindow *frame = GetParentedWxWindow(_hParent); - InputConfigDialog* m_ConfigFrame = new InputConfigDialog( frame, g_plugin, PLUGIN_FULL_NAME, was_init ); - -#ifdef _WIN32 - frame->Disable(); - m_ConfigFrame->ShowModal(); - frame->Enable(); -#else - m_ConfigFrame->ShowModal(); -#endif - -#ifdef _WIN32 - wxMilliSleep( 50 ); // hooray for hacks - frame->SetFocus(); - frame->SetHWND(NULL); -#endif - - m_ConfigFrame->Destroy(); - m_ConfigFrame = NULL; - frame->Destroy(); -#endif - // / - - if ( !was_init ) // if game is running - { -#if defined(HAVE_X11) && HAVE_X11 - XCloseDisplay(dpy); -#endif - DeInitPlugin(); - } -} - -// ___________________________________________________________________________ -// Function: DllDebugger -// Purpose: Open the debugger -// input: a handle to the window that calls this function -// output: none -// -void DllDebugger(HWND _hParent, bool Show) -{ - // wut? -} - -// ___________________________________________________________________________ -// Function: DllSetGlobals -// Purpose: Set the pointer for globals variables -// input: a pointer to the global struct -// output: none -// -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) -{ - // wut? -} - -// ___________________________________________________________________________ -// Function: Initialize -// Purpose: Initialize the plugin -// input: Init -// output: none -// -void Initialize(void *init) -{ - g_PADInitialize = (SPADInitialize*)init; - if ( false == g_plugin.controller_interface.IsInit() ) - InitPlugin( g_PADInitialize->hWnd ); -} - -// ___________________________________________________________________________ -// Function: Shutdown -// Purpose: This function is called when the emulator is shutting down -// a game allowing the dll to de-initialise. -// input: none -// output: none -// -void Shutdown(void) -{ - if ( g_plugin.controller_interface.IsInit() ) - DeInitPlugin(); -} - -// ___________________________________________________________________________ -// Function: DoState -// Purpose: Saves/load state -// input/output: ptr -// input: mode -// -void DoState(unsigned char **ptr, int mode) -{ - // prolly won't need this -} - -// ___________________________________________________________________________ -// Function: EmuStateChange -// Purpose: Notifies the plugin of a change in emulation state -// input: newState -// output: none -// -void EmuStateChange(PLUGIN_EMUSTATE newState) -{ - // maybe use this later -}