Beispiel #1
0
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 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, &params) == 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;
}
/*
void TX_CALLCONVENTION EyeXGaze::GazeHandleEvent(TX_CONSTHANDLE hAsyncData)
{
	TX_HANDLE hEvent = TX_EMPTY_HANDLE;
	TX_HANDLE hBehavior = TX_EMPTY_HANDLE;

	// DataContent를 hEvent에 저장
	txGetAsyncDataContent(hAsyncData, &hEvent);
	//event에서 behavior를 해당 타입대로 추출하여 hBehavior변수에 저장
	if (txGetEventBehavior(hEvent, &hBehavior, TX_BEHAVIORTYPE_GAZEPOINTDATA) == TX_RESULT_OK)
	{
		OnGazeDataEvent(hBehavior);
		txReleaseObject(&hBehavior);
	}
	txReleaseObject(&hEvent);
}
*/
bool EyeXGaze::RegisterConnectionStateChangedHandler()
{
	auto connectionStateChangedTrampoline = [](TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
	{
		static_cast<EyeXGaze*>(userParam)->OnEngineConnectionStateChanged(connectionState);
	};

	// 해당 context에 ticket을 지정하고 세 번째 인자를 state가 change될 때마다 호출한다.
	bool success = txRegisterConnectionStateChangedHandler(_hContext, &_connectionStateChangedTicket, connectionStateChangedTrampoline, this) == TX_RESULT_OK;
	return success;
}
Beispiel #4
0
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;
}
Beispiel #5
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;
}
Beispiel #6
0
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);
}
Beispiel #7
0
/*
 * 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");
    }
}
Beispiel #9
0
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;
}