diff options
Diffstat (limited to 'Tobii-EyeX/samples')
168 files changed, 4828 insertions, 0 deletions
diff --git a/Tobii-EyeX/samples/.vs/Samples/v14/.suo b/Tobii-EyeX/samples/.vs/Samples/v14/.suo Binary files differnew file mode 100755 index 0000000..c6b0831 --- /dev/null +++ b/Tobii-EyeX/samples/.vs/Samples/v14/.suo diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.cpp b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.cpp new file mode 100755 index 0000000..4fbe055 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.cpp @@ -0,0 +1,54 @@ +/*
+ * ActivatableBoardGame sample:
+ * This is an example that demonstrates the use of Activatable interactors in the context of a board game.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#include "stdafx.h"
+#include <windows.h>
+#include <objidl.h>
+#include <gdiplus.h>
+#include "Resource.h"
+#include "Board.h"
+#include "BoardWindow.h"
+
+#pragma comment (lib, "Gdiplus.lib")
+
+// Application entry point.
+int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
+ _In_opt_ HINSTANCE hPrevInstance,
+ _In_ LPTSTR lpCmdLine,
+ _In_ int nCmdShow)
+{
+ UNREFERENCED_PARAMETER(hPrevInstance);
+ UNREFERENCED_PARAMETER(lpCmdLine);
+
+ // initialize the GDI+ library.
+ ULONG_PTR gdiplusToken;
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+ // initialize the Board and the BoardWindow.
+ // these will be un-initialized automatically when they fall out of scope.
+ Board board(8);
+ BoardWindow::RegisterWindowClass(hInstance);
+ BoardWindow window(board, hInstance, nCmdShow);
+
+ HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_GOBANG));
+
+ // Main message loop
+ MSG msg;
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+
+ return (int) msg.wParam;
+}
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.ico b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.ico Binary files differnew file mode 100755 index 0000000..449296f --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.ico diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.rc b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.rc Binary files differnew file mode 100755 index 0000000..718dee1 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.rc diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.vcxproj b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.vcxproj new file mode 100755 index 0000000..5b82b9c --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.vcxproj @@ -0,0 +1,193 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{2732E876-973B-4453-AA9F-D306EFB11922}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>ActivatableBoardGame</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="Board.h" />
+ <ClInclude Include="BoardWindow.h" />
+ <ClInclude Include="EyeXHost.h" />
+ <ClInclude Include="Observer.h" />
+ <ClInclude Include="Resource.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Board.cpp" />
+ <ClCompile Include="BoardWindow.cpp" />
+ <ClCompile Include="ActivatableBoardGame.cpp" />
+ <ClCompile Include="EyeXHost.cpp" />
+ <ClCompile Include="stdafx.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="ActivatableBoardGame.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="ActivatableBoardGame.ico" />
+ <Image Include="small.ico" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <Import Project="..\CopyEyeXDllToOutputDirectory.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.vcxproj.filters b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.vcxproj.filters new file mode 100755 index 0000000..9baf12a --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/ActivatableBoardGame.vcxproj.filters @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="targetver.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Board.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="BoardWindow.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Observer.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="EyeXHost.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ActivatableBoardGame.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Board.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="BoardWindow.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="EyeXHost.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="ActivatableBoardGame.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="small.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="ActivatableBoardGame.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Board.cpp b/Tobii-EyeX/samples/ActivatableBoardGame/Board.cpp new file mode 100755 index 0000000..e59fc92 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Board.cpp @@ -0,0 +1,220 @@ +/*
+ * ActivatableBoardGame sample:
+ * This is an example that demonstrates the use of Activatable interactors in the context of a board game.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#include "stdafx.h"
+#include "Board.h"
+#include <cassert>
+#include <vector>
+#include "Observer.h"
+
+// initialize the random number generator.
+auto const seed = std::random_device()();
+std::mt19937 Board::_randomNumberGenerator(seed);
+
+Board::Board(int size)
+ : _size(size), _board(nullptr), _boardChangedObserver(nullptr)
+{
+ _board = new Marker[_size * _size];
+ BeginNewGame();
+}
+
+Board::~Board()
+{
+ delete[] _board;
+}
+
+void Board::InitBoard()
+{
+ for (int i = 0; i < _size; ++i)
+ {
+ for (int j = 0; j < _size; ++j)
+ {
+ SetMarkerAt(Position(i, j), Marker::None);
+ }
+ }
+
+ SetMarkerAt(Position((_size - 1) / 2, (_size - 1) / 2), Marker::X);
+ SetMarkerAt(Position((_size - 1) / 2, (_size - 1) / 2 + 1), Marker::O);
+ SetMarkerAt(Position((_size - 1) / 2 + 1, (_size - 1) / 2), Marker::O);
+ SetMarkerAt(Position((_size - 1) / 2 + 1, (_size - 1) / 2 + 1), Marker::X);
+}
+
+Board::Marker Board::GetMarkerAt(Position position) const
+{
+ assert(IsValidPosition(position));
+
+ return _board[position.column + position.row * _size];
+}
+
+void Board::SetMarkerAt(Position position, Marker marker)
+{
+ assert(IsValidPosition(position));
+
+ _board[position.column + position.row * _size] = marker;
+
+ NotifyObserver();
+}
+
+void Board::MakeHumanPlayerMove(Position position)
+{
+ if (_playerInTurn == Marker::X &&
+ !IsGameOver() &&
+ GetMarkerAt(position) == Marker::None)
+ {
+ MakeMove(position);
+
+ if (!IsGameOver())
+ {
+ MakeAIPlayerMove();
+ }
+ }
+}
+
+bool Board::CanMakeMoveAt(Position position) const
+{
+ return IsValidPosition(position) &&
+ GetMarkerAt(position) == Marker::None;
+}
+
+void Board::BeginNewGame()
+{
+ InitBoard();
+ _playerInTurn = Marker::X;
+ _winner = Marker::None;
+}
+
+bool Board::IsValidPosition(Position position) const
+{
+ return 0 <= position.row && position.row < _size &&
+ 0 <= position.column && position.column < _size;
+}
+
+void Board::MakeAIPlayerMove()
+{
+ // generate the list of all possible moves. not that they are good or anything, just possible.
+ std::vector<Position> possibleMoves;
+ for (int i = 0; i < _size; i++)
+ {
+ for (int j = 0; j < _size; j++)
+ {
+ Position position(i, j);
+ if (GetMarkerAt(position) == Marker::None)
+ {
+ possibleMoves.push_back(position);
+ }
+ }
+ }
+
+ // since we check whether the game is a draw before calling this method, there should always be at least one possible move.
+ assert(possibleMoves.size() > 0);
+
+ // pick a move at random.
+ std::uniform_int_distribution<int> idist(0, (int)possibleMoves.size() - 1);
+ int randomMoveIndex = idist(_randomNumberGenerator);
+ MakeMove(possibleMoves[randomMoveIndex]);
+}
+
+void Board::MakeMove(Position position)
+{
+ SetMarkerAt(position, _playerInTurn);
+ _playerInTurn = (_playerInTurn == Marker::O) ? Marker::X : Marker::O;
+
+ DetectWinner(position);
+ DetectDrawGame();
+}
+
+void Board::DetectWinner(Position position)
+{
+ auto marker = GetMarkerAt(position);
+
+ for (int i = 0; i < OrientationMaxValue; ++i)
+ {
+ Orientation orientation = (Orientation)i;
+ int sequenceLength(1);
+
+ bool directions[] = { true, false };
+
+ for each (auto forward in directions)
+ {
+ auto neighbor = GetAdjacentPosition(position, orientation, forward);
+ while (IsValidPosition(neighbor) && GetMarkerAt(neighbor) == marker)
+ {
+ sequenceLength++;
+ neighbor = GetAdjacentPosition(neighbor, orientation, forward);
+ }
+ }
+
+ if (sequenceLength >= WinningSequenceLength)
+ {
+ _winner = marker;
+ _playerInTurn = Marker::None;
+ NotifyObserver();
+ }
+ }
+}
+
+void Board::DetectDrawGame()
+{
+ // if there is an empty position, the game isn't a draw (yet).
+ for (int i = 0; i < _size; ++i)
+ {
+ for (int j = 0; j < _size; ++j)
+ {
+ if (GetMarkerAt(Position(i, j)) == Marker::None)
+ {
+ return;
+ }
+ }
+ }
+
+ // no empty positions found: it's a draw.
+ _playerInTurn = Marker::None;
+ NotifyObserver();
+}
+
+Board::Position Board::GetAdjacentPosition(Position position, Orientation orientation, bool forward) const
+{
+ Position delta(-1, -1);
+ switch (orientation)
+ {
+ case Orientation::North:
+ delta = Position(+1, 0);
+ break;
+ case Orientation::East:
+ delta = Position(0, +1);
+ break;
+ case Orientation::Northeast:
+ delta = Position(+1, +1);
+ break;
+ case Orientation::Southeast:
+ delta = Position(-1, +1);
+ break;
+ default:
+ assert(false);
+ }
+
+ if (!forward)
+ {
+ delta.row = -delta.row;
+ delta.column = -delta.column;
+ }
+
+ return Position(position.row + delta.row, position.column + delta.column);
+}
+
+void Board::RegisterBoardChangedObserver(Observer* boardChangedObserver)
+{
+ _boardChangedObserver = boardChangedObserver;
+}
+
+void Board::NotifyObserver()
+{
+ if (_boardChangedObserver)
+ {
+ _boardChangedObserver->SubjectChanged();
+ }
+}
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Board.h b/Tobii-EyeX/samples/ActivatableBoardGame/Board.h new file mode 100755 index 0000000..d6abbe3 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Board.h @@ -0,0 +1,110 @@ +/*
+ * Board class: Implements the game logic and the not-so-clever AI player for the exciting Gobang game.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#pragma once
+
+#include <random>
+
+class Observer;
+
+class Board
+{
+public:
+ // Represents a position on the board.
+ struct Position
+ {
+ int row;
+ int column;
+
+ Position(int paramRow, int paramColumn) : row(paramRow), column(paramColumn) { }
+ };
+
+ // Possible contents of a board position.
+ enum Marker
+ {
+ None,
+ X,
+ O
+ };
+
+ Board(int size);
+ virtual ~Board();
+
+ // gets the size of the board, which is assumed to be square: the number of positions on each side.
+ int Size() const { return _size; }
+
+ // indicates whether the game is over.
+ bool IsGameOver() const { return _playerInTurn == Marker::None; }
+
+ // gets the "name" of the lucky winner.
+ Marker GetWinner() const { return _winner; }
+
+ // gets what's on the board at a given position.
+ Marker GetMarkerAt(Position position) const;
+
+ // indicates whether it is possible to place a marker at a given position.
+ bool CanMakeMoveAt(Position position) const;
+
+ // makes a move for the human player (which will also trigger an AI move).
+ void MakeHumanPlayerMove(Position position);
+
+ // restarts the game.
+ void BeginNewGame();
+
+ // registers an observer that is notified when the board has changed.
+ void RegisterBoardChangedObserver(Observer* boardChangedObserver);
+
+private:
+ enum Orientation
+ {
+ North,
+ East,
+ Northeast,
+ Southeast,
+ OrientationMaxValue
+ };
+
+ // tests whether a position is on the board.
+ bool IsValidPosition(Position position) const;
+
+ // gets a position adjacent to the given one, in a particular direction.
+ Position GetAdjacentPosition(Position position, Orientation orientation, bool forward) const;
+
+ // prepares the board for a new, exciting game.
+ void InitBoard();
+
+ // lets the miserable AI player make a move.
+ void MakeAIPlayerMove();
+
+ // makes a move: places a marker and checks whether anyone has won or if it's a draw game.
+ void MakeMove(Position position);
+
+ // places a marker at the given position.
+ void SetMarkerAt(Position position, Marker marker);
+
+ // checks if the given position is part of a winning sequence.
+ void DetectWinner(Position position);
+
+ // checks if the game is a draw.
+ void DetectDrawGame();
+
+ // notifies the observer, if any, that the board has changed.
+ void NotifyObserver();
+
+ static const int WinningSequenceLength = 5;
+
+ static std::mt19937 _randomNumberGenerator;
+
+ int _size;
+ Marker* _board;
+ Marker _playerInTurn;
+ Marker _winner;
+ Observer* _boardChangedObserver;
+
+ // private copy constructor and operator making the class non-copyable (declared but not implemented).
+ Board(const Board&);
+ Board& operator = (const Board&);
+};
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/BoardWindow.cpp b/Tobii-EyeX/samples/ActivatableBoardGame/BoardWindow.cpp new file mode 100755 index 0000000..7f8b9a7 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/BoardWindow.cpp @@ -0,0 +1,488 @@ +/*
+ * ActivatableBoardGame sample:
+ * This is an example that demonstrates the use of Activatable interactors in the context of a board game.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#include "stdafx.h"
+#include "BoardWindow.h"
+#include "Board.h"
+#include "resource.h"
+
+// window messages used for notifications from the EyeXHost.
+#define WM_EYEX_HOST_STATUS_CHANGED WM_USER + 0
+#define WM_FOCUSED_REGION_CHANGED WM_USER + 1
+#define WM_REGION_ACTIVATED WM_USER + 2
+
+// color scheme.
+const Gdiplus::Color BoardWindow::BackgroundGazeInteractionFunctionalColor = Gdiplus::Color(134, 152, 172); // blue
+const Gdiplus::Color BoardWindow::BackgroundMouseOnlyColor = Gdiplus::Color(164, 156, 153); // grey
+const Gdiplus::Color BoardWindow::GridColor = Gdiplus::Color(110, 57, 88, 109); // dark blue
+const Gdiplus::Color BoardWindow::MarkerColor = Gdiplus::Color(242, 233, 216); // off white
+const Gdiplus::Color BoardWindow::HighlightColor = Gdiplus::Color(20, 242, 233, 216); // transparent off white
+const Gdiplus::Color BoardWindow::WonMessageColor = Gdiplus::Color(200, 64, 82, 60); // transparent dark green
+const Gdiplus::Color BoardWindow::LostMessageColor = Gdiplus::Color(200, 155, 109, 135); // transparent grape
+
+// constants.
+const int BoardWindow::SquareSize = 100;
+const int BoardWindow::MarkerMargin = 14;
+const int BoardWindow::MarkerDiameter = SquareSize - MarkerMargin * 2;
+const TCHAR* BoardWindow::WindowClassName = _T("GobangBoard");
+
+BoardWindow::BoardWindow(Board& board, HINSTANCE hInstance, int nCmdShow)
+ : _board(board), _hInstance(hInstance), _hWnd(0), _hMenu(0), _leftMargin(0), _upperMargin(0)
+{
+ // create the window instance.
+ _hWnd = CreateWindow(
+ WindowClassName,
+ _T("Gobang!"),
+ WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ (_board.Size() + 1) * SquareSize,
+ (_board.Size() + 1) * SquareSize + 40,
+ NULL,
+ NULL,
+ hInstance,
+ NULL);
+
+ if (!_hWnd)
+ {
+ throw new std::runtime_error("Could not create main window.");
+ }
+
+ _hMenu = GetMenu(_hWnd);
+
+ // write the "this" pointer to the extra window memory so that we can reference back to this
+ // object from the window function.
+ SetWindowLongPtr(_hWnd, 0, (LONG_PTR)this);
+
+ ShowWindow(_hWnd, nCmdShow);
+ UpdateWindow(_hWnd);
+
+ _board.RegisterBoardChangedObserver(this);
+
+ // initialize the EyeX host and the activatable regions.
+ _eyeXHost.Init(_hWnd, WM_EYEX_HOST_STATUS_CHANGED, WM_FOCUSED_REGION_CHANGED, WM_REGION_ACTIVATED);
+ UpdateActivatableRegions();
+}
+
+BoardWindow::~BoardWindow()
+{
+}
+
+void BoardWindow::RegisterWindowClass(HINSTANCE hInstance)
+{
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = sizeof(void*); // make room for the "this" pointer.
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_GOBANG));
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = 0;
+ wcex.lpszMenuName = MAKEINTRESOURCE(IDC_GOBANG);
+ wcex.lpszClassName = WindowClassName;
+ wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
+
+ RegisterClassEx(&wcex);
+}
+
+// Callback function invoked when the Board has changed.
+void BoardWindow::SubjectChanged()
+{
+ InvalidateRect(_hWnd, NULL, FALSE);
+ UpdateActivatableRegions();
+}
+
+// Callback function invoked from the message loop to process a Windows message.
+LRESULT CALLBACK BoardWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+
+ // read the "this" pointer from extra window memory.
+ BoardWindow* instance = reinterpret_cast<BoardWindow*>(GetWindowLongPtr(hWnd, 0));
+
+ switch (message)
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+
+ // Parse the menu selections:
+ switch (wmId)
+ {
+ case IDM_NEWGAME:
+ instance->OnNewGameClicked();
+ break;
+
+ case IDM_ABOUT:
+ DialogBox(instance->_hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
+ break;
+
+ case IDM_EXIT:
+ DestroyWindow(hWnd);
+ break;
+
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ break;
+
+ case WM_LBUTTONDOWN:
+ {
+ // mouse button pressed; possibly on a board square.
+ auto point = MAKEPOINTS(lParam);
+ instance->OnSquareClicked(point);
+ }
+ break;
+
+ case WM_PAINT:
+ instance->UpdateMargins();
+ hdc = BeginPaint(hWnd, &ps);
+ instance->OnDraw(hdc);
+ EndPaint(hWnd, &ps);
+ break;
+
+ case WM_ERASEBKGND:
+ // no background erasing needed since our OnDraw method draws the entire window.
+ return TRUE;
+
+ case WM_EYEX_HOST_STATUS_CHANGED:
+ // the background color of the board indicates whether we have a working connection to the engine or not.
+ // so, when the status changes, we force a redraw of the window.
+ InvalidateRect(hWnd, 0, FALSE);
+ break;
+
+ case WM_FOCUSED_REGION_CHANGED:
+ // redraw to display the new focus state.
+ InvalidateRect(hWnd, 0, FALSE);
+ break;
+
+ case WM_REGION_ACTIVATED:
+ instance->OnSquareActivated((UINT)wParam);
+ break;
+
+ case WM_WINDOWPOSCHANGED:
+ // the window was moved, so we need to refresh the screen bounds of our activatable regions.
+ instance->UpdateActivatableRegions();
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ case WM_KEYUP:
+ // trigger an activation command when space is released.
+ if (VK_SPACE == wParam)
+ {
+ instance->_eyeXHost.TriggerActivation();
+ }
+ break;
+
+ case WM_KEYDOWN:
+ // trigger activation mode on when space is pressed down (so activation focus changed events are received, and a highlight can be drawn).
+ if (VK_SPACE == wParam)
+ {
+ instance->_eyeXHost.TriggerActivationModeOn();
+ }
+ break;
+
+
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+
+ return 0;
+}
+
+void BoardWindow::OnDraw(HDC hdc)
+{
+ // use double-buffer drawing to speed up the drawing and reduce flicker.
+ // (the drawing is performed on a bitmap, which is then blitted to the screen in one fell swoop.)
+
+ RECT rect;
+ GetClientRect(_hWnd, &rect);
+ Gdiplus::Bitmap bitmap(rect.right - rect.left, rect.bottom - rect.top);
+ Gdiplus::Graphics graphics(&bitmap);
+
+ // draw the background in a color which depends on the state of the connection to the engine.
+ // blue if the connection is functional, gray otherwise.
+ Gdiplus::Color backgroundColor(BackgroundGazeInteractionFunctionalColor);
+ if (!_eyeXHost.IsFunctional())
+ {
+ backgroundColor = BackgroundMouseOnlyColor;
+ }
+ Gdiplus::SolidBrush backgroundBrush(backgroundColor);
+ graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+
+ // draw the grid
+ DrawGrid(&graphics);
+
+ // draw the markers
+ Gdiplus::Pen markerPen(MarkerColor, 5.0F);
+ for (int row = 0; row < _board.Size(); row++)
+ {
+ for (int col = 0; col < _board.Size(); col++)
+ {
+ switch (_board.GetMarkerAt(Board::Position(row, col)))
+ {
+ case Board::Marker::X:
+ DrawXMarker(&graphics, &markerPen, row, col);
+ break;
+
+ case Board::Marker::O:
+ DrawOMarker(&graphics, &markerPen, row, col);
+ break;
+ }
+ }
+ }
+
+ // draw the focus highlight
+ int focusedRegionId = _eyeXHost.GetFocusedRegionId();
+ if (focusedRegionId >= 0)
+ {
+ DrawHighlight(&graphics, RegionIdToBoardRow(focusedRegionId), RegionIdToBoardColumn(focusedRegionId));
+ }
+
+ // draw the game over message
+ if (_board.IsGameOver())
+ {
+ WCHAR* message;
+ Gdiplus::Color messageColor(0,0,0);
+ switch (_board.GetWinner())
+ {
+ case Board::Marker::X:
+ message = L"YOU WON :)";
+ messageColor = WonMessageColor;
+ break;
+
+ case Board::Marker::O:
+ message = L"YOU LOST :(";
+ messageColor = LostMessageColor;
+ break;
+
+ default:
+ message = L"DRAW";
+ messageColor = LostMessageColor;
+ break;
+ }
+
+ DrawGameOver(&graphics, message, messageColor);
+ }
+
+ Gdiplus::Graphics screen(hdc);
+ screen.DrawImage(&bitmap, 0, 0);
+}
+
+void BoardWindow::DrawGrid(Gdiplus::Graphics *graphics)
+{
+ const int lineMargin = 14;
+
+ Gdiplus::Pen gridPen(GridColor);
+ gridPen.SetDashStyle(Gdiplus::DashStyleDash);
+
+ // horizontal lines
+ auto x0 = _leftMargin - lineMargin;
+ auto x1 = _leftMargin + _board.Size() * SquareSize + lineMargin;
+ for (int i = 0; i <= _board.Size(); i++)
+ {
+ auto y = _upperMargin + i * SquareSize;
+ graphics->DrawLine(&gridPen, x0, y, x1, y);
+ }
+
+ // vertical lines
+ auto y0 = _upperMargin - lineMargin;
+ auto y1 = _upperMargin + _board.Size() * SquareSize + lineMargin;
+ for (int j = 0; j <= _board.Size(); j++)
+ {
+ auto x = _leftMargin + j * SquareSize;
+ graphics->DrawLine(&gridPen, x, y0, x, y1);
+ }
+
+ // dots that guide the eye to the center of the square
+ Gdiplus::SolidBrush gridBrush(GridColor);
+ for (int i = 0; i <= _board.Size(); i++)
+ {
+ for (int j = 0; j <= _board.Size(); j++)
+ {
+ auto x = _leftMargin + (j + 0.5) * SquareSize;
+ auto y = _upperMargin + (i + 0.5) * SquareSize;
+ graphics->FillEllipse(&gridBrush, (Gdiplus::REAL)(x - 1), (Gdiplus::REAL)(y - 1), (Gdiplus::REAL)3, (Gdiplus::REAL)3);
+ }
+ }
+}
+
+void BoardWindow::DrawHighlight(Gdiplus::Graphics *graphics, INT row, INT column)
+{
+ Gdiplus::SolidBrush highlightBrush(HighlightColor);
+
+ int x = BoardToClientAreaX(column) + 1;
+ int y = BoardToClientAreaY(row) + 1;
+
+ graphics->FillRectangle(&highlightBrush, x, y, SquareSize - 1, SquareSize - 1);
+}
+
+void BoardWindow::DrawOMarker(Gdiplus::Graphics *graphics, Gdiplus::Pen *markerPen, INT row, INT column)
+{
+ int x = BoardToClientAreaX(column) + MarkerMargin;
+ int y = BoardToClientAreaY(row) + MarkerMargin;
+
+ graphics->DrawEllipse(markerPen, x, y, MarkerDiameter, MarkerDiameter);
+}
+
+void BoardWindow::DrawXMarker(Gdiplus::Graphics *graphics, Gdiplus::Pen *markerPen, INT row, INT column)
+{
+ int x = BoardToClientAreaX(column) + MarkerMargin;
+ int y = BoardToClientAreaY(row) + MarkerMargin;
+
+ graphics->DrawLine(markerPen, x, y + MarkerDiameter, x + MarkerDiameter, y);
+ graphics->DrawLine(markerPen, x, y, x + MarkerDiameter, y + MarkerDiameter);
+}
+
+void BoardWindow::DrawGameOver(Gdiplus::Graphics *graphics, WCHAR* message, const Gdiplus::Color& messageColor)
+{
+ Gdiplus::Font myFont(L"Arial", 72);
+
+ RECT rect;
+ GetClientRect(_hWnd, &rect);
+ Gdiplus::RectF layoutRect((float)rect.left, (float)rect.top, (float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
+
+ Gdiplus::StringFormat format;
+ format.SetAlignment(Gdiplus::StringAlignmentCenter);
+ format.SetLineAlignment(Gdiplus::StringAlignmentCenter);
+
+ Gdiplus::SolidBrush messageBrush(messageColor);
+
+ graphics->DrawString(
+ message,
+ (INT)wcslen(message),
+ &myFont,
+ layoutRect,
+ &format,
+ &messageBrush);
+}
+
+INT BoardWindow::BoardToClientAreaX(INT column)
+{
+ return column * SquareSize + _leftMargin;
+}
+
+INT BoardWindow::BoardToClientAreaY(INT row)
+{
+ return row * SquareSize + _upperMargin;
+}
+
+INT BoardWindow::ClientAreaToBoardColumn(INT x)
+{
+ return (x - _upperMargin) / SquareSize;
+}
+
+INT BoardWindow::ClientAreaToBoardRow(INT y)
+{
+ return (y - _leftMargin) / SquareSize;
+}
+
+int BoardWindow::BoardPositionToRegionId(int row, int column)
+{
+ return column + row * _board.Size();
+}
+
+int BoardWindow::RegionIdToBoardRow(int regionId)
+{
+ return regionId / _board.Size();
+}
+
+int BoardWindow::RegionIdToBoardColumn(int regionId)
+{
+ return regionId % _board.Size();
+}
+
+void BoardWindow::UpdateMargins()
+{
+ RECT rect;
+ GetClientRect(_hWnd, &rect);
+ _upperMargin = ((rect.bottom - rect.top) - _board.Size() * SquareSize) / 2;
+ _leftMargin = ((rect.right - rect.left) - _board.Size() * SquareSize) / 2;
+}
+
+void BoardWindow::OnSquareClicked(POINTS point)
+{
+ MakeHumanPlayerMove(ClientAreaToBoardRow(point.y), ClientAreaToBoardColumn(point.x));
+}
+
+void BoardWindow::OnSquareActivated(UINT regionId)
+{
+ MakeHumanPlayerMove(RegionIdToBoardRow(regionId), RegionIdToBoardColumn(regionId));
+}
+
+void BoardWindow::MakeHumanPlayerMove(int row, int column)
+{
+ Board::Position position(row, column);
+ if (_board.CanMakeMoveAt(position))
+ {
+ _board.MakeHumanPlayerMove(position);
+ }
+}
+
+void BoardWindow::UpdateActivatableRegions()
+{
+ std::vector<EyeXHost::ActivatableRegion> regions;
+
+ if (!_board.IsGameOver())
+ {
+ for (int row = 0; row < _board.Size(); row++)
+ {
+ for (int column = 0; column < _board.Size(); column++)
+ {
+ POINT point;
+ point.x = BoardToClientAreaX(column);
+ point.y = BoardToClientAreaY(row);
+ ClientToScreen(_hWnd, &point);
+
+ RECT bounds;
+ bounds.left = point.x;
+ bounds.top = point.y;
+ bounds.right = point.x + SquareSize;
+ bounds.bottom = point.y + SquareSize;
+
+ regions.push_back(EyeXHost::ActivatableRegion(BoardPositionToRegionId(row, column), bounds));
+ }
+ }
+ }
+
+ _eyeXHost.SetActivatableRegions(regions);
+}
+
+void BoardWindow::OnNewGameClicked()
+{
+ _board.BeginNewGame();
+ UpdateActivatableRegions();
+}
+
+// Message handler for about box.
+INT_PTR CALLBACK BoardWindow::About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(lParam);
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ return (INT_PTR)TRUE;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hDlg, LOWORD(wParam));
+ return (INT_PTR)TRUE;
+ }
+ break;
+ }
+
+ return (INT_PTR)FALSE;
+}
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/BoardWindow.h b/Tobii-EyeX/samples/ActivatableBoardGame/BoardWindow.h new file mode 100755 index 0000000..50dc346 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/BoardWindow.h @@ -0,0 +1,94 @@ +/*
+ * BoardWindow class: Responsible for the game window and the GDI+ drawing.
+ * Listens to notifications from the Board.
+ * Owns the EyeX host.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#pragma once
+
+#include <Windows.h>
+#include <objidl.h>
+#include <gdiplus.h>
+#include "Observer.h"
+#include "EyeXHost.h"
+
+class Board;
+
+class BoardWindow : Observer
+{
+public:
+ BoardWindow(Board& board, HINSTANCE hInstance, int nCmdShow);
+ virtual ~BoardWindow();
+
+ // registers the window class; must be called once at application initialization.
+ static void RegisterWindowClass(HINSTANCE hInstance);
+
+ // From Observer
+ void SubjectChanged();
+
+private:
+ // window procedure for the main window.
+ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+
+ // window procedure for the About dialog.
+ static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
+
+ // GDI+ drawing methods.
+ void OnDraw(HDC hdc);
+ void DrawGrid(Gdiplus::Graphics *graphics);
+ void DrawHighlight(Gdiplus::Graphics* graphics, int row, int column);
+ void DrawXMarker(Gdiplus::Graphics* graphics, Gdiplus::Pen* pen, int row, int column);
+ void DrawOMarker(Gdiplus::Graphics* graphics, Gdiplus::Pen* pen, int row, int column);
+ void DrawGameOver(Gdiplus::Graphics* graphics, WCHAR* message, const Gdiplus::Color& messageColor);
+
+ // coordinate/board position mapping methods.
+ int BoardToClientAreaX(int column);
+ int BoardToClientAreaY(int row);
+ int ClientAreaToBoardColumn(int x);
+ int ClientAreaToBoardRow(int y);
+
+ // region id/board position mapping methods.
+ int BoardPositionToRegionId(int row, int column);
+ int RegionIdToBoardRow(int regionId);
+ int RegionIdToBoardColumn(int regionId);
+
+ // re-calculates the margins based on the size of the window.
+ void UpdateMargins();
+
+ // reports all vacant board positions as activatable regions to the EyeX host.
+ void UpdateActivatableRegions();
+
+ // makes a move at the given position.
+ void MakeHumanPlayerMove(int row, int column);
+
+ // event handlers.
+ void OnSquareClicked(POINTS point);
+ void OnSquareActivated(UINT regionId);
+ void OnNewGameClicked();
+
+ static const Gdiplus::Color BackgroundGazeInteractionFunctionalColor;
+ static const Gdiplus::Color BackgroundMouseOnlyColor;
+ static const Gdiplus::Color GridColor;
+ static const Gdiplus::Color MarkerColor;
+ static const Gdiplus::Color HighlightColor;
+ static const Gdiplus::Color WonMessageColor;
+ static const Gdiplus::Color LostMessageColor;
+ static const int SquareSize;
+ static const int MarkerMargin;
+ static const int MarkerDiameter;
+ static const TCHAR* WindowClassName;
+
+ Board& _board;
+ EyeXHost _eyeXHost;
+ HINSTANCE _hInstance;
+ HWND _hWnd;
+ HMENU _hMenu;
+ int _leftMargin;
+ int _upperMargin;
+
+ // private copy constructor and operator making the class non-copyable (declared but not implemented).
+ BoardWindow(const BoardWindow&);
+ BoardWindow& operator = (const BoardWindow&);
+};
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/ActivatableBoardGame.lastbuildstate b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/ActivatableBoardGame.lastbuildstate new file mode 100755 index 0000000..5cd4c3b --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/ActivatableBoardGame.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\dev\tobii\samples\|
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.command.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.command.1.tlog Binary files differnew file mode 100755 index 0000000..001d8ba --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.command.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.read.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.read.1.tlog Binary files differnew file mode 100755 index 0000000..ff00e89 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.read.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.write.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.write.1.tlog Binary files differnew file mode 100755 index 0000000..f3a1acb --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/CL.write.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.command.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.command.1.tlog Binary files differnew file mode 100755 index 0000000..5f8e2da --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.command.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.read.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.read.1.tlog Binary files differnew file mode 100755 index 0000000..de1b91d --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.read.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.write.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.write.1.tlog Binary files differnew file mode 100755 index 0000000..97ed8cf --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/link.write.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.command.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.command.1.tlog Binary files differnew file mode 100755 index 0000000..57e38ff --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.command.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.read.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.read.1.tlog Binary files differnew file mode 100755 index 0000000..7e1acc5 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.read.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.write.1.tlog b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.write.1.tlog Binary files differnew file mode 100755 index 0000000..6c4a07a --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Activata.2732E876.tlog/rc.write.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.log b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.log new file mode 100755 index 0000000..8d71d0b --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.log @@ -0,0 +1,8 @@ + stdafx.cpp
+ EyeXHost.cpp
+d:\dev\tobii\samples\activatableboardgame\eyexhost.cpp(243): warning C4477: 'sprintf_s' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'HWND'
+ ActivatableBoardGame.cpp
+ BoardWindow.cpp
+ Board.cpp
+ Generating Code...
+ ActivatableBoardGame.vcxproj -> D:\dev\tobii\samples\Debug\ActivatableBoardGame.exe
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.obj b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.obj Binary files differnew file mode 100755 index 0000000..cdf81f4 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.obj diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.pch b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.pch Binary files differnew file mode 100755 index 0000000..d560dcc --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.pch diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.res b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.res Binary files differnew file mode 100755 index 0000000..6aae112 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/ActivatableBoardGame.res diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Board.obj b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Board.obj Binary files differnew file mode 100755 index 0000000..32b7253 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/Board.obj diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/BoardWindow.obj b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/BoardWindow.obj Binary files differnew file mode 100755 index 0000000..15d39e6 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/BoardWindow.obj diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/EyeXHost.obj b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/EyeXHost.obj Binary files differnew file mode 100755 index 0000000..69a81a1 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/EyeXHost.obj diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/stdafx.obj b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/stdafx.obj Binary files differnew file mode 100755 index 0000000..cb850a6 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/stdafx.obj diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/vc140.idb b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/vc140.idb Binary files differnew file mode 100755 index 0000000..46ca7f9 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/vc140.idb diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Debug/vc140.pdb b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/vc140.pdb Binary files differnew file mode 100755 index 0000000..8d46bc5 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Debug/vc140.pdb diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/EyeXHost.cpp b/Tobii-EyeX/samples/ActivatableBoardGame/EyeXHost.cpp new file mode 100755 index 0000000..410a6cf --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/EyeXHost.cpp @@ -0,0 +1,377 @@ +/*
+ * ActivatableBoardGame sample:
+ * This is an example that demonstrates the use of Activatable interactors in the context of a board game.
+ *
+ * Copyright 2013-2014 Tobii Technology AB. All rights reserved.
+ */
+
+#include "stdafx.h"
+#include "EyeXHost.h"
+#include <objidl.h>
+#include <gdiplus.h>
+#include <cassert>
+#include <cstdint>
+
+#pragma comment (lib, "Tobii.EyeX.Client.lib")
+
+#if INTPTR_MAX == INT64_MAX
+#define WINDOW_HANDLE_FORMAT "%lld"
+#else
+#define WINDOW_HANDLE_FORMAT "%d"
+#endif
+
+EyeXHost::EyeXHost()
+ : _state(Initializing),
+ _hWnd(nullptr),
+ _statusChangedMessage(0), _focusedRegionChangedMessage(0), _regionActivatedMessage(0),
+ _focusedRegionId(-1),
+ _context(TX_EMPTY_HANDLE),
+ _connectionStateChangedTicket(0), _queryHandlerTicket(0), _eventHandlerTicket(0)
+{
+ // initialize the EyeX Engine client library.
+ txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, nullptr, nullptr, nullptr, nullptr);
+
+ // create a context and register event handlers, but don't enable the connection to the engine just yet.
+ // we'll enable the connection in the Init method, when we're ready to handle the
+ // connection-status-changed notifications.
+ bool success = txCreateContext(&_context, TX_FALSE) == TX_RESULT_OK;
+ success &= RegisterConnectionStateChangedHandler();
+ success &= RegisterQueryHandler();
+ success &= RegisterEventHandler();
+
+ if (!success)
+ {
+ SetState(Failed);
+ }
+}
+
+EyeXHost::~EyeXHost()
+{
+ if (_context != TX_EMPTY_HANDLE)
+ {
+ // shut down, then release the context.
+ txShutdownContext(_context, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE);
+ txReleaseContext(&_context);
+ }
+}
+
+void EyeXHost::Init(HWND hWnd, UINT statusChangedMessage, UINT focusedRegionChangedMessage, UINT regionActivatedMessage)
+{
+ _hWnd = hWnd;
+ _statusChangedMessage = statusChangedMessage;
+ _focusedRegionChangedMessage = focusedRegionChangedMessage;
+ _regionActivatedMessage = regionActivatedMessage;
+
+ // connect to the engine.
+ if (txEnableConnection(_context) != TX_RESULT_OK)
+ {
+ SetState(Failed);
+ }
+}
+
+void EyeXHost::SetActivatableRegions(const std::vector<ActivatableRegion>& regions)
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+
+ _regions.assign(regions.begin(), regions.end());
+ ResetFocusedRegionIdIfNonExistent();
+}
+
+int EyeXHost::GetFocusedRegionId() const
+{
+ std::lock_guard<std::mutex> lock(const_cast<std::mutex&>(_mutex));
+
+ return _focusedRegionId;
+}
+
+void EyeXHost::TriggerActivation()
+{
+ TX_HANDLE command(TX_EMPTY_HANDLE);
+ txCreateActionCommand(_context, &command, TX_ACTIONTYPE_ACTIVATE);
+ txExecuteCommandAsync(command, NULL, NULL);
+ txReleaseObject(&command);
+}
+
+void EyeXHost::TriggerActivationModeOn()
+{
+ TX_HANDLE command(TX_EMPTY_HANDLE);
+ txCreateActionCommand(_context, &command, TX_ACTIONTYPE_ACTIVATIONMODEON);
+ txExecuteCommandAsync(command, NULL, NULL);
+ txReleaseObject(&command);
+}
+
+void EyeXHost::SetFocusedRegionId(int regionId)
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+
+ _focusedRegionId = regionId;
+ ResetFocusedRegionIdIfNonExistent();
+ PostMessage(_hWnd, _focusedRegionChangedMessage, 0, 0);
+}
+
+// this method assumes that the mutex is held during the call.
+void EyeXHost::ResetFocusedRegionIdIfNonExistent()
+{
+ for (auto region : _regions)
+ {
+ if (region.id == _focusedRegionId)
+ {
+ return;
+ }
+ }
+
+ _focusedRegionId = -1;
+}
+
+bool EyeXHost::IsFunctional() const
+{
+ return _state == Initializing ||
+ _state == Connected;
+}
+
+void EyeXHost::SetState(State state)
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+
+ if (_state != state)
+ {
+ _state = state;
+
+ // note the use of the asynchronous PostMessage function to marshal the event to the main thread.
+ // (this method is called from OnEngineConnectionStateChanged, which is typically invoked on a worker thread.)
+ PostMessage(_hWnd, _statusChangedMessage, 0, 0);
+ }
+}
+
+bool EyeXHost::RegisterConnectionStateChangedHandler()
+{
+ // we pass the "this" pointer as the user parameter when registering the event handler,
+ // so that we can access it in the callback function.
+
+ auto connectionStateChangedTrampoline = [](TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
+ {
+ static_cast<EyeXHost*>(userParam)->OnEngineConnectionStateChanged(connectionState);
+ };
+
+ bool success = txRegisterConnectionStateChangedHandler(
+ _context,
+ &_connectionStateChangedTicket,
+ connectionStateChangedTrampoline,
+ this) == TX_RESULT_OK;
+
+ return success;
+}
+
+bool EyeXHost::RegisterQueryHandler()
+{
+ auto queryHandlerTrampoline = [](TX_CONSTHANDLE hObject, TX_USERPARAM userParam)
+ {
+ static_cast<EyeXHost*>(userParam)->HandleQuery(hObject);
+ };
+
+ bool success = txRegisterQueryHandler(
+ _context,
+ &_queryHandlerTicket,
+ queryHandlerTrampoline,
+ this) == TX_RESULT_OK;
+
+ return success;
+}
+
+bool EyeXHost::RegisterEventHandler()
+{
+ auto eventHandlerTrampoline = [](TX_CONSTHANDLE hObject, TX_USERPARAM userParam)
+ {
+ static_cast<EyeXHost*>(userParam)->HandleEvent(hObject);
+ };
+
+ bool success = txRegisterEventHandler(_context,
+ &_eventHandlerTicket,
+ eventHandlerTrampoline,
+ this) == TX_RESULT_OK;
+
+ return success;
+}
+
+void EyeXHost::OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState)
+{
+ switch (connectionState)
+ {
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_CONNECTED:
+ SetState(Connected);
+ break;
+
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_DISCONNECTED:
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_TRYINGTOCONNECT:
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_SERVERVERSIONTOOLOW:
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_SERVERVERSIONTOOHIGH:
+ SetState(Disconnected);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void EyeXHost::HandleQuery(TX_CONSTHANDLE hAsyncData)
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+
+ // NOTE. This method will fail silently if, for example, the connection is lost before the snapshot has been committed,
+ // or if we run out of memory. This is by design, because there is nothing we can do to recover from these errors anyway.
+
+ TX_HANDLE hQuery(TX_EMPTY_HANDLE);
+ txGetAsyncDataContent(hAsyncData, &hQuery);
+
+ const int bufferSize = 20;
+ TX_CHAR stringBuffer[bufferSize];
+
+ // read the query bounds from the query, that is, the area on the screen that the query concerns.
+ // the query region is always rectangular.
+ TX_HANDLE hBounds(TX_EMPTY_HANDLE);
+ txGetQueryBounds(hQuery, &hBounds);
+ TX_REAL pX, pY, pWidth, pHeight;
+ txGetRectangularBoundsData(hBounds, &pX, &pY, &pWidth, &pHeight);
+ txReleaseObject(&hBounds);
+ Gdiplus::Rect queryBounds((INT)pX, (INT)pY, (INT)pWidth, (INT)pHeight);
+
+ // create a new snapshot with the same window id and bounds as the query.
+ TX_HANDLE hSnapshot(TX_EMPTY_HANDLE);
+ txCreateSnapshotForQuery(hQuery, &hSnapshot);
+
+ TX_CHAR windowIdString[bufferSize];
+ sprintf_s(windowIdString, bufferSize, WINDOW_HANDLE_FORMAT, _hWnd);
+
+ if (QueryIsForWindowId(hQuery, windowIdString))
+ {
+ // define options for our activatable regions: no, we don't want tentative focus events.
+ TX_ACTIVATABLEPARAMS params = { TX_FALSE };
+
+ // iterate through all regions and create interactors for those that overlap with the query bounds.
+ for (auto region : _regions)
+ {
+ Gdiplus::Rect regionBounds((INT)region.bounds.left, (INT)region.bounds.top,
+ (INT)(region.bounds.right - region.bounds.left), (INT)(region.bounds.bottom - region.bounds.top));
+
+ if (queryBounds.IntersectsWith(regionBounds))
+ {
+ TX_HANDLE hInteractor(TX_EMPTY_HANDLE);
+ sprintf_s(stringBuffer, bufferSize, "%d", region.id);
+
+ TX_RECT bounds;
+ bounds.X = region.bounds.left;
+ bounds.Y = region.bounds.top;
+ bounds.Width = region.bounds.right - region.bounds.left;
+ bounds.Height = region.bounds.bottom - region.bounds.top;
+
+ txCreateRectangularInteractor(hSnapshot, &hInteractor, stringBuffer, &bounds, TX_LITERAL_ROOTID, windowIdString);
+ txCreateActivatableBehavior(hInteractor, ¶ms);
+
+ txReleaseObject(&hInteractor);
+ }
+ }
+ }
+
+ txCommitSnapshotAsync(hSnapshot, OnSnapshotCommitted, nullptr);
+ txReleaseObject(&hSnapshot);
+ txReleaseObject(&hQuery);
+}
+
+void EyeXHost::HandleEvent(TX_CONSTHANDLE hAsyncData)
+{
+ TX_HANDLE hEvent(TX_EMPTY_HANDLE);
+ txGetAsyncDataContent(hAsyncData, &hEvent);
+
+ // NOTE. Uncomment the following line of code to view the event object. The same function can be used with any interaction object.
+ //OutputDebugStringA(txDebugObject(hEvent));
+
+ // read the interactor ID from the event.
+ const int bufferSize = 20;
+ TX_CHAR stringBuffer[bufferSize];
+ TX_SIZE idLength(bufferSize);
+ if (txGetEventInteractorId(hEvent, stringBuffer, &idLength) == TX_RESULT_OK)
+ {
+ int interactorId = atoi(stringBuffer);
+
+ HandleActivatableEvent(hEvent, interactorId);
+ }
+
+ txReleaseObject(&hEvent);
+}
+
+void EyeXHost::HandleActivatableEvent(TX_HANDLE hEvent, int interactorId)
+{
+ TX_HANDLE hActivatable(TX_EMPTY_HANDLE);
+ if (txGetEventBehavior(hEvent, &hActivatable, TX_BEHAVIORTYPE_ACTIVATABLE) == TX_RESULT_OK)
+ {
+ TX_ACTIVATABLEEVENTTYPE eventType;
+ if (txGetActivatableEventType(hActivatable, &eventType) == TX_RESULT_OK)
+ {
+ if (eventType == TX_ACTIVATABLEEVENTTYPE_ACTIVATED)
+ {
+ OnActivated(hActivatable, interactorId);
+ }
+ else if (eventType == TX_ACTIVATABLEEVENTTYPE_ACTIVATIONFOCUSCHANGED)
+ {
+ OnActivationFocusChanged(hActivatable, interactorId);
+ }
+ }
+
+ txReleaseObject(&hActivatable);
+ }
+}
+
+void EyeXHost::OnActivationFocusChanged(TX_HANDLE hBehavior, int interactorId)
+{
+ TX_ACTIVATIONFOCUSCHANGEDEVENTPARAMS eventData;
+ if (txGetActivationFocusChangedEventParams(hBehavior, &eventData) == TX_RESULT_OK)
+ {
+ if (eventData.HasActivationFocus)
+ {
+ SetFocusedRegionId(interactorId);
+ }
+ else
+ {
+ SetFocusedRegionId(-1);
+ }
+ }
+}
+
+void EyeXHost::OnActivated(TX_HANDLE hBehavior, int interactorId)
+{
+ PostMessage(_hWnd, _regionActivatedMessage, interactorId, 0);
+}
+
+void TX_CALLCONVENTION EyeXHost::OnSnapshotCommitted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param)
+{
+ // check the result code using an assertion.
+ // this will catch validation errors and runtime errors in debug builds. in release builds it won't do anything.
+
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ txGetAsyncDataResultCode(hAsyncData, &result);
+ assert(result == TX_RESULT_OK || result == TX_RESULT_CANCELLED);
+}
+
+bool EyeXHost::QueryIsForWindowId(TX_HANDLE hQuery, const TX_CHAR* windowId)
+{
+ const int bufferSize = 20;
+ TX_CHAR buffer[bufferSize];
+
+ TX_SIZE count;
+ if (TX_RESULT_OK == txGetQueryWindowIdCount(hQuery, &count))
+ {
+ for (int i = 0; i < count; i++)
+ {
+ TX_SIZE size = bufferSize;
+ if (TX_RESULT_OK == txGetQueryWindowId(hQuery, i, buffer, &size))
+ {
+ if (0 == strcmp(windowId, buffer))
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/EyeXHost.h b/Tobii-EyeX/samples/ActivatableBoardGame/EyeXHost.h new file mode 100755 index 0000000..98aa84d --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/EyeXHost.h @@ -0,0 +1,111 @@ +/*
+ * EyeXHost class: Responsible for the gaze interaction within a window.
+ * Holds the current set of activatable regions and acts as a simple interactor repository.
+ * Sends notifications as Windows messages so that they are received on the main thread and can be handled there.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#pragma once
+
+#include <windows.h>
+#include <vector>
+#include <mutex>
+#include "eyex/EyeX.h"
+
+class EyeXHost
+{
+public:
+ // Represents an activatable region, that is, one particular kind of interactor.
+ struct ActivatableRegion
+ {
+ int id;
+ RECT bounds;
+
+ ActivatableRegion(int paramId, RECT paramBounds) : id(paramId), bounds(paramBounds) { }
+ };
+
+ EyeXHost();
+ virtual ~EyeXHost();
+
+ // attaches to the window with the given handle.
+ // the message parameters are custom windows messages sent to the window when an event has occurred.
+ void Init(HWND hWnd, UINT statusChangedMessage, UINT focusedRegionChangedMessage, UINT regionActivatedMessage);
+
+ // updates the collection (repository) of activatable regions.
+ void SetActivatableRegions(const std::vector<ActivatableRegion>& regions);
+
+ // gets the ID of the region that currently has the activation focus.
+ int GetFocusedRegionId() const;
+
+ // triggers an activation ("direct click").
+ void TriggerActivation();
+
+ // trigger a request to the EyeX Engine to switch activation mode on.
+ // this will trigger Activation Focus Changed events to be raised for the
+ // interactor the user is looking at/no longer looking at.
+ // in this sample, the focus is used to draw a highlight on in the square
+ // that is about to be "clicked" - where the "X" will be placed.
+ void TriggerActivationModeOn();
+
+ // indicates whether the connection to the EyeX Engine is working.
+ bool IsFunctional() const;
+
+private:
+ enum State
+ {
+ Initializing,
+ Connected,
+ Disconnected,
+ Failed
+ };
+
+ // registers handlers for notifications from the engine.
+ bool RegisterConnectionStateChangedHandler();
+ bool RegisterQueryHandler();
+ bool RegisterEventHandler();
+
+ // event handlers.
+ void OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState);
+ void HandleQuery(TX_CONSTHANDLE hAsyncData);
+ void HandleEvent(TX_CONSTHANDLE hAsyncData);
+ void HandleActivatableEvent(TX_HANDLE hEvent, int interactorId);
+ void OnActivationFocusChanged(TX_HANDLE hBehavior, int interactorId);
+ void OnActivated(TX_HANDLE hBehavior, int interactorId);
+
+ // callback function invoked when a snapshot has been committed.
+ static void TX_CALLCONVENTION OnSnapshotCommitted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param);
+
+ // sets the internal state.
+ void SetState(State state);
+
+ // sets the ID of the region that currently has the activation focus.
+ void SetFocusedRegionId(int regionId);
+
+ // clears the focused region ID if there is no matching region in the repository.
+ void ResetFocusedRegionIdIfNonExistent();
+
+ static bool QueryIsForWindowId(TX_HANDLE hQuery, const TX_CHAR* windowId);
+
+ // mutex protecting the state of the object from race conditions caused by multiple threads.
+ // (for example, a call to SetActivatableRegions from the main thread while the HandleQuery
+ // method is iterating through the regions on a worker thread.)
+ std::mutex _mutex;
+ State _state;
+ std::vector<ActivatableRegion> _regions;
+ int _focusedRegionId;
+ TX_CONTEXTHANDLE _context;
+ TX_TICKET _connectionStateChangedTicket;
+ TX_TICKET _queryHandlerTicket;
+ TX_TICKET _eventHandlerTicket;
+
+ // attached window and custom messages.
+ HWND _hWnd;
+ UINT _statusChangedMessage;
+ UINT _focusedRegionChangedMessage;
+ UINT _regionActivatedMessage;
+
+ // private copy constructor and operator making the class non-copyable (declared but not implemented).
+ EyeXHost(const EyeXHost&);
+ EyeXHost& operator = (const EyeXHost&);
+};
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Observer.h b/Tobii-EyeX/samples/ActivatableBoardGame/Observer.h new file mode 100755 index 0000000..8aa98c1 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Observer.h @@ -0,0 +1,13 @@ +/*
+ * Observer interface: Standard Observer interface used for notifying an object of a change in another object.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#pragma once
+
+class Observer
+{
+public:
+ virtual void SubjectChanged() = 0;
+};
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/Resource.h b/Tobii-EyeX/samples/ActivatableBoardGame/Resource.h Binary files differnew file mode 100755 index 0000000..6a23727 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/Resource.h diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/small.ico b/Tobii-EyeX/samples/ActivatableBoardGame/small.ico Binary files differnew file mode 100755 index 0000000..449296f --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/small.ico diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/stdafx.cpp b/Tobii-EyeX/samples/ActivatableBoardGame/stdafx.cpp new file mode 100755 index 0000000..92e931f --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/stdafx.cpp @@ -0,0 +1,3 @@ +// stdafx.cpp : source file that includes just the standard includes
+
+#include "stdafx.h"
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/stdafx.h b/Tobii-EyeX/samples/ActivatableBoardGame/stdafx.h new file mode 100755 index 0000000..705c92c --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/stdafx.h @@ -0,0 +1,17 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+// C RunTime Header Files
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
diff --git a/Tobii-EyeX/samples/ActivatableBoardGame/targetver.h b/Tobii-EyeX/samples/ActivatableBoardGame/targetver.h new file mode 100755 index 0000000..90e767b --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableBoardGame/targetver.h @@ -0,0 +1,8 @@ +#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
diff --git a/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.cpp b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.cpp new file mode 100755 index 0000000..8cee1c3 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.cpp @@ -0,0 +1,357 @@ +/*
+ * ActivatableButtons sample:
+ * This is an example that demonstrates the Activatable behavior.
+ * It features two buttons that can be clicked by looking at the button and pressing the space bar.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#include "stdafx.h"
+#include <windows.h>
+#include <objidl.h>
+#include <gdiplus.h>
+#include "resource.h"
+#include "EyeXHost.h"
+
+#pragma comment (lib, "Gdiplus.lib")
+
+// window messages used for notifications from the EyeXHost.
+#define WM_EYEX_HOST_STATUS_CHANGED WM_USER + 0
+#define WM_REGION_GOT_ACTIVATION_FOCUS WM_USER + 1
+#define WM_REGION_ACTIVATED WM_USER + 2
+
+// constants.
+static const Gdiplus::Color OriginalBackgroundColor(66, 173, 209);
+static const Gdiplus::Color OtherBackgroundColor(89, 169, 108);
+static const int ChangeButtonLeft = 50;
+static const int ResetButtonLeft = 260;
+static const int ButtonTop = 100;
+static const int ButtonWidth = 160;
+static const int ButtonHeight = 100;
+static const TCHAR* g_szWindowClass = _T("ActivatableButtons");
+
+// global variables.
+static EyeXHost g_eyeXHost;
+static HWND g_hWnd;
+static HWND g_hChangeButton;
+static HWND g_hResetButton;
+static bool g_useOriginalColor = true;
+
+// gets the bounds of a button in screen coordinates.
+RECT GetScreenBounds(HWND hButton)
+{
+ POINT point = { 0, 0 };
+ ClientToScreen(hButton, &point);
+
+ RECT bounds;
+ bounds.left = point.x;
+ bounds.top = point.y;
+ bounds.right = bounds.left + ButtonWidth;
+ bounds.bottom = bounds.top + ButtonHeight;
+
+ return bounds;
+}
+
+// reports the buttons as activatable regions to the EyeX host.
+void UpdateActivatableRegions()
+{
+ std::vector<EyeXHost::ActivatableRegion> regions;
+
+ regions.push_back(EyeXHost::ActivatableRegion(IDC_CHANGE_COLOR_BUTTON, GetScreenBounds(g_hChangeButton)));
+ regions.push_back(EyeXHost::ActivatableRegion(IDC_RESET_COLOR_BUTTON, GetScreenBounds(g_hResetButton)));
+
+ g_eyeXHost.SetActivatableRegions(regions);
+}
+
+// event handler invoked when a "status changed" event has been received from the EyeX host.
+void OnStatusChanged(bool engineConnectionIsFunctional)
+{
+ // update the window title to reflect the engine connection state.
+ if (engineConnectionIsFunctional)
+ {
+ SetWindowText(g_hWnd, _T("ActivatableButtons - Use Ur Eyez! :)"));
+ }
+ else
+ {
+ SetWindowText(g_hWnd, _T("ActivatableButtons - Mouse Only :("));
+ }
+}
+
+// event handler invoked when a region has received the activation focus.
+void OnRegionGotActivationFocus(UINT regionId)
+{
+ // set the keyboard focus to the corresponding button.
+ switch(regionId)
+ {
+ case IDC_CHANGE_COLOR_BUTTON:
+ SetFocus(g_hChangeButton);
+ break;
+
+ case IDC_RESET_COLOR_BUTTON:
+ SetFocus(g_hResetButton);
+ break;
+ }
+}
+
+// event handler invoked when the "change color" button has been activated.
+void OnChangeColorActivated()
+{
+ g_useOriginalColor = false;
+ InvalidateRect(g_hWnd, 0, FALSE);
+}
+
+// event handler invoked when the "reset color" button has been activated.
+void OnResetColorActivated()
+{
+ g_useOriginalColor = true;
+ InvalidateRect(g_hWnd, 0, FALSE);
+}
+
+// event handler invoked when a region has received an activation event.
+void OnRegionActivated(UINT regionId)
+{
+ // route the event to the corresponding button.
+ switch(regionId)
+ {
+ case IDC_CHANGE_COLOR_BUTTON:
+ OnChangeColorActivated();
+ break;
+
+ case IDC_RESET_COLOR_BUTTON:
+ OnResetColorActivated();
+ break;
+ }
+}
+
+void OnDraw(HDC hdc)
+{
+ Gdiplus::Graphics graphics(hdc);
+
+ RECT rect;
+ GetClientRect(g_hWnd, &rect);
+
+ Gdiplus::Color backgroundColor(OriginalBackgroundColor);
+ if (!g_useOriginalColor)
+ {
+ backgroundColor = OtherBackgroundColor;
+ }
+
+ Gdiplus::SolidBrush backgroundBrush(backgroundColor);
+ graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+
+ const TCHAR* message = _T("Click the buttons with your eyes! Look at a button and press the space bar to click. ")
+ _T("(Make sure the window has input focus.)");
+ Gdiplus::Font font(_T("Arial"), 10);
+ Gdiplus::SolidBrush textBrush(Gdiplus::Color::Black);
+ Gdiplus::RectF textRect((Gdiplus::REAL)10,
+ (Gdiplus::REAL)(ButtonTop + ButtonHeight + 20),
+ (Gdiplus::REAL)(rect.right - 20),
+ (Gdiplus::REAL)(rect.bottom - rect.top));
+ Gdiplus::StringFormat textFormat;
+ graphics.DrawString(message, (INT)_tcslen(message), &font, textRect, &textFormat, &textBrush);
+}
+
+//
+// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
+//
+// PURPOSE: Processes messages for the main window.
+//
+// WM_COMMAND - process the application menu
+// WM_PAINT - Paint the main window
+// WM_DESTROY - post a quit message and return
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+
+ switch (message)
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ switch (wmId)
+ {
+ case IDC_CHANGE_COLOR_BUTTON:
+ OnChangeColorActivated();
+ break;
+
+ case IDC_RESET_COLOR_BUTTON:
+ OnResetColorActivated();
+ break;
+
+ case IDM_EXIT:
+ DestroyWindow(hWnd);
+ break;
+
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ break;
+
+ case WM_CREATE:
+ {
+ g_hChangeButton = CreateWindow(
+ _T("BUTTON"),
+ _T("Change color"),
+ WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
+ ChangeButtonLeft, ButtonTop, ButtonWidth, ButtonHeight,
+ hWnd,
+ (HMENU)IDC_CHANGE_COLOR_BUTTON,
+ GetModuleHandle(NULL),
+ NULL);
+ g_hResetButton = CreateWindow(
+ _T("BUTTON"),
+ _T("Reset color"),
+ WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
+ ResetButtonLeft, ButtonTop, ButtonWidth, ButtonHeight,
+ hWnd,
+ (HMENU)IDC_RESET_COLOR_BUTTON,
+ GetModuleHandle(NULL),
+ NULL);
+ }
+ break;
+
+ case WM_PAINT:
+ hdc = BeginPaint(hWnd, &ps);
+ OnDraw(hdc);
+ EndPaint(hWnd, &ps);
+ break;
+
+ case WM_ERASEBKGND:
+ // no background erasing needed since our OnDraw method draws the entire window.
+ return TRUE;
+
+ case WM_EYEX_HOST_STATUS_CHANGED:
+ OnStatusChanged(wParam != FALSE);
+ break;
+
+ case WM_REGION_GOT_ACTIVATION_FOCUS:
+ OnRegionGotActivationFocus((UINT)wParam);
+ break;
+
+ case WM_REGION_ACTIVATED:
+ OnRegionActivated((UINT)wParam);
+ break;
+
+ case WM_WINDOWPOSCHANGED:
+ UpdateActivatableRegions();
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+ case WM_KEYDOWN:
+ // trigger an activation command when space is pressed.
+ if (VK_SPACE == wParam)
+ {
+ g_eyeXHost.TriggerActivation();
+ }
+ break;
+
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ return 0;
+}
+
+//
+// FUNCTION: MyRegisterClass()
+//
+// PURPOSE: Registers the window class.
+//
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ACTIVATABLEBUTTONS));
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = 0;
+ wcex.lpszMenuName = MAKEINTRESOURCE(IDC_ACTIVATABLEBUTTONS);
+ wcex.lpszClassName = g_szWindowClass;
+ wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
+
+ return RegisterClassEx(&wcex);
+}
+
+//
+// FUNCTION: InitInstance(HINSTANCE, int)
+//
+// PURPOSE: Saves instance handle and creates main window
+//
+// COMMENTS:
+//
+// In this function, we save the instance handle in a global variable and
+// create and display the main program window.
+//
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+ g_hWnd = CreateWindow(g_szWindowClass, _T(""), WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, 0, 490, 380, NULL, NULL, hInstance, NULL);
+
+ if (!g_hWnd)
+ {
+ return FALSE;
+ }
+
+ ShowWindow(g_hWnd, nCmdShow);
+ UpdateWindow(g_hWnd);
+
+ // initialize the EyeX host and the activatable regions.
+ g_eyeXHost.Init(g_hWnd, WM_EYEX_HOST_STATUS_CHANGED, WM_REGION_GOT_ACTIVATION_FOCUS, WM_REGION_ACTIVATED);
+ UpdateActivatableRegions();
+
+ return TRUE;
+}
+
+// Application entry point.
+int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
+ _In_opt_ HINSTANCE hPrevInstance,
+ _In_ LPTSTR lpCmdLine,
+ _In_ int nCmdShow)
+{
+ UNREFERENCED_PARAMETER(hPrevInstance);
+ UNREFERENCED_PARAMETER(lpCmdLine);
+
+ // Initialize gdiplus
+ ULONG_PTR gdiplusToken;
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+ MyRegisterClass(hInstance);
+
+ // Perform application initialization:
+ if (!InitInstance (hInstance, nCmdShow))
+ {
+ return FALSE;
+ }
+
+ HACCEL hAccelTable;
+ hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_ACTIVATABLEBUTTONS));
+
+ // Main message loop:
+ MSG msg;
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ // Shutdown:
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+
+ return (int) msg.wParam;
+}
diff --git a/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.ico b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.ico Binary files differnew file mode 100755 index 0000000..449296f --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.ico diff --git a/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.rc b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.rc Binary files differnew file mode 100755 index 0000000..8f97f8c --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.rc diff --git a/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.vcxproj b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.vcxproj new file mode 100755 index 0000000..9bc381e --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.vcxproj @@ -0,0 +1,188 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{3E2A1867-D554-4655-8F03-B6A4C06D4967}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>ActivatableButtons</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ <Manifest>
+ <EnableDpiAwareness>true</EnableDpiAwareness>
+ </Manifest>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="EyeXHost.h" />
+ <ClInclude Include="Resource.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="ActivatableButtons.cpp" />
+ <ClCompile Include="EyeXHost.cpp" />
+ <ClCompile Include="stdafx.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="ActivatableButtons.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="ActivatableButtons.ico" />
+ <Image Include="small.ico" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <Import Project="..\CopyEyeXDllToOutputDirectory.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.vcxproj.filters b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.vcxproj.filters new file mode 100755 index 0000000..dd3cdd3 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/ActivatableButtons.vcxproj.filters @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="targetver.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="EyeXHost.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ActivatableButtons.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="EyeXHost.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="ActivatableButtons.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="small.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="ActivatableButtons.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/ActivatableButtons.lastbuildstate b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/ActivatableButtons.lastbuildstate new file mode 100755 index 0000000..5cd4c3b --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/ActivatableButtons.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\dev\tobii\samples\|
diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.command.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.command.1.tlog Binary files differnew file mode 100755 index 0000000..8c2918b --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.command.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.read.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.read.1.tlog Binary files differnew file mode 100755 index 0000000..64925ad --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.read.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.write.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.write.1.tlog Binary files differnew file mode 100755 index 0000000..54a1b52 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/CL.write.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.command.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.command.1.tlog Binary files differnew file mode 100755 index 0000000..5c8ec49 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.command.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.read.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.read.1.tlog Binary files differnew file mode 100755 index 0000000..5822f11 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.read.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.write.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.write.1.tlog Binary files differnew file mode 100755 index 0000000..2f69de6 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/link.write.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.command.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.command.1.tlog Binary files differnew file mode 100755 index 0000000..4506a2b --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.command.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.read.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.read.1.tlog Binary files differnew file mode 100755 index 0000000..a3ad644 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.read.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.write.1.tlog b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.write.1.tlog Binary files differnew file mode 100755 index 0000000..952d17c --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/Activata.3E2A1867.tlog/rc.write.1.tlog diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.log b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.log new file mode 100755 index 0000000..87b519f --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.log @@ -0,0 +1,6 @@ + stdafx.cpp
+ EyeXHost.cpp
+d:\dev\tobii\samples\activatablebuttons\eyexhost.cpp(158): warning C4477: 'sprintf_s' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'HWND'
+ ActivatableButtons.cpp
+ Generating Code...
+ ActivatableButtons.vcxproj -> D:\dev\tobii\samples\Debug\ActivatableButtons.exe
diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.obj b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.obj Binary files differnew file mode 100755 index 0000000..d058330 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.obj diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.pch b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.pch Binary files differnew file mode 100755 index 0000000..cee1ac5 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.pch diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.res b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.res Binary files differnew file mode 100755 index 0000000..9cfd8cd --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/ActivatableButtons.res diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/EyeXHost.obj b/Tobii-EyeX/samples/ActivatableButtons/Debug/EyeXHost.obj Binary files differnew file mode 100755 index 0000000..b7e4d31 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/EyeXHost.obj diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/stdafx.obj b/Tobii-EyeX/samples/ActivatableButtons/Debug/stdafx.obj Binary files differnew file mode 100755 index 0000000..b3c70a5 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/stdafx.obj diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/vc140.idb b/Tobii-EyeX/samples/ActivatableButtons/Debug/vc140.idb Binary files differnew file mode 100755 index 0000000..ec0d0d4 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/vc140.idb diff --git a/Tobii-EyeX/samples/ActivatableButtons/Debug/vc140.pdb b/Tobii-EyeX/samples/ActivatableButtons/Debug/vc140.pdb Binary files differnew file mode 100755 index 0000000..8f0aa96 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Debug/vc140.pdb diff --git a/Tobii-EyeX/samples/ActivatableButtons/EyeXHost.cpp b/Tobii-EyeX/samples/ActivatableButtons/EyeXHost.cpp new file mode 100755 index 0000000..3291e54 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/EyeXHost.cpp @@ -0,0 +1,294 @@ +/*
+ * ActivatableButtons sample:
+ * This is an example that demonstrates the Activatable behavior.
+ * It features two buttons that can be clicked by looking at the button and pressing the space bar.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#include "stdafx.h"
+#include "EyeXHost.h"
+#include <objidl.h>
+#include <gdiplus.h>
+#include <cassert>
+#include <cstdint>
+
+#pragma comment (lib, "Tobii.EyeX.Client.lib")
+
+#if INTPTR_MAX == INT64_MAX
+#define WINDOW_HANDLE_FORMAT "%lld"
+#else
+#define WINDOW_HANDLE_FORMAT "%d"
+#endif
+
+EyeXHost::EyeXHost()
+ : _hWnd(nullptr), _statusChangedMessage(0), _focusedRegionChangedMessage(0), _regionActivatedMessage(0)
+{
+ // initialize the EyeX Engine client library.
+ txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, nullptr, nullptr, nullptr, nullptr);
+
+ // create a context and register event handlers.
+ txCreateContext(&_context, TX_FALSE);
+ RegisterConnectionStateChangedHandler();
+ RegisterQueryHandler();
+ RegisterEventHandler();
+}
+
+EyeXHost::~EyeXHost()
+{
+ if (_context != TX_EMPTY_HANDLE)
+ {
+ // shut down, then release the context.
+ txShutdownContext(_context, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE);
+ txReleaseContext(&_context);
+ }
+}
+
+void EyeXHost::Init(HWND hWnd, UINT statusChangedMessage, UINT focusedRegionChangedMessage, UINT regionActivatedMessage)
+{
+ _hWnd = hWnd;
+ _statusChangedMessage = statusChangedMessage;
+ _focusedRegionChangedMessage = focusedRegionChangedMessage;
+ _regionActivatedMessage = regionActivatedMessage;
+
+ // connect to the engine.
+ if (txEnableConnection(_context) != TX_RESULT_OK)
+ {
+ PostMessage(_hWnd, _statusChangedMessage, false, 0);
+ }
+}
+
+void EyeXHost::SetActivatableRegions(const std::vector<ActivatableRegion>& regions)
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+
+ _regions.assign(regions.begin(), regions.end());
+}
+
+void EyeXHost::TriggerActivation()
+{
+ TX_HANDLE command(TX_EMPTY_HANDLE);
+ txCreateActionCommand(_context, &command, TX_ACTIONTYPE_ACTIVATE);
+ txExecuteCommandAsync(command, NULL, NULL);
+ txReleaseObject(&command);
+}
+
+void EyeXHost::OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState)
+{
+ // note the use of the asynchronous PostMessage function to marshal the event to the main thread.
+ // (this callback function is typically invoked on a worker thread.)
+ switch (connectionState)
+ {
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_CONNECTED:
+ PostMessage(_hWnd, _statusChangedMessage, true, 0);
+ break;
+
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_DISCONNECTED:
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_TRYINGTOCONNECT:
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_SERVERVERSIONTOOLOW:
+ case TX_CONNECTIONSTATE::TX_CONNECTIONSTATE_SERVERVERSIONTOOHIGH:
+ PostMessage(_hWnd, _statusChangedMessage, false, 0);
+ break;
+
+ default:
+ break;
+ }
+}
+
+bool EyeXHost::RegisterConnectionStateChangedHandler()
+{
+ auto connectionStateChangedTrampoline = [](TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
+ {
+ static_cast<EyeXHost*>(userParam)->OnEngineConnectionStateChanged(connectionState);
+ };
+
+ bool success = txRegisterConnectionStateChangedHandler(_context, &_connectionStateChangedTicket, connectionStateChangedTrampoline, this) == TX_RESULT_OK;
+ return success;
+}
+
+bool EyeXHost::RegisterQueryHandler()
+{
+ auto queryHandlerTrampoline = [](TX_CONSTHANDLE hObject, TX_USERPARAM userParam)
+ {
+ static_cast<EyeXHost*>(userParam)->HandleQuery(hObject);
+ };
+
+ bool success = txRegisterQueryHandler(_context, &_queryHandlerTicket, queryHandlerTrampoline, this) == TX_RESULT_OK;
+ return success;
+}
+
+bool EyeXHost::RegisterEventHandler()
+{
+ auto eventHandlerTrampoline = [](TX_CONSTHANDLE hObject, TX_USERPARAM userParam)
+ {
+ static_cast<EyeXHost*>(userParam)->HandleEvent(hObject);
+ };
+
+ bool success = txRegisterEventHandler(_context, &_eventHandlerTicket, eventHandlerTrampoline, this) == TX_RESULT_OK;
+ return success;
+}
+
+void EyeXHost::HandleQuery(TX_CONSTHANDLE hAsyncData)
+{
+ std::lock_guard<std::mutex> lock(_mutex);
+
+ // NOTE. This method will fail silently if, for example, the connection is lost before the snapshot has been committed,
+ // or if we run out of memory. This is by design, because there is nothing we can do to recover from these errors anyway.
+
+ TX_HANDLE hQuery(TX_EMPTY_HANDLE);
+ txGetAsyncDataContent(hAsyncData, &hQuery);
+
+ const int bufferSize = 20;
+ TX_CHAR stringBuffer[bufferSize];
+
+ // read the query bounds from the query, that is, the area on the screen that the query concerns.
+ // the query region is always rectangular.
+ TX_HANDLE hBounds(TX_EMPTY_HANDLE);
+ txGetQueryBounds(hQuery, &hBounds);
+ TX_REAL pX, pY, pWidth, pHeight;
+ txGetRectangularBoundsData(hBounds, &pX, &pY, &pWidth, &pHeight);
+ txReleaseObject(&hBounds);
+ Gdiplus::Rect queryBounds((INT)pX, (INT)pY, (INT)pWidth, (INT)pHeight);
+
+ // create a new snapshot with the same window id and bounds as the query.
+ TX_HANDLE hSnapshot(TX_EMPTY_HANDLE);
+ txCreateSnapshotForQuery(hQuery, &hSnapshot);
+
+ TX_CHAR windowIdString[bufferSize];
+ sprintf_s(windowIdString, bufferSize, WINDOW_HANDLE_FORMAT, _hWnd);
+
+ if (QueryIsForWindowId(hQuery, windowIdString))
+ {
+ // define options for our activatable regions: no, we don't want tentative focus events.
+ TX_ACTIVATABLEPARAMS params = { TX_FALSE };
+
+ // iterate through all regions and create interactors for those that overlap with the query bounds.
+ for (auto region : _regions)
+ {
+ Gdiplus::Rect regionBounds((INT)region.bounds.left, (INT)region.bounds.top,
+ (INT)(region.bounds.right - region.bounds.left), (INT)(region.bounds.bottom - region.bounds.top));
+
+ if (queryBounds.IntersectsWith(regionBounds))
+ {
+ TX_HANDLE hInteractor(TX_EMPTY_HANDLE);
+
+ sprintf_s(stringBuffer, bufferSize, "%d", region.id);
+
+ TX_RECT bounds;
+ bounds.X = region.bounds.left;
+ bounds.Y = region.bounds.top;
+ bounds.Width = region.bounds.right - region.bounds.left;
+ bounds.Height = region.bounds.bottom - region.bounds.top;
+
+ txCreateRectangularInteractor(hSnapshot, &hInteractor, stringBuffer, &bounds, TX_LITERAL_ROOTID, windowIdString);
+ txCreateActivatableBehavior(hInteractor, ¶ms);
+
+ txReleaseObject(&hInteractor);
+ }
+ }
+ }
+
+ txCommitSnapshotAsync(hSnapshot, OnSnapshotCommitted, nullptr);
+ txReleaseObject(&hSnapshot);
+ txReleaseObject(&hQuery);
+}
+
+void EyeXHost::HandleEvent(TX_CONSTHANDLE hAsyncData)
+{
+ TX_HANDLE hEvent(TX_EMPTY_HANDLE);
+ txGetAsyncDataContent(hAsyncData, &hEvent);
+
+ // NOTE. Uncomment the following line of code to view the event object. The same function can be used with any interaction object.
+ //OutputDebugStringA(txDebugObject(hEvent));
+
+ // read the interactor ID from the event.
+ const int bufferSize = 20;
+ TX_CHAR stringBuffer[bufferSize];
+ TX_SIZE idLength(bufferSize);
+ if (txGetEventInteractorId(hEvent, stringBuffer, &idLength) == TX_RESULT_OK)
+ {
+ int interactorId = atoi(stringBuffer);
+
+ HandleActivatableEvent(hEvent, interactorId);
+ }
+
+ txReleaseObject(&hEvent);
+}
+
+void EyeXHost::HandleActivatableEvent(TX_HANDLE hEvent, int interactorId)
+{
+ TX_HANDLE hActivatable(TX_EMPTY_HANDLE);
+ if (txGetEventBehavior(hEvent, &hActivatable, TX_BEHAVIORTYPE_ACTIVATABLE) == TX_RESULT_OK)
+ {
+ TX_ACTIVATABLEEVENTTYPE eventType;
+ if (txGetActivatableEventType(hActivatable, &eventType) == TX_RESULT_OK)
+ {
+ if (eventType == TX_ACTIVATABLEEVENTTYPE_ACTIVATED)
+ {
+ OnActivated(hActivatable, interactorId);
+ }
+ else if (eventType == TX_ACTIVATABLEEVENTTYPE_ACTIVATIONFOCUSCHANGED)
+ {
+ OnActivationFocusChanged(hActivatable, interactorId);
+ }
+ }
+
+ txReleaseObject(&hActivatable);
+ }
+}
+
+void EyeXHost::OnActivationFocusChanged(TX_HANDLE hBehavior, int interactorId)
+{
+ TX_ACTIVATIONFOCUSCHANGEDEVENTPARAMS eventData;
+ if (txGetActivationFocusChangedEventParams(hBehavior, &eventData) == TX_RESULT_OK)
+ {
+ if (eventData.HasActivationFocus)
+ {
+ PostMessage(_hWnd, _focusedRegionChangedMessage, interactorId, 0);
+ }
+ else
+ {
+ PostMessage(_hWnd, _focusedRegionChangedMessage, -1, 0);
+ }
+
+ }
+}
+
+void EyeXHost::OnActivated(TX_HANDLE hBehavior, int interactorId)
+{
+ PostMessage(_hWnd, _regionActivatedMessage, interactorId, 0);
+}
+
+void TX_CALLCONVENTION EyeXHost::OnSnapshotCommitted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param)
+{
+ // check the result code using an assertion.
+ // this will catch validation errors and runtime errors in debug builds. in release builds it won't do anything.
+
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ txGetAsyncDataResultCode(hAsyncData, &result);
+ assert(result == TX_RESULT_OK || result == TX_RESULT_CANCELLED);
+}
+
+bool EyeXHost::QueryIsForWindowId(TX_HANDLE hQuery, const TX_CHAR* windowId)
+{
+ const int bufferSize = 20;
+ TX_CHAR buffer[bufferSize];
+
+ TX_SIZE count;
+ if (TX_RESULT_OK == txGetQueryWindowIdCount(hQuery, &count))
+ {
+ for (int i = 0; i < count; i++)
+ {
+ TX_SIZE size = bufferSize;
+ if (TX_RESULT_OK == txGetQueryWindowId(hQuery, i, buffer, &size))
+ {
+ if (0 == strcmp(windowId, buffer))
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
diff --git a/Tobii-EyeX/samples/ActivatableButtons/EyeXHost.h b/Tobii-EyeX/samples/ActivatableButtons/EyeXHost.h new file mode 100755 index 0000000..6ee7493 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/EyeXHost.h @@ -0,0 +1,79 @@ +/*
+ * EyeXHost class: Responsible for the gaze interaction within a window.
+ * Holds the current set of activatable regions and acts as a simple interactor repository.
+ * Sends notifications as Windows messages so that they are received on the main thread and can be handled there.
+ *
+ * Copyright 2013 Tobii Technology AB. All rights reserved.
+ */
+
+#pragma once
+
+#include <windows.h>
+#include <vector>
+#include <mutex>
+#include "eyex/EyeX.h"
+
+class EyeXHost
+{
+public:
+ // Represents an activatable region, that is, one particular kind of interactor.
+ struct ActivatableRegion
+ {
+ int id;
+ RECT bounds;
+
+ ActivatableRegion(int paramId, RECT paramBounds) : id(paramId), bounds(paramBounds) { }
+ };
+
+ EyeXHost();
+ virtual ~EyeXHost();
+
+ // attaches to the window with the given handle.
+ // the message parameters are custom windows messages sent to the window when an event has occurred.
+ void Init(HWND hWnd, UINT statusChangedMessage, UINT focusedRegionChangedMessage, UINT regionActivatedMessage);
+
+ // updates the collection (repository) of activatable regions.
+ void SetActivatableRegions(const std::vector<ActivatableRegion>& regions);
+
+ // triggers an activation ("direct click").
+ void TriggerActivation();
+
+private:
+ // registers handlers for notifications from the engine.
+ bool RegisterConnectionStateChangedHandler();
+ bool RegisterQueryHandler();
+ bool RegisterEventHandler();
+
+ // event handlers.
+ void OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState);
+ void HandleQuery(TX_CONSTHANDLE hAsyncData);
+ void HandleEvent(TX_CONSTHANDLE hAsyncData);
+ void HandleActivatableEvent(TX_HANDLE hEvent, int interactorId);
+ void OnActivationFocusChanged(TX_HANDLE hBehavior, int interactorId);
+ void OnActivated(TX_HANDLE hBehavior, int interactorId);
+
+ // callback function invoked when a snapshot has been committed.
+ static void TX_CALLCONVENTION OnSnapshotCommitted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param);
+
+ static bool QueryIsForWindowId(TX_HANDLE hQuery, const TX_CHAR* windowId);
+
+ // mutex protecting the state of the object from race conditions caused by multiple threads.
+ // (for example, a call to SetActivatableRegions from the main thread while the HandleQuery
+ // method is iterating through the regions on a worker thread.)
+ std::mutex _mutex;
+ std::vector<ActivatableRegion> _regions;
+ TX_CONTEXTHANDLE _context;
+ TX_TICKET _connectionStateChangedTicket;
+ TX_TICKET _queryHandlerTicket;
+ TX_TICKET _eventHandlerTicket;
+
+ // attached window and custom messages.
+ HWND _hWnd;
+ UINT _statusChangedMessage;
+ UINT _focusedRegionChangedMessage;
+ UINT _regionActivatedMessage;
+
+ // private copy constructor and operator making the class non-copyable (declared but not implemented).
+ EyeXHost(const EyeXHost&);
+ EyeXHost& operator = (const EyeXHost&);
+};
diff --git a/Tobii-EyeX/samples/ActivatableButtons/Resource.h b/Tobii-EyeX/samples/ActivatableButtons/Resource.h Binary files differnew file mode 100755 index 0000000..0d9e811 --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/Resource.h diff --git a/Tobii-EyeX/samples/ActivatableButtons/small.ico b/Tobii-EyeX/samples/ActivatableButtons/small.ico Binary files differnew file mode 100755 index 0000000..449296f --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/small.ico diff --git a/Tobii-EyeX/samples/ActivatableButtons/stdafx.cpp b/Tobii-EyeX/samples/ActivatableButtons/stdafx.cpp new file mode 100755 index 0000000..92e931f --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/stdafx.cpp @@ -0,0 +1,3 @@ +// stdafx.cpp : source file that includes just the standard includes
+
+#include "stdafx.h"
diff --git a/Tobii-EyeX/samples/ActivatableButtons/stdafx.h b/Tobii-EyeX/samples/ActivatableButtons/stdafx.h new file mode 100755 index 0000000..705c92c --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/stdafx.h @@ -0,0 +1,17 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+// C RunTime Header Files
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
diff --git a/Tobii-EyeX/samples/ActivatableButtons/targetver.h b/Tobii-EyeX/samples/ActivatableButtons/targetver.h new file mode 100755 index 0000000..90e767b --- /dev/null +++ b/Tobii-EyeX/samples/ActivatableButtons/targetver.h @@ -0,0 +1,8 @@ +#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
diff --git a/Tobii-EyeX/samples/CopyEyeXDllToOutputDirectory.targets b/Tobii-EyeX/samples/CopyEyeXDllToOutputDirectory.targets new file mode 100755 index 0000000..bdc798e --- /dev/null +++ b/Tobii-EyeX/samples/CopyEyeXDllToOutputDirectory.targets @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <!-- inject the CopyEyeXDll target into the linking build step -->
+ <PropertyGroup>
+ <BuildLinkAction>$(BuildLinkAction);CopyEyeXDllToOutputDirectory</BuildLinkAction>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <EyeXDllName>Tobii.EyeX.Client.dll</EyeXDllName>
+ <EyeXDllPath Condition=" '$(Platform)' == 'x64' ">..\..\lib\x64\$(EyeXDllName)</EyeXDllPath>
+ <EyeXDllPath Condition=" '$(Platform)' != 'x64' ">..\..\lib\x86\$(EyeXDllName)</EyeXDllPath>
+ </PropertyGroup>
+
+ <Target Name="CopyEyeXDllToOutputDirectory" Inputs="$(EyeXDllPath)" Outputs="$(OutDir)\$(EyeXDllName)">
+ <Copy SourceFiles="$(EyeXDllPath)" DestinationFolder="$(OutDir)" />
+ </Target>
+
+</Project>
diff --git a/Tobii-EyeX/samples/Debug/ActivatableBoardGame.exe b/Tobii-EyeX/samples/Debug/ActivatableBoardGame.exe Binary files differnew file mode 100755 index 0000000..e13b5d0 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/ActivatableBoardGame.exe diff --git a/Tobii-EyeX/samples/Debug/ActivatableBoardGame.ilk b/Tobii-EyeX/samples/Debug/ActivatableBoardGame.ilk Binary files differnew file mode 100755 index 0000000..86410d6 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/ActivatableBoardGame.ilk diff --git a/Tobii-EyeX/samples/Debug/ActivatableBoardGame.pdb b/Tobii-EyeX/samples/Debug/ActivatableBoardGame.pdb Binary files differnew file mode 100755 index 0000000..647659b --- /dev/null +++ b/Tobii-EyeX/samples/Debug/ActivatableBoardGame.pdb diff --git a/Tobii-EyeX/samples/Debug/ActivatableButtons.exe b/Tobii-EyeX/samples/Debug/ActivatableButtons.exe Binary files differnew file mode 100755 index 0000000..fbb924d --- /dev/null +++ b/Tobii-EyeX/samples/Debug/ActivatableButtons.exe diff --git a/Tobii-EyeX/samples/Debug/ActivatableButtons.ilk b/Tobii-EyeX/samples/Debug/ActivatableButtons.ilk Binary files differnew file mode 100755 index 0000000..dae3b90 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/ActivatableButtons.ilk diff --git a/Tobii-EyeX/samples/Debug/ActivatableButtons.pdb b/Tobii-EyeX/samples/Debug/ActivatableButtons.pdb Binary files differnew file mode 100755 index 0000000..66c7dd9 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/ActivatableButtons.pdb diff --git a/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.exe b/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.exe Binary files differnew file mode 100755 index 0000000..eb8dea2 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.exe diff --git a/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.ilk b/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.ilk Binary files differnew file mode 100755 index 0000000..1104292 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.ilk diff --git a/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.pdb b/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.pdb Binary files differnew file mode 100755 index 0000000..c00ee89 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalEyePositionDataStream.pdb diff --git a/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.exe b/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.exe Binary files differnew file mode 100755 index 0000000..cede5c1 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.exe diff --git a/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.ilk b/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.ilk Binary files differnew file mode 100755 index 0000000..eb7355f --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.ilk diff --git a/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.pdb b/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.pdb Binary files differnew file mode 100755 index 0000000..ba64025 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalFixationDataStream.pdb diff --git a/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.exe b/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.exe Binary files differnew file mode 100755 index 0000000..38cca37 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.exe diff --git a/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.ilk b/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.ilk Binary files differnew file mode 100755 index 0000000..82cdd05 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.ilk diff --git a/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.pdb b/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.pdb Binary files differnew file mode 100755 index 0000000..f2b24b2 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalGazeDataStream.pdb diff --git a/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.exe b/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.exe Binary files differnew file mode 100755 index 0000000..8354e4f --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.exe diff --git a/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.ilk b/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.ilk Binary files differnew file mode 100755 index 0000000..771b8f9 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.ilk diff --git a/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.pdb b/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.pdb Binary files differnew file mode 100755 index 0000000..c73bf24 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalStatusNotifications.pdb diff --git a/Tobii-EyeX/samples/Debug/MinimalUserProfiles.exe b/Tobii-EyeX/samples/Debug/MinimalUserProfiles.exe Binary files differnew file mode 100755 index 0000000..7c21075 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalUserProfiles.exe diff --git a/Tobii-EyeX/samples/Debug/MinimalUserProfiles.ilk b/Tobii-EyeX/samples/Debug/MinimalUserProfiles.ilk Binary files differnew file mode 100755 index 0000000..6b20d3f --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalUserProfiles.ilk diff --git a/Tobii-EyeX/samples/Debug/MinimalUserProfiles.pdb b/Tobii-EyeX/samples/Debug/MinimalUserProfiles.pdb Binary files differnew file mode 100755 index 0000000..897badd --- /dev/null +++ b/Tobii-EyeX/samples/Debug/MinimalUserProfiles.pdb diff --git a/Tobii-EyeX/samples/Debug/Tobii.EyeX.Client.dll b/Tobii-EyeX/samples/Debug/Tobii.EyeX.Client.dll Binary files differnew file mode 100755 index 0000000..0e1e975 --- /dev/null +++ b/Tobii-EyeX/samples/Debug/Tobii.EyeX.Client.dll diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.command.1.tlog b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.command.1.tlog Binary files differnew file mode 100755 index 0000000..778592a --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.read.1.tlog b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.read.1.tlog Binary files differnew file mode 100755 index 0000000..d263c73 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.write.1.tlog b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.write.1.tlog Binary files differnew file mode 100755 index 0000000..66e1721 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/CL.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/MinimalEyePositionDataStream.lastbuildstate b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/MinimalEyePositionDataStream.lastbuildstate new file mode 100755 index 0000000..5cd4c3b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/MinimalEyePositionDataStream.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\dev\tobii\samples\|
diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.command.1.tlog b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.command.1.tlog Binary files differnew file mode 100755 index 0000000..063463c --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.read.1.tlog b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.read.1.tlog Binary files differnew file mode 100755 index 0000000..0209802 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.write.1.tlog b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.write.1.tlog Binary files differnew file mode 100755 index 0000000..dfdfde0 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalE.6D2CFFFE.tlog/link.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalEyePositionDataStream.log b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalEyePositionDataStream.log new file mode 100755 index 0000000..f4e7d98 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalEyePositionDataStream.log @@ -0,0 +1,2 @@ + MinimalEyePositionDataStream.c
+ MinimalEyePositionDataStream.vcxproj -> D:\dev\tobii\samples\Debug\MinimalEyePositionDataStream.exe
diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalEyePositionDataStream.obj b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalEyePositionDataStream.obj Binary files differnew file mode 100755 index 0000000..94714f2 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/MinimalEyePositionDataStream.obj diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/vc140.idb b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/vc140.idb Binary files differnew file mode 100755 index 0000000..65a10a3 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/vc140.idb diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/vc140.pdb b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/vc140.pdb Binary files differnew file mode 100755 index 0000000..b8a41a3 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/Debug/vc140.pdb diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.c b/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.c new file mode 100755 index 0000000..b979c6c --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.c @@ -0,0 +1,199 @@ +/*
+ * This is an example that demonstrates how to connect to the EyeX Engine and subscribe to the eye position data stream.
+ *
+ * Copyright 2013-2014 Tobii Technology AB. All rights reserved.
+ */
+
+#include <Windows.h>
+#include <stdio.h>
+#include <conio.h>
+#include <assert.h>
+#include "eyex/EyeX.h"
+
+#pragma comment (lib, "Tobii.EyeX.Client.lib")
+
+// ID of the global interactor that provides our data stream; must be unique within the application.
+static const TX_STRING InteractorId = "Fluttershy";
+
+// global variables
+static TX_HANDLE g_hGlobalInteractorSnapshot = TX_EMPTY_HANDLE;
+
+/*
+ * Initializes g_hGlobalInteractorSnapshot with an interactor that has the Eye Position behavior.
+ */
+BOOL InitializeGlobalInteractorSnapshot(TX_CONTEXTHANDLE hContext)
+{
+ TX_HANDLE hInteractor = TX_EMPTY_HANDLE;
+ TX_HANDLE hBehaviorWithoutParameters = TX_EMPTY_HANDLE;
+
+ BOOL success;
+
+ success = txCreateGlobalInteractorSnapshot(
+ hContext,
+ InteractorId,
+ &g_hGlobalInteractorSnapshot,
+ &hInteractor) == TX_RESULT_OK;
+ success &= txCreateInteractorBehavior(hInteractor, &hBehaviorWithoutParameters, TX_BEHAVIORTYPE_EYEPOSITIONDATA) == TX_RESULT_OK;
+
+ txReleaseObject(&hInteractor);
+
+ return success;
+}
+
+/*
+ * Callback function invoked when a snapshot has been committed.
+ */
+void TX_CALLCONVENTION OnSnapshotCommitted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param)
+{
+ // check the result code using an assertion.
+ // this will catch validation errors and runtime errors in debug builds. in release builds it won't do anything.
+
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ txGetAsyncDataResultCode(hAsyncData, &result);
+ assert(result == TX_RESULT_OK || result == TX_RESULT_CANCELLED);
+}
+
+/*
+ * Callback function invoked when the status of the connection to the EyeX Engine has changed.
+ */
+void TX_CALLCONVENTION OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
+{
+ switch (connectionState) {
+ case TX_CONNECTIONSTATE_CONNECTED: {
+ BOOL success;
+ printf("The connection state is now CONNECTED (We are connected to the EyeX Engine)\n");
+ // commit the snapshot with the global interactor as soon as the connection to the engine is established.
+ // (it cannot be done earlier because committing means "send to the engine".)
+ success = txCommitSnapshotAsync(g_hGlobalInteractorSnapshot, OnSnapshotCommitted, NULL) == TX_RESULT_OK;
+ if (!success) {
+ printf("Failed to initialize the data stream.\n");
+ }
+ else {
+ printf("Waiting for eye position data to start streaming...\n");
+ }
+ }
+ break;
+
+ case TX_CONNECTIONSTATE_DISCONNECTED:
+ printf("The connection state is now DISCONNECTED (We are disconnected from the EyeX Engine)\n");
+ break;
+
+ case TX_CONNECTIONSTATE_TRYINGTOCONNECT:
+ printf("The connection state is now TRYINGTOCONNECT (We are trying to connect to the EyeX Engine)\n");
+ break;
+
+ case TX_CONNECTIONSTATE_SERVERVERSIONTOOLOW:
+ printf("The connection state is now SERVER_VERSION_TOO_LOW: this application requires a more recent version of the EyeX Engine to run.\n");
+ break;
+
+ case TX_CONNECTIONSTATE_SERVERVERSIONTOOHIGH:
+ printf("The connection state is now SERVER_VERSION_TOO_HIGH: this application requires an older version of the EyeX Engine to run.\n");
+ break;
+ }
+}
+
+/*
+ * Handles an event from the Eye Position data stream.
+ */
+void OnEyePositionDataEvent(TX_HANDLE hEyePositionDataBehavior)
+{
+ COORD position = {0,8};
+ TX_EYEPOSITIONDATAEVENTPARAMS eventParams;
+ if (txGetEyePositionDataEventParams(hEyePositionDataBehavior, &eventParams) == TX_RESULT_OK) {
+ SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position);
+
+ // Output information about the left eye.
+ printf("LEFT EYE\n");
+ printf("========\n");
+ printf("3D position: (%.1f, %.1f, %.1f) \n",
+ eventParams.LeftEyeX, eventParams.LeftEyeY, eventParams.LeftEyeZ);
+ printf("Normalized : (%.1f, %.1f, %.1f) \n",
+ eventParams.LeftEyeXNormalized, eventParams.LeftEyeYNormalized, eventParams.LeftEyeZNormalized);
+
+ // Output information about the right eye.
+ printf("\n");
+ printf("RIGHT EYE\n");
+ printf("=========\n");
+ printf("3D position: (%.1f, %.1f, %.1f) \n",
+ eventParams.RightEyeX, eventParams.RightEyeY, eventParams.RightEyeZ);
+ printf("Normalized : (%.1f, %.1f, %.1f) \n",
+ eventParams.RightEyeXNormalized, eventParams.RightEyeYNormalized, eventParams.RightEyeZNormalized);
+
+ printf("\n");
+ printf("The 3D position consists of X,Y,Z coordinates expressed in millimeters \n");
+ printf("in relation to the center of the screen where the eye tracker is mounted. \n");
+ printf("\n");
+ printf("The normalized coordinates are expressed in relation to the track box, \n");
+ printf("i.e. the volume in which the eye tracker is theoretically able to track eyes. \n");
+ printf("- (0,0,0) represents the upper, right corner closest to the eye tracker. \n");
+ printf("- (1,1,1) represents the lower, left corner furthest away from the eye tracker. \n");
+ } else {
+ printf("Failed to interpret eye position data event packet.\n");
+ }
+}
+
+/*
+ * Callback function invoked when an event has been received from the EyeX Engine.
+ */
+void TX_CALLCONVENTION HandleEvent(TX_CONSTHANDLE hAsyncData, TX_USERPARAM userParam)
+{
+ TX_HANDLE hEvent = TX_EMPTY_HANDLE;
+ TX_HANDLE hBehavior = TX_EMPTY_HANDLE;
+
+ txGetAsyncDataContent(hAsyncData, &hEvent);
+
+ // NOTE. Uncomment the following line of code to view the event object. The same function can be used with any interaction object.
+ //OutputDebugStringA(txDebugObject(hEvent));
+
+ if (txGetEventBehavior(hEvent, &hBehavior, TX_BEHAVIORTYPE_EYEPOSITIONDATA) == TX_RESULT_OK) {
+ OnEyePositionDataEvent(hBehavior);
+ txReleaseObject(&hBehavior);
+ }
+
+ // NOTE since this is a very simple application with a single interactor and a single data stream,
+ // our event handling code can be very simple too. A more complex application would typically have to
+ // check for multiple behaviors and route events based on interactor IDs.
+
+ txReleaseObject(&hEvent);
+}
+
+/*
+ * Application entry point.
+ */
+int main(int argc, char* argv[])
+{
+ TX_CONTEXTHANDLE hContext = TX_EMPTY_HANDLE;
+ TX_TICKET hConnectionStateChangedTicket = TX_INVALID_TICKET;
+ TX_TICKET hEventHandlerTicket = TX_INVALID_TICKET;
+ BOOL success;
+
+ // initialize and enable the context that is our link to the EyeX Engine.
+ success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK;
+ success &= txCreateContext(&hContext, TX_FALSE) == TX_RESULT_OK;
+ success &= InitializeGlobalInteractorSnapshot(hContext);
+ success &= txRegisterConnectionStateChangedHandler(hContext, &hConnectionStateChangedTicket, OnEngineConnectionStateChanged, NULL) == TX_RESULT_OK;
+ success &= txRegisterEventHandler(hContext, &hEventHandlerTicket, HandleEvent, NULL) == TX_RESULT_OK;
+ success &= txEnableConnection(hContext) == TX_RESULT_OK;
+
+ // let the events flow until a key is pressed.
+ if (success) {
+ printf("Initialization was successful.\n");
+ } else {
+ printf("Initialization failed.\n");
+ }
+ printf("Press any key to exit...\n");
+ _getch();
+ printf("Exiting.\n");
+
+ // disable and delete the context.
+ txDisableConnection(hContext);
+ txReleaseObject(&g_hGlobalInteractorSnapshot);
+ success = txShutdownContext(hContext, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE) == TX_RESULT_OK;
+ success &= txReleaseContext(&hContext) == TX_RESULT_OK;
+ success &= txUninitializeEyeX() == TX_RESULT_OK;
+ if (!success) {
+ printf("EyeX could not be shut down cleanly. Did you remember to release all handles?\n");
+ }
+
+ return 0;
+}
diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.vcxproj b/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.vcxproj new file mode 100755 index 0000000..fa69b14 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.vcxproj @@ -0,0 +1,160 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="MinimalEyePositionDataStream.c" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>MinimalEyePositionDataStream</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <Import Project="..\CopyEyeXDllToOutputDirectory.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.vcxproj.filters b/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.vcxproj.filters new file mode 100755 index 0000000..eded50f --- /dev/null +++ b/Tobii-EyeX/samples/MinimalEyePositionDataStream/MinimalEyePositionDataStream.vcxproj.filters @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="MinimalEyePositionDataStream.c" />
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.command.1.tlog b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.command.1.tlog Binary files differnew file mode 100755 index 0000000..71e55ee --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.read.1.tlog b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.read.1.tlog Binary files differnew file mode 100755 index 0000000..5f407c0 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.write.1.tlog b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.write.1.tlog Binary files differnew file mode 100755 index 0000000..d898b96 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/CL.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/MinimalFixationDataStream.lastbuildstate b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/MinimalFixationDataStream.lastbuildstate new file mode 100755 index 0000000..5cd4c3b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/MinimalFixationDataStream.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\dev\tobii\samples\|
diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.command.1.tlog b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.command.1.tlog Binary files differnew file mode 100755 index 0000000..e5015ab --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.read.1.tlog b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.read.1.tlog Binary files differnew file mode 100755 index 0000000..e83e6a0 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.write.1.tlog b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.write.1.tlog Binary files differnew file mode 100755 index 0000000..51ff531 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalF.9345876F.tlog/link.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalFixationDataStream.log b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalFixationDataStream.log new file mode 100755 index 0000000..4122cb4 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalFixationDataStream.log @@ -0,0 +1,2 @@ + MinimalFixationDataStream.c
+ MinimalFixationDataStream.vcxproj -> D:\dev\tobii\samples\Debug\MinimalFixationDataStream.exe
diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalFixationDataStream.obj b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalFixationDataStream.obj Binary files differnew file mode 100755 index 0000000..16c002d --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/MinimalFixationDataStream.obj diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/vc140.idb b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/vc140.idb Binary files differnew file mode 100755 index 0000000..9079705 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/vc140.idb diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/vc140.pdb b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/vc140.pdb Binary files differnew file mode 100755 index 0000000..01d5e16 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/Debug/vc140.pdb diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.c b/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.c new file mode 100755 index 0000000..92b530e --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.c @@ -0,0 +1,181 @@ +/*
+ * This is an example that demonstrates how to connect to the EyeX Engine and subscribe to the fixation data stream.
+ *
+ * Copyright 2013-2014 Tobii Technology AB. All rights reserved.
+ */
+
+#include <Windows.h>
+#include <stdio.h>
+#include <conio.h>
+#include <assert.h>
+#include "eyex/EyeX.h"
+
+#pragma comment (lib, "Tobii.EyeX.Client.lib")
+
+// ID of the global interactor that provides our data stream; must be unique within the application.
+static const TX_STRING InteractorId = "Rainbow Dash";
+
+// global variables
+static TX_HANDLE g_hGlobalInteractorSnapshot = TX_EMPTY_HANDLE;
+
+/*
+ * Initializes g_hGlobalInteractorSnapshot with an interactor that has the Fixation Data behavior.
+ */
+BOOL InitializeGlobalInteractorSnapshot(TX_CONTEXTHANDLE hContext)
+{
+ TX_HANDLE hInteractor = TX_EMPTY_HANDLE;
+ TX_FIXATIONDATAPARAMS params = { TX_FIXATIONDATAMODE_SENSITIVE };
+ BOOL success;
+
+ success = txCreateGlobalInteractorSnapshot(
+ hContext,
+ InteractorId,
+ &g_hGlobalInteractorSnapshot,
+ &hInteractor) == TX_RESULT_OK;
+ success &= txCreateFixationDataBehavior(hInteractor, ¶ms) == TX_RESULT_OK;
+
+ txReleaseObject(&hInteractor);
+
+ return success;
+}
+
+/*
+ * Callback function invoked when a snapshot has been committed.
+ */
+void TX_CALLCONVENTION OnSnapshotCommitted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param)
+{
+ // check the result code using an assertion.
+ // this will catch validation errors and runtime errors in debug builds. in release builds it won't do anything.
+
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ txGetAsyncDataResultCode(hAsyncData, &result);
+ assert(result == TX_RESULT_OK || result == TX_RESULT_CANCELLED);
+}
+
+/*
+ * Callback function invoked when the status of the connection to the EyeX Engine has changed.
+ */
+void TX_CALLCONVENTION OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
+{
+ switch (connectionState) {
+ case TX_CONNECTIONSTATE_CONNECTED: {
+ BOOL success;
+ printf("The connection state is now CONNECTED (We are connected to the EyeX Engine)\n");
+ // commit the snapshot with the global interactor as soon as the connection to the engine is established.
+ // (it cannot be done earlier because committing means "send to the engine".)
+ success = txCommitSnapshotAsync(g_hGlobalInteractorSnapshot, OnSnapshotCommitted, NULL) == TX_RESULT_OK;
+ if (!success) {
+ printf("Failed to initialize the data stream.\n");
+ }
+ else
+ {
+ printf("Waiting for fixation data to start streaming...\n");
+ }
+ }
+ break;
+
+ case TX_CONNECTIONSTATE_DISCONNECTED:
+ printf("The connection state is now DISCONNECTED (We are disconnected from the EyeX Engine)\n");
+ break;
+
+ case TX_CONNECTIONSTATE_TRYINGTOCONNECT:
+ printf("The connection state is now TRYINGTOCONNECT (We are trying to connect to the EyeX Engine)\n");
+ break;
+
+ case TX_CONNECTIONSTATE_SERVERVERSIONTOOLOW:
+ printf("The connection state is now SERVER_VERSION_TOO_LOW: this application requires a more recent version of the EyeX Engine to run.\n");
+ break;
+
+ case TX_CONNECTIONSTATE_SERVERVERSIONTOOHIGH:
+ printf("The connection state is now SERVER_VERSION_TOO_HIGH: this application requires an older version of the EyeX Engine to run.\n");
+ break;
+ }
+}
+
+/*
+ * Handles an event from the fixation data stream.
+ */
+void OnFixationDataEvent(TX_HANDLE hFixationDataBehavior)
+{
+ TX_FIXATIONDATAEVENTPARAMS eventParams;
+ TX_FIXATIONDATAEVENTTYPE eventType;
+ char* eventDescription;
+
+ if (txGetFixationDataEventParams(hFixationDataBehavior, &eventParams) == TX_RESULT_OK) {
+ eventType = eventParams.EventType;
+
+ eventDescription = (eventType == TX_FIXATIONDATAEVENTTYPE_DATA) ? "Data"
+ : ((eventType == TX_FIXATIONDATAEVENTTYPE_END) ? "End"
+ : "Begin");
+
+ printf("Fixation %s: (%.1f, %.1f) timestamp %.0f ms\n", eventDescription, eventParams.X, eventParams.Y, eventParams.Timestamp);
+ } else {
+ printf("Failed to interpret fixation data event packet.\n");
+ }
+}
+
+/*
+ * Callback function invoked when an event has been received from the EyeX Engine.
+ */
+void TX_CALLCONVENTION HandleEvent(TX_CONSTHANDLE hAsyncData, TX_USERPARAM userParam)
+{
+ TX_HANDLE hEvent = TX_EMPTY_HANDLE;
+ TX_HANDLE hBehavior = TX_EMPTY_HANDLE;
+
+ txGetAsyncDataContent(hAsyncData, &hEvent);
+
+ // NOTE. Uncomment the following line of code to view the event object. The same function can be used with any interaction object.
+ //OutputDebugStringA(txDebugObject(hEvent));
+
+ if (txGetEventBehavior(hEvent, &hBehavior, TX_BEHAVIORTYPE_FIXATIONDATA) == TX_RESULT_OK) {
+ OnFixationDataEvent(hBehavior);
+ txReleaseObject(&hBehavior);
+ }
+
+ // NOTE since this is a very simple application with a single interactor and a single data stream,
+ // our event handling code can be very simple too. A more complex application would typically have to
+ // check for multiple behaviors and route events based on interactor IDs.
+
+ txReleaseObject(&hEvent);
+}
+
+/*
+ * Application entry point.
+ */
+int main(int argc, char* argv[])
+{
+ TX_CONTEXTHANDLE hContext = TX_EMPTY_HANDLE;
+ TX_TICKET hConnectionStateChangedTicket = TX_INVALID_TICKET;
+ TX_TICKET hEventHandlerTicket = TX_INVALID_TICKET;
+ BOOL success;
+
+ // initialize and enable the context that is our link to the EyeX Engine.
+ success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK;
+ success &= txCreateContext(&hContext, TX_FALSE) == TX_RESULT_OK;
+ success &= InitializeGlobalInteractorSnapshot(hContext);
+ success &= txRegisterConnectionStateChangedHandler(hContext, &hConnectionStateChangedTicket, OnEngineConnectionStateChanged, NULL) == TX_RESULT_OK;
+ success &= txRegisterEventHandler(hContext, &hEventHandlerTicket, HandleEvent, NULL) == TX_RESULT_OK;
+ success &= txEnableConnection(hContext) == TX_RESULT_OK;
+
+ // let the events flow until a key is pressed.
+ if (success) {
+ printf("Initialization was successful.\n");
+ } else {
+ printf("Initialization failed.\n");
+ }
+ printf("Press any key to exit...\n");
+ _getch();
+ printf("Exiting.\n");
+
+ // disable and delete the context.
+ txDisableConnection(hContext);
+ txReleaseObject(&g_hGlobalInteractorSnapshot);
+ success = txShutdownContext(hContext, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE) == TX_RESULT_OK;
+ success &= txReleaseContext(&hContext) == TX_RESULT_OK;
+ success &= txUninitializeEyeX() == TX_RESULT_OK;
+ if (!success) {
+ printf("EyeX could not be shut down cleanly. Did you remember to release all handles?\n");
+ }
+
+ return 0;
+}
diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.vcxproj b/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.vcxproj new file mode 100755 index 0000000..c341a56 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.vcxproj @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9345876F-09E3-4764-9B3C-6496152D523E}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>MinimalFixationStream</RootNamespace>
+ <ProjectName>MinimalFixationDataStream</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="MinimalFixationDataStream.c" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <Import Project="..\CopyEyeXDllToOutputDirectory.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.vcxproj.filters b/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.vcxproj.filters new file mode 100755 index 0000000..f22a6b0 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalFixationDataStream/MinimalFixationDataStream.vcxproj.filters @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="MinimalFixationDataStream.c" />
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.command.1.tlog b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.command.1.tlog Binary files differnew file mode 100755 index 0000000..a5e9eba --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.read.1.tlog b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.read.1.tlog Binary files differnew file mode 100755 index 0000000..2e1fac2 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.write.1.tlog b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.write.1.tlog Binary files differnew file mode 100755 index 0000000..5d60166 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/CL.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/MinimalGazeDataStream.lastbuildstate b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/MinimalGazeDataStream.lastbuildstate new file mode 100755 index 0000000..5cd4c3b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/MinimalGazeDataStream.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\dev\tobii\samples\|
diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.command.1.tlog b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.command.1.tlog Binary files differnew file mode 100755 index 0000000..00cba87 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.read.1.tlog b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.read.1.tlog Binary files differnew file mode 100755 index 0000000..ccbfc24 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.write.1.tlog b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.write.1.tlog Binary files differnew file mode 100755 index 0000000..acf58be --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalG.CB99F84F.tlog/link.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalGazeDataStream.log b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalGazeDataStream.log new file mode 100755 index 0000000..08e8caa --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalGazeDataStream.log @@ -0,0 +1,2 @@ + MinimalGazeDataStream.c
+ MinimalGazeDataStream.vcxproj -> D:\dev\tobii\samples\Debug\MinimalGazeDataStream.exe
diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalGazeDataStream.obj b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalGazeDataStream.obj Binary files differnew file mode 100755 index 0000000..21cef4f --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/MinimalGazeDataStream.obj diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/vc140.idb b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/vc140.idb Binary files differnew file mode 100755 index 0000000..7720ab5 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/vc140.idb diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/vc140.pdb b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/vc140.pdb Binary files differnew file mode 100755 index 0000000..022bd91 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/Debug/vc140.pdb diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.c b/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.c new file mode 100755 index 0000000..20b3eab --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.c @@ -0,0 +1,171 @@ +/*
+ * This is an example that demonstrates how to connect to the EyeX Engine and subscribe to the lightly filtered gaze data stream.
+ *
+ * Copyright 2013-2014 Tobii Technology AB. All rights reserved.
+ */
+
+#include <Windows.h>
+#include <stdio.h>
+#include <conio.h>
+#include <assert.h>
+#include "eyex/EyeX.h"
+
+#pragma comment (lib, "Tobii.EyeX.Client.lib")
+
+// ID of the global interactor that provides our data stream; must be unique within the application.
+static const TX_STRING InteractorId = "Twilight Sparkle";
+
+// global variables
+static TX_HANDLE g_hGlobalInteractorSnapshot = TX_EMPTY_HANDLE;
+
+/*
+ * Initializes g_hGlobalInteractorSnapshot with an interactor that has the Gaze Point behavior.
+ */
+BOOL InitializeGlobalInteractorSnapshot(TX_CONTEXTHANDLE hContext)
+{
+ TX_HANDLE hInteractor = TX_EMPTY_HANDLE;
+ TX_GAZEPOINTDATAPARAMS params = { TX_GAZEPOINTDATAMODE_LIGHTLYFILTERED };
+ BOOL success;
+
+ success = txCreateGlobalInteractorSnapshot(
+ hContext,
+ InteractorId,
+ &g_hGlobalInteractorSnapshot,
+ &hInteractor) == TX_RESULT_OK;
+ success &= txCreateGazePointDataBehavior(hInteractor, ¶ms) == TX_RESULT_OK;
+
+ txReleaseObject(&hInteractor);
+
+ return success;
+}
+
+/*
+ * Callback function invoked when a snapshot has been committed.
+ */
+void TX_CALLCONVENTION OnSnapshotCommitted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param)
+{
+ // check the result code using an assertion.
+ // this will catch validation errors and runtime errors in debug builds. in release builds it won't do anything.
+
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ txGetAsyncDataResultCode(hAsyncData, &result);
+ assert(result == TX_RESULT_OK || result == TX_RESULT_CANCELLED);
+}
+
+/*
+ * Callback function invoked when the status of the connection to the EyeX Engine has changed.
+ */
+void TX_CALLCONVENTION OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
+{
+ switch (connectionState) {
+ case TX_CONNECTIONSTATE_CONNECTED: {
+ BOOL success;
+ printf("The connection state is now CONNECTED (We are connected to the EyeX Engine)\n");
+ // commit the snapshot with the global interactor as soon as the connection to the engine is established.
+ // (it cannot be done earlier because committing means "send to the engine".)
+ success = txCommitSnapshotAsync(g_hGlobalInteractorSnapshot, OnSnapshotCommitted, NULL) == TX_RESULT_OK;
+ if (!success) {
+ printf("Failed to initialize the data stream.\n");
+ }
+ else {
+ printf("Waiting for gaze data to start streaming...\n");
+ }
+ }
+ break;
+
+ case TX_CONNECTIONSTATE_DISCONNECTED:
+ printf("The connection state is now DISCONNECTED (We are disconnected from the EyeX Engine)\n");
+ break;
+
+ case TX_CONNECTIONSTATE_TRYINGTOCONNECT:
+ printf("The connection state is now TRYINGTOCONNECT (We are trying to connect to the EyeX Engine)\n");
+ break;
+
+ case TX_CONNECTIONSTATE_SERVERVERSIONTOOLOW:
+ printf("The connection state is now SERVER_VERSION_TOO_LOW: this application requires a more recent version of the EyeX Engine to run.\n");
+ break;
+
+ case TX_CONNECTIONSTATE_SERVERVERSIONTOOHIGH:
+ printf("The connection state is now SERVER_VERSION_TOO_HIGH: this application requires an older version of the EyeX Engine to run.\n");
+ break;
+ }
+}
+
+/*
+ * Handles an event from the Gaze Point data stream.
+ */
+void OnGazeDataEvent(TX_HANDLE hGazeDataBehavior)
+{
+ TX_GAZEPOINTDATAEVENTPARAMS eventParams;
+ if (txGetGazePointDataEventParams(hGazeDataBehavior, &eventParams) == TX_RESULT_OK) {
+ printf("Gaze Data: (%.1f, %.1f) timestamp %.0f ms\n", eventParams.X, eventParams.Y, eventParams.Timestamp);
+ } else {
+ printf("Failed to interpret gaze data event packet.\n");
+ }
+}
+
+/*
+ * Callback function invoked when an event has been received from the EyeX Engine.
+ */
+void TX_CALLCONVENTION HandleEvent(TX_CONSTHANDLE hAsyncData, TX_USERPARAM userParam)
+{
+ TX_HANDLE hEvent = TX_EMPTY_HANDLE;
+ TX_HANDLE hBehavior = TX_EMPTY_HANDLE;
+
+ txGetAsyncDataContent(hAsyncData, &hEvent);
+
+ // NOTE. Uncomment the following line of code to view the event object. The same function can be used with any interaction object.
+ //OutputDebugStringA(txDebugObject(hEvent));
+
+ if (txGetEventBehavior(hEvent, &hBehavior, TX_BEHAVIORTYPE_GAZEPOINTDATA) == TX_RESULT_OK) {
+ OnGazeDataEvent(hBehavior);
+ txReleaseObject(&hBehavior);
+ }
+
+ // NOTE since this is a very simple application with a single interactor and a single data stream,
+ // our event handling code can be very simple too. A more complex application would typically have to
+ // check for multiple behaviors and route events based on interactor IDs.
+
+ txReleaseObject(&hEvent);
+}
+
+/*
+ * Application entry point.
+ */
+int main(int argc, char* argv[])
+{
+ TX_CONTEXTHANDLE hContext = TX_EMPTY_HANDLE;
+ TX_TICKET hConnectionStateChangedTicket = TX_INVALID_TICKET;
+ TX_TICKET hEventHandlerTicket = TX_INVALID_TICKET;
+ BOOL success;
+
+ // initialize and enable the context that is our link to the EyeX Engine.
+ success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK;
+ success &= txCreateContext(&hContext, TX_FALSE) == TX_RESULT_OK;
+ success &= InitializeGlobalInteractorSnapshot(hContext);
+ success &= txRegisterConnectionStateChangedHandler(hContext, &hConnectionStateChangedTicket, OnEngineConnectionStateChanged, NULL) == TX_RESULT_OK;
+ success &= txRegisterEventHandler(hContext, &hEventHandlerTicket, HandleEvent, NULL) == TX_RESULT_OK;
+ success &= txEnableConnection(hContext) == TX_RESULT_OK;
+
+ // let the events flow until a key is pressed.
+ if (success) {
+ printf("Initialization was successful.\n");
+ } else {
+ printf("Initialization failed.\n");
+ }
+ printf("Press any key to exit...\n");
+ _getch();
+ printf("Exiting.\n");
+
+ // disable and delete the context.
+ txDisableConnection(hContext);
+ txReleaseObject(&g_hGlobalInteractorSnapshot);
+ success = txShutdownContext(hContext, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE) == TX_RESULT_OK;
+ success &= txReleaseContext(&hContext) == TX_RESULT_OK;
+ success &= txUninitializeEyeX() == TX_RESULT_OK;
+ if (!success) {
+ printf("EyeX could not be shut down cleanly. Did you remember to release all handles?\n");
+ }
+
+ return 0;
+}
diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.vcxproj b/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.vcxproj new file mode 100755 index 0000000..efd3412 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.vcxproj @@ -0,0 +1,160 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="MinimalGazeDataStream.c" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{CB99F84F-43D5-4F18-A2A9-79E4669A300E}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>MinimalGazeDataStream</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <Import Project="..\CopyEyeXDllToOutputDirectory.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.vcxproj.filters b/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.vcxproj.filters new file mode 100755 index 0000000..7d650f2 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalGazeDataStream/MinimalGazeDataStream.vcxproj.filters @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="MinimalGazeDataStream.c" />
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.command.1.tlog b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.command.1.tlog Binary files differnew file mode 100755 index 0000000..200a5ed --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.read.1.tlog b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.read.1.tlog Binary files differnew file mode 100755 index 0000000..4844ea7 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.write.1.tlog b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.write.1.tlog Binary files differnew file mode 100755 index 0000000..616875d --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/CL.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/MinimalStatusNotifications.lastbuildstate b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/MinimalStatusNotifications.lastbuildstate new file mode 100755 index 0000000..5cd4c3b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/MinimalStatusNotifications.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\dev\tobii\samples\|
diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.command.1.tlog b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.command.1.tlog Binary files differnew file mode 100755 index 0000000..6472281 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.read.1.tlog b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.read.1.tlog Binary files differnew file mode 100755 index 0000000..8855258 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.write.1.tlog b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.write.1.tlog Binary files differnew file mode 100755 index 0000000..5bd757b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalS.30C25EF3.tlog/link.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalStatusNotifications.log b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalStatusNotifications.log new file mode 100755 index 0000000..ce35307 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalStatusNotifications.log @@ -0,0 +1,2 @@ + MinimalStatusNotifications.c
+ MinimalStatusNotifications.vcxproj -> D:\dev\tobii\samples\Debug\MinimalStatusNotifications.exe
diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalStatusNotifications.obj b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalStatusNotifications.obj Binary files differnew file mode 100755 index 0000000..d7cb8b6 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/MinimalStatusNotifications.obj diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/vc140.idb b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/vc140.idb Binary files differnew file mode 100755 index 0000000..cf7c720 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/vc140.idb diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/vc140.pdb b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/vc140.pdb Binary files differnew file mode 100755 index 0000000..64cd628 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/Debug/vc140.pdb diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.c b/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.c new file mode 100755 index 0000000..1d7ce26 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.c @@ -0,0 +1,186 @@ +/*
+ * This is an example that demonstrates two ways of getting status information from the EyeX Engine.
+ *
+ * Copyright 2013-2014 Tobii Technology AB. All rights reserved.
+ */
+
+#include <Windows.h>
+#include <stdio.h>
+#include <conio.h>
+#include <assert.h>
+#include "eyex/EyeX.h"
+
+#pragma comment (lib, "Tobii.EyeX.Client.lib")
+
+// global variables
+static TX_CONTEXTHANDLE g_hContext = TX_EMPTY_HANDLE;
+
+/*
+ * Handles a state-changed notification, or the response from a get-state operation.
+ */
+void OnStateReceived(TX_HANDLE hStateBag)
+{
+ TX_BOOL success;
+ TX_INTEGER eyeTrackingState;
+ TX_SIZE2 displaySize;
+ TX_SIZE2 screenBounds;
+ TX_SIZE stringSize = 0;
+ TX_STRING currentProfileName;
+ TX_INTEGER presenceData;
+ TX_INTEGER gazeTracking;
+
+ success = (txGetStateValueAsInteger(hStateBag, TX_STATEPATH_EYETRACKINGSTATE, &eyeTrackingState) == TX_RESULT_OK);
+ if (success) {
+ switch (eyeTrackingState) {
+ case TX_EYETRACKINGDEVICESTATUS_TRACKING:
+ printf("Eye Tracking Device Status: 'TRACKING'.\n"
+ "That means that the eye tracker is up and running and trying to track your eyes.\n");
+ break;
+
+ default:
+ printf("The eye tracking device is not tracking.\n"
+ "It could be a that the eye tracker is not connected, or that a screen setup or\n"
+ "user calibration is missing. The status code is %d.\n", eyeTrackingState);
+ }
+ }
+
+ success = (txGetStateValueAsSize2(hStateBag, TX_STATEPATH_EYETRACKINGDISPLAYSIZE, &displaySize) == TX_RESULT_OK);
+ if (success) {
+ printf("Display Size: %5.2f x %5.2f mm\n", displaySize.Width, displaySize.Height);
+ }
+
+ success = (txGetStateValueAsSize2(hStateBag, TX_STATEPATH_EYETRACKINGSCREENBOUNDS, &screenBounds) == TX_RESULT_OK);
+ if (success) {
+ printf("Screen Bounds: %5.0f x %5.0f pixels\n\n", screenBounds.Width, screenBounds.Height);
+ }
+
+ success = (txGetStateValueAsInteger(hStateBag, TX_STATEPATH_USERPRESENCE, &presenceData) == TX_RESULT_OK);
+ if (success) {
+ if (presenceData != TX_USERPRESENCE_UNKNOWN) {
+ printf("User is %s\n", presenceData == TX_USERPRESENCE_PRESENT ? "present" : "NOT present" );
+ }
+ }
+
+ // The following state requires EyeX Engine 1.3.0 or later:
+ success = (txGetStateValueAsString(hStateBag, TX_STATEPATH_EYETRACKINGCURRENTPROFILENAME, NULL, &stringSize) == TX_RESULT_OK);
+ if (success) {
+ currentProfileName = (TX_STRING)malloc(stringSize*sizeof(char));
+ success = (txGetStateValueAsString(hStateBag, TX_STATEPATH_EYETRACKINGCURRENTPROFILENAME, currentProfileName, &stringSize) == TX_RESULT_OK);
+ if (success) {
+ printf("Current user profile name is: %s\n", currentProfileName);
+ }
+ free(currentProfileName);
+ }
+
+ // The following state requires EyeX Engine 1.4.0 or later:
+ success = (txGetStateValueAsInteger(hStateBag, TX_STATEPATH_GAZETRACKING, &gazeTracking) == TX_RESULT_OK);
+ if (success) {
+ printf("User's eye-gaze is %s\n", gazeTracking == TX_GAZETRACKING_GAZETRACKED ? "tracked" : "NOT tracked");
+ }
+}
+
+/*
+ * Handles engine state change notifications.
+ */
+void TX_CALLCONVENTION OnEngineStateChanged(TX_CONSTHANDLE hAsyncData, TX_USERPARAM userParam)
+{
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ TX_HANDLE hStateBag = TX_EMPTY_HANDLE;
+
+ if (txGetAsyncDataResultCode(hAsyncData, &result) == TX_RESULT_OK &&
+ txGetAsyncDataContent(hAsyncData, &hStateBag) == TX_RESULT_OK) {
+ OnStateReceived(hStateBag);
+ txReleaseObject(&hStateBag);
+ }
+}
+
+/*
+ * Callback function invoked when the status of the connection to the EyeX Engine has changed.
+ */
+void TX_CALLCONVENTION OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
+{
+ if (connectionState == TX_CONNECTIONSTATE_CONNECTED) {
+ printf("We're now connected to the EyeX Engine!\n");
+ printf("Now that we're connected: get the current eye tracking device status, display size and screen bounds...\n\n");
+
+ // NOTE. A request for the TX_STATEPATH_EYETRACKING state path (which expands to
+ // "eyeTracking") will also query for all sub-paths ("eyeTracking.whatever") -- which
+ // explains why this request provides data for the eye tracking device status etc.
+ txGetStateAsync(g_hContext, TX_STATEPATH_EYETRACKING, OnEngineStateChanged, NULL);
+ }
+}
+
+/*
+ * Application entry point.
+ */
+int main(int argc, char* argv[])
+{
+ TX_TICKET hConnectionStateChangedTicket = TX_INVALID_TICKET;
+ TX_TICKET hPresenceStateChangedTicket = TX_INVALID_TICKET;
+ TX_TICKET hGazeTrackingStateChangedTicket = TX_INVALID_TICKET;
+ TX_BOOL success;
+ TX_EYEXAVAILABILITY availability;
+
+ printf(
+ "===============================================================================\n\n"
+ "This sample illustrates two different ways of getting status information from\n"
+ "the EyeX Engine.\n\n"
+ "- First we try and connect to the EyeX Engine. When we get a connection we read\n"
+ " and print the current values of the eye tracking device status, the display\n"
+ " size and the screen bounds. This is done once per connection to the EyeX\n"
+ " Engine.\n\n"
+ "- When we have a connection to the Engine, we set up a listener for changes of\n"
+ " the user presence state. When the user's eyes are found the user is\n"
+ " considered present, when the eyes cannot be found, the user is considered not\n"
+ " present. Try blocking and unblocking the eye tracker's view of your eyes to\n"
+ " see the changes in the user presence state.\n\n"
+ "===============================================================================\n\n");
+
+ if (txGetEyeXAvailability(&availability) == TX_RESULT_OK) {
+ if (availability == TX_EYEXAVAILABILITY_NOTAVAILABLE) {
+ printf(
+ "This sample requires the EyeX Engine, but it isn't available.\n"
+ "Please install the EyeX Engine and try again.\n");
+ exit(-1);
+ }
+ else if (availability == TX_EYEXAVAILABILITY_NOTRUNNING) {
+ printf(
+ "This sample requires the EyeX Engine, but it isn't running.\n"
+ "Please make sure that the EyeX Engine is started.\n");
+ }
+ }
+
+ // initialize and enable the context that is our link to the EyeX Engine.
+ // register observers on the connection state, TX_STATEPATH_USERPRESENCE and the TX_STATEPATH_GAZETRACKING engine state.
+ success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK;
+ success &= txCreateContext(&g_hContext, TX_FALSE) == TX_RESULT_OK;
+ success &= txRegisterConnectionStateChangedHandler(g_hContext, &hConnectionStateChangedTicket, OnEngineConnectionStateChanged, NULL) == TX_RESULT_OK;
+ success &= txRegisterStateChangedHandler(g_hContext, &hPresenceStateChangedTicket, TX_STATEPATH_USERPRESENCE, OnEngineStateChanged, NULL) == TX_RESULT_OK;
+ success &= txRegisterStateChangedHandler(g_hContext, &hGazeTrackingStateChangedTicket, TX_STATEPATH_GAZETRACKING, OnEngineStateChanged, NULL) == TX_RESULT_OK;
+ success &= txEnableConnection(g_hContext) == TX_RESULT_OK;
+
+ // let the events flow until a key is pressed.
+ if (success) {
+ printf("Initialization was successful.\n");
+ printf("We are waiting for a connection to the EyeX Engine...\n\n");
+ } else {
+ printf("Initialization failed.\n\n");
+ }
+
+ printf("Press any key to exit...\n\n");
+ _getch();
+ printf("Exiting.\n");
+
+ // unregister handlers and delete the context.
+ txUnregisterConnectionStateChangedHandler(g_hContext, hConnectionStateChangedTicket);
+ txUnregisterStateChangedHandler(g_hContext, hPresenceStateChangedTicket);
+ txUnregisterStateChangedHandler(g_hContext, hGazeTrackingStateChangedTicket);
+ success = txShutdownContext(g_hContext, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE) == TX_RESULT_OK;
+ success &= txReleaseContext(&g_hContext) == TX_RESULT_OK;
+ success &= txUninitializeEyeX() == TX_RESULT_OK;
+ if (!success) {
+ printf("EyeX could not be shut down cleanly. Did you remember to release all handles?\n");
+ }
+
+ return 0;
+}
diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.vcxproj b/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.vcxproj new file mode 100755 index 0000000..7dbcced --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.vcxproj @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>MinimalStatusNotifications</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="MinimalStatusNotifications.c" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <Import Project="..\CopyEyeXDllToOutputDirectory.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.vcxproj.filters b/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.vcxproj.filters new file mode 100755 index 0000000..9e567fb --- /dev/null +++ b/Tobii-EyeX/samples/MinimalStatusNotifications/MinimalStatusNotifications.vcxproj.filters @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="MinimalStatusNotifications.c" />
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.command.1.tlog b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.command.1.tlog Binary files differnew file mode 100755 index 0000000..ca3124c --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.read.1.tlog b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.read.1.tlog Binary files differnew file mode 100755 index 0000000..b9b14b8 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.write.1.tlog b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.write.1.tlog Binary files differnew file mode 100755 index 0000000..c26f1a7 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/CL.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/MinimalUserProfiles.lastbuildstate b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/MinimalUserProfiles.lastbuildstate new file mode 100755 index 0000000..5cd4c3b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/MinimalUserProfiles.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
+Debug|Win32|D:\dev\tobii\samples\|
diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.command.1.tlog b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.command.1.tlog Binary files differnew file mode 100755 index 0000000..586a19e --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.command.1.tlog diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.read.1.tlog b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.read.1.tlog Binary files differnew file mode 100755 index 0000000..1b2f2e9 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.read.1.tlog diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.write.1.tlog b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.write.1.tlog Binary files differnew file mode 100755 index 0000000..4add4c6 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalU.7644167B.tlog/link.write.1.tlog diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalUserProfiles.log b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalUserProfiles.log new file mode 100755 index 0000000..2a34286 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalUserProfiles.log @@ -0,0 +1,4 @@ + stdafx.cpp
+ MinimalUserProfiles.cpp
+ Generating Code...
+ MinimalUserProfiles.vcxproj -> D:\dev\tobii\samples\Debug\MinimalUserProfiles.exe
diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalUserProfiles.obj b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalUserProfiles.obj Binary files differnew file mode 100755 index 0000000..1a00765 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/MinimalUserProfiles.obj diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/stdafx.obj b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/stdafx.obj Binary files differnew file mode 100755 index 0000000..ea32af6 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/stdafx.obj diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/vc140.idb b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/vc140.idb Binary files differnew file mode 100755 index 0000000..b32eb42 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/vc140.idb diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/Debug/vc140.pdb b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/vc140.pdb Binary files differnew file mode 100755 index 0000000..3ce102d --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/Debug/vc140.pdb diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.cpp b/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.cpp new file mode 100755 index 0000000..022486b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.cpp @@ -0,0 +1,269 @@ +/*
+ * MinimalUserProfiles sample:
+ * This is an example that demontrates how to retrieve and listen to changes to
+ * the states Current Profile Name and Profiles, and how to change the Current
+ * Profile.
+ *
+ * (It is written in mostly very C-style C++, to make it similar to the other
+ * minimal samples but still make use of std::vector and std::string. Using those
+ * makes the implementation more straightforward when handling the Profile state
+ * which is very dynamic in nature: an unknown number of profile name entries of
+ * unknown size.)
+ *
+ * Known limitation: this sample only works correctly for up to 10 profiles. It
+ * will list all profiles, but the input will only read one digit, so 9 will be
+ * the highest selectable index.
+ *
+ * Copyright 2015 Tobii AB (publ). All rights reserved.
+ */
+
+#include <Windows.h>
+#include <stdio.h>
+#include <conio.h>
+#include "stdafx.h"
+#include "eyex\EyeX.h"
+
+#pragma comment (lib, "Tobii.EyeX.Client.lib")
+
+static const UINT32 MIN_SIZE = 1;
+static const TX_STRING MIN_ENGINE_VERSION = "1.3.0";
+
+// global variables
+static TX_CONTEXTHANDLE g_hContext = TX_EMPTY_HANDLE;
+static std::string g_currentProfileName = "";
+static std::vector<std::string> g_profiles;
+
+/*
+ * Prints info about the current user profile, all available profiles and how
+ * to change to another profile.
+ */
+void PrintInfo()
+{
+ if (g_currentProfileName.length() < MIN_SIZE || g_profiles.size() < MIN_SIZE) {
+ return;
+ }
+
+ printf("\n-------------------------------------------------------------------------\n");
+ printf("\n Current user profile: %s\n", g_currentProfileName.c_str());
+ printf("\n All user profiles:\n");
+ int index = 0;
+ for (std::string profile : g_profiles) {
+ printf(" %i. %s\n", index++, profile.c_str());
+ }
+ printf("\n-------------------------------------------------------------------------\n");
+ printf("\nEnter the number of the profile you want to change to (or 'q' to quit): ");
+}
+
+/*
+ * Tries to extract an array of strings for the given state bag and state path.
+ * Returns TX_TRUE if successful, TX_FALSE otherwise.
+ * If successful, the arrayOfStrings parameter will be populated with the strings.
+ *
+ * This can be used to "unpack" a state bag with a TX_STATEPATH_EYETRACKINGPROFILES
+ * state's multiple null-terminated string to a more manageable format.
+ */
+TX_BOOL GetStateValueAsArrayOfStrings(TX_CONSTHANDLE hStateBag, TX_CONSTSTRING valuePath, std::vector<std::string> *arrayOfStrings)
+{
+ TX_SIZE stringSize = 0;
+ TX_BOOL success;
+
+ success = (txGetStateValueAsString(hStateBag, valuePath, nullptr, &stringSize)) == TX_RESULT_OK;
+ if (!success)
+ {
+ return TX_FALSE;
+ }
+
+ TX_STRING stringValue = new TX_CHAR[stringSize];
+ success = (txGetStateValueAsString(hStateBag, valuePath, stringValue, &stringSize) == TX_RESULT_OK);
+ if (!success)
+ {
+ delete[] stringValue;
+ return TX_FALSE;
+ }
+
+ TX_STRING stringPtr = stringValue;
+ while (*stringPtr != '\0')
+ {
+ TX_STRING startPoint = stringPtr;
+ while (*stringPtr != '\0')
+ {
+ stringPtr++;
+ }
+
+ std::string str = std::string(startPoint, stringPtr - startPoint);
+ arrayOfStrings->push_back(str);
+ stringPtr++;
+ }
+
+ return TX_TRUE;
+}
+
+/*
+ * Handles a state-changed notification, or the response from a get-state operation.
+ */
+void OnStateReceived(TX_HANDLE hStateBag)
+{
+ TX_BOOL success;
+ TX_SIZE stringSize = 0;
+ TX_STRING engineVersion;
+ TX_STRING profileName;
+ std::vector<std::string> profiles;
+
+ success = (txGetStateValueAsString(hStateBag, TX_STATEPATH_ENGINEINFOVERSION, NULL, &stringSize) == TX_RESULT_OK);
+ if (success) {
+ engineVersion = (TX_STRING)malloc(stringSize*sizeof(char));
+ if (txGetStateValueAsString(hStateBag, TX_STATEPATH_ENGINEINFOVERSION, engineVersion, &stringSize) == TX_RESULT_OK) {
+ printf("\nEyeX Engine version: %s. This sample requires EyeX Engine %s or higher.\n", engineVersion, MIN_ENGINE_VERSION);
+ }
+ free(engineVersion);
+ }
+
+ success = (txGetStateValueAsString(hStateBag, TX_STATEPATH_EYETRACKINGCURRENTPROFILENAME, NULL, &stringSize) == TX_RESULT_OK);
+ if (success) {
+ profileName = (TX_STRING)malloc(stringSize*sizeof(char));
+ if (txGetStateValueAsString(hStateBag, TX_STATEPATH_EYETRACKINGCURRENTPROFILENAME, profileName, &stringSize) == TX_RESULT_OK) {
+ g_currentProfileName = profileName;
+ }
+ free(profileName);
+ }
+
+ success = GetStateValueAsArrayOfStrings(hStateBag, TX_STATEPATH_EYETRACKINGPROFILES, &profiles);
+ if (success) {
+ g_profiles = profiles;
+ }
+
+ PrintInfo();
+}
+
+/*
+ * Handles engine state change notifications.
+ */
+void TX_CALLCONVENTION OnEngineStateChanged(TX_CONSTHANDLE hAsyncData, TX_USERPARAM userParam)
+{
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ TX_HANDLE hStateBag = TX_EMPTY_HANDLE;
+
+ if (txGetAsyncDataResultCode(hAsyncData, &result) == TX_RESULT_OK &&
+ txGetAsyncDataContent(hAsyncData, &hStateBag) == TX_RESULT_OK) {
+ OnStateReceived(hStateBag);
+ txReleaseObject(&hStateBag);
+ }
+}
+
+/*
+ * Callback function invoked when the status of the connection to the EyeX Engine has changed.
+ */
+void TX_CALLCONVENTION OnEngineConnectionStateChanged(TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
+{
+ if (connectionState == TX_CONNECTIONSTATE_CONNECTED) {
+ printf("We're now connected to the EyeX Engine!\n");
+ printf("Now that we're connected: get the user profiles...\n\n");
+
+ // the two states below requires EyeX Engine 1.3.0, so check engine version as well
+ txGetStateAsync(g_hContext, TX_STATEPATH_ENGINEINFOVERSION, OnEngineStateChanged, NULL);
+ txGetStateAsync(g_hContext, TX_STATEPATH_EYETRACKINGCURRENTPROFILENAME, OnEngineStateChanged, NULL);
+ txGetStateAsync(g_hContext, TX_STATEPATH_EYETRACKINGPROFILES, OnEngineStateChanged, NULL);
+ }
+}
+
+/*
+ * Callback function invoked when the async call to set current profile is completed.
+ */
+void TX_CALLCONVENTION OnSetCurrentProfileCompleted(TX_CONSTHANDLE hAsyncData, TX_USERPARAM userParam)
+{
+ TX_BOOL success;
+ TX_RESULT result = TX_RESULT_UNKNOWN;
+ success = (txGetAsyncDataResultCode(hAsyncData, &result) == TX_RESULT_OK && result == TX_RESULT_OK);
+ if (success == TX_FALSE) {
+ printf("\nSomething went wrong when trying to change the current profile.\n");
+ }
+}
+
+/*
+ * Change profile to the profile with index profileIndex as listed by the application's PrintInfo function.
+ */
+void ChangeProfileTo(int profileIndex)
+{
+ TX_CONSTSTRING profileName = (TX_CONSTSTRING)g_profiles[profileIndex].c_str();
+ if (profileName == g_currentProfileName) {
+ printf("\nYou selected the current profile. Try again: ");
+ } else {
+ printf("\nChanging user profile to '%s'.\n", profileName);
+ txSetCurrentProfile(g_hContext, profileName, OnSetCurrentProfileCompleted, NULL);
+ }
+}
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ printf("Press 'q' to quit the application.\n\n");
+
+ TX_TICKET hConnectionStateChangedTicket = TX_INVALID_TICKET;
+ TX_TICKET hCurrentProfileNameChangedTicket = TX_INVALID_TICKET;
+ TX_TICKET hEyeTrackingProfilesChangedTicket = TX_INVALID_TICKET;
+ TX_BOOL success;
+ TX_EYEXAVAILABILITY availability;
+
+ if (txGetEyeXAvailability(&availability) == TX_RESULT_OK) {
+ if (availability == TX_EYEXAVAILABILITY_NOTAVAILABLE) {
+ printf(
+ "This sample requires the EyeX Engine, but it isn't available.\n"
+ "Please install the EyeX Engine and try again.\n");
+ exit(-1);
+ }
+ else if (availability == TX_EYEXAVAILABILITY_NOTRUNNING) {
+ printf(
+ "This sample requires the EyeX Engine, but it isn't running.\n"
+ "Please make sure that the EyeX Engine is started.\n");
+ }
+ }
+
+ // initialize and enable the context that is our link to the EyeX Engine.
+ // register observers on the connection state, current profile name state, and profiles state.
+ success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK;
+ success &= txCreateContext(&g_hContext, TX_FALSE) == TX_RESULT_OK;
+ success &= txRegisterConnectionStateChangedHandler(g_hContext, &hConnectionStateChangedTicket, OnEngineConnectionStateChanged, NULL) == TX_RESULT_OK;
+ success &= txRegisterStateChangedHandler(g_hContext, &hCurrentProfileNameChangedTicket, TX_STATEPATH_EYETRACKINGCURRENTPROFILENAME, OnEngineStateChanged, NULL) == TX_RESULT_OK;
+ success &= txRegisterStateChangedHandler(g_hContext, &hEyeTrackingProfilesChangedTicket, TX_STATEPATH_EYETRACKINGPROFILES, OnEngineStateChanged, NULL) == TX_RESULT_OK;
+ success &= txEnableConnection(g_hContext) == TX_RESULT_OK;
+
+ if (success) {
+ printf("Initialization was successful.\n");
+ printf("We are waiting for a connection to the EyeX Engine...\n\n");
+ } else {
+ printf("Initialization failed.\n\n");
+ }
+
+ // read profile index entered by user, if valid: change profile.
+ // keep reading input until 'q' is read and application should exit.
+ // known limitation: only reads one character, meaning 9 will be the highest
+ // selectable profile index.
+ auto keepRunning = true;
+ while(keepRunning) {
+ int input = _getch();
+ char inputChar = input;
+ printf("%c\n", inputChar);
+ int profileIndex = input - '0';
+ if (input == 'q') {
+ printf("\nExiting.\n");
+ keepRunning = false;
+ } else if (isdigit(input) && ((unsigned int)profileIndex < g_profiles.size())) {
+ ChangeProfileTo(profileIndex);
+ } else {
+ printf("\nIllegal profile index: '%c'. Try again: ", inputChar);
+ }
+ }
+
+ // unregister handlers and delete the context.
+ txUnregisterConnectionStateChangedHandler(g_hContext, hConnectionStateChangedTicket);
+ txUnregisterStateChangedHandler(g_hContext, hCurrentProfileNameChangedTicket);
+ txUnregisterStateChangedHandler(g_hContext, hEyeTrackingProfilesChangedTicket);
+ success = txShutdownContext(g_hContext, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE) == TX_RESULT_OK;
+ success &= txReleaseContext(&g_hContext) == TX_RESULT_OK;
+ success &= txUninitializeEyeX() == TX_RESULT_OK;
+ if (!success) {
+ printf("EyeX could not be shut down cleanly. Did you remember to release all handles?\n");
+ }
+
+ return 0;
+}
+
diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.vcxproj b/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.vcxproj new file mode 100755 index 0000000..3481b69 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.vcxproj @@ -0,0 +1,163 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{7644167B-708E-4D09-A523-FB0F59871D82}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>MinimalUserProfiles</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x86</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>..\..\lib\x64</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="MinimalUserProfiles.cpp" />
+ <ClCompile Include="stdafx.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.vcxproj.filters b/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.vcxproj.filters new file mode 100755 index 0000000..614e5c9 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/MinimalUserProfiles.vcxproj.filters @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="targetver.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="MinimalUserProfiles.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/ReadMe.txt b/Tobii-EyeX/samples/MinimalUserProfiles/ReadMe.txt new file mode 100755 index 0000000..4171f7a --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/ReadMe.txt @@ -0,0 +1,40 @@ +========================================================================
+ CONSOLE APPLICATION : MinimalUserProfiles Project Overview
+========================================================================
+
+AppWizard has created this MinimalUserProfiles application for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your MinimalUserProfiles application.
+
+
+MinimalUserProfiles.vcxproj
+ This is the main project file for VC++ projects generated using an Application Wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+MinimalUserProfiles.vcxproj.filters
+ This is the filters file for VC++ projects generated using an Application Wizard.
+ It contains information about the association between the files in your project
+ and the filters. This association is used in the IDE to show grouping of files with
+ similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+ "Source Files" filter).
+
+MinimalUserProfiles.cpp
+ This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+ These files are used to build a precompiled header (PCH) file
+ named MinimalUserProfiles.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/stdafx.cpp b/Tobii-EyeX/samples/MinimalUserProfiles/stdafx.cpp new file mode 100755 index 0000000..92e931f --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/stdafx.cpp @@ -0,0 +1,3 @@ +// stdafx.cpp : source file that includes just the standard includes
+
+#include "stdafx.h"
diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/stdafx.h b/Tobii-EyeX/samples/MinimalUserProfiles/stdafx.h new file mode 100755 index 0000000..cb987d8 --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/stdafx.h @@ -0,0 +1,13 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#include <stdio.h>
+#include <tchar.h>
diff --git a/Tobii-EyeX/samples/MinimalUserProfiles/targetver.h b/Tobii-EyeX/samples/MinimalUserProfiles/targetver.h new file mode 100755 index 0000000..90e767b --- /dev/null +++ b/Tobii-EyeX/samples/MinimalUserProfiles/targetver.h @@ -0,0 +1,8 @@ +#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <SDKDDKVer.h>
diff --git a/Tobii-EyeX/samples/Samples.VC.db b/Tobii-EyeX/samples/Samples.VC.db Binary files differnew file mode 100755 index 0000000..64613ae --- /dev/null +++ b/Tobii-EyeX/samples/Samples.VC.db diff --git a/Tobii-EyeX/samples/Samples.sln b/Tobii-EyeX/samples/Samples.sln new file mode 100755 index 0000000..58c7450 --- /dev/null +++ b/Tobii-EyeX/samples/Samples.sln @@ -0,0 +1,85 @@ +
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ActivatableBoardGame", "ActivatableBoardGame\ActivatableBoardGame.vcxproj", "{2732E876-973B-4453-AA9F-D306EFB11922}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinimalStatusNotifications", "MinimalStatusNotifications\MinimalStatusNotifications.vcxproj", "{30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinimalGazeDataStream", "MinimalGazeDataStream\MinimalGazeDataStream.vcxproj", "{CB99F84F-43D5-4F18-A2A9-79E4669A300E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ActivatableButtons", "ActivatableButtons\ActivatableButtons.vcxproj", "{3E2A1867-D554-4655-8F03-B6A4C06D4967}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinimalFixationDataStream", "MinimalFixationDataStream\MinimalFixationDataStream.vcxproj", "{9345876F-09E3-4764-9B3C-6496152D523E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinimalEyePositionDataStream", "MinimalEyePositionDataStream\MinimalEyePositionDataStream.vcxproj", "{6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinimalUserProfiles", "MinimalUserProfiles\MinimalUserProfiles.vcxproj", "{7644167B-708E-4D09-A523-FB0F59871D82}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Debug|Win32.Build.0 = Debug|Win32
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Debug|x64.ActiveCfg = Debug|x64
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Debug|x64.Build.0 = Debug|x64
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Release|Win32.ActiveCfg = Release|Win32
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Release|Win32.Build.0 = Release|Win32
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Release|x64.ActiveCfg = Release|x64
+ {2732E876-973B-4453-AA9F-D306EFB11922}.Release|x64.Build.0 = Release|x64
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Debug|Win32.ActiveCfg = Debug|Win32
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Debug|Win32.Build.0 = Debug|Win32
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Debug|x64.ActiveCfg = Debug|x64
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Debug|x64.Build.0 = Debug|x64
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Release|Win32.ActiveCfg = Release|Win32
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Release|Win32.Build.0 = Release|Win32
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Release|x64.ActiveCfg = Release|x64
+ {30C25EF3-4FB1-425F-82FA-B4D3B3DAAD76}.Release|x64.Build.0 = Release|x64
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Debug|Win32.Build.0 = Debug|Win32
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Debug|x64.ActiveCfg = Debug|x64
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Debug|x64.Build.0 = Debug|x64
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Release|Win32.ActiveCfg = Release|Win32
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Release|Win32.Build.0 = Release|Win32
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Release|x64.ActiveCfg = Release|x64
+ {CB99F84F-43D5-4F18-A2A9-79E4669A300E}.Release|x64.Build.0 = Release|x64
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Debug|Win32.Build.0 = Debug|Win32
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Debug|x64.ActiveCfg = Debug|x64
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Debug|x64.Build.0 = Debug|x64
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Release|Win32.ActiveCfg = Release|Win32
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Release|Win32.Build.0 = Release|Win32
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Release|x64.ActiveCfg = Release|x64
+ {3E2A1867-D554-4655-8F03-B6A4C06D4967}.Release|x64.Build.0 = Release|x64
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Debug|Win32.Build.0 = Debug|Win32
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Debug|x64.ActiveCfg = Debug|x64
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Debug|x64.Build.0 = Debug|x64
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Release|Win32.ActiveCfg = Release|Win32
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Release|Win32.Build.0 = Release|Win32
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Release|x64.ActiveCfg = Release|x64
+ {9345876F-09E3-4764-9B3C-6496152D523E}.Release|x64.Build.0 = Release|x64
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Debug|Win32.Build.0 = Debug|Win32
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Debug|x64.ActiveCfg = Debug|x64
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Debug|x64.Build.0 = Debug|x64
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Release|Win32.ActiveCfg = Release|Win32
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Release|Win32.Build.0 = Release|Win32
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Release|x64.ActiveCfg = Release|x64
+ {6D2CFFFE-00E9-41C8-B389-059DA9AABDFC}.Release|x64.Build.0 = Release|x64
+ {7644167B-708E-4D09-A523-FB0F59871D82}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7644167B-708E-4D09-A523-FB0F59871D82}.Debug|Win32.Build.0 = Debug|Win32
+ {7644167B-708E-4D09-A523-FB0F59871D82}.Debug|x64.ActiveCfg = Debug|x64
+ {7644167B-708E-4D09-A523-FB0F59871D82}.Debug|x64.Build.0 = Debug|x64
+ {7644167B-708E-4D09-A523-FB0F59871D82}.Release|Win32.ActiveCfg = Release|Win32
+ {7644167B-708E-4D09-A523-FB0F59871D82}.Release|Win32.Build.0 = Release|Win32
+ {7644167B-708E-4D09-A523-FB0F59871D82}.Release|x64.ActiveCfg = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
|