aboutsummaryrefslogtreecommitdiff
path: root/bindings/cs
diff options
context:
space:
mode:
authorJustin Berger <j.david.berger@gmail.com>2018-03-28 16:34:33 -0600
committerJustin Berger <j.david.berger@gmail.com>2018-03-28 16:37:49 -0600
commit70596acbbe766045c95f64a65b411d4cd7584918 (patch)
tree307358305c58c9c6f12ef46ec773bd85e2301da6 /bindings/cs
parent595ba8b255f6f4fd9ebc1c9dbff33577c13115f9 (diff)
downloadlibsurvive-70596acbbe766045c95f64a65b411d4cd7584918.tar.gz
libsurvive-70596acbbe766045c95f64a65b411d4cd7584918.tar.bz2
Slight refactoring
Diffstat (limited to 'bindings/cs')
-rw-r--r--bindings/cs/.gitignore3
-rw-r--r--bindings/cs/LibSurviveBinding.sln25
-rw-r--r--bindings/cs/LibSurviveBinding/Binding.cs33
-rw-r--r--bindings/cs/LibSurviveBinding/Config_entry.cs31
-rw-r--r--bindings/cs/LibSurviveBinding/LibSurviveBinding.csproj18
-rw-r--r--bindings/cs/LibSurviveBinding/LightcapElement.cs6
-rw-r--r--bindings/cs/LibSurviveBinding/Program.cs62
-rw-r--r--bindings/cs/LibSurviveBinding/SurviveContext.cs44
-rw-r--r--bindings/cs/LibSurviveBinding/SurviveObject.cs6
-rw-r--r--bindings/cs/LibSurviveBinding/SurvivePose.cs6
-rw-r--r--bindings/cs/LibSurviveBinding/config_group.cs14
11 files changed, 248 insertions, 0 deletions
diff --git a/bindings/cs/.gitignore b/bindings/cs/.gitignore
new file mode 100644
index 0000000..6d14531
--- /dev/null
+++ b/bindings/cs/.gitignore
@@ -0,0 +1,3 @@
+*.dll
+obj/
+bin/ \ No newline at end of file
diff --git a/bindings/cs/LibSurviveBinding.sln b/bindings/cs/LibSurviveBinding.sln
new file mode 100644
index 0000000..539470c
--- /dev/null
+++ b/bindings/cs/LibSurviveBinding.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27428.2015
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibSurviveBinding", "LibSurviveBinding\LibSurviveBinding.csproj", "{3DEFC8F7-C61E-4BC2-B743-E39453C6BA10}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {3DEFC8F7-C61E-4BC2-B743-E39453C6BA10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3DEFC8F7-C61E-4BC2-B743-E39453C6BA10}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3DEFC8F7-C61E-4BC2-B743-E39453C6BA10}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3DEFC8F7-C61E-4BC2-B743-E39453C6BA10}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {CA47A8D6-3379-4ABA-927E-86BBDDE1D304}
+ EndGlobalSection
+EndGlobal
diff --git a/bindings/cs/LibSurviveBinding/Binding.cs b/bindings/cs/LibSurviveBinding/Binding.cs
new file mode 100644
index 0000000..f4f0652
--- /dev/null
+++ b/bindings/cs/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/bindings/cs/LibSurviveBinding/Config_entry.cs b/bindings/cs/LibSurviveBinding/Config_entry.cs
new file mode 100644
index 0000000..85a6701
--- /dev/null
+++ b/bindings/cs/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/bindings/cs/LibSurviveBinding/LibSurviveBinding.csproj b/bindings/cs/LibSurviveBinding/LibSurviveBinding.csproj
new file mode 100644
index 0000000..646c16d
--- /dev/null
+++ b/bindings/cs/LibSurviveBinding/LibSurviveBinding.csproj
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>netcoreapp2.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <None Update="libsurvive.dll">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.NETCore.App" Version="2.0.1" />
+ </ItemGroup>
+</Project>
diff --git a/bindings/cs/LibSurviveBinding/LightcapElement.cs b/bindings/cs/LibSurviveBinding/LightcapElement.cs
new file mode 100644
index 0000000..ca51fb9
--- /dev/null
+++ b/bindings/cs/LibSurviveBinding/LightcapElement.cs
@@ -0,0 +1,6 @@
+namespace LibSurviveBinding
+{
+ public class LightcapElement
+ {
+ }
+} \ No newline at end of file
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)
+ {
+
+ }
+ }
+}
diff --git a/bindings/cs/LibSurviveBinding/SurviveContext.cs b/bindings/cs/LibSurviveBinding/SurviveContext.cs
new file mode 100644
index 0000000..2ba9b7c
--- /dev/null
+++ b/bindings/cs/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/bindings/cs/LibSurviveBinding/SurviveObject.cs b/bindings/cs/LibSurviveBinding/SurviveObject.cs
new file mode 100644
index 0000000..bb9e3cd
--- /dev/null
+++ b/bindings/cs/LibSurviveBinding/SurviveObject.cs
@@ -0,0 +1,6 @@
+namespace LibSurviveBinding
+{
+ public class SurviveObject
+ {
+ }
+} \ No newline at end of file
diff --git a/bindings/cs/LibSurviveBinding/SurvivePose.cs b/bindings/cs/LibSurviveBinding/SurvivePose.cs
new file mode 100644
index 0000000..9808d89
--- /dev/null
+++ b/bindings/cs/LibSurviveBinding/SurvivePose.cs
@@ -0,0 +1,6 @@
+namespace LibSurviveBinding
+{
+ public class SurvivePose
+ {
+ }
+} \ No newline at end of file
diff --git a/bindings/cs/LibSurviveBinding/config_group.cs b/bindings/cs/LibSurviveBinding/config_group.cs
new file mode 100644
index 0000000..8a2f00e
--- /dev/null
+++ b/bindings/cs/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