diff options
author | Justin Berger <j.david.berger@gmail.com> | 2018-03-28 16:34:33 -0600 |
---|---|---|
committer | Justin Berger <j.david.berger@gmail.com> | 2018-03-28 16:37:49 -0600 |
commit | 70596acbbe766045c95f64a65b411d4cd7584918 (patch) | |
tree | 307358305c58c9c6f12ef46ec773bd85e2301da6 /bindings/cs/LibSurviveBinding/Program.cs | |
parent | 595ba8b255f6f4fd9ebc1c9dbff33577c13115f9 (diff) | |
download | libsurvive-70596acbbe766045c95f64a65b411d4cd7584918.tar.gz libsurvive-70596acbbe766045c95f64a65b411d4cd7584918.tar.bz2 |
Slight refactoring
Diffstat (limited to 'bindings/cs/LibSurviveBinding/Program.cs')
-rw-r--r-- | bindings/cs/LibSurviveBinding/Program.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/bindings/cs/LibSurviveBinding/Program.cs b/bindings/cs/LibSurviveBinding/Program.cs new file mode 100644 index 0000000..b6d0d8f --- /dev/null +++ b/bindings/cs/LibSurviveBinding/Program.cs @@ -0,0 +1,62 @@ +using System; +using System.Runtime.InteropServices; + +namespace LibSurVive +{ + class Program + { + [DllImport("libsurvive", CallingConvention = CallingConvention.StdCall)] + static extern IntPtr survive_init_internal(int argc, string[] 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); + public delegate void light_process_func( IntPtr so, int sensor_id, int acode, int timeinsweep, + UInt32 timecode, UInt32 length, UInt32 lighthouse); + + [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 void survive_install_light_fn(IntPtr ctx, light_process_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); + + [DllImport("libsurvive", CallingConvention = CallingConvention.StdCall)] + static extern int survive_poll(IntPtr ctx); + + static void Main(string[] args) + { + IntPtr context = survive_init_internal(args.Length, args); + + survive_install_lighthouse_pose_fn(context, LighthousPos); + survive_install_raw_pose_fn(context, PositionUpdate); + survive_install_light_fn(context, LightUpdate); + + survive_startup(context); + survive_cal_install(context); + + while(survive_poll(context) == 0) {} + + } + + public static void LightUpdate( IntPtr so, int sensor_id, int acode, int timeinsweep, + UInt32 timecode, UInt32 length, UInt32 lighthouse) { + Console.WriteLine(timeinsweep); + } + + 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) + { + + } + } +} |