diff --git a/Source/Project64-core/N64System/Mips/PifRam.cpp b/Source/Project64-core/N64System/Mips/PifRam.cpp index 6e9a7696a..ef2f6883a 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.cpp +++ b/Source/Project64-core/N64System/Mips/PifRam.cpp @@ -459,7 +459,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) Command[4] = 0x00; switch (Controllers[Control].Plugin) { - case PLUGIN_TANSFER_PAK: + case PLUGIN_TRANSFER_PAK: case PLUGIN_RUMBLE_PAK: case PLUGIN_MEMPAK: case PLUGIN_RAW: @@ -506,7 +506,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) { case PLUGIN_RUMBLE_PAK: Rumblepak::ReadFrom(address, data); break; case PLUGIN_MEMPAK: g_Mempak->ReadFrom(Control, address, data); break; - case PLUGIN_TANSFER_PAK: Transferpak::ReadFrom((uint16_t)address, data); break; + case PLUGIN_TRANSFER_PAK: Transferpak::ReadFrom((uint16_t)address, data); break; case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; default: memset(&Command[5], 0, 0x20); @@ -547,7 +547,7 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) { case PLUGIN_MEMPAK: g_Mempak->WriteTo(Control, address, data); break; case PLUGIN_RUMBLE_PAK: Rumblepak::WriteTo(Control, address, data); break; - case PLUGIN_TANSFER_PAK: Transferpak::WriteTo((uint16_t)address, data); break; + case PLUGIN_TRANSFER_PAK: Transferpak::WriteTo((uint16_t)address, data); break; case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; } diff --git a/Source/Project64-core/N64System/N64System.cpp b/Source/Project64-core/N64System/N64System.cpp index 42645be54..09bc26fd1 100644 --- a/Source/Project64-core/N64System/N64System.cpp +++ b/Source/Project64-core/N64System/N64System.cpp @@ -763,6 +763,10 @@ void CN64System::EndEmulation(void) void CN64System::Pause() { + if (m_Plugins && m_Plugins->Control()->EmulationPaused) + { + m_Plugins->Control()->EmulationPaused(); + } if (m_EndEmulation) { return; diff --git a/Source/Project64-core/Plugins/AudioPlugin.cpp b/Source/Project64-core/Plugins/AudioPlugin.cpp index f34e899df..5e55c1f18 100644 --- a/Source/Project64-core/Plugins/AudioPlugin.cpp +++ b/Source/Project64-core/Plugins/AudioPlugin.cpp @@ -1,11 +1,13 @@ #include "stdafx.h" -#include -#include -#include + #include #include +#include +#include #include +#include #include +#include #ifdef _WIN32 #include #endif @@ -28,10 +30,10 @@ CAudioPlugin::~CAudioPlugin() bool CAudioPlugin::LoadFunctions(void) { - g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false); + g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false); // Find entries for functions in DLL - void(CALL *InitiateAudio)(void); + void(CALL * InitiateAudio)(void); LoadFunction(InitiateAudio); LoadFunction(AiDacrateChanged); LoadFunction(AiLenChanged); @@ -40,15 +42,39 @@ bool CAudioPlugin::LoadFunctions(void) LoadFunction(ProcessAList); // Make sure DLL has all needed functions - if (AiDacrateChanged == nullptr) { UnloadPlugin(); return false; } - if (AiLenChanged == nullptr) { UnloadPlugin(); return false; } - if (AiReadLength == nullptr) { UnloadPlugin(); return false; } - if (InitiateAudio == nullptr) { UnloadPlugin(); return false; } - if (ProcessAList == nullptr) { UnloadPlugin(); return false; } + if (AiDacrateChanged == nullptr) + { + UnloadPlugin(); + return false; + } + if (AiLenChanged == nullptr) + { + UnloadPlugin(); + return false; + } + if (AiReadLength == nullptr) + { + UnloadPlugin(); + return false; + } + if (InitiateAudio == nullptr) + { + UnloadPlugin(); + return false; + } + if (ProcessAList == nullptr) + { + UnloadPlugin(); + return false; + } if (m_PluginInfo.Version >= 0x0102) { - if (PluginOpened == nullptr) { UnloadPlugin(); return false; } + if (PluginOpened == nullptr) + { + UnloadPlugin(); + return false; + } } return true; } @@ -57,12 +83,10 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) { struct AUDIO_INFO { - void * hwnd; + void * hWnd; void * hinst; - int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary - // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 + int32_t Reserved; uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) // This will be in the same memory format as the rest of the memory uint8_t * RDRAM; @@ -82,20 +106,23 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) }; // Get function from DLL - int32_t(CALL *InitiateAudio)(AUDIO_INFO Audio_Info); + int32_t(CALL * InitiateAudio)(AUDIO_INFO Audio_Info); LoadFunction(InitiateAudio); - if (InitiateAudio == nullptr) { return false; } + if (InitiateAudio == nullptr) + { + return false; + } - AUDIO_INFO Info = { 0 }; + AUDIO_INFO Info = {0}; #ifdef _WIN32 - Info.hwnd = Window ? Window->GetWindowHandle() : nullptr; + Info.hWnd = Window ? Window->GetWindowHandle() : nullptr; Info.hinst = Window ? Window->GetModuleInstance() : nullptr; #else - Info.hwnd = nullptr; + Info.hWnd = nullptr; Info.hinst = nullptr; #endif - Info.MemoryBswaped = true; + Info.Reserved = true; Info.CheckInterrupts = DummyCheckInterrupts; // We are initializing the plugin before any ROM is loaded so we do not have any correct @@ -138,7 +165,6 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) Info.AI__DACRATE_REG = &Reg.AI_DACRATE_REG; Info.AI__BITRATE_REG = &Reg.AI_BITRATE_REG; } - m_Initialized = InitiateAudio(Info) != 0; #ifdef _WIN32 @@ -183,7 +209,10 @@ void CAudioPlugin::UnloadPluginDetails(void) void CAudioPlugin::DacrateChanged(SYSTEM_TYPE Type) { - if (!Initialized()) { return; } + if (!Initialized()) + { + return; + } WriteTrace(TraceAudioPlugin, TraceDebug, "SystemType: %s", Type == SYSTEM_NTSC ? "SYSTEM_NTSC" : "SYSTEM_PAL"); //uint32_t Frequency = g_Reg->AI_DACRATE_REG * 30; diff --git a/Source/Project64-core/Plugins/AudioPlugin.h b/Source/Project64-core/Plugins/AudioPlugin.h index a3d953fa6..87bd4853b 100644 --- a/Source/Project64-core/Plugins/AudioPlugin.h +++ b/Source/Project64-core/Plugins/AudioPlugin.h @@ -10,25 +10,34 @@ public: void DacrateChanged(SYSTEM_TYPE Type); bool Initiate(CN64System * System, RenderWindow * Window); - void(CALL *AiLenChanged)(void); - uint32_t(CALL *AiReadLength)(void); - void(CALL *ProcessAList)(void); + void(CALL * AiLenChanged)(void); + uint32_t(CALL * AiReadLength)(void); + void(CALL * ProcessAList)(void); private: - CAudioPlugin(const CAudioPlugin&); - CAudioPlugin& operator=(const CAudioPlugin&); + CAudioPlugin(const CAudioPlugin &); + CAudioPlugin & operator=(const CAudioPlugin &); - virtual int32_t GetDefaultSettingStartRange() const { return FirstAudioDefaultSet; } - virtual int32_t GetSettingStartRange() const { return FirstAudioSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_AUDIO; } + virtual int32_t GetDefaultSettingStartRange() const + { + return FirstAudioDefaultSet; + } + virtual int32_t GetSettingStartRange() const + { + return FirstAudioSettings; + } + PLUGIN_TYPE type() + { + return PLUGIN_TYPE_AUDIO; + } void * m_hAudioThread; bool LoadFunctions(void); void UnloadPluginDetails(void); - void(CALL *AiUpdate) (int32_t Wait); - void(CALL *AiDacrateChanged)(SYSTEM_TYPE Type); + void(CALL * AiUpdate)(int32_t Wait); + void(CALL * AiDacrateChanged)(SYSTEM_TYPE Type); static void AudioThread(CAudioPlugin * _this); }; diff --git a/Source/Project64-core/Plugins/ControllerPlugin.cpp b/Source/Project64-core/Plugins/ControllerPlugin.cpp index 23ed078a7..9528f45a5 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.cpp +++ b/Source/Project64-core/Plugins/ControllerPlugin.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" -#include -#include -#include + #include "ControllerPlugin.h" +#include +#include +#include CControl_Plugin::CControl_Plugin(void) : WM_KeyDown(nullptr), @@ -26,7 +27,7 @@ CControl_Plugin::~CControl_Plugin() bool CControl_Plugin::LoadFunctions(void) { // Find entries for functions in DLL - void(CALL *InitiateControllers)(void); + void(CALL * InitiateControllers)(void); LoadFunction(InitiateControllers); LoadFunction(ControllerCommand); LoadFunction(GetKeys); @@ -34,13 +35,23 @@ bool CControl_Plugin::LoadFunctions(void) LoadFunction(WM_KeyDown); LoadFunction(WM_KeyUp); LoadFunction(RumbleCommand); + LoadFunction(WM_KillFocus); + LoadFunction(EmulationPaused); // Make sure DLL had all needed functions - if (InitiateControllers == nullptr) { UnloadPlugin(); return false; } + if (InitiateControllers == nullptr) + { + UnloadPlugin(); + return false; + } if (m_PluginInfo.Version >= 0x0102) { - if (PluginOpened == nullptr) { UnloadPlugin(); return false; } + if (PluginOpened == nullptr) + { + UnloadPlugin(); + return false; + } } // Allocate our own controller @@ -58,7 +69,7 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) for (int32_t i = 0; i < 4; i++) { - m_PluginControllers[i].Present = false; + m_PluginControllers[i].Present = PRESENT_NONE; m_PluginControllers[i].RawData = false; m_PluginControllers[i].Plugin = PLUGIN_NONE; } @@ -67,9 +78,12 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) if (m_PluginInfo.Version == 0x0100) { // Get function from DLL - void(CALL *InitiateControllers_1_0)(void * hMainWindow, CONTROL Controls[4]); + void(CALL * InitiateControllers_1_0)(void * hMainWindow, CONTROL Controls[4]); _LoadFunction("InitiateControllers", InitiateControllers_1_0); - if (InitiateControllers_1_0 == nullptr) { return false; } + if (InitiateControllers_1_0 == nullptr) + { + return false; + } #ifdef _WIN32 InitiateControllers_1_0(Window->GetWindowHandle(), m_PluginControllers); #else @@ -84,19 +98,22 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) ControlInfo.HEADER = (System == nullptr ? Buffer : g_Rom->GetRomAddress()); #ifdef _WIN32 ControlInfo.hinst = Window ? Window->GetModuleInstance() : nullptr; - ControlInfo.hMainWindow = Window ? Window->GetWindowHandle() : nullptr; + ControlInfo.hWnd = Window ? Window->GetWindowHandle() : nullptr; #else ControlInfo.hinst = nullptr; - ControlInfo.hMainWindow = nullptr; + ControlInfo.hWnd = nullptr; #endif - ControlInfo.MemoryBswaped = true; + ControlInfo.Reserved = true; if (m_PluginInfo.Version == 0x0101) { // Get function from DLL - void(CALL *InitiateControllers_1_1)(CONTROL_INFO ControlInfo); + void(CALL * InitiateControllers_1_1)(CONTROL_INFO ControlInfo); _LoadFunction("InitiateControllers", InitiateControllers_1_1); - if (InitiateControllers_1_1 == nullptr) { return false; } + if (InitiateControllers_1_1 == nullptr) + { + return false; + } InitiateControllers_1_1(ControlInfo); m_Initialized = true; @@ -104,9 +121,12 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) else if (m_PluginInfo.Version >= 0x0102) { // Get function from DLL - void(CALL *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo); + void(CALL * InitiateControllers_1_2)(CONTROL_INFO * ControlInfo); _LoadFunction("InitiateControllers", InitiateControllers_1_2); - if (InitiateControllers_1_2 == nullptr) { return false; } + if (InitiateControllers_1_2 == nullptr) + { + return false; + } InitiateControllers_1_2(&ControlInfo); m_Initialized = true; @@ -136,10 +156,16 @@ void CControl_Plugin::UnloadPluginDetails(void) void CControl_Plugin::UpdateKeys(void) { - if (!m_AllocatedControllers) { return; } + if (!m_AllocatedControllers) + { + return; + } for (int32_t cont = 0; cont < sizeof(m_Controllers) / sizeof(m_Controllers[0]); cont++) { - if (!m_Controllers[cont]->Present()) { continue; } + if (!m_Controllers[cont]->Present()) + { + continue; + } if (!m_Controllers[cont]->m_RawData) { GetKeys(cont, &m_Controllers[cont]->m_Buttons); @@ -149,7 +175,10 @@ void CControl_Plugin::UpdateKeys(void) g_Notify->BreakPoint(__FILE__, __LINE__); } } - if (ReadController) { ReadController(-1, nullptr); } + if (ReadController) + { + ReadController(-1, nullptr); + } } void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin) @@ -169,7 +198,7 @@ void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin) } } -CCONTROL::CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType) : +CCONTROL::CCONTROL(int32_t & Present, int32_t & RawData, int32_t & PlugType) : m_Present(Present), m_RawData(RawData), m_PlugType(PlugType) { m_Buttons.Value = 0; diff --git a/Source/Project64-core/Plugins/ControllerPlugin.h b/Source/Project64-core/Plugins/ControllerPlugin.h index 0efdf8552..63cdd80db 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.h +++ b/Source/Project64-core/Plugins/ControllerPlugin.h @@ -1,74 +1,26 @@ #pragma once #include - -#pragma warning(push) -#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union - -typedef union -{ - uint32_t Value; - struct - { - unsigned R_DPAD : 1; - unsigned L_DPAD : 1; - unsigned D_DPAD : 1; - unsigned U_DPAD : 1; - unsigned START_BUTTON : 1; - unsigned Z_TRIG : 1; - unsigned B_BUTTON : 1; - unsigned A_BUTTON : 1; - - unsigned R_CBUTTON : 1; - unsigned L_CBUTTON : 1; - unsigned D_CBUTTON : 1; - unsigned U_CBUTTON : 1; - unsigned R_TRIG : 1; - unsigned L_TRIG : 1; - unsigned Reserved1 : 1; - unsigned Reserved2 : 1; - - signed X_AXIS : 8; - - signed Y_AXIS : 8; - }; -} BUTTONS; -#pragma warning(pop) - -typedef struct -{ - int32_t Present; - int32_t RawData; - int32_t Plugin; -} CONTROL; - -typedef struct -{ - void * hMainWindow; - void * hinst; - - int32_t MemoryBswaped; // Memory in client or server-native endian - uint8_t * HEADER; // The ROM header (first 40h bytes of the ROM) - CONTROL * Controls; // Pointer to array of 4 controllers, i.e.: CONTROL Controls[4]; -} CONTROL_INFO; - -enum PluginType -{ - PLUGIN_NONE = 1, - PLUGIN_MEMPAK = 2, - PLUGIN_RUMBLE_PAK = 3, - PLUGIN_TANSFER_PAK = 4, // Not implemented for non-raw data - PLUGIN_RAW = 5, // The controller plugin is passed in raw data -}; +#include class CControl_Plugin; class CCONTROL { public: - CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType); - inline bool Present(void) const { return m_Present != 0; } - inline uint32_t Buttons(void) const { return m_Buttons.Value; } - inline PluginType Plugin(void) const { return static_cast(m_PlugType); } + CCONTROL(int32_t & Present, int32_t & RawData, int32_t & PlugType); + inline bool Present(void) const + { + return m_Present != 0; + } + inline uint32_t Buttons(void) const + { + return m_Buttons.Value; + } + inline PluginType Plugin(void) const + { + return static_cast(m_PlugType); + } + private: friend class CControl_Plugin; @@ -78,8 +30,8 @@ private: BUTTONS m_Buttons; CCONTROL(void); - CCONTROL(const CCONTROL&); - CCONTROL& operator=(const CCONTROL&); + CCONTROL(const CCONTROL &); + CCONTROL & operator=(const CCONTROL &); }; class CControl_Plugin : public CPlugin @@ -92,23 +44,40 @@ public: void SetControl(CControl_Plugin const * const Plugin); void UpdateKeys(void); - void(CALL *WM_KeyDown) (uint32_t wParam, uint32_t lParam); - void(CALL *WM_KeyUp) (uint32_t wParam, uint32_t lParam); - void(CALL *RumbleCommand) (int32_t Control, int32_t bRumble); - void(CALL *GetKeys) (int32_t Control, BUTTONS * Keys); - void(CALL *ReadController) (int32_t Control, uint8_t * Command); - void(CALL *ControllerCommand) (int32_t Control, uint8_t * Command); + void(CALL * WM_KeyDown)(uint32_t wParam, uint32_t lParam); + void(CALL * WM_KeyUp)(uint32_t wParam, uint32_t lParam); + void(CALL * WM_KillFocus)(uint32_t wParam, uint32_t lParam); + void(CALL * EmulationPaused)(); + void(CALL * RumbleCommand)(int32_t Control, int32_t bRumble); + void(CALL * GetKeys) (int32_t Control, BUTTONS * Keys); + void(CALL * ReadController)(int32_t Control, uint8_t * Command); + void(CALL * ControllerCommand)(int32_t Control, uint8_t * Command); - inline CCONTROL const * Controller(int32_t control) { return m_Controllers[control]; } - inline CONTROL * PluginControllers(void) { return m_PluginControllers; } + inline CCONTROL const * Controller(int32_t control) + { + return m_Controllers[control]; + } + inline CONTROL * PluginControllers(void) + { + return m_PluginControllers; + } private: - CControl_Plugin(const CControl_Plugin&); - CControl_Plugin& operator=(const CControl_Plugin&); + CControl_Plugin(const CControl_Plugin &); + CControl_Plugin & operator=(const CControl_Plugin &); - virtual int32_t GetDefaultSettingStartRange() const { return FirstCtrlDefaultSet; } - virtual int32_t GetSettingStartRange() const { return FirstCtrlSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_CONTROLLER; } + virtual int32_t GetDefaultSettingStartRange() const + { + return FirstCtrlDefaultSet; + } + virtual int32_t GetSettingStartRange() const + { + return FirstCtrlSettings; + } + PLUGIN_TYPE type() + { + return PLUGIN_TYPE_CONTROLLER; + } bool LoadFunctions(void); void UnloadPluginDetails(void); diff --git a/Source/Project64-core/Plugins/GFXPlugin.cpp b/Source/Project64-core/Plugins/GFXPlugin.cpp index 2b12e3933..f6a5f8480 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.cpp +++ b/Source/Project64-core/Plugins/GFXPlugin.cpp @@ -1,29 +1,30 @@ #include "stdafx.h" -#include -#include -#include + +#include "GFXPlugin.h" #include #include +#include +#include #include -#include "GFXPlugin.h" +#include CGfxPlugin::CGfxPlugin() : -CaptureScreen(nullptr), -ChangeWindow(nullptr), -DrawScreen(nullptr), -DrawStatus(nullptr), -MoveScreen(nullptr), -ProcessDList(nullptr), -ProcessRDPList(nullptr), -ShowCFB(nullptr), -UpdateScreen(nullptr), -ViStatusChanged(nullptr), -ViWidthChanged(nullptr), -SoftReset(nullptr), -GetRomBrowserMenu(nullptr), -OnRomBrowserMenuItem(nullptr), -GetDebugInfo(nullptr), -InitiateDebugger(nullptr) + CaptureScreen(nullptr), + ChangeWindow(nullptr), + DrawScreen(nullptr), + DrawStatus(nullptr), + MoveScreen(nullptr), + ProcessDList(nullptr), + ProcessRDPList(nullptr), + ShowCFB(nullptr), + UpdateScreen(nullptr), + ViStatusChanged(nullptr), + ViWidthChanged(nullptr), + SoftReset(nullptr), + GetRomBrowserMenu(nullptr), + OnRomBrowserMenuItem(nullptr), + GetDebugInfo(nullptr), + InitiateDebugger(nullptr) { memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); } @@ -39,7 +40,7 @@ CGfxPlugin::~CGfxPlugin() bool CGfxPlugin::LoadFunctions(void) { // Find entries for functions in DLL - int32_t(CALL *InitiateGFX) (void * Gfx_Info); + int32_t(CALL * InitiateGFX)(void * Gfx_Info); LoadFunction(InitiateGFX); LoadFunction(ChangeWindow); LoadFunction(DrawScreen); @@ -62,15 +63,46 @@ bool CGfxPlugin::LoadFunctions(void) LoadFunction(OnRomBrowserMenuItem); // Make sure DLL had all needed functions - if (ChangeWindow == nullptr) { UnloadPlugin(); return false; } - if (DrawScreen == nullptr) { DrawScreen = DummyDrawScreen; } - if (InitiateGFX == nullptr) { UnloadPlugin(); return false; } - if (MoveScreen == nullptr) { MoveScreen = DummyMoveScreen; } - if (ProcessDList == nullptr) { UnloadPlugin(); return false; } - if (UpdateScreen == nullptr) { UnloadPlugin(); return false; } - if (ViStatusChanged == nullptr) { ViStatusChanged = DummyViStatusChanged; } - if (ViWidthChanged == nullptr) { ViWidthChanged = DummyViWidthChanged; } - if (SoftReset == nullptr) { SoftReset = DummySoftReset; } + if (ChangeWindow == nullptr) + { + UnloadPlugin(); + return false; + } + if (DrawScreen == nullptr) + { + DrawScreen = DummyDrawScreen; + } + if (InitiateGFX == nullptr) + { + UnloadPlugin(); + return false; + } + if (MoveScreen == nullptr) + { + MoveScreen = DummyMoveScreen; + } + if (ProcessDList == nullptr) + { + UnloadPlugin(); + return false; + } + if (UpdateScreen == nullptr) + { + UnloadPlugin(); + return false; + } + if (ViStatusChanged == nullptr) + { + ViStatusChanged = DummyViStatusChanged; + } + if (ViWidthChanged == nullptr) + { + ViWidthChanged = DummyViWidthChanged; + } + if (SoftReset == nullptr) + { + SoftReset = DummySoftReset; + } if (m_PluginInfo.Version >= 0x0103) { @@ -80,14 +112,30 @@ bool CGfxPlugin::LoadFunctions(void) LoadFunction(GetDebugInfo); _LoadFunction("InitiateGFXDebugger", InitiateDebugger); - if (ProcessRDPList == nullptr) { UnloadPlugin(); return false; } - if (CaptureScreen == nullptr) { UnloadPlugin(); return false; } - if (ShowCFB == nullptr) { UnloadPlugin(); return false; } + if (ProcessRDPList == nullptr) + { + UnloadPlugin(); + return false; + } + if (CaptureScreen == nullptr) + { + UnloadPlugin(); + return false; + } + if (ShowCFB == nullptr) + { + UnloadPlugin(); + return false; + } } if (m_PluginInfo.Version >= 0x0104) { - if (PluginOpened == nullptr) { UnloadPlugin(); return false; } + if (PluginOpened == nullptr) + { + UnloadPlugin(); + return false; + } } if (GetDebugInfo != nullptr) @@ -113,14 +161,14 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) typedef struct { - void * hWnd; // Render window - void * hStatusBar; // If render window does not have a status bar then this is NULL + void * hWnd; // Render window + void * hStatusBar; // If render window does not have a status bar then this is NULL - int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary // eg. the first 8 bytes are stored like this: // 4 3 2 1 8 7 6 5 - uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) + uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) // This will be in the same memory format as the rest of the memory uint8_t * RDRAM; uint8_t * DMEM; @@ -152,14 +200,14 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) uint32_t * VI__X_SCALE_REG; uint32_t * VI__Y_SCALE_REG; - void(CALL *CheckInterrupts)(void); + void(CALL * CheckInterrupts)(void); #ifdef ANDROID - void(CALL *SwapBuffers)(void); + void(CALL * SwapBuffers)(void); #endif } GFX_INFO; // Get function from DLL - int32_t(CALL *InitiateGFX)(GFX_INFO Gfx_Info); + int32_t(CALL * InitiateGFX)(GFX_INFO Gfx_Info); _LoadFunction("InitiateGFX", InitiateGFX); if (InitiateGFX == nullptr) { @@ -167,7 +215,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) return false; } - GFX_INFO Info = { 0 }; + GFX_INFO Info = {0}; Info.MemoryBswaped = true; #if defined(ANDROID) || defined(__ANDROID__) @@ -267,13 +315,10 @@ void CGfxPlugin::UnloadPluginDetails(void) } memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); - // CaptureScreen = nullptr; ChangeWindow = nullptr; GetDebugInfo = nullptr; DrawScreen = nullptr; DrawStatus = nullptr; - // FrameBufferRead = nullptr; - // FrameBufferWrite = nullptr; InitiateDebugger = nullptr; MoveScreen = nullptr; ProcessDList = nullptr; diff --git a/Source/Project64-core/Plugins/GFXPlugin.h b/Source/Project64-core/Plugins/GFXPlugin.h index 8922ace24..c016a997c 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.h +++ b/Source/Project64-core/Plugins/GFXPlugin.h @@ -8,34 +8,34 @@ class CGfxPlugin : public CPlugin // Menu // Items should have an ID between 5101 and 5200 void * hGFXMenu; - void(CALL *ProcessMenuItem)(int32_t ID); + void(CALL * ProcessMenuItem)(int32_t ID); // Breakpoints int32_t UseBPoints; char BPPanelName[20]; - void(CALL *Add_BPoint) (void); - void(CALL *CreateBPPanel) (void * hDlg, void * rcBox); - void(CALL *HideBPPanel) (void); - void(CALL *PaintBPPanel) (void * ps); - void(CALL *ShowBPPanel) (void); - void(CALL *RefreshBpoints) (void * hList); - void(CALL *RemoveBpoint) (void * hList, int32_t index); - void(CALL *RemoveAllBpoint) (void); + void(CALL * Add_BPoint)(void); + void(CALL * CreateBPPanel)(void * hDlg, void * rcBox); + void(CALL * HideBPPanel)(void); + void(CALL * PaintBPPanel)(void * ps); + void(CALL * ShowBPPanel)(void); + void(CALL * RefreshBpoints)(void * hList); + void(CALL * RemoveBpoint)(void * hList, int32_t index); + void(CALL * RemoveAllBpoint)(void); // GFX command window - void(CALL *Enter_GFX_Commands_Window)(void); + void(CALL * Enter_GFX_Commands_Window)(void); } GFXDEBUG_INFO; typedef struct { - void(CALL *UpdateBreakPoints)(void); - void(CALL *UpdateMemory)(void); - void(CALL *UpdateR4300iRegisters)(void); - void(CALL *Enter_BPoint_Window)(void); - void(CALL *Enter_R4300i_Commands_Window)(void); - void(CALL *Enter_R4300i_Register_Window)(void); - void(CALL *Enter_RSP_Commands_Window)(void); - void(CALL *Enter_Memory_Window)(void); + void(CALL * UpdateBreakPoints)(void); + void(CALL * UpdateMemory)(void); + void(CALL * UpdateR4300iRegisters)(void); + void(CALL * Enter_BPoint_Window)(void); + void(CALL * Enter_R4300i_Commands_Window)(void); + void(CALL * Enter_R4300i_Register_Window)(void); + void(CALL * Enter_RSP_Commands_Window)(void); + void(CALL * Enter_Memory_Window)(void); } DEBUG_INFO; public: @@ -45,51 +45,73 @@ public: bool LoadFunctions(void); bool Initiate(CN64System * System, RenderWindow * Window); - void(CALL *CaptureScreen) (const char *); - void(CALL *ChangeWindow) (void); - void(CALL *DrawScreen) (void); - void(CALL *DrawStatus) (const char * lpString, int32_t RightAlign); - void(CALL *MoveScreen) (int32_t xpos, int32_t ypos); - void(CALL *ProcessDList) (void); - void(CALL *ProcessRDPList) (void); - void(CALL *ShowCFB) (void); - void(CALL *UpdateScreen) (void); - void(CALL *ViStatusChanged) (void); - void(CALL *ViWidthChanged) (void); - void(CALL *SoftReset) (void); + void(CALL * CaptureScreen)(const char *); + void(CALL * ChangeWindow)(void); + void(CALL * DrawScreen)(void); + void(CALL * DrawStatus)(const char * lpString, int32_t RightAlign); + void(CALL * MoveScreen)(int32_t xpos, int32_t ypos); + void(CALL * ProcessDList)(void); + void(CALL * ProcessRDPList)(void); + void(CALL * ShowCFB)(void); + void(CALL * UpdateScreen)(void); + void(CALL * ViStatusChanged)(void); + void(CALL * ViWidthChanged)(void); + void(CALL * SoftReset)(void); #ifdef ANDROID - void(CALL *SurfaceCreated) (void); - void(CALL *SurfaceChanged) (int w, int h); + void(CALL * SurfaceCreated)(void); + void(CALL * SurfaceChanged)(int w, int h); #endif // ROM browser void *(CALL * GetRomBrowserMenu)(void); // Items should have an ID between 4101 and 4200 void(CALL * OnRomBrowserMenuItem)(int32_t MenuID, void * hParent, uint8_t * HEADER); - void * GetDebugMenu(void) { return m_GFXDebug.hGFXMenu; } + void * GetDebugMenu(void) + { + return m_GFXDebug.hGFXMenu; + } void ProcessMenuItem(int32_t id); private: - CGfxPlugin(const CGfxPlugin&); - CGfxPlugin& operator=(const CGfxPlugin&); + CGfxPlugin(const CGfxPlugin &); + CGfxPlugin & operator=(const CGfxPlugin &); - virtual int32_t GetDefaultSettingStartRange() const { return FirstGfxDefaultSet; } - virtual int32_t GetSettingStartRange() const { return FirstGfxSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_GFX; } + virtual int32_t GetDefaultSettingStartRange() const + { + return FirstGfxDefaultSet; + } + virtual int32_t GetSettingStartRange() const + { + return FirstGfxSettings; + } + PLUGIN_TYPE type() + { + return PLUGIN_TYPE_VIDEO; + } void UnloadPluginDetails(void); GFXDEBUG_INFO m_GFXDebug; - void(CALL *GetDebugInfo) (GFXDEBUG_INFO * GFXDebugInfo); - void(CALL *InitiateDebugger)(DEBUG_INFO DebugInfo); + void(CALL * GetDebugInfo)(GFXDEBUG_INFO * GFXDebugInfo); + void(CALL * InitiateDebugger)(DEBUG_INFO DebugInfo); #ifdef ANDROID static void SwapBuffers(void); #endif - static void CALL DummyDrawScreen(void) {} - static void CALL DummyMoveScreen(int32_t /*xpos*/, int32_t /*ypos*/) {} - static void CALL DummyViStatusChanged(void) {} - static void CALL DummyViWidthChanged(void) {} - static void CALL DummySoftReset(void) {} + static void CALL DummyDrawScreen(void) + { + } + static void CALL DummyMoveScreen(int32_t /*xpos*/, int32_t /*ypos*/) + { + } + static void CALL DummyViStatusChanged(void) + { + } + static void CALL DummyViWidthChanged(void) + { + } + static void CALL DummySoftReset(void) + { + } }; \ No newline at end of file diff --git a/Source/Project64-core/Plugins/Plugin.cpp b/Source/Project64-core/Plugins/Plugin.cpp index b3f27bec3..b2e8352bd 100644 --- a/Source/Project64-core/Plugins/Plugin.cpp +++ b/Source/Project64-core/Plugins/Plugin.cpp @@ -1,14 +1,15 @@ #include "stdafx.h" -#include -#include -#include + #include +#include +#include +#include CPlugins::CPlugins(SettingID PluginDirSetting, bool SyncPlugins) : m_MainWindow(nullptr), m_SyncWindow(nullptr), m_PluginDirSetting(PluginDirSetting), - m_PluginDir(g_Settings->LoadStringVal(PluginDirSetting)), + m_PluginDir(CPath(g_Settings->LoadStringVal(PluginDirSetting)).NormalizePath(CPath(CPath::MODULE_DIRECTORY))), m_Gfx(nullptr), m_Audio(nullptr), m_RSP(nullptr), @@ -63,12 +64,12 @@ void CPlugins::PluginChanged(CPlugins * _this) bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0; bool bRspChange = _stricmp(_this->m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; bool bContChange = _stricmp(_this->m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; - bool bDirChange = _stricmp(_this->m_PluginDir.c_str(), g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str()) != 0; + bool bDirChange = _stricmp(_this->m_PluginDir, CPath(g_Settings->LoadStringVal(_this->m_PluginDirSetting)).NormalizePath(CPath(CPath::MODULE_DIRECTORY))) != 0; WriteTrace(TracePlugins, TraceVerbose, "m_GfxFile: \"%s\" Game_Plugin_Gfx: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bGfxChange ? "true" : "false"); - WriteTrace(TracePlugins, TraceVerbose, "m_AudioFile: \"%s\" Game_Plugin_Audio: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bAudioChange ? "true" : "false"); - WriteTrace(TracePlugins, TraceVerbose, "m_RSPFile: \"%s\" Game_Plugin_RSP: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bRspChange ? "true" : "false"); - WriteTrace(TracePlugins, TraceVerbose, "m_ControlFile: \"%s\" Game_Plugin_Controller: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bContChange ? "true" : "false"); - WriteTrace(TracePlugins, TraceVerbose, "m_PluginDir: \"%s\" m_PluginDirSetting: \"%s\" changed: %s", _this->m_PluginDir.c_str(), g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str(), bDirChange ? "true" : "false"); + WriteTrace(TracePlugins, TraceVerbose, "m_AudioFile: \"%s\" Game_Plugin_Audio: \"%s\" changed: %s", _this->m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str(), bAudioChange ? "true" : "false"); + WriteTrace(TracePlugins, TraceVerbose, "m_RSPFile: \"%s\" Game_Plugin_RSP: \"%s\" changed: %s", _this->m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str(), bRspChange ? "true" : "false"); + WriteTrace(TracePlugins, TraceVerbose, "m_ControlFile: \"%s\" Game_Plugin_Controller: \"%s\" changed: %s", _this->m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str(), bContChange ? "true" : "false"); + WriteTrace(TracePlugins, TraceVerbose, "m_PluginDir: \"%s\" m_PluginDirSetting: \"%s\" changed: %s", (const char *)_this->m_PluginDir, g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str(), bDirChange ? "true" : "false"); if (bDirChange) { WriteTrace(TracePlugins, TraceDebug, "Plugin directory changed"); @@ -81,10 +82,22 @@ void CPlugins::PluginChanged(CPlugins * _this) if (bGfxChange || bAudioChange || bRspChange || bContChange) { - if (bGfxChange) { WriteTrace(TracePlugins, TraceDebug, "GFX plugin changed"); } - if (bAudioChange) { WriteTrace(TracePlugins, TraceDebug, "Audio plugin changed"); } - if (bRspChange) { WriteTrace(TracePlugins, TraceDebug, "RSP plugin changed"); } - if (bContChange) { WriteTrace(TracePlugins, TraceDebug, "Controller plugin changed"); } + if (bGfxChange) + { + WriteTrace(TracePlugins, TraceDebug, "GFX plugin changed"); + } + if (bAudioChange) + { + WriteTrace(TracePlugins, TraceDebug, "Audio plugin changed"); + } + if (bRspChange) + { + WriteTrace(TracePlugins, TraceDebug, "RSP plugin changed"); + } + if (bContChange) + { + WriteTrace(TracePlugins, TraceDebug, "Controller plugin changed"); + } if (g_Settings->LoadBool(GameRunning_CPU_Running)) { // Ensure that base system actually exists before we go triggering the event @@ -102,7 +115,7 @@ void CPlugins::PluginChanged(CPlugins * _this) } template -static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type, bool IsCopy) +static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type *& plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type, bool IsCopy) { if (plugin != nullptr) { @@ -141,10 +154,10 @@ void CPlugins::CreatePlugins(void) { WriteTrace(TracePlugins, TraceInfo, "Start"); - LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir.c_str(), m_GfxFile, TraceGFXPlugin, "GFX", m_SyncPlugins); - LoadPlugin(Game_Plugin_Audio, Plugin_AUDIO_CurVer, m_Audio, m_PluginDir.c_str(), m_AudioFile, TraceAudioPlugin, "Audio", m_SyncPlugins); - LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir.c_str(), m_RSPFile, TraceRSPPlugin, "RSP", m_SyncPlugins); - LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir.c_str(), m_ControlFile, TraceControllerPlugin, "Control", m_SyncPlugins); + LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir, m_GfxFile, TraceGFXPlugin, "GFX", m_SyncPlugins); + LoadPlugin(Game_Plugin_Audio, Plugin_AUDIO_CurVer, m_Audio, m_PluginDir, m_AudioFile, TraceAudioPlugin, "Audio", m_SyncPlugins); + LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir, m_RSPFile, TraceRSPPlugin, "RSP", m_SyncPlugins); + LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir, m_ControlFile, TraceControllerPlugin, "Control", m_SyncPlugins); // Enable debugger if (m_RSP != nullptr && m_RSP->EnableDebugging) @@ -276,22 +289,46 @@ bool CPlugins::Initiate(CN64System * System) { WriteTrace(TracePlugins, TraceDebug, "Start"); // Check to make sure we have the plugin available to be used - if (m_Gfx == nullptr) { return false; } - if (m_Audio == nullptr) { return false; } - if (m_RSP == nullptr) { return false; } - if (m_Control == nullptr) { return false; } + if (m_Gfx == nullptr) + { + return false; + } + if (m_Audio == nullptr) + { + return false; + } + if (m_RSP == nullptr) + { + return false; + } + if (m_Control == nullptr) + { + return false; + } WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate starting"); - if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate done"); WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate starting"); - if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate done"); WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate starting"); - if (!m_Control->Initiate(System, m_MainWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate done"); WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate starting"); - if (!m_RSP->Initiate(this, System)) { return false; } + if (!m_RSP->Initiate(this, System)) + { + return false; + } WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate done"); WriteTrace(TracePlugins, TraceDebug, "Done"); m_initilized = true; @@ -322,47 +359,71 @@ bool CPlugins::Reset(CN64System * System) bRspChange = true; } - if (bGfxChange) { DestroyGfxPlugin(); } - if (bAudioChange) { DestroyAudioPlugin(); } - if (bRspChange) { DestroyRspPlugin(); } - if (bContChange) { DestroyControlPlugin(); } + if (bGfxChange) + { + DestroyGfxPlugin(); + } + if (bAudioChange) + { + DestroyAudioPlugin(); + } + if (bRspChange) + { + DestroyRspPlugin(); + } + if (bContChange) + { + DestroyControlPlugin(); + } CreatePlugins(); if (m_Gfx && bGfxChange) { WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate starting"); - if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceGFXPlugin, TraceDebug, "GFX initiate done"); } if (m_Audio && bAudioChange) { WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate starting"); - if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate done"); } if (m_Control && bContChange) { WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate starting"); - if (!m_Control->Initiate(System, m_MainWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate done"); } if (m_RSP && bRspChange) { WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate starting"); - if (!m_RSP->Initiate(this, System)) { return false; } + if (!m_RSP->Initiate(this, System)) + { + return false; + } WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate done"); } - if (System) - { - System->RefreshSyncToAudio(); - } + if (System) + { + System->RefreshSyncToAudio(); + } WriteTrace(TracePlugins, TraceDebug, "Done"); return true; } -void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) +void CPlugins::ConfigPlugin(void * hParent, PLUGIN_TYPE Type) { if (g_BaseSystem) { @@ -372,7 +433,10 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) switch (Type) { case PLUGIN_TYPE_RSP: - if (m_RSP == nullptr || m_RSP->DllConfig == nullptr) { break; } + if (m_RSP == nullptr || m_RSP->DllConfig == nullptr) + { + break; + } if (!m_RSP->Initialized()) { if (!m_RSP->Initiate(this, nullptr)) @@ -382,8 +446,11 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) } m_RSP->DllConfig(hParent); break; - case PLUGIN_TYPE_GFX: - if (m_Gfx == nullptr || m_Gfx->DllConfig == nullptr) { break; } + case PLUGIN_TYPE_VIDEO: + if (m_Gfx == nullptr || m_Gfx->DllConfig == nullptr) + { + break; + } if (!m_Gfx->Initialized()) { if (!m_Gfx->Initiate(nullptr, m_MainWindow)) @@ -394,7 +461,10 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) m_Gfx->DllConfig(hParent); break; case PLUGIN_TYPE_AUDIO: - if (m_Audio == nullptr || m_Audio->DllConfig == nullptr) { break; } + if (m_Audio == nullptr || m_Audio->DllConfig == nullptr) + { + break; + } if (!m_Audio->Initialized()) { if (!m_Audio->Initiate(nullptr, m_MainWindow)) @@ -409,7 +479,10 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) } break; case PLUGIN_TYPE_CONTROLLER: - if (m_Control == nullptr || m_Control->DllConfig == nullptr) { break; } + if (m_Control == nullptr || m_Control->DllConfig == nullptr) + { + break; + } if (!m_Control->Initialized()) { if (!m_Control->Initiate(nullptr, m_MainWindow)) @@ -441,7 +514,7 @@ void DummyFunction(void) bool CPlugins::CopyPlugins(const stdstr & DstDir) const { // Copy GFX plugin - CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); + CPath srcGfxPlugin((const char *)m_PluginDir, g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); dstGfxPlugin.SetName(stdstr_f("%s-copy", dstGfxPlugin.GetName().c_str()).c_str()); @@ -456,7 +529,7 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const } // Copy m_Audio plugin - CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); + CPath srcAudioPlugin((const char *)m_PluginDir, g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); dstAudioPlugin.SetName(stdstr_f("%s-copy", dstAudioPlugin.GetName().c_str()).c_str()); if (!dstAudioPlugin.DirectoryExists()) @@ -468,7 +541,7 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const return false; } // Copy RSP plugin - CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); + CPath srcRSPPlugin((const char *)m_PluginDir, g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); dstRSPPlugin.SetName(stdstr_f("%s-copy", dstRSPPlugin.GetName().c_str()).c_str()); if (!dstRSPPlugin.DirectoryExists()) @@ -481,7 +554,7 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const } // Copy Controller plugin - CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); + CPath srcContPlugin((const char *)m_PluginDir, g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); dstContPlugin.SetName(stdstr_f("%s-copy", dstContPlugin.GetName().c_str()).c_str()); if (!dstContPlugin.DirectoryExists()) diff --git a/Source/Project64-core/Plugins/Plugin.h b/Source/Project64-core/Plugins/Plugin.h index 213e429c7..0641ed967 100644 --- a/Source/Project64-core/Plugins/Plugin.h +++ b/Source/Project64-core/Plugins/Plugin.h @@ -1,100 +1,80 @@ #pragma once -#include +#include #include #include - -#ifndef PLUGIN_INFO_STRUCT -#define PLUGIN_INFO_STRUCT - -typedef struct -{ - uint16_t Version; // Should be set to 1 - uint16_t Type; // Set to PLUGIN_TYPE_GFX - char Name[100]; // Name of the DLL - - // If DLL supports these memory options then set them to TRUE or FALSE if it does not support it - int32_t NormalMemory; // A normal BYTE array - int32_t MemoryBswaped; // A normal BYTE array where the memory has been pre-bswap'd on a DWORD (32-bit) boundary -} PLUGIN_INFO; - -#endif +#include +#include // Enums enum SETTING_DATA_TYPE { - Data_DWORD_General = 0, // A uint32_t setting used anywhere - Data_String_General = 1, // A string setting used anywhere - Data_DWORD_Game = 2, // A uint32_t associated with the current game - Data_String_Game = 3, // A string associated with the current game - Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the ROM database - Data_String_RDB = 5, // A string associated with the current game in the ROM database - Data_DWORD_RDB_Setting = 6, // A uint32_t read from the ROM database, with config file + Data_DWORD_General = 0, // A uint32_t setting used anywhere + Data_String_General = 1, // A string setting used anywhere + Data_DWORD_Game = 2, // A uint32_t associated with the current game + Data_String_Game = 3, // A string associated with the current game + Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the ROM database + Data_String_RDB = 5, // A string associated with the current game in the ROM database + Data_DWORD_RDB_Setting = 6, // A uint32_t read from the ROM database, with config file Data_String_RDB_Setting = 7, // A string read from the ROM database, with config file }; typedef struct { - uint32_t dwSize; - int32_t DefaultStartRange; - int32_t SettingStartRange; - int32_t MaximumSettings; - int32_t NoDefault; - int32_t DefaultLocation; + uint32_t dwSize; + int32_t DefaultStartRange; + int32_t SettingStartRange; + int32_t MaximumSettings; + int32_t NoDefault; + int32_t DefaultLocation; void * handle; - uint32_t(*GetSetting) (void * handle, int32_t ID); - const char * (*GetSettingSz) (void * handle, int32_t ID, char * Buffer, int32_t BufferLen); - void(*SetSetting) (void * handle, int32_t ID, uint32_t Value); - void(*SetSettingSz) (void * handle, int32_t ID, const char * Value); - void(*RegisterSetting) (void * handle, int32_t ID, int32_t DefaultID, SettingDataType Type, - SettingType Location, const char * Category, const char * DefaultStr, uint32_t Value); - void(*UseUnregisteredSetting) (int32_t ID); + uint32_t (*GetSetting)(void * handle, int32_t ID); + const char * (*GetSettingSz)(void * handle, int32_t ID, char * Buffer, int32_t BufferLen); + void (*SetSetting)(void * handle, int32_t ID, uint32_t Value); + void (*SetSettingSz)(void * handle, int32_t ID, const char * Value); + void (*RegisterSetting)(void * handle, int32_t ID, int32_t DefaultID, SettingDataType Type, + SettingType Location, const char * Category, const char * DefaultStr, uint32_t Value); + void (*UseUnregisteredSetting)(int32_t ID); } PLUGIN_SETTINGS; typedef struct { - uint32_t(*FindSystemSettingId) (void * handle, const char * Name); + uint32_t (*FindSystemSettingId)(void * handle, const char * Name); } PLUGIN_SETTINGS2; typedef struct { - void(*FlushSettings) (void * handle); + void (*FlushSettings)(void * handle); } PLUGIN_SETTINGS3; typedef struct { - typedef void(*SettingChangedFunc)(void *); + typedef void (*SettingChangedFunc)(void *); - void(*RegisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); - void(*UnregisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); + void (*RegisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); + void (*UnregisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); } PLUGIN_SETTINGS_NOTIFICATION; typedef struct { - void(*DisplayError)(const char * Message); - void(*FatalError)(const char * Message); - void(*DisplayMessage)(int DisplayTime, const char * Message); - void(*DisplayMessage2)(const char * Message); - void(*BreakPoint)(const char * FileName, int32_t LineNumber); + void (*DisplayError)(const char * Message); + void (*FatalError)(const char * Message); + void (*DisplayMessage)(int DisplayTime, const char * Message); + void (*DisplayMessage2)(const char * Message); + void (*BreakPoint)(const char * FileName, int32_t LineNumber); } PLUGIN_NOTIFICATION; -enum PLUGIN_TYPE -{ - PLUGIN_TYPE_NONE = 0, - PLUGIN_TYPE_RSP = 1, - PLUGIN_TYPE_GFX = 2, - PLUGIN_TYPE_AUDIO = 3, - PLUGIN_TYPE_CONTROLLER = 4, -}; - class CSettings; -class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin; +class CGfxPlugin; +class CAudioPlugin; +class CRSP_Plugin; +class CControl_Plugin; class CN64System; class CPlugins; #if defined(_WIN32) #include #else -#define __interface struct +#define __interface struct #endif __interface RenderWindow @@ -130,20 +110,41 @@ public: bool ResetInUiThread(CN64System * System); void GameReset(void); - inline CGfxPlugin * Gfx(void) const { return m_Gfx; } - inline CAudioPlugin * Audio(void) const { return m_Audio; } - inline CRSP_Plugin * RSP(void) const { return m_RSP; } - inline CControl_Plugin * Control(void) const { return m_Control; } + inline CGfxPlugin * Gfx(void) const + { + return m_Gfx; + } + inline CAudioPlugin * Audio(void) const + { + return m_Audio; + } + inline CRSP_Plugin * RSP(void) const + { + return m_RSP; + } + inline CControl_Plugin * Control(void) const + { + return m_Control; + } - inline RenderWindow * MainWindow(void) const { return m_MainWindow; } - inline RenderWindow * SyncWindow(void) const { return m_SyncWindow; } + inline RenderWindow * MainWindow(void) const + { + return m_MainWindow; + } + inline RenderWindow * SyncWindow(void) const + { + return m_SyncWindow; + } - inline bool initilized(void) const { return m_initilized; } + inline bool initilized(void) const + { + return m_initilized; + } private: CPlugins(void); - CPlugins(const CPlugins&); - CPlugins& operator=(const CPlugins&); + CPlugins(const CPlugins &); + CPlugins & operator=(const CPlugins &); void DestroyGfxPlugin(void); void DestroyAudioPlugin(void); @@ -156,12 +157,12 @@ private: RenderWindow * m_SyncWindow; SettingID m_PluginDirSetting; - stdstr m_PluginDir; + CPath m_PluginDir; // Plugins - CGfxPlugin * m_Gfx; - CAudioPlugin * m_Audio; - CRSP_Plugin * m_RSP; + CGfxPlugin * m_Gfx; + CAudioPlugin * m_Audio; + CRSP_Plugin * m_RSP; CControl_Plugin * m_Control; stdstr m_GfxFile; diff --git a/Source/Project64-core/Plugins/PluginBase.cpp b/Source/Project64-core/Plugins/PluginBase.cpp index 65fece0ae..152d192f0 100644 --- a/Source/Project64-core/Plugins/PluginBase.cpp +++ b/Source/Project64-core/Plugins/PluginBase.cpp @@ -1,20 +1,20 @@ #include "stdafx.h" -#include #include +#include CPlugin::CPlugin() : -DllAbout(nullptr), -DllConfig(nullptr), -CloseDLL(nullptr), -RomOpen(nullptr), -RomClosed(nullptr), -PluginOpened(nullptr), -SetSettingInfo(nullptr), -SetSettingInfo2(nullptr), -SetSettingInfo3(nullptr), -m_LibHandle(nullptr), -m_Initialized(false), -m_RomOpen(false) + DllAbout(nullptr), + DllConfig(nullptr), + CloseDLL(nullptr), + RomOpen(nullptr), + RomClosed(nullptr), + PluginOpened(nullptr), + SetSettingInfo(nullptr), + SetSettingInfo2(nullptr), + SetSettingInfo3(nullptr), + m_LibHandle(nullptr), + m_Initialized(false), + m_RomOpen(false) { memset(&m_PluginInfo, 0, sizeof(m_PluginInfo)); } @@ -46,13 +46,22 @@ bool CPlugin::Load(const char * FileName) } // Get DLL information - void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo); + void(CALL * GetDllInfo)(PLUGIN_INFO * PluginInfo); LoadFunction(GetDllInfo); - if (GetDllInfo == nullptr) { return false; } + if (GetDllInfo == nullptr) + { + return false; + } GetDllInfo(&m_PluginInfo); - if (!ValidPluginVersion(m_PluginInfo)) { return false; } - if (m_PluginInfo.Type != type()) { return false; } + if (!ValidPluginVersion(m_PluginInfo)) + { + return false; + } + if (m_PluginInfo.Type != type()) + { + return false; + } LoadFunction(CloseDLL); LoadFunction(RomOpen); @@ -79,8 +88,8 @@ bool CPlugin::Load(const char * FileName) { WriteTrace(PluginTraceType(), TraceDebug, "Found SetSettingNotificationInfo"); PLUGIN_SETTINGS_NOTIFICATION info; - info.RegisterChangeCB = (void(*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sRegisterChangeCB; - info.UnregisterChangeCB = (void(*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sUnregisterChangeCB; + info.RegisterChangeCB = (void (*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sRegisterChangeCB; + info.UnregisterChangeCB = (void (*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sUnregisterChangeCB; SetSettingNotificationInfo(&info); } @@ -89,7 +98,7 @@ bool CPlugin::Load(const char * FileName) { WriteTrace(PluginTraceType(), TraceDebug, "Found SetSettingInfo3"); PLUGIN_SETTINGS3 info; - info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings; + info.FlushSettings = (void (*)(void * handle))CSettings::FlushSettings; SetSettingInfo3(&info); } @@ -114,11 +123,11 @@ bool CPlugin::Load(const char * FileName) info.NoDefault = Default_None; info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile; info.handle = g_Settings; - info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting; - info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting; - info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz; - info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting; - info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz; + info.RegisterSetting = (void (*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t)) & CSettings::RegisterSetting; + info.GetSetting = (uint32_t(*)(void *, int)) & CSettings::GetSetting; + info.GetSettingSz = (const char * (*)(void *, int, char *, int)) & CSettings::GetSettingSz; + info.SetSetting = (void (*)(void *, int, uint32_t)) & CSettings::SetSetting; + info.SetSettingSz = (void (*)(void *, int, const char *)) & CSettings::SetSettingSz; info.UseUnregisteredSetting = nullptr; SetSettingInfo(&info); @@ -154,7 +163,7 @@ void CPlugin::RomOpened(RenderWindow * Render) } #ifdef ANDROID - if (m_PluginInfo.Type == PLUGIN_TYPE_GFX) + if (m_PluginInfo.Type == PLUGIN_TYPE_VIDEO) { WriteTrace(PluginTraceType(), TraceDebug, "Render = %p", Render); if (Render != nullptr) @@ -186,7 +195,7 @@ void CPlugin::RomClose(RenderWindow * Render) } #ifdef ANDROID - if (m_PluginInfo.Type == PLUGIN_TYPE_GFX) + if (m_PluginInfo.Type == PLUGIN_TYPE_VIDEO) { WriteTrace(PluginTraceType(), TraceDebug, "Render = %p", Render); if (Render != NULL) @@ -220,10 +229,10 @@ void CPlugin::Close(RenderWindow * Render) WriteTrace(PluginTraceType(), TraceDebug, "(%s): Start", PluginType()); RomClose(Render); m_Initialized = false; - if (CloseDLL != nullptr) - { - CloseDLL(); - } + if (CloseDLL != nullptr) + { + CloseDLL(); + } WriteTrace(PluginTraceType(), TraceDebug, "(%s): Done", PluginType()); } @@ -258,7 +267,7 @@ const char * CPlugin::PluginType() const switch (m_PluginInfo.Type) { case PLUGIN_TYPE_RSP: return "RSP"; - case PLUGIN_TYPE_GFX: return "GFX"; + case PLUGIN_TYPE_VIDEO: return "Video"; case PLUGIN_TYPE_AUDIO: return "Audio"; case PLUGIN_TYPE_CONTROLLER: return "Control"; } @@ -270,7 +279,7 @@ TraceModuleProject64 CPlugin::PluginTraceType() const switch (m_PluginInfo.Type) { case PLUGIN_TYPE_RSP: return TraceRSPPlugin; - case PLUGIN_TYPE_GFX: return TraceGFXPlugin; + case PLUGIN_TYPE_VIDEO: return TraceGFXPlugin; case PLUGIN_TYPE_AUDIO: return TraceAudioPlugin; case PLUGIN_TYPE_CONTROLLER: return TraceControllerPlugin; } @@ -282,28 +291,64 @@ bool CPlugin::ValidPluginVersion(PLUGIN_INFO & PluginInfo) switch (PluginInfo.Type) { case PLUGIN_TYPE_RSP: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0001) { return true; } - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - if (PluginInfo.Version == 0x0103) { return true; } + if (PluginInfo.Version == 0x0001) + { + return true; + } + if (PluginInfo.Version == 0x0100) + { + return true; + } + if (PluginInfo.Version == 0x0101) + { + return true; + } + if (PluginInfo.Version == 0x0102) + { + return true; + } + if (PluginInfo.Version == 0x0103) + { + return true; + } break; - case PLUGIN_TYPE_GFX: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0102) { return true; } - if (PluginInfo.Version == 0x0103) { return true; } - if (PluginInfo.Version == 0x0104) { return true; } + case PLUGIN_TYPE_VIDEO: + if (PluginInfo.Version == 0x0102) + { + return true; + } + if (PluginInfo.Version == 0x0103) + { + return true; + } + if (PluginInfo.Version == 0x0104) + { + return true; + } break; case PLUGIN_TYPE_AUDIO: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } + if (PluginInfo.Version == 0x0101) + { + return true; + } + if (PluginInfo.Version == 0x0102) + { + return true; + } break; case PLUGIN_TYPE_CONTROLLER: - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } + if (PluginInfo.Version == 0x0100) + { + return true; + } + if (PluginInfo.Version == 0x0101) + { + return true; + } + if (PluginInfo.Version == 0x0102) + { + return true; + } break; } return false; diff --git a/Source/Project64-core/Plugins/PluginBase.h b/Source/Project64-core/Plugins/PluginBase.h index 48babbd25..6f4bc7d4c 100644 --- a/Source/Project64-core/Plugins/PluginBase.h +++ b/Source/Project64-core/Plugins/PluginBase.h @@ -1,24 +1,25 @@ #pragma once +#include +#include #include #include -#include -#include - -#if defined(_WIN32) -#define CALL __cdecl -#else -#define CALL -#endif +#include class CPlugin : - private CDebugSettings + protected CDebugSettings { public: CPlugin(); virtual ~CPlugin(); - inline const char * PluginName() const { return m_PluginInfo.Name; } - inline bool Initialized() { return m_Initialized; } + inline const char * PluginName() const + { + return m_PluginInfo.Name; + } + inline bool Initialized() + { + return m_Initialized; + } virtual int32_t GetDefaultSettingStartRange() const = 0; virtual int32_t GetSettingStartRange() const = 0; @@ -30,8 +31,8 @@ public: void GameReset(RenderWindow * Render); void Close(RenderWindow * Render); - void(CALL *DllAbout) (void * hWnd); - void(CALL *DllConfig) (void * hParent); + void(CALL * DllAbout)(void * hWnd); + void(CALL * DllConfig)(void * hParent); static bool ValidPluginVersion(PLUGIN_INFO & PluginInfo); @@ -43,15 +44,15 @@ protected: virtual PLUGIN_TYPE type() = 0; virtual bool LoadFunctions(void) = 0; - void(CALL *CloseDLL) (void); - void(CALL *RomOpen) (void); - void(CALL *RomClosed) (void); - void(CALL *PluginOpened)(void); - void(CALL *SetSettingInfo)(PLUGIN_SETTINGS *); - void(CALL *SetSettingInfo2)(PLUGIN_SETTINGS2 *); - void(CALL *SetSettingInfo3)(PLUGIN_SETTINGS3 *); - void(CALL *SetSettingNotificationInfo)(PLUGIN_SETTINGS_NOTIFICATION *); - void(CALL *SetPluginNotification)(PLUGIN_NOTIFICATION *); + void(CALL * CloseDLL)(void); + void(CALL * RomOpen)(void); + void(CALL * RomClosed)(void); + void(CALL * PluginOpened)(void); + void(CALL * SetSettingInfo)(PLUGIN_SETTINGS *); + void(CALL * SetSettingInfo2)(PLUGIN_SETTINGS2 *); + void(CALL * SetSettingInfo3)(PLUGIN_SETTINGS3 *); + void(CALL * SetSettingNotificationInfo)(PLUGIN_SETTINGS_NOTIFICATION *); + void(CALL * SetPluginNotification)(PLUGIN_NOTIFICATION *); DynLibHandle m_LibHandle; bool m_Initialized, m_RomOpen; @@ -66,7 +67,7 @@ protected: // Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments // i.e. _LoadFunction("CloseDLL", CloseDLL); #define LoadFunction(functionName) _LoadFunctionVoid(#functionName, (void **)&functionName) -#define _LoadFunction(functionName,function) _LoadFunctionVoid(functionName, (void **)&function) +#define _LoadFunction(functionName, function) _LoadFunctionVoid(functionName, (void **)&function) private: static void DisplayError(const char * Message); diff --git a/Source/Project64-core/Project64-core.vcxproj b/Source/Project64-core/Project64-core.vcxproj index 531a2d147..7de2d390e 100644 --- a/Source/Project64-core/Project64-core.vcxproj +++ b/Source/Project64-core/Project64-core.vcxproj @@ -132,8 +132,11 @@ + + + diff --git a/Source/Project64-core/Project64-core.vcxproj.filters b/Source/Project64-core/Project64-core.vcxproj.filters index b34b4cb90..e73b9e4ce 100644 --- a/Source/Project64-core/Project64-core.vcxproj.filters +++ b/Source/Project64-core/Project64-core.vcxproj.filters @@ -677,6 +677,15 @@ Header Files\Plugin Spec + + Header Files\Plugin Spec + + + Header Files\Plugin Spec + + + Header Files\Plugin Spec + diff --git a/Source/Project64-input/CProject64Input.cpp b/Source/Project64-input/CProject64Input.cpp index 5569e0e1f..def108760 100644 --- a/Source/Project64-input/CProject64Input.cpp +++ b/Source/Project64-input/CProject64Input.cpp @@ -8,7 +8,8 @@ CProject64Input::CProject64Input(HINSTANCE hinst) : m_hinst(hinst), m_Scanning(false), m_DisplayCtrlId(0), - m_iFirstController(-1) + m_iFirstController(-1), + m_MouseLock(false) { memset(m_Controllers, 0, sizeof(m_Controllers)); } @@ -45,11 +46,17 @@ void CProject64Input::InitiateControllers(CONTROL_INFO * ControlInfo) { g_Settings->LoadController(i, m_ControlInfo.Controls[i], m_Controllers[i]); m_DirectInput->MapControllerDevice(m_Controllers[i]); - if (m_ControlInfo.Controls[i].Present != 0 && m_iFirstController < 0) + if (m_ControlInfo.Controls[i].Present != PRESENT_NONE && m_iFirstController < 0) { m_iFirstController = i; } } + + g_Settings->GetControllerMouse(m_N64Mouse); + m_DirectInput->MapControllerDevice(m_N64Mouse); + + g_Settings->LoadShortcuts(m_Shortcuts); + m_DirectInput->MapShortcutDevice(m_Shortcuts); } void CProject64Input::GetKeys(int32_t Control, BUTTONS * Keys) @@ -62,23 +69,53 @@ void CProject64Input::GetKeys(int32_t Control, BUTTONS * Keys) if (Control == m_iFirstController) { m_DirectInput->UpdateDeviceData(); + CheckShortcuts(); } - N64CONTROLLER & Controller = m_Controllers[Control]; - Keys->R_DPAD = m_DirectInput->IsButtonPressed(Controller.R_DPAD); - Keys->L_DPAD = m_DirectInput->IsButtonPressed(Controller.L_DPAD); - Keys->D_DPAD = m_DirectInput->IsButtonPressed(Controller.D_DPAD); - Keys->U_DPAD = m_DirectInput->IsButtonPressed(Controller.U_DPAD); - Keys->START_BUTTON = m_DirectInput->IsButtonPressed(Controller.START_BUTTON); - Keys->Z_TRIG = m_DirectInput->IsButtonPressed(Controller.Z_TRIG); - Keys->B_BUTTON = m_DirectInput->IsButtonPressed(Controller.B_BUTTON); - Keys->A_BUTTON = m_DirectInput->IsButtonPressed(Controller.A_BUTTON); - Keys->R_CBUTTON = m_DirectInput->IsButtonPressed(Controller.R_CBUTTON); - Keys->L_CBUTTON = m_DirectInput->IsButtonPressed(Controller.L_CBUTTON); - Keys->D_CBUTTON = m_DirectInput->IsButtonPressed(Controller.D_CBUTTON); - Keys->U_CBUTTON = m_DirectInput->IsButtonPressed(Controller.U_CBUTTON); - Keys->R_TRIG = m_DirectInput->IsButtonPressed(Controller.R_TRIG); - Keys->L_TRIG = m_DirectInput->IsButtonPressed(Controller.L_TRIG); - m_DirectInput->GetAxis(Controller, Keys); + if (m_ControlInfo.Controls[Control].Present == PRESENT_MOUSE) + { + //Mouse + if (m_MouseLock) + { + LockCursor(); + m_N64Mouse.Sensitivity = m_Controllers[Control].Sensitivity; + Keys->R_DPAD = m_DirectInput->IsButtonPressed(m_N64Mouse.R_DPAD); + Keys->L_DPAD = m_DirectInput->IsButtonPressed(m_N64Mouse.L_DPAD); + Keys->D_DPAD = m_DirectInput->IsButtonPressed(m_N64Mouse.D_DPAD); + Keys->U_DPAD = m_DirectInput->IsButtonPressed(m_N64Mouse.U_DPAD); + Keys->START_BUTTON = m_DirectInput->IsButtonPressed(m_N64Mouse.START_BUTTON); + Keys->Z_TRIG = m_DirectInput->IsButtonPressed(m_N64Mouse.Z_TRIG); + Keys->B_BUTTON = m_DirectInput->IsButtonPressed(m_N64Mouse.B_BUTTON); + Keys->A_BUTTON = m_DirectInput->IsButtonPressed(m_N64Mouse.A_BUTTON); + Keys->R_CBUTTON = m_DirectInput->IsButtonPressed(m_N64Mouse.R_CBUTTON); + Keys->L_CBUTTON = m_DirectInput->IsButtonPressed(m_N64Mouse.L_CBUTTON); + Keys->D_CBUTTON = m_DirectInput->IsButtonPressed(m_N64Mouse.D_CBUTTON); + Keys->U_CBUTTON = m_DirectInput->IsButtonPressed(m_N64Mouse.U_CBUTTON); + Keys->R_TRIG = m_DirectInput->IsButtonPressed(m_N64Mouse.R_TRIG); + Keys->L_TRIG = m_DirectInput->IsButtonPressed(m_N64Mouse.L_TRIG); + m_DirectInput->GetAxis(m_N64Mouse, Keys); + } + } + else + { + //Controller + N64CONTROLLER& Controller = m_Controllers[Control]; + Keys->R_DPAD = m_DirectInput->IsButtonPressed(Controller.R_DPAD); + Keys->L_DPAD = m_DirectInput->IsButtonPressed(Controller.L_DPAD); + Keys->D_DPAD = m_DirectInput->IsButtonPressed(Controller.D_DPAD); + Keys->U_DPAD = m_DirectInput->IsButtonPressed(Controller.U_DPAD); + Keys->START_BUTTON = m_DirectInput->IsButtonPressed(Controller.START_BUTTON); + Keys->Z_TRIG = m_DirectInput->IsButtonPressed(Controller.Z_TRIG); + Keys->B_BUTTON = m_DirectInput->IsButtonPressed(Controller.B_BUTTON); + Keys->A_BUTTON = m_DirectInput->IsButtonPressed(Controller.A_BUTTON); + Keys->R_CBUTTON = m_DirectInput->IsButtonPressed(Controller.R_CBUTTON); + Keys->L_CBUTTON = m_DirectInput->IsButtonPressed(Controller.L_CBUTTON); + Keys->D_CBUTTON = m_DirectInput->IsButtonPressed(Controller.D_CBUTTON); + Keys->U_CBUTTON = m_DirectInput->IsButtonPressed(Controller.U_CBUTTON); + Keys->R_TRIG = m_DirectInput->IsButtonPressed(Controller.R_TRIG); + Keys->L_TRIG = m_DirectInput->IsButtonPressed(Controller.L_TRIG); + m_DirectInput->GetAxis(Controller, Keys); + } + } void CProject64Input::StartScanDevices(int32_t DisplayCtrlId) @@ -141,3 +178,75 @@ bool CProject64Input::ResetController(uint32_t ControlIndex, CONTROL & ControlIn m_DirectInput->MapControllerDevice(Controller); return true; } + +void CProject64Input::CheckShortcuts() +{ + bool isPressed = m_DirectInput->IsButtonPressed(m_Shortcuts.LOCKMOUSE); + if ((isPressed == true) && (m_Shortcuts.LOCKMOUSE_PRESSED == false)) + { + LockMouseSwitch(); + } + m_Shortcuts.LOCKMOUSE_PRESSED = isPressed; +} + +bool CProject64Input::SaveShortcuts() +{ + CGuard guard(m_CS); + + g_Settings->SaveShortcuts(m_Shortcuts); + m_DirectInput->MapShortcutDevice(m_Shortcuts); + return true; +} + +bool CProject64Input::ResetShortcuts(SHORTCUTS& Shortcuts) +{ + g_Settings->ResetShortcuts(Shortcuts); + m_DirectInput->MapShortcutDevice(Shortcuts); + return true; +} + +void CProject64Input::LockMouse() +{ + if (IsMouseUsed() == false) return UnlockMouse(); + if (m_MouseLock == true) return; + PostMessage((HWND)m_ControlInfo.hWnd, WM_HIDE_CUROSR, false, 0); + m_MouseLock = true; +} + +void CProject64Input::UnlockMouse() +{ + if (m_MouseLock == false) return; + PostMessage((HWND)m_ControlInfo.hWnd, WM_HIDE_CUROSR, true, 0); + m_MouseLock = false; +} + +void CProject64Input::LockMouseSwitch() +{ + if (m_MouseLock == true) + { + UnlockMouse(); + } + else + { + LockMouse(); + } +} + +bool CProject64Input::IsMouseUsed() +{ + for (uint32_t i = 0, n = sizeof(m_Controllers) / sizeof(m_Controllers[0]); i < n; i++) + { + if (m_ControlInfo.Controls[i].Present == PRESENT_MOUSE) + { + return true; + } + } + return false; +} + +void CProject64Input::LockCursor() +{ + RECT rect; + GetWindowRect((HWND)m_ControlInfo.hWnd, &rect); + SetCursorPos((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2); +} diff --git a/Source/Project64-input/CProject64Input.h b/Source/Project64-input/CProject64Input.h index 219638211..d1dcf6322 100644 --- a/Source/Project64-input/CProject64Input.h +++ b/Source/Project64-input/CProject64Input.h @@ -2,11 +2,18 @@ #include #include "DirectInput.h" #include "N64Controller.h" +#include "Shortcuts.h" #include #include class CProject64Input { + enum + { + WM_HIDE_CUROSR = WM_USER + 10, + WM_MAKE_FOCUS = WM_USER + 17 + }; + public: CProject64Input(HINSTANCE hinst); ~CProject64Input(); @@ -22,12 +29,21 @@ public: std::wstring ControllerDevices(const N64CONTROLLER & Controller); bool SaveController(uint32_t ControlIndex); bool ResetController(uint32_t ControlIndex, CONTROL & ControlInfo, N64CONTROLLER & Controller); + void CheckShortcuts(); + bool SaveShortcuts(); + bool ResetShortcuts(SHORTCUTS& Shortcuts); + void LockMouse(); + void UnlockMouse(); + void LockMouseSwitch(); + bool IsMouseUsed(); + void LockCursor(); inline HINSTANCE hInst(void) const { return m_hinst; } inline bool IsScanning(void) const { return m_Scanning; } inline int32_t DisplayCtrlId(void) const { return m_DisplayCtrlId; } inline N64CONTROLLER & Controllers(int32_t Controller) { return m_Controllers[Controller]; } inline CONTROL & ControlInfo(int32_t Controller) { return m_ControlInfo.Controls[Controller]; } + inline SHORTCUTS& Shortcuts() { return m_Shortcuts; } private: CProject64Input(); @@ -37,11 +53,14 @@ private: CriticalSection m_CS; CONTROL_INFO m_ControlInfo; N64CONTROLLER m_Controllers[4]; + N64CONTROLLER m_N64Mouse; + SHORTCUTS m_Shortcuts; std::unique_ptr m_DirectInput; HINSTANCE m_hinst; bool m_Scanning; int32_t m_DisplayCtrlId; int32_t m_iFirstController; + bool m_MouseLock; }; extern CProject64Input * g_InputPlugin; diff --git a/Source/Project64-input/DirectInput.cpp b/Source/Project64-input/DirectInput.cpp index 2b4427ba1..9efbf90c7 100644 --- a/Source/Project64-input/DirectInput.cpp +++ b/Source/Project64-input/DirectInput.cpp @@ -90,6 +90,28 @@ void CDirectInput::MapControllerDevice(N64CONTROLLER & Controller) } } +void CDirectInput::MapShortcutDevice(SHORTCUTS& Shortcuts) +{ + BUTTON* Buttons[] = + { + &Shortcuts.LOCKMOUSE, + }; + + CGuard Guard(m_DeviceCS); + for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++) + { + DEVICE_MAP::iterator itr = m_Devices.find(Buttons[i]->DeviceGuid); + if (itr != m_Devices.end()) + { + Buttons[i]->Device = &itr->second; + } + else + { + Buttons[i]->Device = nullptr; + } + } +} + BOOL CDirectInput::stEnumMakeDeviceList(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) { return ((CDirectInput *)pvRef)->EnumMakeDeviceList(lpddi); @@ -231,6 +253,13 @@ std::wstring CDirectInput::ButtonAssignment(BUTTON & Button) " \\/", " <" }; + static const char* iMouse[] = + { + "X-axis", + "Y-axis", + "Z-axis", + "Button" + }; if (Button.BtnType == BTNTYPE_JOYBUTTON) { @@ -278,6 +307,24 @@ std::wstring CDirectInput::ButtonAssignment(BUTTON & Button) return L"Keyboard: ???"; } } + if (Button.BtnType == BTNTYPE_MOUSEAXE) + { + stdstr_f Offset("%u", Button.Offset); + if (Button.Offset < (sizeof(iMouse) / sizeof(iMouse[0]))) + { + Offset = iMouse[Button.Offset]; + } + stdstr_f AxisId(" %u", Button.AxisID); + if (Button.AxisID < (sizeof(AxeID) / sizeof(AxeID[0]))) + { + AxisId = AxeID[Button.AxisID]; + } + return stdstr_f("%s%s", Offset.c_str(), AxisId.c_str()).ToUTF16(); + } + if (Button.BtnType == BTNTYPE_MOUSEBUTTON) + { + return stdstr_f("Button %u", Button.Offset).ToUTF16(); + } if (Button.BtnType == BTNTYPE_UNASSIGNED) { return L""; @@ -361,11 +408,15 @@ bool CDirectInput::IsButtonPressed(BUTTON & Button) return (Device.State.Keyboard[Button.Offset] & 0x80) != 0; case BTNTYPE_JOYBUTTON: return (Device.State.Joy.rgbButtons[Button.Offset] & 0x80) != 0; + case BTNTYPE_MOUSEBUTTON: + return (Device.State.Mouse.rgbButtons[Button.Offset] & 0x80) != 0; case BTNTYPE_JOYPOV: return JoyPadPovPressed((AI_POV)Button.AxisID, ((uint32_t *)&Device.State.Joy)[Button.Offset]); case BTNTYPE_JOYSLIDER: case BTNTYPE_JOYAXE: return Button.AxisID ? ((uint32_t*)&Device.State.Joy)[Button.Offset] > AXIS_BOTTOM_VALUE : ((uint32_t *)&Device.State.Joy)[Button.Offset] < AXIS_TOP_VALUE; + case BTNTYPE_MOUSEAXE: + return Button.AxisID ? ((uint32_t*)&Device.State.Mouse)[Button.Offset] > AXIS_BOTTOM_VALUE : ((uint32_t*)&Device.State.Mouse)[Button.Offset] < AXIS_TOP_VALUE; } return false; } @@ -413,6 +464,7 @@ void CDirectInput::GetAxis(N64CONTROLLER & Controller, BUTTONS * Keys) } DEVICE & Device = *(DEVICE *)Button.Device; LPLONG plRawState = (LPLONG)&Device.State.Joy; + LPLONG plRawStateMouse = (LPLONG)&Device.State.Mouse; switch (Button.BtnType) { @@ -420,6 +472,20 @@ void CDirectInput::GetAxis(N64CONTROLLER & Controller, BUTTONS * Keys) case BTNTYPE_JOYAXE: l_Value = (plRawState[Button.Offset] - MAX_AXIS_VALUE) * -1; + if (Button.AxisID == AI_AXE_NEGATIVE) + { + fNegInput = !fNegInput; + b_Value = (l_Value < 0); + } + else + { + b_Value = (l_Value > 0); + } + break; + case BTNTYPE_MOUSEAXE: + l_Value = (plRawStateMouse[Button.Offset]) * -1; + l_Value *= Controller.Sensitivity * MOUSESCALEVALUE; + if (Button.AxisID == AI_AXE_NEGATIVE) { fNegInput = !fNegInput; @@ -444,6 +510,13 @@ void CDirectInput::GetAxis(N64CONTROLLER & Controller, BUTTONS * Keys) l_Value = MAX_AXIS_VALUE; } break; + case BTNTYPE_MOUSEBUTTON: + b_Value = (Device.State.Mouse.rgbButtons[Button.Offset] & 0x80) != 0; + if (b_Value) + { + l_Value = MAX_AXIS_VALUE; + } + break; case BTNTYPE_JOYPOV: b_Value = JoyPadPovPressed((AI_POV)Button.AxisID, ((uint32_t *)&Device.State.Joy)[Button.Offset]); if (b_Value) @@ -705,6 +778,93 @@ CDirectInput::ScanResult CDirectInput::ScanGamePad(const GUID & DeviceGuid, LPDI return SCAN_FAILED; } +CDirectInput::ScanResult CDirectInput::ScanMouse(const GUID& DeviceGuid, LPDIRECTINPUTDEVICE8 didHandle, DIMOUSESTATE2& BaseState, BUTTON& pButton) +{ + DIJOYSTATE MouseState = { 0 }; + HRESULT hr = didHandle->GetDeviceState(sizeof(DIMOUSESTATE2), &MouseState); + if (FAILED(hr)) + { + didHandle->Acquire(); + return SCAN_FAILED; + } + + uint32_t Mouse[][2] = + { + { DIMOFS_X / sizeof(uint32_t), BTNTYPE_MOUSEAXE }, + { DIMOFS_Y / sizeof(uint32_t), BTNTYPE_MOUSEAXE }, + { DIMOFS_Z / sizeof(uint32_t), BTNTYPE_MOUSEAXE } + }; + + uint8_t bAxeDirection = 0; + int32_t foundJoyPad = -1; + + for (int32_t i = 0, n = sizeof(Mouse) / sizeof(Mouse[0]); i < n; i++) + { + uint32_t lValue = ((int32_t*)&MouseState)[Mouse[i][0]]; + uint32_t BaseValue = ((int32_t*)&BaseState)[Mouse[i][0]]; + + if (Mouse[i][1] == BTNTYPE_MOUSEAXE) + { + if ((lValue < AXIS_TOP_VALUE && BaseValue < AXIS_TOP_VALUE) || (lValue > AXIS_BOTTOM_VALUE && BaseValue > AXIS_BOTTOM_VALUE)) + { + continue; + } + ((int32_t*)&(BaseState))[Mouse[i][0]] = lValue; + if (lValue < AXIS_TOP_VALUE) + { + bAxeDirection = AI_AXE_POSITIVE; + foundJoyPad = i; + break; + } + else if (lValue > AXIS_BOTTOM_VALUE) + { + bAxeDirection = AI_AXE_NEGATIVE; + foundJoyPad = i; + break; + } + } + else + { + if (lValue == BaseValue) + { + continue; + } + ((int32_t*)&(BaseState))[Mouse[i][0]] = lValue; + } + } + + if (foundJoyPad >= 0) + { + pButton.Offset = (uint8_t)Mouse[foundJoyPad][0]; + pButton.AxisID = (uint8_t)bAxeDirection; + pButton.BtnType = (BtnType)Mouse[foundJoyPad][1]; + pButton.DeviceGuid = DeviceGuid; + pButton.Device = nullptr; + return SCAN_SUCCEED; + } + + for (uint8_t i = 0, n = sizeof(MouseState.rgbButtons) / sizeof(MouseState.rgbButtons[0]); i < n; i++) + { + if (BaseState.rgbButtons[i] == MouseState.rgbButtons[i]) + { + continue; + } + BaseState.rgbButtons[i] = MouseState.rgbButtons[i]; + + if ((MouseState.rgbButtons[i] & 0x80) == 0) + { + continue; + } + pButton.Offset = i; + pButton.AxisID = 0; + pButton.BtnType = BTNTYPE_MOUSEBUTTON; + pButton.DeviceGuid = DeviceGuid; + pButton.Device = nullptr; + return SCAN_SUCCEED; + } + return SCAN_FAILED; +} + bool CDirectInput::AcquireDevice(LPDIRECTINPUTDEVICE8 lpDirectInputDevice) { HRESULT hResult = lpDirectInputDevice->Acquire(); diff --git a/Source/Project64-input/DirectInput.h b/Source/Project64-input/DirectInput.h index 42507d9e7..72e541e4b 100644 --- a/Source/Project64-input/DirectInput.h +++ b/Source/Project64-input/DirectInput.h @@ -3,6 +3,7 @@ #include "Button.h" #include "DeviceNotification.h" #include "N64Controller.h" +#include "Shortcuts.h" #include #define DIRECTINPUT_VERSION 0x0800 #include @@ -23,6 +24,7 @@ class CDirectInput AI_AXE_POSITIVE = 0, AI_AXE_NEGATIVE = 1, THRESHOLD = 50, + MOUSESCALEVALUE = 10, }; enum AI_POV @@ -46,6 +48,7 @@ public: void Initiate(CONTROL_INFO * ControlInfo); void MapControllerDevice(N64CONTROLLER & Controller); + void MapShortcutDevice(SHORTCUTS& Shortcuts); ScanResult ScanDevices(BUTTON & Button); std::wstring ButtonAssignment(BUTTON & Button); std::wstring ControllerDevices(const N64CONTROLLER & Controller); @@ -63,6 +66,7 @@ private: BOOL EnumMakeDeviceList(LPCDIDEVICEINSTANCE lpddi); ScanResult ScanKeyboard(const GUID & DeviceGuid, LPDIRECTINPUTDEVICE8 didHandle, uint8_t * KeyboardState, BUTTON & pButton); ScanResult ScanGamePad(const GUID & DeviceGuid, LPDIRECTINPUTDEVICE8 didHandle, DIJOYSTATE & BaseState, BUTTON & pButton); + ScanResult ScanMouse(const GUID& DeviceGuid, LPDIRECTINPUTDEVICE8 didHandle, DIMOUSESTATE2& BaseState, BUTTON& pButton); bool AcquireDevice(LPDIRECTINPUTDEVICE8 lpDirectInputDevice); void RefreshDeviceList(void); bool JoyPadPovPressed(AI_POV Pov, int32_t Angle); diff --git a/Source/Project64-input/InputConfigUI.cpp b/Source/Project64-input/InputConfigUI.cpp index 82ab66c4c..24bd1f619 100644 --- a/Source/Project64-input/InputConfigUI.cpp +++ b/Source/Project64-input/InputConfigUI.cpp @@ -4,6 +4,7 @@ #include "wtl-BitmapPicture.h" #include "wtl-ScanButton.h" #include "OptionsUI.h" +#include "ShortcutsUI.h" #include #include #include "resource.h" @@ -30,7 +31,8 @@ public: COMMAND_HANDLER_EX(IDC_BTN_DEFAULTS, BN_CLICKED, DefaultBtnClicked) COMMAND_HANDLER_EX(IDC_BTN_SETUP, BN_CLICKED, SetupBtnClicked) COMMAND_HANDLER_EX(IDC_BTN_OPTIONS, BN_CLICKED, OptionsBtnClicked) - COMMAND_HANDLER_EX(IDC_CHK_PLUGGED_IN, BN_CLICKED, PluggedInChanged) + COMMAND_HANDLER_EX(IDC_BTN_SHORTCUT, BN_CLICKED, ShortcutsBtnClicked) + COMMAND_HANDLER_EX(IDC_DEVICETYPE, CBN_SELCHANGE, PluggedInChanged) NOTIFY_HANDLER_EX(IDC_TACK_RANGE, NM_RELEASEDCAPTURE, ItemChangedNotify); MESSAGE_HANDLER(WM_HSCROLL, OnScroll) MESSAGE_HANDLER(CScanButton::WM_SCAN_SUCCESS, OnScanSuccess) @@ -51,11 +53,13 @@ private: void DefaultBtnClicked(UINT Code, int id, HWND ctl); void SetupBtnClicked(UINT Code, int id, HWND ctl); void OptionsBtnClicked(UINT Code, int id, HWND ctl); + void ShortcutsBtnClicked(UINT Code, int id, HWND ctl); void PluggedInChanged(UINT Code, int id, HWND ctl); LRESULT ItemChangedNotify(NMHDR* /*pNMHDR*/); + void DisplayControllerImage(void); void DisplayController(void); void ButtonChannged(const BUTTON & Button); - void EnablePage(bool Enable); + void EnablePage(int32_t Present); static void stButtonChanged(size_t data, const BUTTON & Button) { ((CControllerSettings *)data)->ButtonChannged(Button); } std::wstring m_Title; @@ -73,6 +77,8 @@ private: CScanButton m_ButtonA, m_ButtonB, m_ButtonStart; CScanButton m_ButtonZtrigger, m_ButtonRTrigger, m_ButtonLTrigger; CScanButton m_ButtonAnalogU, m_ButtonAnalogD, m_ButtonAnalogL, m_ButtonAnalogR; + CComboBox m_DeviceType; + SHORTCUTS m_Shortcuts; }; class CInputConfigUI : @@ -96,6 +102,7 @@ CControllerSettings::CControllerSettings(uint32_t ControllerNumber) : m_SetupIndex(-1), m_Controller(g_InputPlugin->Controllers(ControllerNumber)), m_ControlInfo(g_InputPlugin->ControlInfo(ControllerNumber)), + m_Shortcuts(g_InputPlugin->Shortcuts()), m_ButtonUDPad(m_Controller.U_DPAD, IDC_EDIT_DIGITIAL_UP, IDC_BTN_DIGITIAL_UP), m_ButtonDDPad(m_Controller.D_DPAD, IDC_EDIT_DIGITIAL_DOWN, IDC_BTN_DIGITIAL_DOWN), m_ButtonLDPad(m_Controller.L_DPAD, IDC_EDIT_DIGITIAL_LEFT, IDC_BTN_DIGITIAL_LEFT), @@ -130,9 +137,10 @@ BOOL CControllerSettings::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam m_Range.SetRangeMin(1); m_Range.SetRangeMax(100); m_PluggedIn.Attach(GetDlgItem(IDC_CHK_PLUGGED_IN)); + m_DeviceType.Attach(GetDlgItem(IDC_DEVICETYPE)); m_ControllerImg.SubclassWindow(GetDlgItem(IDC_BMP_CONTROLLER)); - m_ControllerImg.SetBitmap(MAKEINTRESOURCE(IDB_CONTROLLER)); + CScanButton * Buttons[] = { &m_ButtonUDPad, &m_ButtonDDPad, &m_ButtonLDPad, &m_ButtonRDPad, &m_ButtonA, &m_ButtonB, &m_ButtonCUp, &m_ButtonCDown, &m_ButtonCLeft, &m_ButtonCRight, &m_ButtonStart, @@ -145,8 +153,16 @@ BOOL CControllerSettings::OnInitDialog(CWindow /*wndFocus*/, LPARAM /*lInitParam Buttons[i]->SubclassWindow(m_hWnd); Buttons[i]->SetChangeCallback(stButtonChanged, (size_t)this); } + + int Index = m_DeviceType.AddString(L"None"); + m_DeviceType.SetItemData(Index, PRESENT_NONE); + Index = m_DeviceType.AddString(L"N64 Controller"); + m_DeviceType.SetItemData(Index, PRESENT_CONT); + Index = m_DeviceType.AddString(L"N64 Mouse"); + m_DeviceType.SetItemData(Index, PRESENT_MOUSE); + DisplayController(); - EnablePage(m_PluggedIn.GetCheck() == BST_CHECKED); + EnablePage(m_DeviceType.GetItemData(m_DeviceType.GetCurSel())); return TRUE; } @@ -170,7 +186,7 @@ LRESULT CControllerSettings::OnApply() Controller.Range = (uint8_t)m_Range.GetPos(); Controller.DeadZone = (uint8_t)m_DeadZone.GetPos(); CONTROL & ControlInfo = g_InputPlugin->ControlInfo(m_ControllerNumber); - ControlInfo.Present = (m_PluggedIn.GetCheck() == BST_CHECKED) ? 1 : 0; + ControlInfo.Present = m_DeviceType.GetItemData(m_DeviceType.GetCurSel()); ControlInfo.Plugin = m_ControlInfo.Plugin; return g_InputPlugin->SaveController(m_ControllerNumber) ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE; } @@ -238,10 +254,16 @@ void CControllerSettings::OptionsBtnClicked(UINT /*Code*/, int /*id*/, HWND /*ct ConfigOption(m_ControllerNumber, m_ControlInfo, m_Controller); } +void CControllerSettings::ShortcutsBtnClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) +{ + ConfigShortcut(m_Shortcuts); +} + void CControllerSettings::PluggedInChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); - EnablePage(m_PluggedIn.GetCheck() == BST_CHECKED); + EnablePage(m_DeviceType.GetItemData(m_DeviceType.GetCurSel())); + DisplayControllerImage(); } LRESULT CControllerSettings::ItemChangedNotify(NMHDR* /*pNMHDR*/) @@ -250,9 +272,34 @@ LRESULT CControllerSettings::ItemChangedNotify(NMHDR* /*pNMHDR*/) return 0; } +void CControllerSettings::DisplayControllerImage(void) +{ + if (m_DeviceType.GetItemData(m_DeviceType.GetCurSel()) != PRESENT_MOUSE) + { + m_ControllerImg.SetBitmap(MAKEINTRESOURCE(IDB_CONTROLLER)); + } + else + { + m_ControllerImg.SetBitmap(MAKEINTRESOURCE(IDB_MOUSE)); + } + m_ControllerImg.Invalidate(); +} + void CControllerSettings::DisplayController(void) { - m_PluggedIn.SetCheck(m_ControlInfo.Present != 0 ? BST_CHECKED : BST_UNCHECKED); + int32_t index = 0; + m_DeviceType.SetCurSel(0); + for (index = 0; index < m_DeviceType.GetCount(); index++) + { + if (m_DeviceType.GetItemData(index) == m_ControlInfo.Present) + { + m_DeviceType.SetCurSel(index); + break; + } + } + + DisplayControllerImage(); + m_Range.SetPos(m_Controller.Range); m_DeadZone.SetPos(m_Controller.DeadZone); CWindow(GetDlgItem(IDC_LABEL_RANGE)).SetWindowText(stdstr_f("%d%%", m_Range.GetPos()).ToUTF16().c_str()); @@ -281,8 +328,9 @@ void CControllerSettings::ButtonChannged(const BUTTON & Button) CPropertySheetWindow(GetParent()).SetModified(m_hWnd); } -void CControllerSettings::EnablePage(bool Enable) +void CControllerSettings::EnablePage(int32_t Present) { + bool Enable = Present == PRESENT_CONT; GetDlgItem(IDC_SLIDE_DEADZONE).EnableWindow(Enable); GetDlgItem(IDC_SLIDER_RANGE).EnableWindow(Enable); GetDlgItem(IDC_EDIT_LTRIGGER).EnableWindow(Enable); @@ -322,6 +370,8 @@ void CControllerSettings::EnablePage(bool Enable) GetDlgItem(IDC_BTN_BUTTON_START).EnableWindow(Enable); GetDlgItem(IDC_BTN_BUTTON_Z).EnableWindow(Enable); GetDlgItem(IDC_BTN_SETUP).EnableWindow(Enable); + + Enable = Present != PRESENT_NONE; GetDlgItem(IDC_BTN_DEFAULTS).EnableWindow(Enable); GetDlgItem(IDC_BTN_OPTIONS).EnableWindow(Enable); } diff --git a/Source/Project64-input/InputMain.cpp b/Source/Project64-input/InputMain.cpp index 15d80b203..d2c31036b 100644 --- a/Source/Project64-input/InputMain.cpp +++ b/Source/Project64-input/InputMain.cpp @@ -60,6 +60,10 @@ Output: None #ifdef _WIN32 EXPORT void CALL DllConfig(void * hParent) { + if (g_InputPlugin != nullptr) + { + g_InputPlugin->UnlockMouse(); + } ConfigInput(hParent); } #endif @@ -154,6 +158,10 @@ Output: None EXPORT void CALL RomClosed(void) { + if (g_InputPlugin != nullptr) + { + g_InputPlugin->UnlockMouse(); + } } /* @@ -166,6 +174,26 @@ Output: None EXPORT void CALL RomOpen(void) { + if (g_InputPlugin != nullptr) + { + g_InputPlugin->LockMouse(); + } +} + +/* +Function: EmulationPaused +Purpose: This function is called when the emulation is paused. (from the +emulation thread) +Input: None +Output: None +*/ + +EXPORT void CALL EmulationPaused(void) +{ + if (g_InputPlugin != nullptr) + { + g_InputPlugin->UnlockMouse(); + } } /* @@ -192,6 +220,22 @@ EXPORT void CALL WM_KeyUp(uint32_t /*wParam*/, uint32_t /*lParam*/) { } +/* +Function: WM_KillFocus +Purpose: To pass the WM_KILLFOCUS message from the emulator to the +plugin. +Input: wParam and lParam of the WM_KILLFOCUS message. +Output: None +*/ + +EXPORT void CALL WM_KillFocus(uint32_t /*wParam*/, uint32_t /*lParam*/) +{ + if (g_InputPlugin != nullptr) + { + g_InputPlugin->UnlockMouse(); + } +} + EXPORT void CALL PluginLoaded(void) { SetupInputSettings(); diff --git a/Source/Project64-input/InputSettings.cpp b/Source/Project64-input/InputSettings.cpp index 67ad4b5bb..ad795f0bd 100644 --- a/Source/Project64-input/InputSettings.cpp +++ b/Source/Project64-input/InputSettings.cpp @@ -5,6 +5,7 @@ CInputSettings * g_Settings = nullptr; +/* Default First N64 Controller Setup */ static char * Control0_U_DPAD_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 17 0 5"; static char * Control0_D_DPAD_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 25 0 5"; static char * Control0_L_DPAD_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 24 0 5"; @@ -25,10 +26,28 @@ static char * Control0_L_ANALOG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000 static char * Control0_R_ANALOG_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} CD 0 5"; static const uint32_t Default_DeadZone = 25; static const uint32_t Default_Range = 100; +static const uint32_t Default_Sensitivity = 100; static const uint32_t Default_Plugin = PLUGIN_MEMPAK; static const bool Default_RealN64Range = true; static const bool Default_RemoveDuplicate = true; +/* Default Mouse Setup (Forced) */ +static char* Mouse_A_BUTTON_Default = "{6F1D2B60-D5A0-11CF-BFC7-444553540000} 00 0 6"; +static char* Mouse_B_BUTTON_Default = "{6F1D2B60-D5A0-11CF-BFC7-444553540000} 01 0 6"; +static char* Mouse_U_ANALOG_Default = "{6F1D2B60-D5A0-11CF-BFC7-444553540000} 01 0 7"; +static char* Mouse_D_ANALOG_Default = "{6F1D2B60-D5A0-11CF-BFC7-444553540000} 01 1 7"; +static char* Mouse_L_ANALOG_Default = "{6F1D2B60-D5A0-11CF-BFC7-444553540000} 00 0 7"; +static char* Mouse_R_ANALOG_Default = "{6F1D2B60-D5A0-11CF-BFC7-444553540000} 00 1 7"; +static const uint32_t DefaultMouse_DeadZone = 1; +static const uint32_t DefaultMouse_Range = 100; +static const uint32_t DefaultMouse_Plugin = PLUGIN_NONE; +static const uint32_t DefaultMouse_Sensitivity = 100; +static const bool DefaultMouse_RealN64Range = false; +static const bool DefaultMouse_RemoveDuplicate = true; + +/* Default Shortcuts Setup */ +static char* Shortcuts_LOCKMOUSE_Default = "{6F1D2B61-D5A0-11CF-BFC7-444553540000} 0F 0 5"; + CInputSettings::CInputSettings() { RegisterSettings(); @@ -40,12 +59,18 @@ CInputSettings::~CInputSettings() void CInputSettings::LoadController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller) { - struct + InputSettingID PresentSettings[] = { Set_Control0_Present, Set_Control1_Present, Set_Control2_Present, Set_Control3_Present }; + InputSettingID PluginSettings[] = { Set_Control0_Plugin, Set_Control1_Plugin, Set_Control2_Plugin, Set_Control3_Plugin }; + + ControllerInfo.Present = ControlIndex < (sizeof(PresentSettings) / sizeof(PresentSettings[0])) ? GetSetting((short)PresentSettings[ControlIndex]) : PRESENT_NONE; + ControllerInfo.Plugin = ControlIndex < (sizeof(PluginSettings) / sizeof(PluginSettings[0])) ? GetSetting((short)PluginSettings[ControlIndex]) : Default_Plugin; + + struct { - BUTTON & Button; + BUTTON& Button; InputSettingID SettingId; uint32_t ControlIndex; - } + } Buttons[] = { { Controller.U_DPAD, Set_Control0_U_DPAD, 0 }, @@ -135,26 +160,37 @@ void CInputSettings::LoadController(uint32_t ControlIndex, CONTROL & ControllerI Buttons[i].Button = StrToButton(GetSettingSz((short)Buttons[i].SettingId, Buffer, sizeof(Buffer) / sizeof(Buffer[0]))); } - InputSettingID PresentSettings[] = { Set_Control0_Present, Set_Control1_Present, Set_Control2_Present, Set_Control3_Present }; - InputSettingID PluginSettings[] = { Set_Control0_Plugin, Set_Control1_Plugin, Set_Control2_Plugin, Set_Control3_Plugin }; InputSettingID RangeSettings[] = { Set_Control0_Range, Set_Control1_Range, Set_Control2_Range, Set_Control3_Range }; InputSettingID DeadZoneSettings[] = { Set_Control0_Deadzone, Set_Control1_Deadzone, Set_Control2_Deadzone,Set_Control3_Deadzone }; + InputSettingID SensitivitySettings[] = { Set_Control0_Sensitivity, Set_Control1_Sensitivity, Set_Control2_Sensitivity, Set_Control3_Sensitivity }; InputSettingID RealN64RangeSettings[] = { Set_Control0_RealN64Range, Set_Control1_RealN64Range, Set_Control2_RealN64Range, Set_Control3_RealN64Range }; InputSettingID RemoveDuplicateSettings[] = { Set_Control0_RemoveDuplicate, Set_Control1_RemoveDuplicate, Set_Control2_RemoveDuplicate, Set_Control3_RemoveDuplicate }; - ControllerInfo.Present = ControlIndex < (sizeof(PresentSettings) / sizeof(PresentSettings[0])) ? GetSetting((short)PresentSettings[ControlIndex]) != 0 : 0; - ControllerInfo.Plugin = ControlIndex < (sizeof(PluginSettings) / sizeof(PluginSettings[0])) ? GetSetting((short)PluginSettings[ControlIndex]) : Default_Plugin; Controller.Range = (uint8_t)(ControlIndex < (sizeof(RangeSettings) / sizeof(RangeSettings[0])) ? GetSetting((short)RangeSettings[ControlIndex]) : Default_Range); if (Controller.Range == 0) { Controller.Range = 1; } if (Controller.Range > 100) { Controller.Range = 100; } Controller.DeadZone = (uint8_t)(ControlIndex < (sizeof(DeadZoneSettings) / sizeof(DeadZoneSettings[0])) ? GetSetting((short)DeadZoneSettings[ControlIndex]) : Default_DeadZone); if (Controller.DeadZone > 100) { Controller.DeadZone = 100; } + Controller.Sensitivity = (uint8_t)(ControlIndex < (sizeof(SensitivitySettings) / sizeof(SensitivitySettings[0])) ? GetSetting((short)SensitivitySettings[ControlIndex]) : Default_Sensitivity); + if (Controller.Sensitivity > 100) { Controller.Sensitivity = 100; } Controller.RealN64Range = (ControlIndex < (sizeof(RealN64RangeSettings) / sizeof(RealN64RangeSettings[0])) ? GetSetting((short)RealN64RangeSettings[ControlIndex]) != 0 : Default_RealN64Range); Controller.RemoveDuplicate = (ControlIndex < (sizeof(RemoveDuplicateSettings) / sizeof(RemoveDuplicateSettings[0])) ? GetSetting((short)RemoveDuplicateSettings[ControlIndex]) != 0 : Default_RemoveDuplicate); } void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & ControllerInfo, const N64CONTROLLER & Controller) { + InputSettingID PresentSettings[] = { Set_Control0_Present, Set_Control1_Present, Set_Control2_Present, Set_Control3_Present }; + InputSettingID PluginSettings[] = { Set_Control0_Plugin, Set_Control1_Plugin, Set_Control2_Plugin, Set_Control3_Plugin }; + + if (ControlIndex < (sizeof(PresentSettings) / sizeof(PresentSettings[0]))) + { + SetSetting((short)PresentSettings[ControlIndex], ControllerInfo.Present); + } + if (ControlIndex < (sizeof(PluginSettings) / sizeof(PluginSettings[0]))) + { + SetSetting((short)PluginSettings[ControlIndex], ControllerInfo.Plugin); + } + struct { const BUTTON & Button; @@ -181,6 +217,7 @@ void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & Contr { Controller.D_ANALOG, Set_Control0_D_ANALOG, 0 }, { Controller.L_ANALOG, Set_Control0_L_ANALOG, 0 }, { Controller.R_ANALOG, Set_Control0_R_ANALOG, 0 }, + { Controller.U_DPAD, Set_Control1_U_DPAD, 1 }, { Controller.D_DPAD, Set_Control1_D_DPAD, 1 }, { Controller.L_DPAD, Set_Control1_L_DPAD, 1 }, @@ -239,10 +276,9 @@ void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & Contr { Controller.R_ANALOG, Set_Control3_R_ANALOG, 3 }, }; - InputSettingID PresentSettings[] = { Set_Control0_Present, Set_Control1_Present, Set_Control2_Present, Set_Control3_Present }; - InputSettingID PluginSettings[] = { Set_Control0_Plugin, Set_Control1_Plugin, Set_Control2_Plugin, Set_Control3_Plugin }; InputSettingID RangeSettings[] = { Set_Control0_Range, Set_Control1_Range, Set_Control2_Range, Set_Control3_Range }; InputSettingID DeadZoneSettings[] = { Set_Control0_Deadzone, Set_Control1_Deadzone, Set_Control2_Deadzone,Set_Control3_Deadzone }; + InputSettingID SensitivitySettings[] = { Set_Control0_Sensitivity, Set_Control1_Sensitivity, Set_Control2_Sensitivity, Set_Control3_Sensitivity }; InputSettingID RealN64RangeSettings[] = { Set_Control0_RealN64Range, Set_Control1_RealN64Range, Set_Control2_RealN64Range, Set_Control3_RealN64Range }; InputSettingID RemoveDuplicateSettings[] = { Set_Control0_RemoveDuplicate, Set_Control1_RemoveDuplicate, Set_Control2_RemoveDuplicate, Set_Control3_RemoveDuplicate }; @@ -255,15 +291,6 @@ void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & Contr SetSettingSz((short)Buttons[i].SettingId, ButtonToStr(Buttons[i].Button).c_str()); } - if (ControlIndex < (sizeof(PresentSettings) / sizeof(PresentSettings[0]))) - { - SetSetting((short)PresentSettings[ControlIndex], ControllerInfo.Present); - } - if (ControlIndex < (sizeof(PluginSettings) / sizeof(PluginSettings[0]))) - { - SetSetting((short)PluginSettings[ControlIndex], ControllerInfo.Plugin); - } - if (ControlIndex < (sizeof(RangeSettings) / sizeof(RangeSettings[0]))) { SetSetting((short)RangeSettings[ControlIndex], Controller.Range); @@ -273,6 +300,10 @@ void CInputSettings::SaveController(uint32_t ControlIndex, const CONTROL & Contr { SetSetting((short)DeadZoneSettings[ControlIndex], Controller.DeadZone); } + if (ControlIndex < (sizeof(SensitivitySettings) / sizeof(SensitivitySettings[0]))) + { + SetSetting((short)SensitivitySettings[ControlIndex], Controller.Sensitivity); + } if (ControlIndex < (sizeof(RealN64RangeSettings) / sizeof(RealN64RangeSettings[0]))) { SetSetting((short)RealN64RangeSettings[ControlIndex], Controller.RealN64Range ? 1 : 0); @@ -381,10 +412,110 @@ void CInputSettings::ResetController(uint32_t ControlIndex, CONTROL & Controller } Controller.Range = Default_Range; Controller.DeadZone = Default_DeadZone; - ControllerInfo.Present = ControlIndex == 0 ? 1 : 0; + Controller.Sensitivity = Default_Sensitivity; + ControllerInfo.Present = ControlIndex == 0 ? PRESENT_CONT : PRESENT_NONE; ControllerInfo.Plugin = Default_Plugin; } +void CInputSettings::GetControllerMouse(N64CONTROLLER& Controller) +{ + struct + { + BUTTON& Button; + const char* DefaultValue; + } + Buttons[] = + { + { Controller.U_DPAD, "" }, + { Controller.D_DPAD, "" }, + { Controller.L_DPAD, "" }, + { Controller.R_DPAD, "" }, + { Controller.A_BUTTON, Mouse_A_BUTTON_Default }, + { Controller.B_BUTTON, Mouse_B_BUTTON_Default }, + { Controller.U_CBUTTON, "" }, + { Controller.D_CBUTTON, "" }, + { Controller.L_CBUTTON, "" }, + { Controller.R_CBUTTON, "" }, + { Controller.START_BUTTON, "" }, + { Controller.Z_TRIG, "" }, + { Controller.R_TRIG, "" }, + { Controller.L_TRIG, "" }, + { Controller.U_ANALOG, Mouse_U_ANALOG_Default }, + { Controller.D_ANALOG, Mouse_D_ANALOG_Default }, + { Controller.L_ANALOG, Mouse_L_ANALOG_Default }, + { Controller.R_ANALOG, Mouse_R_ANALOG_Default }, + }; + + for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++) + { + Buttons[i].Button = StrToButton(Buttons[i].DefaultValue); + } + Controller.Range = DefaultMouse_Range; + Controller.DeadZone = DefaultMouse_DeadZone; + Controller.Sensitivity = DefaultMouse_Sensitivity; + Controller.RealN64Range = DefaultMouse_RealN64Range; + Controller.RemoveDuplicate = DefaultMouse_RemoveDuplicate; +} + +void CInputSettings::LoadShortcuts(SHORTCUTS& Shortcuts) +{ + struct + { + BUTTON& Button; + InputSettingID SettingId; + } + Buttons[] = + { + { Shortcuts.LOCKMOUSE, Set_Shortcut_LOCKMOUSE }, + }; + + char Buffer[400]; + for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++) + { + Buttons[i].Button = StrToButton(GetSettingSz((short)Buttons[i].SettingId, Buffer, sizeof(Buffer) / sizeof(Buffer[0]))); + } + + Shortcuts.LOCKMOUSE_PRESSED = false; +} + +void CInputSettings::SaveShortcuts(SHORTCUTS& Shortcuts) +{ + struct + { + const BUTTON& Button; + InputSettingID SettingId; + } + Buttons[] = + { + { Shortcuts.LOCKMOUSE, Set_Shortcut_LOCKMOUSE }, + }; + + for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++) + { + SetSettingSz((short)Buttons[i].SettingId, ButtonToStr(Buttons[i].Button).c_str()); + } +} + +void CInputSettings::ResetShortcuts(SHORTCUTS& Shortcuts) +{ + struct + { + BUTTON& Button; + const char* DefaultValue; + } + Buttons[] = + { + { Shortcuts.LOCKMOUSE, Shortcuts_LOCKMOUSE_Default }, + }; + + for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++) + { + Buttons[i].Button = StrToButton(Buttons[i].DefaultValue); + } + + Shortcuts.LOCKMOUSE_PRESSED = false; +} + BUTTON CInputSettings::StrToButton(const char * Buffer) { BUTTON Button = { 0 }; @@ -419,6 +550,7 @@ void CInputSettings::RegisterSettings(void) RegisterSetting(Set_Control0_Plugin, Data_DWORD_General, "Plugin", "Controller 1", Default_Plugin, nullptr); RegisterSetting(Set_Control0_Range, Data_DWORD_General, "Range", "Controller 1", Default_Range, nullptr); RegisterSetting(Set_Control0_Deadzone, Data_DWORD_General, "Deadzone", "Controller 1", Default_DeadZone, nullptr); + RegisterSetting(Set_Control0_Sensitivity, Data_DWORD_General, "Sensitivity", "Controller 1", Default_Sensitivity, nullptr); RegisterSetting(Set_Control0_RealN64Range, Data_DWORD_General, "RealN64Range", "Controller 1", Default_RealN64Range, nullptr); RegisterSetting(Set_Control0_RemoveDuplicate, Data_DWORD_General, "Remove Duplicate", "Controller 1", Default_RemoveDuplicate, nullptr); RegisterSetting(Set_Control0_U_DPAD, Data_String_General, "DPadUp", "Controller 1", 0, Control0_U_DPAD_Default); @@ -444,6 +576,7 @@ void CInputSettings::RegisterSettings(void) RegisterSetting(Set_Control1_Plugin, Data_DWORD_General, "Plugin", "Controller 2", Default_Plugin, nullptr); RegisterSetting(Set_Control1_Range, Data_DWORD_General, "Range", "Controller 2", Default_Range, nullptr); RegisterSetting(Set_Control1_Deadzone, Data_DWORD_General, "Deadzone", "Controller 2", Default_DeadZone, nullptr); + RegisterSetting(Set_Control1_Sensitivity, Data_DWORD_General, "Sensitivity", "Controller 2", Default_Sensitivity, nullptr); RegisterSetting(Set_Control1_RealN64Range, Data_DWORD_General, "RealN64Range", "Controller 2", Default_RealN64Range, nullptr); RegisterSetting(Set_Control1_RemoveDuplicate, Data_DWORD_General, "Remove Duplicate", "Controller 2", Default_RemoveDuplicate, nullptr); RegisterSetting(Set_Control1_U_DPAD, Data_String_General, "DPadUp", "Controller 2", 0, ""); @@ -469,6 +602,7 @@ void CInputSettings::RegisterSettings(void) RegisterSetting(Set_Control2_Plugin, Data_DWORD_General, "Plugin", "Controller 3", Default_Plugin, nullptr); RegisterSetting(Set_Control2_Range, Data_DWORD_General, "Range", "Controller 3", Default_Range, nullptr); RegisterSetting(Set_Control2_Deadzone, Data_DWORD_General, "Deadzone", "Controller 3", Default_DeadZone, nullptr); + RegisterSetting(Set_Control2_Sensitivity, Data_DWORD_General, "Sensitivity", "Controller 3", Default_Sensitivity, nullptr); RegisterSetting(Set_Control2_RealN64Range, Data_DWORD_General, "RealN64Range", "Controller 3", Default_RealN64Range, nullptr); RegisterSetting(Set_Control2_RemoveDuplicate, Data_DWORD_General, "Remove Duplicate", "Controller 3", Default_RemoveDuplicate, nullptr); RegisterSetting(Set_Control2_U_DPAD, Data_String_General, "DPadUp", "Controller 3", 0, ""); @@ -494,6 +628,7 @@ void CInputSettings::RegisterSettings(void) RegisterSetting(Set_Control3_Plugin, Data_DWORD_General, "Plugin", "Controller 4", Default_Plugin, nullptr); RegisterSetting(Set_Control3_Range, Data_DWORD_General, "Range", "Controller 4", Default_Range, nullptr); RegisterSetting(Set_Control3_Deadzone, Data_DWORD_General, "Deadzone", "Controller 4", Default_DeadZone, nullptr); + RegisterSetting(Set_Control3_Sensitivity, Data_DWORD_General, "Sensitivity", "Controller 4", Default_Sensitivity, nullptr); RegisterSetting(Set_Control3_RealN64Range, Data_DWORD_General, "RealN64Range", "Controller 4", Default_RealN64Range, nullptr); RegisterSetting(Set_Control3_RemoveDuplicate, Data_DWORD_General, "Remove Duplicate", "Controller 4", Default_RemoveDuplicate, nullptr); RegisterSetting(Set_Control3_U_DPAD, Data_String_General, "DPadUp", "Controller 4", 0, ""); @@ -514,6 +649,8 @@ void CInputSettings::RegisterSettings(void) RegisterSetting(Set_Control3_D_ANALOG, Data_String_General, "AnalogDown", "Controller 4", 0, ""); RegisterSetting(Set_Control3_L_ANALOG, Data_String_General, "AnalogLeft", "Controller 4", 0, ""); RegisterSetting(Set_Control3_R_ANALOG, Data_String_General, "AnalogRight", "Controller 4", 0, ""); + + RegisterSetting(Set_Shortcut_LOCKMOUSE, Data_String_General, "LockMouse", "Shortcuts", 0, Shortcuts_LOCKMOUSE_Default); } void SetupInputSettings(void) diff --git a/Source/Project64-input/InputSettings.h b/Source/Project64-input/InputSettings.h index a28e01054..45bd6c3e8 100644 --- a/Source/Project64-input/InputSettings.h +++ b/Source/Project64-input/InputSettings.h @@ -2,6 +2,7 @@ #include #include #include "N64Controller.h" +#include "Shortcuts.h" #include class CInputSettings @@ -13,6 +14,11 @@ public: void LoadController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller); void SaveController(uint32_t ControlIndex, const CONTROL & ControllerInfo, const N64CONTROLLER & Controller); void ResetController(uint32_t ControlIndex, CONTROL & ControllerInfo, N64CONTROLLER & Controller); + void GetControllerMouse(N64CONTROLLER& Controller); + + void LoadShortcuts(SHORTCUTS& Shortcuts); + void SaveShortcuts(SHORTCUTS& Shortcuts); + void ResetShortcuts(SHORTCUTS& Shortcuts); private: CInputSettings(const CInputSettings&); diff --git a/Source/Project64-input/InputSettingsID.h b/Source/Project64-input/InputSettingsID.h index 21950a3a9..7feb3b0c4 100644 --- a/Source/Project64-input/InputSettingsID.h +++ b/Source/Project64-input/InputSettingsID.h @@ -6,6 +6,7 @@ enum InputSettingID Set_Control0_Plugin, Set_Control0_Range, Set_Control0_Deadzone, + Set_Control0_Sensitivity, Set_Control0_RealN64Range, Set_Control0_RemoveDuplicate, Set_Control0_U_DPAD, @@ -31,6 +32,7 @@ enum InputSettingID Set_Control1_Plugin, Set_Control1_Range, Set_Control1_Deadzone, + Set_Control1_Sensitivity, Set_Control1_RealN64Range, Set_Control1_RemoveDuplicate, Set_Control1_U_DPAD, @@ -56,6 +58,7 @@ enum InputSettingID Set_Control2_Plugin, Set_Control2_Range, Set_Control2_Deadzone, + Set_Control2_Sensitivity, Set_Control2_RealN64Range, Set_Control2_RemoveDuplicate, Set_Control2_U_DPAD, @@ -81,6 +84,7 @@ enum InputSettingID Set_Control3_Plugin, Set_Control3_Range, Set_Control3_Deadzone, + Set_Control3_Sensitivity, Set_Control3_RealN64Range, Set_Control3_RemoveDuplicate, Set_Control3_U_DPAD, @@ -101,4 +105,6 @@ enum InputSettingID Set_Control3_D_ANALOG, Set_Control3_L_ANALOG, Set_Control3_R_ANALOG, + + Set_Shortcut_LOCKMOUSE, }; diff --git a/Source/Project64-input/Mouse.bmp b/Source/Project64-input/Mouse.bmp new file mode 100644 index 000000000..781108f27 Binary files /dev/null and b/Source/Project64-input/Mouse.bmp differ diff --git a/Source/Project64-input/N64Controller.h b/Source/Project64-input/N64Controller.h index ba5836273..662d843df 100644 --- a/Source/Project64-input/N64Controller.h +++ b/Source/Project64-input/N64Controller.h @@ -23,6 +23,7 @@ typedef struct BUTTON R_ANALOG; uint8_t Range; uint8_t DeadZone; + uint8_t Sensitivity; bool RealN64Range; bool RemoveDuplicate; } N64CONTROLLER; diff --git a/Source/Project64-input/OptionsUI.cpp b/Source/Project64-input/OptionsUI.cpp index 252b7a6a8..51b9c29a3 100644 --- a/Source/Project64-input/OptionsUI.cpp +++ b/Source/Project64-input/OptionsUI.cpp @@ -11,6 +11,7 @@ public: BEGIN_MSG_MAP(COptionsDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + MESSAGE_HANDLER(WM_HSCROLL, OnScroll) COMMAND_ID_HANDLER(IDOK, OnOkCmd) COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) END_MSG_MAP() @@ -29,6 +30,13 @@ public: CButton(GetDlgItem(IDC_REAL_N64_RANGE)).SetCheck(m_Controller.RealN64Range ? BST_CHECKED : BST_UNCHECKED); CButton(GetDlgItem(IDC_REMOVE_DUPLICATE)).SetCheck(m_Controller.RemoveDuplicate ? BST_CHECKED : BST_UNCHECKED); + m_Sensitivity.Attach(GetDlgItem(IDC_SLIDE_SENSITIVITY)); + m_Sensitivity.SetTicFreq(1); + m_Sensitivity.SetRangeMin(1); + m_Sensitivity.SetRangeMax(100); + m_Sensitivity.SetPos(m_Controller.Sensitivity); + CWindow(GetDlgItem(IDC_TXT_SENSITIVITY)).SetWindowText(stdstr_f("Mouse Sensitivity: %d%%", m_Sensitivity.GetPos()).ToUTF16().c_str()); + CComboBox ControllerPak(GetDlgItem(IDC_PAKTYPE)); int Index = ControllerPak.AddString(L"None"); ControllerPak.SetItemData(Index, PLUGIN_NONE); @@ -67,9 +75,16 @@ public: bChanged = true; } + uint8_t Sensitivity = (uint8_t)m_Sensitivity.GetPos(); + if (Sensitivity != m_Controller.Sensitivity) + { + m_Controller.Sensitivity = Sensitivity; + bChanged = true; + } + CComboBox ControllerPak(GetDlgItem(IDC_PAKTYPE)); DWORD_PTR Pak = ControllerPak.GetItemData(ControllerPak.GetCurSel()); - if (Pak != m_ControlInfo.Plugin) + if (Pak != (DWORD_PTR)m_ControlInfo.Plugin) { m_ControlInfo.Plugin = (Pak & 0xFFFFFFFF); bChanged = true; @@ -87,9 +102,19 @@ public: EndDialog(wID); return 0; } + LRESULT OnScroll(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) + { + LONG SliderId = CWindow((HWND)lParam).GetWindowLong(GWL_ID); + if (SliderId == IDC_SLIDE_SENSITIVITY) + { + CWindow(GetDlgItem(IDC_TXT_SENSITIVITY)).SetWindowText(stdstr_f("Mouse Sensitivity: %d%%", m_Sensitivity.GetPos()).ToUTF16().c_str()); + } + return 0; + } uint32_t m_ControlIndex; CONTROL & m_ControlInfo; N64CONTROLLER & m_Controller; + CTrackBarCtrl m_Sensitivity; }; void ConfigOption(uint32_t ControlIndex, CONTROL & ControlInfo, N64CONTROLLER & Controller) diff --git a/Source/Project64-input/Project64-input.rc b/Source/Project64-input/Project64-input.rc index 2c959dcb2..c3dd33b4b 100644 Binary files a/Source/Project64-input/Project64-input.rc and b/Source/Project64-input/Project64-input.rc differ diff --git a/Source/Project64-input/Project64-input.vcxproj b/Source/Project64-input/Project64-input.vcxproj index d9a397a92..55a7d6237 100644 --- a/Source/Project64-input/Project64-input.vcxproj +++ b/Source/Project64-input/Project64-input.vcxproj @@ -60,6 +60,7 @@ + @@ -71,10 +72,11 @@ - + + @@ -87,6 +89,7 @@ + diff --git a/Source/Project64-input/Project64-input.vcxproj.filters b/Source/Project64-input/Project64-input.vcxproj.filters index 52932c733..594caf3bc 100644 --- a/Source/Project64-input/Project64-input.vcxproj.filters +++ b/Source/Project64-input/Project64-input.vcxproj.filters @@ -42,11 +42,11 @@ Source Files + + Source Files + - - Header Files - Header Files @@ -86,6 +86,12 @@ Header Files + + Header Files + + + Header Files + @@ -101,5 +107,8 @@ Resource Files + + Resource Files + \ No newline at end of file diff --git a/Source/Project64-input/Shortcuts.h b/Source/Project64-input/Shortcuts.h new file mode 100644 index 000000000..580c2fb96 --- /dev/null +++ b/Source/Project64-input/Shortcuts.h @@ -0,0 +1,9 @@ +#pragma once +#include "Button.h" + +typedef struct +{ + BUTTON LOCKMOUSE; + + bool LOCKMOUSE_PRESSED; +} SHORTCUTS; diff --git a/Source/Project64-input/ShortcutsUI.cpp b/Source/Project64-input/ShortcutsUI.cpp new file mode 100644 index 000000000..249420757 --- /dev/null +++ b/Source/Project64-input/ShortcutsUI.cpp @@ -0,0 +1,132 @@ +#include "ShortcutsUI.h" +#include "CProject64Input.h" +#include "wtl.h" +#include "wtl-ScanButton.h" +#include "resource.h" +#include + +class CShortcutsDlg : + public CDialogImpl +{ +public: + enum { IDD = IDD_Shortcuts }; + + BEGIN_MSG_MAP(CShortcutsDlg) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_ID_HANDLER(IDOK, OnOkCmd) + COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) + MESSAGE_HANDLER(CScanButton::WM_SCAN_SUCCESS, OnScanSuccess) + MESSAGE_HANDLER(CScanButton::WM_SCAN_CANCELED, OnScanCanceled) + END_MSG_MAP() + + CShortcutsDlg(SHORTCUTS & Shortcuts) : + m_Shortcuts(Shortcuts), + m_SetupIndex(-1), + m_ButtonLockMouse(m_Shortcuts.LOCKMOUSE, IDC_EDIT_LOCKMOUSE, IDC_BTN_LOCKMOUSE) + { + } + + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + CenterWindow(GetParent()); + SetWindowText(stdstr_f("Shortcuts").ToUTF16().c_str()); + + CScanButton* Buttons[] = { + &m_ButtonLockMouse + }; + + for (size_t i = 0, n = sizeof(Buttons) / sizeof(Buttons[0]); i < n; i++) + { + Buttons[i]->SubclassWindow(m_hWnd); + Buttons[i]->SetChangeCallback(stButtonChanged, (size_t)this); + } + + return TRUE; + } + + LRESULT OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + SHORTCUTS& Shortcuts = g_InputPlugin->Shortcuts(); + Shortcuts = m_Shortcuts; + g_InputPlugin->SaveShortcuts(); + EndDialog(wID); + return 0; + } + LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) + { + EndDialog(wID); + return 0; + } + +private: + SHORTCUTS& m_Shortcuts; + CScanButton m_ButtonLockMouse; + int32_t m_SetupIndex; + + static void stButtonChanged(size_t data, const BUTTON& Button) { ((CShortcutsDlg*)data)->ButtonChannged(Button); } + + void ButtonChannged(const BUTTON& Button) + { + BUTTON EmptyButton = { 0 }; + BUTTON* buttons[] = + { + &m_Shortcuts.LOCKMOUSE, + }; + + bool Changed = false; + for (size_t b = 0; b < (sizeof(buttons) / sizeof(buttons[0])); b++) + { + if (buttons[b]->Offset == Button.Offset && + buttons[b]->AxisID == Button.AxisID && + buttons[b]->BtnType == Button.BtnType && + memcmp(&buttons[b]->DeviceGuid, &Button.DeviceGuid, sizeof(Button.DeviceGuid)) == 0) + { + *buttons[b] = EmptyButton; + Changed = true; + } + } + + if (Changed) + { + CScanButton* ScanButtons[] = { + &m_ButtonLockMouse, + }; + + for (size_t i = 0, n = sizeof(ScanButtons) / sizeof(ScanButtons[0]); i < n; i++) + { + ScanButtons[i]->DisplayButton(); + } + } + CPropertySheetWindow(GetParent()).SetModified(m_hWnd); + } + + LRESULT OnScanSuccess(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + if (m_SetupIndex < 0) + { + return 0; + } + + CScanButton* Buttons[] = { + &m_ButtonLockMouse + }; + + m_SetupIndex += 1; + if (m_SetupIndex < (sizeof(Buttons) / sizeof(Buttons[0]))) + { + Buttons[m_SetupIndex]->DetectKey(); + } + return 0; + } + + LRESULT OnScanCanceled(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) + { + m_SetupIndex = -1; + return 0; + } +}; + +void ConfigShortcut(SHORTCUTS & Shortcuts) +{ + CShortcutsDlg(Shortcuts).DoModal(); +} diff --git a/Source/Project64-input/ShortcutsUI.h b/Source/Project64-input/ShortcutsUI.h new file mode 100644 index 000000000..adbabd8a7 --- /dev/null +++ b/Source/Project64-input/ShortcutsUI.h @@ -0,0 +1,6 @@ +#pragma once +#include +#include +#include "Shortcuts.h" + +void ConfigShortcut(SHORTCUTS & Shortcuts); diff --git a/Source/Project64-input/Version.h.in b/Source/Project64-input/Version.h.in index 45c4b9a74..3d1d657c9 100644 --- a/Source/Project64-input/Version.h.in +++ b/Source/Project64-input/Version.h.in @@ -6,6 +6,7 @@ #define VERSION_REVISION 2 #define VERSION_BUILD 9999 #define VERSION_PREFIX "Dev-" +#define VERSION_BUILD_YEAR 2025 #define GIT_REVISION "" #define GIT_REVISION_SHORT "" @@ -25,7 +26,7 @@ #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR -#define VER_COPYRIGHT_STR "Copyright (C) 2021" +#define VER_COPYRIGHT_STR "Copyright (C) " STRINGIZE(VERSION_BUILD_YEAR) #ifdef _DEBUG #define VER_VER_DEBUG VS_FF_DEBUG diff --git a/Source/Project64-input/resource.h b/Source/Project64-input/resource.h index 957b293ae..3fe87f0c5 100644 Binary files a/Source/Project64-input/resource.h and b/Source/Project64-input/resource.h differ diff --git a/Source/Project64-plugin-spec/Input.h b/Source/Project64-plugin-spec/Input.h index 9080b1cb9..eefb0f931 100644 --- a/Source/Project64-plugin-spec/Input.h +++ b/Source/Project64-plugin-spec/Input.h @@ -15,6 +15,13 @@ enum PluginType PLUGIN_RAW = 5, }; +enum PresentType +{ + PRESENT_NONE = 0, + PRESENT_CONT = 1, + PRESENT_MOUSE = 2, +}; + #if defined(__cplusplus) extern "C" { #endif @@ -119,6 +126,15 @@ data. */ EXPORT void CALL ReadController(int Control, uint8_t * Command); +/* +Function: EmulationPaused +Purpose: This function is called when the emulation is paused. (from the +emulation thread) +Input: None +Output: None +*/ +EXPORT void CALL EmulationPaused(void); + /* Function: WM_KeyDown Purpose: To pass the WM_KeyDown message from the emulator to the @@ -137,6 +153,15 @@ Output: None */ EXPORT void CALL WM_KeyUp(uint32_t wParam, uint32_t lParam); +/* +Function: WM_KillFocus +Purpose: To pass the WM_KILLFOCUS message from the emulator to the +plugin. +Input: wParam and lParam of the WM_KILLFOCUS message. +Output: None +*/ +EXPORT void CALL WM_KillFocus(uint32_t wParam, uint32_t lParam); + #if defined(__cplusplus) } #endif diff --git a/Source/Project64/Plugins/PluginList.cpp b/Source/Project64/Plugins/PluginList.cpp index b6d8b1bc7..bb542cbd0 100644 --- a/Source/Project64/Plugins/PluginList.cpp +++ b/Source/Project64/Plugins/PluginList.cpp @@ -1,11 +1,13 @@ #include "stdafx.h" -#include + #include "PluginList.h" #include +#include CPluginList::CPluginList(bool bAutoFill /* = true */) : -m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") + m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") { + m_PluginDir.NormalizePath(CPath(CPath::MODULE_DIRECTORY)); if (bAutoFill) { LoadList(); @@ -18,7 +20,7 @@ CPluginList::~CPluginList() int CPluginList::GetPluginCount() const { - return m_PluginList.size(); + return (int)((INT_PTR)m_PluginList.size()); } const CPluginList::PLUGIN * CPluginList::GetPluginInfo(int indx) const @@ -75,15 +77,15 @@ void CPluginList::AddPluginFromDir(CPath Dir) continue; } - void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo); + void(CALL * GetDllInfo)(PLUGIN_INFO * PluginInfo); GetDllInfo = (void(CALL *)(PLUGIN_INFO *))GetProcAddress(hLib, "GetDllInfo"); if (GetDllInfo == nullptr) { continue; } - PLUGIN Plugin = { 0 }; - Plugin.Info.MemoryBswaped = true; + PLUGIN Plugin = {0}; + Plugin.Info.Reserved2 = true; GetDllInfo(&Plugin.Info); if (!CPlugin::ValidPluginVersion(Plugin.Info)) { diff --git a/Source/Project64/Plugins/PluginList.h b/Source/Project64/Plugins/PluginList.h index 0fa4c3e1f..9cfcde333 100644 --- a/Source/Project64/Plugins/PluginList.h +++ b/Source/Project64/Plugins/PluginList.h @@ -8,24 +8,24 @@ public: typedef struct { PLUGIN_INFO Info; - bool AboutFunction; - CPath FullPath; - stdstr FileName; + bool AboutFunction; + CPath FullPath; + stdstr FileName; } PLUGIN; public: CPluginList(bool bAutoFill = true); ~CPluginList(); - bool LoadList(void); - int GetPluginCount(void) const; + bool LoadList(void); + int GetPluginCount(void) const; const PLUGIN * GetPluginInfo(int indx) const; private: - typedef std::vector PluginList; + typedef std::vector PluginList; PluginList m_PluginList; - CPath m_PluginDir; + CPath m_PluginDir; void AddPluginFromDir(CPath Dir); }; diff --git a/Source/Project64/UserInterface/MainMenu.cpp b/Source/Project64/UserInterface/MainMenu.cpp index e4bfc79c2..d893de56a 100644 --- a/Source/Project64/UserInterface/MainMenu.cpp +++ b/Source/Project64/UserInterface/MainMenu.cpp @@ -468,7 +468,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI break; case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceUserInterface, TraceDebug, "ID_OPTIONS_CONFIG_GFX"); - g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_GFX); + g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_VIDEO); break; case ID_OPTIONS_CONFIG_AUDIO: WriteTrace(TraceUserInterface, TraceDebug, "ID_OPTIONS_CONFIG_AUDIO"); diff --git a/Source/Project64/UserInterface/MainWindow.cpp b/Source/Project64/UserInterface/MainWindow.cpp index 5bc395282..1cd038f0e 100644 --- a/Source/Project64/UserInterface/MainWindow.cpp +++ b/Source/Project64/UserInterface/MainWindow.cpp @@ -822,14 +822,22 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO break; } - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) { - if (g_BaseSystem) + if (bAutoSleep()) { g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); } + + if (g_Plugins && g_Plugins->Control()->WM_KillFocus) + { + g_Plugins->Control()->WM_KillFocus((uint32_t)((UINT_PTR)wParam), (uint32_t)((UINT_PTR)lParam)); + } } } + } break; case WM_ACTIVATEAPP: { diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp index 2e05f4085..5ee676adc 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp @@ -29,7 +29,7 @@ CGamePluginPage::CGamePluginPage(HWND hParent, const RECT & rcDispay) m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME)); m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME)); - AddPlugins(GFX_LIST, Game_EditPlugin_Gfx, PLUGIN_TYPE_GFX); + AddPlugins(GFX_LIST, Game_EditPlugin_Gfx, PLUGIN_TYPE_VIDEO); AddPlugins(AUDIO_LIST, Game_EditPlugin_Audio, PLUGIN_TYPE_AUDIO); AddPlugins(CONT_LIST, Game_EditPlugin_Contr, PLUGIN_TYPE_CONTROLLER); AddPlugins(RSP_LIST, Game_EditPlugin_RSP, PLUGIN_TYPE_RSP); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp index 16fcc75d5..6095673e9 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp @@ -28,7 +28,7 @@ COptionPluginPage::COptionPluginPage(HWND hParent, const RECT & rcDispay) m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME)); m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME)); - AddPlugins(GFX_LIST, Plugin_GFX_Current, PLUGIN_TYPE_GFX); + AddPlugins(GFX_LIST, Plugin_GFX_Current, PLUGIN_TYPE_VIDEO); AddPlugins(AUDIO_LIST, Plugin_AUDIO_Current, PLUGIN_TYPE_AUDIO); AddPlugins(CONT_LIST, Plugin_CONT_Current, PLUGIN_TYPE_CONTROLLER); AddPlugins(RSP_LIST, Plugin_RSP_Current, PLUGIN_TYPE_RSP);