aboutsummaryrefslogtreecommitdiff
path: root/csharp-binding/LibSurviveBinding/Program.cs
blob: 7ae8e768d56b523d05d3e86496e0d3b5dd271450 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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)
        {

        }
    }
}