bool ofxTobiiEyeX::registerFixationEventHandler(const string& InteractorId, TX_FIXATIONDATAMODE mode) { auto& handle = mFixationHandle; handle.hConnectionStateChangedTicket = TX_INVALID_TICKET; handle.hEventHandlerTicket = TX_INVALID_TICKET; TX_CONSTSTRING ID = InteractorId.c_str(); TX_FIXATIONDATAPARAMS params = { mode }; TX_HANDLE hInteractor = TX_EMPTY_HANDLE; bool success = true; success &= txCreateContext(&handle.hContext, TX_FALSE) == TX_RESULT_OK; success &= txCreateGlobalInteractorSnapshot(handle.hContext, ID, &handle.hGlobalInteractorSnapshot, &hInteractor) == TX_RESULT_OK; success &= txCreateFixationDataBehavior(hInteractor, ¶ms) == TX_RESULT_OK; success &= txReleaseObject(&hInteractor) == TX_RESULT_OK; success &= txRegisterConnectionStateChangedHandler(handle.hContext, &handle.hConnectionStateChangedTicket, OnEngineConnectionStateChanged, handle.hGlobalInteractorSnapshot) == TX_RESULT_OK; success &= txRegisterEventHandler(handle.hContext, &handle.hEventHandlerTicket, HandleEvent, nullptr) == TX_RESULT_OK; success &= txEnableConnection(handle.hContext) == TX_RESULT_OK; if (!success) { ofLogError(smAddonName, "Registing fixation data event handler was failed."); } 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; }
bool EyeXGaze::RegisterEventHandler() { auto eventHandlerTrampoline = [](TX_CONSTHANDLE hObject, TX_USERPARAM userParam) { //static_cast<EyeXGaze*>(userParam)->GazeHandleEvent(hObject); static_cast<EyeXGaze*>(userParam)->FixHandleEvent(hObject); // Fixation static_cast<EyeXGaze*>(userParam)->HandleEvent(hObject); // Activatable Region }; bool success = txRegisterEventHandler(_hContext, &_connectionStateChangedTicket, eventHandlerTrampoline, this) == TX_RESULT_OK; return success; }
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 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; }
/* * 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; }