diff options
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/cs/Demo/App.config | 6 | ||||
-rw-r--r-- | bindings/cs/Demo/Demo.csproj | 86 | ||||
-rw-r--r-- | bindings/cs/Demo/Program.cs | 32 | ||||
-rw-r--r-- | bindings/cs/Demo/Properties/AssemblyInfo.cs | 36 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding.sln | 54 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/Binding.cs | 33 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/Config_entry.cs | 31 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/LibSurviveBinding.csproj | 18 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/LightcapElement.cs | 6 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/Program.cs | 62 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/SurviveContext.cs | 44 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/SurviveObject.cs | 6 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/SurvivePose.cs | 6 | ||||
-rw-r--r-- | bindings/cs/LibSurviveBinding/config_group.cs | 14 | ||||
-rw-r--r-- | bindings/cs/libsurvive.net/SurviveContext.cs | 90 | ||||
-rw-r--r-- | bindings/cs/libsurvive.net/cfunctions.cs | 84 | ||||
-rw-r--r-- | bindings/cs/libsurvive.net/libsurvive.net.csproj | 7 |
17 files changed, 389 insertions, 226 deletions
diff --git a/bindings/cs/Demo/App.config b/bindings/cs/Demo/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/bindings/cs/Demo/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> +</configuration>
\ No newline at end of file diff --git a/bindings/cs/Demo/Demo.csproj b/bindings/cs/Demo/Demo.csproj new file mode 100644 index 0000000..f347a5e --- /dev/null +++ b/bindings/cs/Demo/Demo.csproj @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{D3A43A2F-03B7-4A10-928F-686790036838}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Demo</RootNamespace> + <AssemblyName>Demo</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\x64\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\libsurvive.net\libsurvive.net.csproj"> + <Project>{da1b12d7-a121-4d40-b363-4893e4f88b8a}</Project> + <Name>libsurvive.net</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include=".NETFramework,Version=v4.6.1"> + <Visible>False</Visible> + <ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/bindings/cs/Demo/Program.cs b/bindings/cs/Demo/Program.cs new file mode 100644 index 0000000..1644360 --- /dev/null +++ b/bindings/cs/Demo/Program.cs @@ -0,0 +1,32 @@ +using libsurvive; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo +{ + internal class MyHandler : SurviveContext + { + public MyHandler() + { + } + + public MyHandler(string[] args) : base(args) + { + } + } + class Program + { + static void Main(string[] args) + { + MyHandler handler = new MyHandler(args); + + while (handler.Poll() == 0) { + } + + } + + } +} diff --git a/bindings/cs/Demo/Properties/AssemblyInfo.cs b/bindings/cs/Demo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2c6a6c7 --- /dev/null +++ b/bindings/cs/Demo/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Demo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Demo")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d3a43a2f-03b7-4a10-928f-686790036838")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/bindings/cs/LibSurviveBinding.sln b/bindings/cs/LibSurviveBinding.sln index 539470c..b2e2f11 100644 --- a/bindings/cs/LibSurviveBinding.sln +++ b/bindings/cs/LibSurviveBinding.sln @@ -1,20 +1,62 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27428.2015 +VisualStudioVersion = 15.0.27130.2003 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibSurviveBinding", "LibSurviveBinding\LibSurviveBinding.csproj", "{3DEFC8F7-C61E-4BC2-B743-E39453C6BA10}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{D3A43A2F-03B7-4A10-928F-686790036838}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "libsurvive.net", "libsurvive.net\libsurvive.net.csproj", "{DA1B12D7-A121-4D40-B363-4893E4F88B8A}" + ProjectSection(ProjectDependencies) = postProject + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F} = {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsurvive", "..\..\winbuild\libsurvive\libsurvive.vcxproj", "{435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 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 + {D3A43A2F-03B7-4A10-928F-686790036838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Debug|x64.ActiveCfg = Debug|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Debug|x64.Build.0 = Debug|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Debug|x86.ActiveCfg = Debug|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Debug|x86.Build.0 = Debug|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Release|Any CPU.Build.0 = Release|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Release|x64.ActiveCfg = Release|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Release|x64.Build.0 = Release|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Release|x86.ActiveCfg = Release|Any CPU + {D3A43A2F-03B7-4A10-928F-686790036838}.Release|x86.Build.0 = Release|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Debug|x64.ActiveCfg = Debug|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Debug|x64.Build.0 = Debug|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Debug|x86.ActiveCfg = Debug|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Debug|x86.Build.0 = Debug|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Release|Any CPU.Build.0 = Release|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Release|x64.ActiveCfg = Release|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Release|x64.Build.0 = Release|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Release|x86.ActiveCfg = Release|Any CPU + {DA1B12D7-A121-4D40-B363-4893E4F88B8A}.Release|x86.Build.0 = Release|Any CPU + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Debug|Any CPU.ActiveCfg = Debug|x64 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Debug|Any CPU.Build.0 = Debug|x64 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Debug|x64.ActiveCfg = Debug|x64 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Debug|x64.Build.0 = Debug|x64 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Debug|x86.ActiveCfg = Debug|Win32 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Debug|x86.Build.0 = Debug|Win32 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Release|Any CPU.ActiveCfg = Release|Win32 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Release|x64.ActiveCfg = Release|x64 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Release|x64.Build.0 = Release|x64 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Release|x86.ActiveCfg = Release|Win32 + {435CFD2C-8724-42EE-8FDE-71EF7D2C6B2F}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/bindings/cs/LibSurviveBinding/Binding.cs b/bindings/cs/LibSurviveBinding/Binding.cs deleted file mode 100644 index f4f0652..0000000 --- a/bindings/cs/LibSurviveBinding/Binding.cs +++ /dev/null @@ -1,33 +0,0 @@ -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 deleted file mode 100644 index 85a6701..0000000 --- a/bindings/cs/LibSurviveBinding/Config_entry.cs +++ /dev/null @@ -1,31 +0,0 @@ -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 deleted file mode 100644 index 646c16d..0000000 --- a/bindings/cs/LibSurviveBinding/LibSurviveBinding.csproj +++ /dev/null @@ -1,18 +0,0 @@ -<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 deleted file mode 100644 index ca51fb9..0000000 --- a/bindings/cs/LibSurviveBinding/LightcapElement.cs +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index b6d0d8f..0000000 --- a/bindings/cs/LibSurviveBinding/Program.cs +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index 2ba9b7c..0000000 --- a/bindings/cs/LibSurviveBinding/SurviveContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -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 deleted file mode 100644 index bb9e3cd..0000000 --- a/bindings/cs/LibSurviveBinding/SurviveObject.cs +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 9808d89..0000000 --- a/bindings/cs/LibSurviveBinding/SurvivePose.cs +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 8a2f00e..0000000 --- a/bindings/cs/LibSurviveBinding/config_group.cs +++ /dev/null @@ -1,14 +0,0 @@ -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/bindings/cs/libsurvive.net/SurviveContext.cs b/bindings/cs/libsurvive.net/SurviveContext.cs new file mode 100644 index 0000000..1fb8c11 --- /dev/null +++ b/bindings/cs/libsurvive.net/SurviveContext.cs @@ -0,0 +1,90 @@ +using System; + +namespace libsurvive +{ + using SurviveContextPtr = IntPtr; + using SurviveObjectPtr = IntPtr; + using SurvivePosePtr = IntPtr; + + public class SurviveContext : IDisposable + { + protected IntPtr ctx; + + public void Dispose() + { + cfunctions.survive_close(ctx); + ctx = IntPtr.Zero; + } + + public SurviveContext() : this(null) { } + + public SurviveContext(string[] args) + { + string[] newArgs = new string[args.Length + 1]; + newArgs[0] = System.Reflection.Assembly.GetEntryAssembly().FullName; + Array.Copy(args, 0, newArgs, 1, args.Length); + + ctx = cfunctions.survive_init_internal(newArgs.Length, newArgs); + + cfunctions.survive_install_raw_pose_fn(ctx, PoseEvent); + cfunctions.survive_install_light_fn(ctx, LightEvent); + cfunctions.survive_install_lighthouse_pose_fn(ctx, LightHouseEvent); + cfunctions.survive_install_angle_fn(ctx, AngleEvent); + cfunctions.survive_install_button_fn(ctx, ButtonEvent); + cfunctions.survive_install_htc_config_fn(ctx, HTCConfigEvent); + cfunctions.survive_install_imu_fn(ctx, IMUEvent); + cfunctions.survive_install_error_fn(ctx, ErrorEvent); + cfunctions.survive_install_info_fn(ctx, InfoEvent); + } + + protected void InfoEvent(SurviveObjectPtr ctx, string fault) + { + Console.Out.WriteLine(fault); + } + + protected void ErrorEvent(SurviveObjectPtr ctx, string fault) + { + Console.Error.WriteLine(fault); + } + + protected void IMUEvent(SurviveObjectPtr so, int mask, double[] accelgyro, uint timecode, int id) + { + cfunctions.survive_default_imu_process(so, mask, accelgyro, timecode, id); + } + + protected int HTCConfigEvent(SurviveObjectPtr so, string ct0conf, int len) + { + return cfunctions.survive_default_htc_config_process(so, ct0conf, len); + } + + protected void ButtonEvent(SurviveObjectPtr so, byte eventType, byte buttonId, byte axis1Id, ushort axis1Val, byte axis2Id, ushort axis2Val) + { + cfunctions.survive_default_button_process(so, eventType, buttonId, axis1Id, axis1Val, axis2Id, axis2Val); + } + + protected void AngleEvent(SurviveObjectPtr so, int sensor_id, int acode, uint timecode, double length, double angle, uint lh) + { + cfunctions.survive_default_angle_process(so, sensor_id, acode, timecode, length, angle, lh); + } + + protected void LightHouseEvent(SurviveObjectPtr ctx, byte lighthouse, ref SurvivePose lighthouse_pose, ref SurvivePose object_pose) + { + cfunctions.survive_default_lighthouse_pose_process(ctx, lighthouse, ref lighthouse_pose, ref object_pose); + } + + protected void LightEvent(SurviveObjectPtr so, int sensor_id, int acode, int timeinsweep, UInt32 timecode, UInt32 length, UInt32 lighthouse) + { + cfunctions.survive_default_light_process(so, sensor_id, acode, timeinsweep, timecode, length, lighthouse); + } + + protected void PoseEvent(IntPtr so, byte lighthouse, ref SurvivePose pose) + { + cfunctions.survive_default_raw_pose_process(so, lighthouse, ref pose); + } + + public int Poll() + { + return cfunctions.survive_poll(ctx); + } + } +}
\ No newline at end of file diff --git a/bindings/cs/libsurvive.net/cfunctions.cs b/bindings/cs/libsurvive.net/cfunctions.cs new file mode 100644 index 0000000..f9d88f0 --- /dev/null +++ b/bindings/cs/libsurvive.net/cfunctions.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace libsurvive +{ + using SurviveContextPtr = IntPtr; + using SurviveObjectPtr = IntPtr; + using SurvivePosePtr = IntPtr; + + [StructLayout(LayoutKind.Sequential)] + public struct SurvivePose + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public double[] Pos; // Position in the form xyz + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + public double[] Rot; // Quaternion in the form wxyz + } + + class cfunctions + { + +#pragma warning disable IDE1006 // Naming Styles + [DllImport("libsurvive")] + public static extern SurviveContextPtr survive_init_internal(int argc, string[] args); + [DllImport("libsurvive")] + public static extern SurviveContextPtr survive_close(SurviveContextPtr ctx); + [DllImport("libsurvive")] + public static extern int survive_poll(SurviveContextPtr ctx); + [DllImport("libsurvive")] + public static extern int survive_startup(SurviveContextPtr ctx); + + [DllImport("libsurvive")] + public static extern void survive_install_htc_config_fn(SurviveContextPtr ctx, htc_config_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_info_fn(SurviveContextPtr ctx, text_feedback_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_error_fn(SurviveContextPtr ctx, text_feedback_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_imu_fn(SurviveContextPtr ctx, imu_process_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_angle_fn(SurviveContextPtr ctx, angle_process_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_button_fn(SurviveContextPtr ctx, button_process_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_raw_pose_fn(SurviveContextPtr ctx, raw_pose_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_lighthouse_pose_fn(SurviveContextPtr ctx, lighthouse_pose_func fbp); + [DllImport("libsurvive")] + public static extern void survive_install_light_fn(SurviveContextPtr ctx, light_process_func fbp); + [DllImport("libsurvive")] + public static extern void survive_cal_install(SurviveContextPtr ctx); + + [DllImport("libsurvive")] + public static extern void survive_default_light_process(SurviveObjectPtr so, int sensor_id, int acode, int timeinsweep, UInt32 timecode, UInt32 length, UInt32 lh); + [DllImport("libsurvive")] + public static extern void survive_default_imu_process(SurviveObjectPtr so, int mode, double[] accelgyro, UInt32 timecode, int id); + [DllImport("libsurvive")] + public static extern void survive_default_angle_process(SurviveObjectPtr so, int sensor_id, int acode, UInt32 timecode, double length, double angle, UInt32 lh); + [DllImport("libsurvive")] + public static extern void survive_default_button_process(SurviveObjectPtr so, byte eventType, byte buttonId, byte axis1Id, UInt16 axis1Val, byte axis2Id, UInt16 axis2Val); + [DllImport("libsurvive")] + public static extern void survive_default_raw_pose_process(SurviveObjectPtr so, byte lighthouse, ref SurvivePose pose); + [DllImport("libsurvive")] + public static extern void survive_default_lighthouse_pose_process(SurviveContextPtr ctx, byte lighthouse, ref SurvivePose lh_pose, + ref SurvivePose obj_pose); + [DllImport("libsurvive")] + public static extern int survive_default_htc_config_process(SurviveObjectPtr so, string ct0conf, int len); + +#pragma warning restore IDE1006 // Naming Styles + } + + public delegate int htc_config_func(SurviveObjectPtr so, string ct0conf, int len); + public delegate void text_feedback_func(SurviveContextPtr ctx, string fault); + public delegate void light_process_func(SurviveObjectPtr so, int sensor_id, int acode, int timeinsweep, UInt32 timecode, UInt32 length, UInt32 lighthouse); + public delegate void imu_process_func(SurviveObjectPtr so, int mask, double[] accelgyro, UInt32 timecode, int id); + public delegate void angle_process_func(SurviveObjectPtr so, int sensor_id, int acode, UInt32 timecode, double length, double angle, UInt32 lh); + public delegate void button_process_func(SurviveObjectPtr so, byte eventType, byte buttonId, byte axis1Id, UInt16 axis1Val, byte axis2Id, UInt16 axis2Val); + public delegate void raw_pose_func(SurviveObjectPtr so, byte lighthouse, ref SurvivePose pose); + public delegate void lighthouse_pose_func(SurviveContextPtr ctx, byte lighthouse, ref SurvivePose lighthouse_pose, + ref SurvivePose object_pose); + +} diff --git a/bindings/cs/libsurvive.net/libsurvive.net.csproj b/bindings/cs/libsurvive.net/libsurvive.net.csproj new file mode 100644 index 0000000..eac3503 --- /dev/null +++ b/bindings/cs/libsurvive.net/libsurvive.net.csproj @@ -0,0 +1,7 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>netstandard1.6</TargetFramework> + </PropertyGroup> + +</Project> |