diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index 3db3ae50d..a0a908ebe 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -60,6 +60,9 @@ bool CControl_Plugin::LoadFunctions(void) bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) { + CONTROL_INFO ControlInfo; + uint8_t Buffer[100]; + for (int32_t i = 0; i < 4; i++) { m_PluginControllers[i].Present = FALSE; @@ -67,6 +70,15 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) m_PluginControllers[i].Plugin = PLUGIN_NONE; } + if (m_PluginInfo.Version >= 0x0101) + { + ControlInfo.Controls = m_PluginControllers; + ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); + ControlInfo.hinst = GetModuleHandle(NULL); + ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; + ControlInfo.MemoryBswaped = TRUE; + } + // Test Plugin version if (m_PluginInfo.Version == 0x0100) { @@ -74,26 +86,28 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]); InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); if (InitiateControllers_1_0 == NULL) { return false; } - InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow,m_PluginControllers); + + InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow, m_PluginControllers); m_Initialized = true; } - else if (m_PluginInfo.Version >= 0x0101) + else if (m_PluginInfo.Version == 0x0101) { //Get Function from DLL - void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO * ControlInfo); - InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); + void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO ControlInfo); + InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); if (InitiateControllers_1_1 == NULL) { return false; } - CONTROL_INFO ControlInfo; - uint8_t Buffer[100]; + InitiateControllers_1_1(ControlInfo); + m_Initialized = true; + } + else if (m_PluginInfo.Version >= 0x0102) + { + //Get Function from DLL + void(__cdecl *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo); + InitiateControllers_1_2 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); + if (InitiateControllers_1_2 == NULL) { return false; } - ControlInfo.Controls = m_PluginControllers; - ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); - ControlInfo.hinst = GetModuleHandle(NULL); - ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; - ControlInfo.MemoryBswaped = TRUE; - - InitiateControllers_1_1(&ControlInfo); + InitiateControllers_1_2(&ControlInfo); m_Initialized = true; }