Example #1
0
/*
 * Handles an event from the EyePosition data stream.
 */
void OnEyepositionDataEvent(TX_HANDLE hGazeDataBehavior)
{
    TX_EYEPOSITIONDATAEVENTPARAMS eventParams;
    if (txGetEyePositionDataEventParams(hGazeDataBehavior, &eventParams) == TX_RESULT_OK) {
        //printf("Has Left Eye Position: %d\n", eventParams.HasLeftEyePosition);
		lastKnownEyePositionData = eventParams;
    } else {
        printf("Failed to interpret gaze data event packet.\n");
        printf ("Error code: %d.\n", txGetEyePositionDataEventParams(hGazeDataBehavior, &eventParams));
    }
}
/*
* Handles an event from the Gaze Point data stream.
*/
void OnPositionDataEvent(TX_HANDLE hGazeDataBehavior)
{	
	float data[9]   = { 0, 0, 0, 0, 0, 0, 0, 0 ,0 };
	int iResult;

	TX_EYEPOSITIONDATAEVENTPARAMS eventParams;
	if (txGetEyePositionDataEventParams(hGazeDataBehavior, &eventParams) == TX_RESULT_OK) 
	{
		/* Every time there is an event, send a package*/			
		//TCP	Preparing data package = #bytes, BehaviorType, XL, YL, ZL, XR, YR, ZR, Timestamp
		data[0] = 32; // Number of following bytes (8 values * 4 bytes / value)
		data[1] = eventParams.Timestamp; // Seconds since the System Boot Time
		data[2] = 3;  // Behavior Type, 3 for Eye Position
		data[3] = eventParams.LeftEyeX;
		data[4] = eventParams.LeftEyeY;
		data[5] = eventParams.LeftEyeZ;
		data[6] = eventParams.RightEyeX;
		data[7] = eventParams.RightEyeY;
		data[8] = eventParams.RightEyeZ;
		
		printf("Eye Position: L(%.1f, %.1f, %.1f), R(%.1f, %.1f, %.1f), time %.0f ms\n", eventParams.LeftEyeX, eventParams.LeftEyeY, eventParams.LeftEyeZ, eventParams.RightEyeX, eventParams.RightEyeY, eventParams.RightEyeZ, eventParams.Timestamp);

		if (streaming)
		{
			for (int a = 0; a < 9; a++) //Up tp a < number of elements
			{
				SendFloatClientSocket(clientSocket, data[a]);
			}
		}	
	}
	else 
	{
		printf("Failed to interpret gaze data event packet.\n");	
	}
}
void TX_CALLCONVENTION ofxTobiiEyeX::HandleEvent(TX_CONSTHANDLE hAsyncData, TX_USERPARAM param)
{
	TX_HANDLE hEvent = TX_EMPTY_HANDLE;
	TX_HANDLE hBehavior = TX_EMPTY_HANDLE;

	txGetAsyncDataContent(hAsyncData, &hEvent);
	
	if (txGetEventBehavior(hEvent, &hBehavior, TX_BEHAVIORTYPE_GAZEPOINTDATA) == TX_RESULT_OK)
	{
		if (txGetGazePointDataEventParams(hBehavior, &smGazePointDataEventParams) != TX_RESULT_OK)
		{
			ofLogError(smAddonName, "Failed to interpret gaze data event packet.");
		}
	}
	
	if (txGetEventBehavior(hEvent, &hBehavior, TX_BEHAVIORTYPE_EYEPOSITIONDATA) == TX_RESULT_OK)
	{
		if (txGetEyePositionDataEventParams(hBehavior, &smEyePositionEventParams) != TX_RESULT_OK)
		{
			ofLogError(smAddonName, "Failed to interpret eye position event packet.");
		}
	}

	if (txGetEventBehavior(hEvent, &hBehavior, TX_BEHAVIORTYPE_FIXATIONDATA) == TX_RESULT_OK)
	{
		if (txGetFixationDataEventParams(hBehavior, &smFixationEventParams) != TX_RESULT_OK)
		{
			ofLogError(smAddonName, "Failed to interpret fixation event packet.");
		}
	}

	txReleaseObject(&hBehavior);
	txReleaseObject(&hEvent);
}
Example #4
0
/*
 * Handles an event from the Eye Position data stream.
 */
void OnEyePositionDataEvent(TX_HANDLE hGazeDataBehavior)
{
	TX_EYEPOSITIONDATAEVENTPARAMS eventParams;
	if (txGetEyePositionDataEventParams(hGazeDataBehavior, &eventParams) == TX_RESULT_OK) {
		//printf("Eye Position Data: (%.1f, %.1f) timestamp %.0f ms\n", eventParams.LeftEyeX, eventParams.LeftEyeY, eventParams.Timestamp);
		leftEyeX=eventParams.LeftEyeX*10;
		leftEyeY=eventParams.LeftEyeY*10;
	} else {
		printf("Failed to interpret eye postion data event packet.\n");
	}
}
Example #5
0
void Tobii::OnEyePositionDataEvent(TX_HANDLE hEyePositionDataBehavior)
{
	TX_EYEPOSITIONDATAEVENTPARAMS eventParams;
	if (txGetEyePositionDataEventParams(hEyePositionDataBehavior, &eventParams) == TX_RESULT_OK)
	{
		bool leftEyeClosed = !eventParams.HasLeftEyePosition;
		bool rightEyeClosed = !eventParams.HasRightEyePosition;

		leftEyeClosedCount = leftEyeClosed ? leftEyeClosedCount + 1 : 0;
		rightEyeClosedCount = rightEyeClosed ? rightEyeClosedCount + 1 : 0;
	}
}