From 1ef5eca30cc9a033c75f6a6d01b22e3104a1977d Mon Sep 17 00:00:00 2001 From: nakeee Date: Sun, 18 Jan 2009 13:02:38 +0000 Subject: [PATCH] trying to support 2 pads plugins I don't have joystick so please check njoy and if someone can check if njoy and pad simple can be used together:) todo: add configuration now you can just do it from the ini by defining pad?Plugin manually git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1920 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 12 ++++-- Source/Core/Core/Src/HW/SI.cpp | 38 ++++++++----------- .../Core/Src/HW/SI_DeviceGCController.cpp | 3 +- Source/PluginSpecs/pluginspecs_pad.h | 1 + 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index b9d369098f..b3fad9597b 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -332,13 +332,19 @@ THREAD_RETURN EmuThread(void *pArg) dspInit.pGenerateDSPInterrupt = Callback_DSPInterrupt; dspInit.pGetAudioStreaming = AudioInterface::Callback_GetStreaming; pm.GetDSP()->Initialize((void *)&dspInit); - + + + for (int i=0;iInitialize((void *)&PADInitialize); - + PADInitialize.padNumber = i; + pm.GetPAD(i)->Initialize((void *)&PADInitialize); + + } + // Load and Init WiimotePlugin - only if we are booting in wii mode if (_CoreParameter.bWii) { SWiimoteInitialize WiimoteInitialize; diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 192db7598e..2bd5d09f7c 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -231,28 +231,22 @@ void UpdateInterrupts(); void Init() { - for (int i = 0; i < NUMBER_OF_CHANNELS; i++) - { - g_Channel[i].m_Out.Hex = 0; - g_Channel[i].m_InHi.Hex = 0; - g_Channel[i].m_InLo.Hex = 0; - } - - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(0); - - unsigned int AttachedPadMask; - if (pad != NULL) - AttachedPadMask = pad->PAD_GetAttachedPads(); - else - AttachedPadMask = 1; - - for (int i = 0; i < 4; i++) - { - if (AttachedPadMask & (1 << i)) - g_Channel[i].m_pDevice = new CSIDevice_GCController(i); - else - g_Channel[i].m_pDevice = new CSIDevice_Dummy(i); - } + for (int i = 0; i < NUMBER_OF_CHANNELS; i++) { + + g_Channel[i].m_Out.Hex = 0; + g_Channel[i].m_InHi.Hex = 0; + g_Channel[i].m_InLo.Hex = 0; + } + + // TODO: allow dynamic attaching/detaching of plugins + // maybe this code should be in the pad plugin loader at all? + for (int i = 0; i < MAXPADS; i++) { + Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(i); + if (pad != NULL && (pad->PAD_GetAttachedPads() & (1 << i))) + g_Channel[i].m_pDevice = new CSIDevice_GCController(i); + else + g_Channel[i].m_pDevice = new CSIDevice_Dummy(i); + } g_Poll.Hex = 0; g_ComCSR.Hex = 0; diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index 7cb07a05c7..e74eeb2f46 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -119,7 +119,8 @@ CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) { SPADStatus PadStatus; memset(&PadStatus, 0 ,sizeof(PadStatus)); - Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(0); + Common::PluginPAD* pad = + CPluginManager::GetInstance().GetPAD(ISIDevice::m_iDeviceNumber); pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); _Hi = (u32)((u8)PadStatus.stickY); diff --git a/Source/PluginSpecs/pluginspecs_pad.h b/Source/PluginSpecs/pluginspecs_pad.h index 4ba867cef5..b901e670f4 100644 --- a/Source/PluginSpecs/pluginspecs_pad.h +++ b/Source/PluginSpecs/pluginspecs_pad.h @@ -35,6 +35,7 @@ typedef struct { HWND hWnd; TLog pLog; + int padNumber; } SPADInitialize; typedef struct