diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 258b6c3..ccc273e 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -131,3 +131,9 @@ jobs: with: name: UnityIGCSConnector.dll path: ./Release/UnityIGCSConnector.dll + + - name: Upload Unity IGCS Connector 32bit + uses: actions/upload-artifact@v3 + with: + name: UnityIGCSConnector.32.dll + path: ./Release/UnityIGCSConnector.32.dll diff --git a/UnityIGCSConnector/UnityIGCSConnector.vcxproj b/UnityIGCSConnector/UnityIGCSConnector.vcxproj index 8a9dd2b..22d1749 100644 --- a/UnityIGCSConnector/UnityIGCSConnector.vcxproj +++ b/UnityIGCSConnector/UnityIGCSConnector.vcxproj @@ -76,13 +76,19 @@ false - UnityIGCSConnector + UnityIGCSConnector.32 + $(SolutionDir)..\$(Configuration)\ + false UnityIGCSConnector + $(SolutionDir)..\$(Configuration)\ + false - UnityIGCSConnector + UnityIGCSConnector.32 + $(SolutionDir)..\$(Configuration)\ + false @@ -90,7 +96,7 @@ true WIN32;_DEBUG;UNITYIGCSCONNECTOR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h @@ -107,7 +113,7 @@ true WIN32;NDEBUG;UNITYIGCSCONNECTOR_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h @@ -164,4 +170,4 @@ - \ No newline at end of file + diff --git a/UnityIGCSConnector/dllmain.c b/UnityIGCSConnector/dllmain.c index e16ef01..d822686 100644 --- a/UnityIGCSConnector/dllmain.c +++ b/UnityIGCSConnector/dllmain.c @@ -19,7 +19,7 @@ SessionCallback GlobalEndSession = NULL; // There are things that only needs to be run once. static int first_initialization = 1; -EXPOSE int IGCS_StartScreenshotSession(uint8_t _ignore) { +EXPOSE int __cdecl IGCS_StartScreenshotSession(uint8_t _ignore) { if (GlobalStartSession) { GlobalStartSession(); printf("Called StartSession\n"); @@ -27,12 +27,12 @@ EXPOSE int IGCS_StartScreenshotSession(uint8_t _ignore) { return 0; } -EXPOSE void IGCS_EndScreenshotSession() { +EXPOSE void __cdecl IGCS_EndScreenshotSession() { GlobalEndSession(); printf("Called EndSession\n"); } -EXPOSE uint8_t* U_IGCS_Initialize(MoveCameraCallback cb, SessionCallback start_cb, SessionCallback end_cb) { +EXPOSE uint8_t* __cdecl U_IGCS_Initialize(MoveCameraCallback cb, SessionCallback start_cb, SessionCallback end_cb) { AllocConsole(); printf("Initializing callback\n"); GlobalCallback = cb; @@ -40,7 +40,11 @@ EXPOSE uint8_t* U_IGCS_Initialize(MoveCameraCallback cb, SessionCallback start_c GlobalEndSession = end_cb; // Load IGCS +#ifdef _M_IX86 + HMODULE igcs = LoadLibraryA("IgcsConnector.addon32"); +#else HMODULE igcs = LoadLibraryA("IgcsConnector.addon64"); +#endif if (!igcs) { MessageBoxA( @@ -69,9 +73,9 @@ EXPOSE uint8_t* U_IGCS_Initialize(MoveCameraCallback cb, SessionCallback start_c } -EXPOSE void IGCS_MoveCameraPanorama() {} +EXPOSE void __cdecl IGCS_MoveCameraPanorama() {} -EXPOSE void IGCS_MoveCameraMultishot(float step_left, float step_up, float fov, int from_start) { +EXPOSE void __cdecl IGCS_MoveCameraMultishot(float step_left, float step_up, float fov, int from_start) { GlobalCallback(step_left, step_up, fov, from_start); return; } diff --git a/build_connector.ps1 b/build_connector.ps1 index 2a7957b..906324c 100644 --- a/build_connector.ps1 +++ b/build_connector.ps1 @@ -1,3 +1,6 @@ # ----------- Build UnityIGCSConnector ------------ -msbuild.exe UnityIGCSConnector/UnityIGCSConnector.sln -p:Configuration=Release +msbuild.exe UnityIGCSConnector/UnityIGCSConnector.sln -p:Configuration=Release -p:Platform=x64 + +msbuild.exe UnityIGCSConnector/UnityIGCSConnector.sln -p:Configuration=Release -p:Platform=x86 + diff --git a/src/Cinematic/UnityIGCSConnector.cs b/src/Cinematic/UnityIGCSConnector.cs index f93a4c5..1f12f05 100644 --- a/src/Cinematic/UnityIGCSConnector.cs +++ b/src/Cinematic/UnityIGCSConnector.cs @@ -22,8 +22,13 @@ namespace CinematicUnityExplorer.Cinematic public class UnityIGCSConnector { // UnityIGCSConnector.dll definitions. + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void MoveCameraCallback(float step_left, float step_up, float fov, int from_start); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void SessionCallback(); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate IntPtr U_IGCS_Initialize(MoveCameraCallback callback, SessionCallback start_cb, SessionCallback end_cb); // Store the initial position when a session start in IGCSDof. @@ -118,10 +123,11 @@ namespace CinematicUnityExplorer.Cinematic public UnityIGCSConnector() { - var lib = NativeMethods.LoadLibrary(@"UnityIGCSConnector.dll"); + var libraryName = IntPtr.Size == 8 ? @"UnityIGCSConnector.dll" : @"UnityIGCSConnector.32.dll"; + var lib = NativeMethods.LoadLibrary(libraryName); if (lib == IntPtr.Zero) { - ExplorerCore.LogWarning("UnityIGCSConnector.dll was not found so IGCSDof will not be available"); + ExplorerCore.LogWarning($"{libraryName} was not found so IGCSDof will not be available"); return; }