bool ofxTobiiEyeX::setup() { if (txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, nullptr, nullptr, nullptr, nullptr) != TX_RESULT_OK) { ofLogError(smAddonName, "Initialization failed."); return false; } return true; }
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(); }
BOOL InitEyeX() { BOOL success; success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK; success &= txCreateContext(&eyeXContext, TX_FALSE) == TX_RESULT_OK; success &= InitializeGlobalInteractorSnapshot(eyeXContext); success &= txRegisterConnectionStateChangedHandler(eyeXContext, &hConnectionStateChangedTicket, OnEngineConnectionStateChanged, NULL) == TX_RESULT_OK; success &= txRegisterEventHandler(eyeXContext, &hEventHandlerTicket, HandleEvent, NULL) == TX_RESULT_OK; success &= txEnableConnection(eyeXContext) == TX_RESULT_OK; return success; }
void eyeXHost::init() { _context = TX_EMPTY_HANDLE; _connectionStateChangedTicket = TX_INVALID_TICKET; _eventHandlerTicket = TX_INVALID_TICKET; bool success; success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK; success &= txCreateContext(&_context, TX_FALSE) == TX_RESULT_OK; success &= InitializeGlobalInteractorSnapshot(_context); RegisterConnectionStateChangedHandler(); RegisterEventHandler(); success &= txEnableConnection(_context) == TX_RESULT_OK; }
EyeXGaze::EyeXGaze() : _hWnd(nullptr), _statusChangedMessage(0), _focusRegionChangedMessage(0), _regionActivatedMessage(0) { txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, nullptr, nullptr, nullptr, nullptr);// client library사용을위한 init txCreateContext(&_hContext, TX_FALSE); // context 생성 InitializeGlobalInteractorSnapshot(_hContext); // global interactor snapshot 생성 ( 나중에 gaze data stream 받기위함 ) // 핸들러 등록 RegisterConnectionStateChangedHandler(); RegisterQueryHandler(); RegisterEventHandler(); }
void Connect(void) { // initialize variables TX_TICKET hConnectionStateChangedTicket = TX_INVALID_TICKET; TX_TICKET hEventHandlerTicket = TX_INVALID_TICKET; BOOL success; // create data stack q_create(); // 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; // short pause to try and ensure that the callbacks are fired and the printf messages sent to Matlab before this function terminates Sleep(100); }
/* * Application entry point. */ int startEyeX(void) { // 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 &= InitializeGlobalInteractorSnapshot1(hContext); success &= InitializeGlobalInteractorSnapshot2(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("running...\n"); // _getch(); return 0; }
/** * Setup and initialize connection to Tobii Eye Tracker */ void tobii_setup() { 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"); } }
void Tobii::InitializeTobii() { 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; if (success) { printf("Initialization was successful.\n"); } else { printf("Initialization failed.\n"); } }
/* * 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; }
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); } }
/* * Application entry point. */ int main(int argc, char* argv[]) { char *ip = NULL; char *port = NULL; int iResult = 0; system("cls"); // Check input arguments for IP and PORT and open client socket if required if (argc != 3) { printf("Usage: %s <IP> <PORT>\n", argv[0]); printf("EyeX data will not be streamed\n"); } else { ip = argv[1]; port = argv[2]; printf("Trying connection with %s : %s\n", ip, port); clientSocket = OpenClientSocket(ip, port); if (clientSocket == INVALID_SOCKET) { printf("Error at connection with %s : %s\n", ip, port); printf("EyeX data will not be streamed\n"); } else { streaming = TRUE; } } Sleep(2000); 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 X to exit...\n"); _getch(); printf("Exiting.\n"); // disable and delete the context. txDisableConnection(hContext); txReleaseObject(&g_hGlobalInteractorSnapshot); txShutdownContext(hContext, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE); txReleaseContext(&hContext); if (streaming) { SendFloatClientSocket(clientSocket, -1); CloseClientSocket(clientSocket); } Beep(300, 750); return 0; }