Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
Cloning PSMoveFreepieBridge
Browse files Browse the repository at this point in the history
  • Loading branch information
HipsterSloth committed Sep 30, 2018
1 parent 54b3cb3 commit bcdc88c
Show file tree
Hide file tree
Showing 301 changed files with 62,465 additions and 34 deletions.
44 changes: 12 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
Debug/*
Release/*
ipch/*
.vs/*
FreepieWriter/bin/*
FreepieWriter/obj/*
FreepieWriterBridge/Debug/*
FreepieWriterBridge/Release/*
PSMoveFreepieBridge/Debug/*
PSMoveFreepieBridge/Release/*
x64/*
*.sdf
58 changes: 58 additions & 0 deletions FreepieWriter/FreepieWriter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace FreepieWriter
{
public class FreepieWriter
{
[StructLayout(LayoutKind.Sequential)]
public struct FreepieData
{
public float yaw;
public float pitch;
public float roll;

public float x;
public float y;
public float z;
}

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetDllDirectory(string lpPathName);

[DllImport("freepie_io.dll")]
private static extern int freepie_io_6dof_slots();

[DllImport("freepie_io.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int freepie_io_6dof_write(int index, int length, FreepieData[] data);

private static bool bInit = false;

private static void init()
{
//Set freepie DLL path so we don't have to include it
var path = Registry.GetValue(string.Format("{0}\\Software\\{1}", Registry.CurrentUser, "FreePIE"), "path", null) as string;
SetDllDirectory(path);
bInit = true;
}

public static void WriteData(FreepieData data, Int32 freepieIndex = 0)
{
if (!bInit)
{
init();
}

FreepieData[] toArray = new FreepieData[1];
toArray[0] = data;
int result = freepie_io_6dof_write(freepieIndex, 1, toArray);

if (result != 0)
{
throw new Exception("FreepieWriter - Could not write pose to freepie index " + freepieIndex + ", Freepie result " + result);
}
}
}
}
54 changes: 54 additions & 0 deletions FreepieWriter/FreepieWriter.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{8408DE33-57B4-4953-B8DE-F68FC6B4E12D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FreepieWriter</RootNamespace>
<AssemblyName>FreepieWriter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<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="FreepieWriter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
36 changes: 36 additions & 0 deletions FreepieWriter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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("FreepieWriter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FreepieWriter")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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("8408de33-57b4-4953-b8de-f68fc6b4e12d")]

// 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")]
38 changes: 38 additions & 0 deletions FreepieWriterBridge/AssemblyInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "stdafx.h"

using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;

//
// 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:AssemblyTitleAttribute(L"FreepieWriterBridge")];
[assembly:AssemblyDescriptionAttribute(L"")];
[assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"")];
[assembly:AssemblyProductAttribute(L"FreepieWriterBridge")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2016")];
[assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")];

//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly:AssemblyVersionAttribute("1.0.*")];

[assembly:ComVisible(false)];

[assembly:CLSCompliantAttribute(true)];
6 changes: 6 additions & 0 deletions FreepieWriterBridge/FreepieWriterBridge.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This is the main DLL file.

#include "stdafx.h"

#include "FreepieWriterBridge.h"

28 changes: 28 additions & 0 deletions FreepieWriterBridge/FreepieWriterBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include "../thirdparty/headers/FreePIE/freepie_io.h"
using namespace System;

namespace FreepieWriterBridge {

public ref class FreepieWriterBridge
{
public:static void WriteToFreepie(freepie_io_6dof_data data, int32_t freepieIndex)
{
//Can't send freepie_io_6dof_data directly, need to copy into CS compatible struct
FreepieWriter::FreepieWriter::FreepieData csData;
csData.x = data.x;
csData.y = data.y;
csData.z = data.z;
csData.pitch = data.pitch;
csData.yaw = data.yaw;
csData.roll = data.roll;
FreepieWriter::FreepieWriter::WriteData(csData, freepieIndex);
}
};
}

__declspec(dllexport) void WriteToFreepie(freepie_io_6dof_data data, int32_t freepieIndex = 0)
{
FreepieWriterBridge::FreepieWriterBridge bridge;
bridge.WriteToFreepie(data, freepieIndex);
}
Loading

0 comments on commit bcdc88c

Please sign in to comment.