Skip to content

Commit d584a12

Browse files
committed
Added C++ sample
1 parent 25ea413 commit d584a12

8 files changed

Lines changed: 310 additions & 0 deletions

File tree

С++/GetData/GetData.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26430.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GetData", "GetData\GetData.vcxproj", "{66768760-6FF7-4282-8356-8B3FC35F6CF3}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Debug|x64.ActiveCfg = Debug|x64
17+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Debug|x64.Build.0 = Debug|x64
18+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Debug|x86.ActiveCfg = Debug|Win32
19+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Debug|x86.Build.0 = Debug|Win32
20+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Release|x64.ActiveCfg = Release|x64
21+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Release|x64.Build.0 = Release|x64
22+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Release|x86.ActiveCfg = Release|Win32
23+
{66768760-6FF7-4282-8356-8B3FC35F6CF3}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal

С++/GetData/GetData/GetData.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "stdafx.h"
2+
#include <Windows.h>
3+
4+
typedef struct _HMDData
5+
{
6+
double X;
7+
double Y;
8+
double Z;
9+
double Yaw;
10+
double Pitch;
11+
double Roll;
12+
} THMD, *PHMD;
13+
14+
//Other typedef structs in Library https://github.com/TrueOpenVR/TrueOpenVR-Core/tree/master/Library/
15+
16+
typedef DWORD(_stdcall *_GetHMDData)(__out THMD* myHMD);
17+
18+
19+
int main()
20+
{
21+
//Path to "TOVR.dll" on Registry - "HKEY_CURRENT_USER\Software\TrueOpenVR" parameter "Library"
22+
HMODULE hDll = LoadLibrary(L"TOVR.dll");
23+
if (hDll == NULL) {
24+
printf("ERROR: unable to load DLL\n");
25+
return 1;
26+
}
27+
28+
THMD myHMD;
29+
30+
ZeroMemory(&myHMD, sizeof(THMD));
31+
32+
_GetHMDData GetHMDData;
33+
34+
GetHMDData = (_GetHMDData)GetProcAddress(hDll, "GetHMDData");
35+
36+
if (GetHMDData == NULL) {
37+
printf("ERROR: unable to find DLL function\n");
38+
return 1;
39+
}
40+
41+
DWORD iResult = GetHMDData(&myHMD);
42+
43+
Sleep(300);
44+
45+
GetHMDData(&myHMD);
46+
47+
printf("Result = %d\n", iResult);
48+
49+
printf("X = %f\nY = %f\nZ = %f\nYaw = %f\nPitch = %f\nRoll = %f\n\n", myHMD.X, myHMD.Y, myHMD.Z, myHMD.Yaw, myHMD.Pitch, myHMD.Roll);
50+
51+
system("pause");
52+
FreeLibrary(hDll);
53+
hDll = nullptr;
54+
return 0;
55+
}

С++/GetData/GetData/GetData.h

Whitespace-only changes.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>15.0</VCProjectVersion>
23+
<ProjectGuid>{66768760-6FF7-4282-8356-8B3FC35F6CF3}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<RootNamespace>GetData</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v141</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v141</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v141</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v141</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<LinkIncremental>true</LinkIncremental>
75+
</PropertyGroup>
76+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
77+
<LinkIncremental>true</LinkIncremental>
78+
</PropertyGroup>
79+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
80+
<LinkIncremental>false</LinkIncremental>
81+
</PropertyGroup>
82+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
83+
<LinkIncremental>false</LinkIncremental>
84+
</PropertyGroup>
85+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
86+
<ClCompile>
87+
<PrecompiledHeader>Use</PrecompiledHeader>
88+
<WarningLevel>Level3</WarningLevel>
89+
<Optimization>Disabled</Optimization>
90+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
91+
</ClCompile>
92+
<Link>
93+
<SubSystem>Console</SubSystem>
94+
</Link>
95+
</ItemDefinitionGroup>
96+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
97+
<ClCompile>
98+
<PrecompiledHeader>Use</PrecompiledHeader>
99+
<WarningLevel>Level3</WarningLevel>
100+
<Optimization>Disabled</Optimization>
101+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
102+
</ClCompile>
103+
<Link>
104+
<SubSystem>Console</SubSystem>
105+
</Link>
106+
</ItemDefinitionGroup>
107+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
108+
<ClCompile>
109+
<WarningLevel>Level3</WarningLevel>
110+
<PrecompiledHeader>Use</PrecompiledHeader>
111+
<Optimization>MaxSpeed</Optimization>
112+
<FunctionLevelLinking>true</FunctionLevelLinking>
113+
<IntrinsicFunctions>true</IntrinsicFunctions>
114+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115+
</ClCompile>
116+
<Link>
117+
<SubSystem>Console</SubSystem>
118+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
119+
<OptimizeReferences>true</OptimizeReferences>
120+
</Link>
121+
</ItemDefinitionGroup>
122+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
123+
<ClCompile>
124+
<WarningLevel>Level3</WarningLevel>
125+
<PrecompiledHeader>Use</PrecompiledHeader>
126+
<Optimization>MaxSpeed</Optimization>
127+
<FunctionLevelLinking>true</FunctionLevelLinking>
128+
<IntrinsicFunctions>true</IntrinsicFunctions>
129+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
130+
</ClCompile>
131+
<Link>
132+
<SubSystem>Console</SubSystem>
133+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
134+
<OptimizeReferences>true</OptimizeReferences>
135+
</Link>
136+
</ItemDefinitionGroup>
137+
<ItemGroup>
138+
<Text Include="ReadMe.txt" />
139+
</ItemGroup>
140+
<ItemGroup>
141+
<ClInclude Include="GetData.h" />
142+
<ClInclude Include="stdafx.h" />
143+
<ClInclude Include="targetver.h" />
144+
</ItemGroup>
145+
<ItemGroup>
146+
<ClCompile Include="GetData.cpp" />
147+
<ClCompile Include="stdafx.cpp">
148+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
149+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
150+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
151+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
152+
</ClCompile>
153+
</ItemGroup>
154+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
155+
<ImportGroup Label="ExtensionTargets">
156+
</ImportGroup>
157+
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Файлы исходного кода">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Заголовочные файлы">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Файлы ресурсов">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<Text Include="ReadMe.txt" />
19+
</ItemGroup>
20+
<ItemGroup>
21+
<ClInclude Include="stdafx.h">
22+
<Filter>Заголовочные файлы</Filter>
23+
</ClInclude>
24+
<ClInclude Include="targetver.h">
25+
<Filter>Заголовочные файлы</Filter>
26+
</ClInclude>
27+
<ClInclude Include="GetData.h">
28+
<Filter>Заголовочные файлы</Filter>
29+
</ClInclude>
30+
</ItemGroup>
31+
<ItemGroup>
32+
<ClCompile Include="stdafx.cpp">
33+
<Filter>Файлы исходного кода</Filter>
34+
</ClCompile>
35+
<ClCompile Include="GetData.cpp">
36+
<Filter>Файлы исходного кода</Filter>
37+
</ClCompile>
38+
</ItemGroup>
39+
</Project>

С++/GetData/GetData/stdafx.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// stdafx.cpp: исходный файл, содержащий только стандартные включаемые модули
2+
// GetData.pch будет предкомпилированным заголовком
3+
// stdafx.obj будет содержать предварительно откомпилированные сведения о типе
4+
5+
#include "stdafx.h"
6+
7+
// TODO: Установите ссылки на любые требующиеся дополнительные заголовки в файле STDAFX.H
8+
// , а не в данном файле

С++/GetData/GetData/stdafx.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// stdafx.h: включаемый файл для стандартных системных включаемых файлов
2+
// или включаемых файлов для конкретного проекта, которые часто используются, но
3+
// не часто изменяются
4+
//
5+
6+
#pragma once
7+
8+
#include "targetver.h"
9+
10+
#include <stdio.h>
11+
#include <tchar.h>
12+
13+
14+
15+
// TODO: Установите здесь ссылки на дополнительные заголовки, требующиеся для программы

С++/GetData/GetData/targetver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
// Включение SDKDDKVer.h обеспечивает определение самой последней доступной платформы Windows.
4+
5+
// Если требуется выполнить сборку приложения для предыдущей версии Windows, включите WinSDKVer.h и
6+
// задайте для макроса _WIN32_WINNT значение поддерживаемой платформы перед включением SDKDDKVer.h.
7+
8+
#include <SDKDDKVer.h>

0 commit comments

Comments
 (0)