From ef18541ac2e1e97de9f04f132ac7b2b1ba21e515 Mon Sep 17 00:00:00 2001 From: dpeter99 Date: Wed, 28 Mar 2018 17:34:56 +0200 Subject: c# binding WIP --- csharp-binding/LibSurviveBinding/Binding.cs | 33 ++++++++++ csharp-binding/LibSurviveBinding/Config_entry.cs | 31 +++++++++ .../LibSurviveBinding/LibSurviveBinding.csproj | 14 ++++ .../LibSurviveBinding/LightcapElement.cs | 6 ++ csharp-binding/LibSurviveBinding/Program.cs | 71 +++++++++++++++++++++ csharp-binding/LibSurviveBinding/SurviveContext.cs | 44 +++++++++++++ csharp-binding/LibSurviveBinding/SurviveObject.cs | 6 ++ csharp-binding/LibSurviveBinding/SurvivePose.cs | 6 ++ .../bin/Debug/netcoreapp2.0/LibSurviveBinding.dll | Bin 0 -> 8192 bytes .../bin/Debug/netcoreapp2.0/LibSurviveBinding.pdb | Bin 0 -> 1044 bytes .../bin/Debug/netcoreapp2.0/libsurvive.dll | Bin 0 -> 365056 bytes csharp-binding/LibSurviveBinding/config_group.cs | 14 ++++ csharp-binding/LibSurviveBinding/libsurvive.dll | Bin 0 -> 365056 bytes .../LibSurviveBinding.AssemblyInfo.cs | 23 +++++++ .../LibSurviveBinding.AssemblyInfoInputs.cache | 1 + ...ibSurviveBinding.csproj.CoreCompileInputs.cache | 1 + .../LibSurviveBinding.csproj.FileListAbsolute.txt | 12 ++++ ...iveBinding.csprojResolveAssemblyReference.cache | Bin 0 -> 480497 bytes .../obj/Debug/netcoreapp2.0/LibSurviveBinding.dll | Bin 0 -> 8192 bytes .../obj/Debug/netcoreapp2.0/LibSurviveBinding.pdb | Bin 0 -> 1044 bytes .../obj/LibSurviveBinding.csproj.nuget.cache | 5 ++ .../obj/LibSurviveBinding.csproj.nuget.g.props | 18 ++++++ .../obj/LibSurviveBinding.csproj.nuget.g.targets | 10 +++ 23 files changed, 295 insertions(+) create mode 100644 csharp-binding/LibSurviveBinding/Binding.cs create mode 100644 csharp-binding/LibSurviveBinding/Config_entry.cs create mode 100644 csharp-binding/LibSurviveBinding/LibSurviveBinding.csproj create mode 100644 csharp-binding/LibSurviveBinding/LightcapElement.cs create mode 100644 csharp-binding/LibSurviveBinding/Program.cs create mode 100644 csharp-binding/LibSurviveBinding/SurviveContext.cs create mode 100644 csharp-binding/LibSurviveBinding/SurviveObject.cs create mode 100644 csharp-binding/LibSurviveBinding/SurvivePose.cs create mode 100644 csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.dll create mode 100644 csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.pdb create mode 100644 csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/libsurvive.dll create mode 100644 csharp-binding/LibSurviveBinding/config_group.cs create mode 100644 csharp-binding/LibSurviveBinding/libsurvive.dll create mode 100644 csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfo.cs create mode 100644 csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfoInputs.cache create mode 100644 csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.CoreCompileInputs.cache create mode 100644 csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.FileListAbsolute.txt create mode 100644 csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csprojResolveAssemblyReference.cache create mode 100644 csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.dll create mode 100644 csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.pdb create mode 100644 csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.cache create mode 100644 csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.props create mode 100644 csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.targets (limited to 'csharp-binding/LibSurviveBinding') diff --git a/csharp-binding/LibSurviveBinding/Binding.cs b/csharp-binding/LibSurviveBinding/Binding.cs new file mode 100644 index 0000000..f4f0652 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/Binding.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace LibSurviveBinding +{ + class Binding + { + /* + typedef int (* htc_config_func) (SurviveObject* so, char* ct0conf, int len); + typedef void (* text_feedback_func) (SurviveContext* ctx, const char* fault ); + typedef void (* light_process_func) (SurviveObject* so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, uint32_t lighthouse); + typedef void (* imu_process_func) (SurviveObject* so, int mask, FLT* accelgyro, uint32_t timecode, int id); + typedef void (* angle_process_func) (SurviveObject* so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle, uint32_t lh); + typedef void (* button_process_func) (SurviveObject* so, uint8_t eventType, uint8_t buttonId, uint8_t axis1Id, uint16_t axis1Val, uint8_t axis2Id, uint16_t axis2Val); + typedef void (* raw_pose_func) (SurviveObject* so, uint8_t lighthouse, SurvivePose* pose); + typedef void (* lighthouse_pose_func) (SurviveContext* ctx, uint8_t lighthouse, SurvivePose* lighthouse_pose, + SurvivePose* object_pose); + */ + } + + public delegate int htc_config_func(IntPtr so, char ct0conf, int len); + public delegate void text_feedback_func(IntPtr ctx, string fault); + public delegate void light_process_func(IntPtr so, int sensor_id, int acode, int timeinsweep, UInt32 timecode, UInt32 length, UInt32 lighthouse); + public delegate void imu_process_func(IntPtr so, int mask, double accelgyro, UInt32 timecode, int id); + public delegate void angle_process_func(IntPtr so, int sensor_id, int acode, UInt32 timecode, double length, double angle, UInt32 lh); + public delegate void button_process_func(IntPtr so, byte eventType, byte buttonId, byte axis1Id, UInt16 axis1Val, byte axis2Id, UInt16 axis2Val); + 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 handle_lightcap_func (IntPtr so, IntPtr le); + +} diff --git a/csharp-binding/LibSurviveBinding/Config_entry.cs b/csharp-binding/LibSurviveBinding/Config_entry.cs new file mode 100644 index 0000000..85a6701 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/Config_entry.cs @@ -0,0 +1,31 @@ +namespace LibSurviveBinding +{ + + // internal class Config_entry + // { + // char[] tag; + // cval_type type; + // /** + // union { + //uint32_t i; + // FLT f; + // } + + // numeric; + // **/ + // char* data; + // uint32_t elements; + + // } + + // public enum cval_type + // { + // CONFIG_UNKNOWN = 0, + // CONFIG_FLOAT = 1, + // CONFIG_UINT32 = 2, + // CONFIG_STRING = 3, + // CONFIG_FLOAT_ARRAY = 4, + // } + + +} \ No newline at end of file diff --git a/csharp-binding/LibSurviveBinding/LibSurviveBinding.csproj b/csharp-binding/LibSurviveBinding/LibSurviveBinding.csproj new file mode 100644 index 0000000..e3be07c --- /dev/null +++ b/csharp-binding/LibSurviveBinding/LibSurviveBinding.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp2.0 + + + + + Always + + + + diff --git a/csharp-binding/LibSurviveBinding/LightcapElement.cs b/csharp-binding/LibSurviveBinding/LightcapElement.cs new file mode 100644 index 0000000..ca51fb9 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/LightcapElement.cs @@ -0,0 +1,6 @@ +namespace LibSurviveBinding +{ + public class LightcapElement + { + } +} \ No newline at end of file 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) + { + + } + } +} diff --git a/csharp-binding/LibSurviveBinding/SurviveContext.cs b/csharp-binding/LibSurviveBinding/SurviveContext.cs new file mode 100644 index 0000000..2ba9b7c --- /dev/null +++ b/csharp-binding/LibSurviveBinding/SurviveContext.cs @@ -0,0 +1,44 @@ +namespace LibSurviveBinding +{ + /* + public struct SurviveContext + { + text_feedback_func faultfunction; + text_feedback_func notefunction; + light_process_func lightproc; + imu_process_func imuproc; + angle_process_func angleproc; + button_process_func buttonproc; + raw_pose_func rawposeproc; + lighthouse_pose_func lighthouseposeproc; + htc_config_func configfunction; + handle_lightcap_func lightcapfunction; + + Config_group global_config_values; + Config_group* lh_config; //lighthouse configs + Config_group* temporary_config_values; //Set per-session, from command-line. Not saved but override global_config_values + + //Calibration data: + int activeLighthouses; + BaseStationData bsd[NUM_LIGHTHOUSES]; + SurviveCalData* calptr; //If and only if the calibration subsystem is attached. + struct SurviveRecordingData *recptr; // Iff recording is attached + SurviveObject** objs; + int objs_ct; + + void** drivers; + DeviceDriverCb* driverpolls; + DeviceDriverCb* drivercloses; + DeviceDriverMagicCb* drivermagics; + int driver_ct; + + SurviveState state; + + void* buttonservicethread; + ButtonQueue buttonQueue; + + void* user_ptr; + + } + */ +} \ No newline at end of file diff --git a/csharp-binding/LibSurviveBinding/SurviveObject.cs b/csharp-binding/LibSurviveBinding/SurviveObject.cs new file mode 100644 index 0000000..bb9e3cd --- /dev/null +++ b/csharp-binding/LibSurviveBinding/SurviveObject.cs @@ -0,0 +1,6 @@ +namespace LibSurviveBinding +{ + public class SurviveObject + { + } +} \ No newline at end of file diff --git a/csharp-binding/LibSurviveBinding/SurvivePose.cs b/csharp-binding/LibSurviveBinding/SurvivePose.cs new file mode 100644 index 0000000..9808d89 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/SurvivePose.cs @@ -0,0 +1,6 @@ +namespace LibSurviveBinding +{ + public class SurvivePose + { + } +} \ No newline at end of file diff --git a/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.dll b/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.dll new file mode 100644 index 0000000..08f1a10 Binary files /dev/null and b/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.dll differ diff --git a/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.pdb b/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.pdb new file mode 100644 index 0000000..c8442a1 Binary files /dev/null and b/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/LibSurviveBinding.pdb differ diff --git a/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/libsurvive.dll b/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/libsurvive.dll new file mode 100644 index 0000000..09738c8 Binary files /dev/null and b/csharp-binding/LibSurviveBinding/bin/Debug/netcoreapp2.0/libsurvive.dll differ diff --git a/csharp-binding/LibSurviveBinding/config_group.cs b/csharp-binding/LibSurviveBinding/config_group.cs new file mode 100644 index 0000000..8a2f00e --- /dev/null +++ b/csharp-binding/LibSurviveBinding/config_group.cs @@ -0,0 +1,14 @@ +using System; + +namespace LibSurviveBinding +{ + /* + internal class Config_group + { + Config_entry config_entries; + UInt16 used_entries; + UInt16 max_entries; + + } + */ +} \ No newline at end of file diff --git a/csharp-binding/LibSurviveBinding/libsurvive.dll b/csharp-binding/LibSurviveBinding/libsurvive.dll new file mode 100644 index 0000000..09738c8 Binary files /dev/null and b/csharp-binding/LibSurviveBinding/libsurvive.dll differ diff --git a/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfo.cs b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfo.cs new file mode 100644 index 0000000..0c76a75 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("LibSurviveBinding")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("LibSurviveBinding")] +[assembly: System.Reflection.AssemblyTitleAttribute("LibSurviveBinding")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfoInputs.cache b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfoInputs.cache new file mode 100644 index 0000000..27570f7 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +b297cfadb5fc15fdc85ac80d1db8dc47ecc7fa1f diff --git a/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.CoreCompileInputs.cache b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..d7b7e81 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +e5ec51aa179849bdaf5ff16a14a375413f2f7a0b diff --git a/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.FileListAbsolute.txt b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..a699d0e --- /dev/null +++ b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csproj.FileListAbsolute.txt @@ -0,0 +1,12 @@ +P:\csharp\LibSurviveBinding\bin\Debug\netcoreapp2.0\LibSurviveBinding.deps.json +P:\csharp\LibSurviveBinding\bin\Debug\netcoreapp2.0\LibSurviveBinding.runtimeconfig.json +P:\csharp\LibSurviveBinding\bin\Debug\netcoreapp2.0\LibSurviveBinding.runtimeconfig.dev.json +P:\csharp\LibSurviveBinding\bin\Debug\netcoreapp2.0\LibSurviveBinding.dll +P:\csharp\LibSurviveBinding\bin\Debug\netcoreapp2.0\LibSurviveBinding.pdb +P:\csharp\LibSurviveBinding\obj\Debug\netcoreapp2.0\LibSurviveBinding.csprojResolveAssemblyReference.cache +P:\csharp\LibSurviveBinding\obj\Debug\netcoreapp2.0\LibSurviveBinding.csproj.CoreCompileInputs.cache +P:\csharp\LibSurviveBinding\obj\Debug\netcoreapp2.0\LibSurviveBinding.AssemblyInfoInputs.cache +P:\csharp\LibSurviveBinding\obj\Debug\netcoreapp2.0\LibSurviveBinding.AssemblyInfo.cs +P:\csharp\LibSurviveBinding\obj\Debug\netcoreapp2.0\LibSurviveBinding.dll +P:\csharp\LibSurviveBinding\obj\Debug\netcoreapp2.0\LibSurviveBinding.pdb +P:\csharp\LibSurviveBinding\bin\Debug\netcoreapp2.0\libsurvive.dll diff --git a/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csprojResolveAssemblyReference.cache b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..94b7814 Binary files /dev/null and b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.csprojResolveAssemblyReference.cache differ diff --git a/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.dll b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.dll new file mode 100644 index 0000000..08f1a10 Binary files /dev/null and b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.dll differ diff --git a/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.pdb b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.pdb new file mode 100644 index 0000000..c8442a1 Binary files /dev/null and b/csharp-binding/LibSurviveBinding/obj/Debug/netcoreapp2.0/LibSurviveBinding.pdb differ diff --git a/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.cache b/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.cache new file mode 100644 index 0000000..55c49f2 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.cache @@ -0,0 +1,5 @@ +{ + "version": 1, + "dgSpecHash": "WfCkKm3U/vtoEsgbYzrhLfrfUejWLQZtOI4PCmuZ/c/RM+JDSQotxYTHxQQ6Blgu3cg1aVoZ15gcgmVkgjRwSg==", + "success": true +} \ No newline at end of file diff --git a/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.props b/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.props new file mode 100644 index 0000000..f4fbbaa --- /dev/null +++ b/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.props @@ -0,0 +1,18 @@ + + + + True + NuGet + P:\csharp\LibSurviveBinding\obj\project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\Peter\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder + PackageReference + 4.6.1 + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + + + + \ No newline at end of file diff --git a/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.targets b/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.targets new file mode 100644 index 0000000..91fd1c9 --- /dev/null +++ b/csharp-binding/LibSurviveBinding/obj/LibSurviveBinding.csproj.nuget.g.targets @@ -0,0 +1,10 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + + + + + \ No newline at end of file -- cgit v1.2.3