diff options
author | CNLohr <charles@cnlohr.com> | 2018-03-28 16:32:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-28 16:32:28 -0400 |
commit | 595ba8b255f6f4fd9ebc1c9dbff33577c13115f9 (patch) | |
tree | 31b885caee99c4688c6b3fadff559795fbd39784 /csharp-binding/LibSurviveBinding/Program.cs | |
parent | 8a6be7bacaa8858f8e493a696d3c2cff563851d7 (diff) | |
parent | 6f7759314baf66f69fa7a335a1f17c65e90661f2 (diff) | |
download | libsurvive-595ba8b255f6f4fd9ebc1c9dbff33577c13115f9.tar.gz libsurvive-595ba8b255f6f4fd9ebc1c9dbff33577c13115f9.tar.bz2 |
Merge pull request #119 from dpeter99/master
The start of the c# binding
Diffstat (limited to 'csharp-binding/LibSurviveBinding/Program.cs')
-rw-r--r-- | csharp-binding/LibSurviveBinding/Program.cs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/csharp-binding/LibSurviveBinding/Program.cs b/csharp-binding/LibSurviveBinding/Program.cs new file mode 100644 index 0000000..7ae8e76 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/Program.cs @@ -0,0 +1,71 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibSurVive +{ + class Program + { + [DllImport("libsurvive", CallingConvention = CallingConvention.StdCall)] + static extern IntPtr survive_init_internal(int argc, char[] args); + + public delegate void raw_pose_func(IntPtr so, byte lighthouse, IntPtr pose); + public delegate void lighthouse_pose_func(IntPtr ctx, byte lighthouse, IntPtr lighthouse_pose, IntPtr object_pose); + + [DllImport("libsurvive", CallingConvention = CallingConvention.StdCall)] + static extern void survive_install_raw_pose_fn(IntPtr ctx, raw_pose_func fbp); + [DllImport("libsurvive", CallingConvention = CallingConvention.StdCall)] + static extern void survive_install_lighthouse_pose_fn(IntPtr ctx, lighthouse_pose_func fbp); + + + [DllImport("libsurvive", CallingConvention = CallingConvention.StdCall)] + static extern int survive_startup(IntPtr ctx); + [DllImport("libsurvive", CallingConvention = CallingConvention.StdCall)] + static extern void survive_cal_install(IntPtr ctx); + + public static lighthouse_pose_func lighthouse_Pose_Func { get; private set; } + public static raw_pose_func raw_Pose_Func { get; private set; } + + static void Main(string[] args) + { + IntPtr context = survive_init_internal(0, null); + + lighthouse_Pose_Func = LighthousPos; + survive_install_lighthouse_pose_fn(context, lighthouse_Pose_Func); + raw_Pose_Func = PositionUpdate; + survive_install_raw_pose_fn(context, raw_Pose_Func); + + try + { + int a = survive_startup(context); + //survive_cal_install(context); + } + catch (Exception) + { + + throw; + } + + bool running = true; + + + + Console.WriteLine("Hello World!"); + + while (running) + { + Console.ReadLine(); + } + + } + + public static void PositionUpdate(IntPtr so, byte lighthouse, IntPtr pose) + { + //Console.WriteLine(pose); + } + + public static void LighthousPos(IntPtr ctx, byte lighthouse, IntPtr lighthouse_pose, IntPtr object_pose) + { + + } + } +} |