diff options
author | Justin Berger <j.david.berger@gmail.com> | 2018-03-28 20:36:05 -0600 |
---|---|---|
committer | Justin Berger <j.david.berger@gmail.com> | 2018-03-28 20:36:05 -0600 |
commit | 91f0cab811e983da63ea49f6e24afae283138a1c (patch) | |
tree | 5778c7f27e29ce51a9b86897dcf0e3a03beeed1b | |
parent | bb37e04c7ec35f28ec929afb9634fea1db007723 (diff) | |
download | libsurvive-91f0cab811e983da63ea49f6e24afae283138a1c.tar.gz libsurvive-91f0cab811e983da63ea49f6e24afae283138a1c.tar.bz2 |
Functional C# in windows
25 files changed, 441 insertions, 261 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> diff --git a/calibrate.c b/calibrate.c index 569c5cb..e21c310 100644 --- a/calibrate.c +++ b/calibrate.c @@ -404,8 +404,6 @@ void * SurviveThread(void *jnk) survive_install_angle_fn( ctx, my_angle_process ); survive_startup( ctx ); - - survive_cal_install( ctx ); if( !ctx ) diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 8a1474b..85078f7 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -10,6 +10,13 @@ extern "C" { #endif + +#ifdef _WIN32 +#define SURVIVE_EXPORT __declspec(dllexport) +#else +#define SURVIVE_EXPORT +#endif + /** * This struct encodes what the last effective angles seen on a sensor were, and when they occured. */ @@ -203,7 +210,7 @@ struct SurviveContext void survive_verify_FLT_size(uint32_t user_size); // Baked in size of FLT to verify users of the library have the correct setting. -SurviveContext * survive_init_internal( int argc, char * const * argv ); +SURVIVE_EXPORT SurviveContext * survive_init_internal( int argc, char * const * argv ); /** * Call survive_init to get a populated SurviveContext pointer. @@ -224,20 +231,20 @@ static inline SurviveContext * survive_init( int argc, char * const * argv ) //For any of these, you may pass in 0 for the function pointer to use default behavior. //In general unless you are doing wacky things like recording or playing back data, you won't need to use this. -void survive_install_htc_config_fn( SurviveContext *ctx, htc_config_func fbp ); -void survive_install_info_fn( SurviveContext * ctx, text_feedback_func fbp ); -void survive_install_error_fn( SurviveContext * ctx, text_feedback_func fbp ); -void survive_install_light_fn( SurviveContext * ctx, light_process_func fbp ); -void survive_install_imu_fn( SurviveContext * ctx, imu_process_func fbp ); -void survive_install_angle_fn( SurviveContext * ctx, angle_process_func fbp ); -void survive_install_button_fn(SurviveContext * ctx, button_process_func fbp); -void survive_install_raw_pose_fn(SurviveContext * ctx, raw_pose_func fbp); -void survive_install_lighthouse_pose_fn(SurviveContext *ctx, lighthouse_pose_func fbp); -int survive_startup( SurviveContext * ctx ); -int survive_poll( SurviveContext * ctx ); -void survive_close( SurviveContext * ctx ); - -SurviveObject * survive_get_so_by_name( SurviveContext * ctx, const char * name ); +SURVIVE_EXPORT void survive_install_htc_config_fn( SurviveContext *ctx, htc_config_func fbp ); +SURVIVE_EXPORT void survive_install_info_fn( SurviveContext * ctx, text_feedback_func fbp ); +SURVIVE_EXPORT void survive_install_error_fn( SurviveContext * ctx, text_feedback_func fbp ); +SURVIVE_EXPORT void survive_install_light_fn( SurviveContext * ctx, light_process_func fbp ); +SURVIVE_EXPORT void survive_install_imu_fn( SurviveContext * ctx, imu_process_func fbp ); +SURVIVE_EXPORT void survive_install_angle_fn( SurviveContext * ctx, angle_process_func fbp ); +SURVIVE_EXPORT void survive_install_button_fn(SurviveContext * ctx, button_process_func fbp); +SURVIVE_EXPORT void survive_install_raw_pose_fn(SurviveContext * ctx, raw_pose_func fbp); +SURVIVE_EXPORT void survive_install_lighthouse_pose_fn(SurviveContext *ctx, lighthouse_pose_func fbp); +SURVIVE_EXPORT int survive_startup( SurviveContext * ctx ); +SURVIVE_EXPORT int survive_poll( SurviveContext * ctx ); +SURVIVE_EXPORT void survive_close( SurviveContext * ctx ); + +SURVIVE_EXPORT SurviveObject * survive_get_so_by_name( SurviveContext * ctx, const char * name ); //Utilitiy functions. int survive_simple_inflate( SurviveContext * ctx, const char * input, int inlen, char * output, int outlen ); @@ -249,30 +256,30 @@ int survive_send_magic( SurviveContext * ctx, int magic_code, void * data, int d #define SC_OVERRIDE 2 //Set, to new default value. #define SC_SETCONFIG 4 //Set, both in-memory and config file. Use in conjunction with SC_OVERRIDE. -FLT survive_configf( SurviveContext * ctx, const char *tag, char flags, FLT def ); -uint32_t survive_configi( SurviveContext * ctx, const char *tag, char flags, uint32_t def ); -const char * survive_configs( SurviveContext * ctx, const char *tag, char flags, const char *def ); +SURVIVE_EXPORT FLT survive_configf( SurviveContext * ctx, const char *tag, char flags, FLT def ); +SURVIVE_EXPORT uint32_t survive_configi( SurviveContext * ctx, const char *tag, char flags, uint32_t def ); +SURVIVE_EXPORT const char * survive_configs( SurviveContext * ctx, const char *tag, char flags, const char *def ); //Install the calibrator. -void survive_cal_install( SurviveContext * ctx ); //XXX This will be removed if not already done so. +SURVIVE_EXPORT void survive_cal_install( SurviveContext * ctx ); //XXX This will be removed if not already done so. // Read back a human-readable string description of the calibration status -int survive_cal_get_status( SurviveContext * ctx, char * description, int description_length ); +SURVIVE_EXPORT int survive_cal_get_status( SurviveContext * ctx, char * description, int description_length ); // Induce haptic feedback -int survive_haptic(SurviveObject * so, uint8_t reserved, uint16_t pulseHigh, uint16_t pulseLow, uint16_t repeatCount); +SURVIVE_EXPORT int survive_haptic(SurviveObject * so, uint8_t reserved, uint16_t pulseHigh, uint16_t pulseLow, uint16_t repeatCount); //Call these from your callback if overridden. //Accept higher-level data. -void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length , uint32_t lh); -void survive_default_imu_process( SurviveObject * so, int mode, FLT * accelgyro, uint32_t timecode, int id ); -void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle, uint32_t lh ); -void survive_default_button_process(SurviveObject * so, uint8_t eventType, uint8_t buttonId, uint8_t axis1Id, uint16_t axis1Val, uint8_t axis2Id, uint16_t axis2Val); -void survive_default_raw_pose_process(SurviveObject *so, uint8_t lighthouse, SurvivePose *pose); -void survive_default_lighthouse_pose_process(SurviveContext *ctx, uint8_t lighthouse, SurvivePose *lh_pose, +SURVIVE_EXPORT void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length , uint32_t lh); +SURVIVE_EXPORT void survive_default_imu_process( SurviveObject * so, int mode, FLT * accelgyro, uint32_t timecode, int id ); +SURVIVE_EXPORT void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle, uint32_t lh ); +SURVIVE_EXPORT void survive_default_button_process(SurviveObject * so, uint8_t eventType, uint8_t buttonId, uint8_t axis1Id, uint16_t axis1Val, uint8_t axis2Id, uint16_t axis2Val); +SURVIVE_EXPORT void survive_default_raw_pose_process(SurviveObject *so, uint8_t lighthouse, SurvivePose *pose); +SURVIVE_EXPORT void survive_default_lighthouse_pose_process(SurviveContext *ctx, uint8_t lighthouse, SurvivePose *lh_pose, SurvivePose *obj_pose); -int survive_default_htc_config_process(SurviveObject *so, char *ct0conf, int len); +SURVIVE_EXPORT int survive_default_htc_config_process(SurviveObject *so, char *ct0conf, int len); diff --git a/redist/symbol_enumerator.c b/redist/symbol_enumerator.c index fcb3727..58bbfaa 100644 --- a/redist/symbol_enumerator.c +++ b/redist/symbol_enumerator.c @@ -60,7 +60,7 @@ BOOL WINAPI SymCleanup( HANDLE hProcess ); -BOOL CALLBACK __cdecl mycb( +BOOL mycb( PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext @@ -71,10 +71,11 @@ BOOL CALLBACK __cdecl mycb( int EnumerateSymbols( SymEnumeratorCallback cb ) { - HANDLE proc = GetCurrentProcess(); + HANDLE proc = GetCurrentProcess(); if( !SymInitialize( proc, 0, 1 ) ) return -1; if( !SymEnumSymbols( proc, 0, "*!*", &mycb, (void*)cb ) ) { + fprintf(stderr, "SymEnumSymbols returned %d\n", GetLastError()); SymCleanup(proc); return -2; } diff --git a/src/survive.c b/src/survive.c index 899d206..f46f128 100644 --- a/src/survive.c +++ b/src/survive.c @@ -111,6 +111,11 @@ SurviveContext *survive_init_internal(int argc, char *const *argv) { MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho) MANUAL_DRIVER_REGISTRATION(PoserDummy) MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive) + MANUAL_DRIVER_REGISTRATION(DriverRegPlayback) + + MANUAL_DRIVER_REGISTRATION(DisambiguatorCharles) + MANUAL_DRIVER_REGISTRATION(DisambiguatorStateBased) + MANUAL_DRIVER_REGISTRATION(DisambiguatorTurvey) #endif SurviveContext *ctx = calloc(1, sizeof(SurviveContext)); diff --git a/src/survive_playback.c b/src/survive_playback.c index 43a3c0b..c73dd2f 100644 --- a/src/survive_playback.c +++ b/src/survive_playback.c @@ -275,7 +275,7 @@ static int playback_poll(struct SurviveContext *ctx, void *_driver) { if (f && !feof(f) && !ferror(f)) { driver->lineno++; - char *line; + char *line = 0; if (driver->next_time_us == 0) { size_t n = 0; diff --git a/winbuild/libsurvive/libsurvive.def b/winbuild/libsurvive/libsurvive.def index fb2f05e..3a50ce6 100644 --- a/winbuild/libsurvive/libsurvive.def +++ b/winbuild/libsurvive/libsurvive.def @@ -10,6 +10,7 @@ EXPORTS survive_install_light_fn survive_install_imu_fn survive_install_angle_fn + survive_install_htc_config_fn survive_send_magic survive_cal_install survive_cal_get_status @@ -26,3 +27,4 @@ EXPORTS survive_default_lighthouse_pose_process quatnormalize quatrotatevector +
\ No newline at end of file diff --git a/winbuild/libsurvive/libsurvive.vcxproj b/winbuild/libsurvive/libsurvive.vcxproj index acf8500..6268d63 100644 --- a/winbuild/libsurvive/libsurvive.vcxproj +++ b/winbuild/libsurvive/libsurvive.vcxproj @@ -27,7 +27,7 @@ </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> + <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <PlatformToolset>v141</PlatformToolset> <CharacterSet>MultiByte</CharacterSet> @@ -77,7 +77,7 @@ </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>FLT=double;USE_DOUBLE;RUNTIME_SYMNUM;RUNTIME_SYMNUMX;NOZLIB;_CRT_SECURE_NO_WARNINGS;HIDAPI;WINDOWS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>FLT=double;USE_DOUBLE;MANUAL_REGISTRATION;NOZLIB;_CRT_SECURE_NO_WARNINGS;HIDAPI;WINDOWS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\winbuild;..\..\include\libsurvive;..\..\redist;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ClCompile> <Link> @@ -169,6 +169,7 @@ <ClCompile Include="..\..\src\survive_process.c" /> <ClCompile Include="..\..\src\survive_reproject.c" /> <ClCompile Include="..\..\src\survive_sensor_activations.c" /> + <ClCompile Include="..\..\src\survive_statebased_disambiguator.c" /> <ClCompile Include="..\..\src\survive_turveybiguator.c" /> <ClCompile Include="..\..\src\survive_usb.c" /> <ClCompile Include="..\..\src\survive_vive.c" /> diff --git a/winbuild/libsurvive/libsurvive.vcxproj.filters b/winbuild/libsurvive/libsurvive.vcxproj.filters index 717038c..5387108 100644 --- a/winbuild/libsurvive/libsurvive.vcxproj.filters +++ b/winbuild/libsurvive/libsurvive.vcxproj.filters @@ -105,6 +105,9 @@ <ClCompile Include="..\getdelim.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\..\src\survive_statebased_disambiguator.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\src\ootx_decoder.h"> |