Index: include/CBlobTracker.h
===================================================================
--- include/CBlobTracker.h	(revision 3)
+++ include/CBlobTracker.h	(working copy)
@@ -146,7 +146,9 @@
 		std::vector<std::vector<CFinger> > history;
 		std::vector<CBlob> blobList;
 		std::vector<BlobEquiv> equivalences;
+	public:
 		std::vector<CFinger> current;
+	private:
 		std::vector<ITouchListener *> listenerList;
 
 #ifdef WIN32
Index: include/CvCaptureFilter.h
===================================================================
--- include/CvCaptureFilter.h	(revision 3)
+++ include/CvCaptureFilter.h	(working copy)
@@ -8,8 +8,13 @@
 #include <cv.h>
 #include <cxcore.h>
 #include <highgui.h>
-#include <process.h>
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <process.h>
+#elif defined(__APPLE__)
+	
+#endif
+
 // FIXME: we should put this in a namespace
 
 class TOUCHLIB_FILTER_EXPORT CvCaptureFilter : public Filter
@@ -18,7 +23,7 @@
 		static CvCapture* capture;
 		static void acquireImage(void *param);
 		static IplImage* acquiredImage;
-		static HANDLE hThread;
+		//static HANDLE hThread;
 		char source[255];
 	public:
 		CvCaptureFilter(char*);
Index: include/CaptureFilter.h
===================================================================
--- include/CaptureFilter.h	(revision 3)
+++ include/CaptureFilter.h	(working copy)
@@ -8,8 +8,13 @@
 #include <cv.h>
 #include <cxcore.h>
 #include <highgui.h>
-#include <process.h>
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <process.h>
+#elif defined(__APPLE__)
+	
+#endif
+
 // FIXME: we should put this in a namespace
 
 class TOUCHLIB_FILTER_EXPORT CaptureFilter : public Filter
@@ -18,7 +23,7 @@
 		static CvCapture* capture;
 		static void acquireImage(void *param);
 		static IplImage* acquiredImage;
-		static HANDLE hThread;
+		//static HANDLE hThread;
 		char source[255];
 	public:
 		CaptureFilter(char*);
Index: include/mesh2d.h
===================================================================
--- include/mesh2d.h	(revision 3)
+++ include/mesh2d.h	(working copy)
@@ -149,7 +149,7 @@
 		void getBarycentricCoords(vector2d<T> pt, int tri_ind, float &bary_A, float &bary_B, float &bary_C)
 		{
 			vector2d<T> pt_local;
-			pt_local = p - position;
+			pt_local = pt - position;
 			pt_local.rotateBy(-rotation, vector2d<T>(0,0));
 			pt_local /= scale;
 
Index: include/CTouchScreen.h
===================================================================
--- include/CTouchScreen.h	(revision 3)
+++ include/CTouchScreen.h	(working copy)
@@ -5,8 +5,14 @@
 #include "CBlobTracker.h"
 #include "ITouchEvent.h"
 #include "Filter.h"
-#include <process.h>
-#include <windows.h>
+
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <process.h>
+	#include <windows.h>
+#elif defined(__APPLE__)
+	#include <pthread.h>
+#endif
+
 #include "ITouchListener.h"
 #include "mesh2d.h"
 
@@ -96,7 +102,11 @@
 
 //////////
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 		static void _processEntryPoint(void *obj);
+#elif defined(__APPLE__)
+		static void* _processEntryPoint(void *obj);
+#endif
 
 		void cameraToScreenSpace(float &x, float &y);
 
@@ -116,8 +126,13 @@
 		bool debugMode;
 		bool volatile bTracking;
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 		static HANDLE hThread;
 		static HANDLE eventListMutex;
+#elif defined(__APPLE__)
+		static pthread_t hThread;
+		static pthread_mutex_t eventListMutex;
+#endif
 
 		CBlobTracker tracker;
 
Index: include/VideoWrapperFilter.h
===================================================================
--- include/VideoWrapperFilter.h	(revision 3)
+++ include/VideoWrapperFilter.h	(working copy)
@@ -3,11 +3,13 @@
 
 #include <Filter.h>
 
-#include <windows.h>
-#include <tchar.h>
-#include <dshow.h>
-#include <streams.h>
-#include <process.h>
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <windows.h>
+	#include <tchar.h>
+	#include <dshow.h>
+	#include <streams.h>
+	#include <process.h>
+#endif
 
 #include <VideoWrapper.h>
 
Index: include/vector2d.h
===================================================================
--- include/vector2d.h	(revision 3)
+++ include/vector2d.h	(working copy)
@@ -222,7 +222,7 @@
 
 		static bool isOnSameSide(vector2d<T> p1, vector2d<T> p2, vector2d<T> a, vector2d<T> b)
 		{
-			vector2df ba = b - a;
+			vector2d<float> ba = b - a;
 
 			float cp1 = ba.crossProduct(p1-a);
 			float cp2 = ba.crossProduct(p2-a);
Index: src/CvCaptureFilter.cpp
===================================================================
--- src/CvCaptureFilter.cpp	(revision 3)
+++ src/CvCaptureFilter.cpp	(working copy)
@@ -1,6 +1,8 @@
 
 #include <CvCaptureFilter.h>
-#include <windows.h>
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <windows.h>
+#endif
 
 #include <cv.h>
 #include <cxcore.h>
@@ -8,7 +10,7 @@
 
 CvCapture * CvCaptureFilter::capture = 0;
 IplImage* CvCaptureFilter::acquiredImage = 0;
-HANDLE CvCaptureFilter::hThread = 0;
+//HANDLE CvCaptureFilter::hThread = 0;
 
 CvCaptureFilter::CvCaptureFilter(char* s) : Filter(s)
 {
@@ -71,9 +73,12 @@
 			if(strcmp(value, "cam") == 0)
 			{
 				capture = cvCaptureFromCAM( CV_CAP_ANY );
-				//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
-				//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 				cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH_HEIGHT, 640480);
+#elif defined(__APPLE__)
+				cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
+				cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
+#endif
 
 				cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, 30);
 
Index: src/configapp.cpp
===================================================================
--- src/configapp.cpp	(revision 3)
+++ src/configapp.cpp	(working copy)
@@ -1,20 +1,25 @@
-#pragma once
-#define WIN32_LEAN_AND_MEAN 
-#define _WIN32_WINNT  0x0500
 
-#include <windows.h>
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#pragma once
+	#define WIN32_LEAN_AND_MEAN 
+	#define _WIN32_WINNT  0x0500
 
+	#include <windows.h>
+	#include <tchar.h>
+	
+	#include "glut.h"
+	
+	#pragma comment( lib, "glut32" )
+	#pragma comment( lib, "user32" )
+#elif defined(__APPLE__)
+	#include <GLUT/glut.h>
+#endif
+
 #include <cv.h>
 #include <cxcore.h>
 #include <highgui.h>
 #include <map>
 
-#include <tchar.h>
-
-#include "glut.h"
-#pragma comment( lib, "glut32" )
-#pragma comment( lib, "user32" )
-
 #include "TouchScreenDevice.h"
 #include "TouchData.h"
 
@@ -22,7 +27,9 @@
 
 #include <stdio.h>
 
-#include <cvcam.h>
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <cvcam.h>
+#endif
 
 void glutDrawBox(float x1, float y1, float x2, float y2, float r, float g, float b);
 void glutDrawPlus(float x1, float y1, float s, float r, float g, float b);
@@ -121,6 +128,7 @@
 
 		if(curcalib == -1)
 		{
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 			INPUT aInput;
 
 			aInput.type = INPUT_MOUSE;
@@ -132,6 +140,7 @@
 			aInput.mi.dy = ((1.0f - data.Y) * 65535.0f);
 
 			int aResult = SendInput(1, &aInput, sizeof(INPUT) );
+#endif
 		}
 	}
 
@@ -142,6 +151,7 @@
 
 		if(curcalib == -1)
 		{
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 			INPUT aInput;
 
 			aInput.type = INPUT_MOUSE;
@@ -153,6 +163,7 @@
 			aInput.mi.dy = ((1.0f - data.Y) * 65535.0f);
 
 			int aResult = SendInput(1, &aInput, sizeof(INPUT) );
+#endif
 		}
 	}
 
@@ -172,6 +183,7 @@
 
 		if(curcalib == -1)
 		{
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 			INPUT aInput;
 
 			aInput.type = INPUT_MOUSE;
@@ -180,6 +192,7 @@
 			aInput.mi.mouseData = 0;
 			aInput.mi.time = 0;
 			int aResult = SendInput(1, &aInput, sizeof(INPUT) );
+#endif
 		}
 	}
 
@@ -352,13 +365,21 @@
 	glutMainLoop();
 }
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 int _tmain(int argc, char * argv[])
+#elif defined(__APPLE__)
+int main(int argc, char * argv[])
+#endif
 {
 	screen = TouchScreenDevice::getTouchScreen();
 
 	if(!screen->loadConfig("config.xml"))
 	{
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 		screen->pushFilter("dsvlcapture", "capture1");
+#elif defined(__APPLE__)
+		screen->pushFilter("cvcapture", "capture1");
+#endif
 		screen->pushFilter("mono", "mono2");
 		screen->pushFilter("smooth", "smooth3");
 		screen->pushFilter("backgroundremove", "background4");
@@ -369,7 +390,7 @@
 		screen->setParameter("rectify6", "level", "25");
 
 		screen->setParameter("capture1", "source", "cam");
-		//screen->setParameter("capture1", "source", "../tests/simple-2point.avi");
+		//screen->setParameter("capture1", "source", "/Users/dan/Projects/touchlib/tests/simple-2point.avi");
 		//screen->setParameter("capture1", "source", "../tests/hard-5point.avi");
 
 		screen->setParameter("bc5", "brightness", "0.1");
@@ -381,10 +402,11 @@
 	screen->registerListener((ITouchListener *)&app);
 	// Note: Begin processing should only be called after the screen is set up
 
-	screen->beginProcessing();
+	//screen->beginProcessing();
 
 	do
 	{
+		screen->process();
 
 		int keypressed = cvWaitKey(32) & 255;
 
Index: src/CaptureFilter.cpp
===================================================================
--- src/CaptureFilter.cpp	(revision 3)
+++ src/CaptureFilter.cpp	(working copy)
@@ -1,14 +1,17 @@
 
 #include <CaptureFilter.h>
-#include <windows.h>
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <windows.h>
+#endif
+
 #include <cv.h>
 #include <cxcore.h>
 #include <highgui.h>
 
 CvCapture * CaptureFilter::capture = 0;
 IplImage* CaptureFilter::acquiredImage = 0;
-HANDLE CaptureFilter::hThread = 0;
+//HANDLE CaptureFilter::hThread = 0;
 
 CaptureFilter::CaptureFilter(char* s) : Filter(s)
 {
Index: src/VideoWrapperFilter.cpp
===================================================================
--- src/VideoWrapperFilter.cpp	(revision 3)
+++ src/VideoWrapperFilter.cpp	(working copy)
@@ -4,7 +4,11 @@
 
 VideoWrapperFilter::VideoWrapperFilter(char *s) : Filter(s)
 {
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 	strcpy(videostring, "vc: 0 320 30 I420 1");
+#elif defined(__APPLE__)
+	strcpy(videostring, "qt: 0 640 30 rgb 0");
+#endif
 	g_hVideo = 0;
 
 	destination = NULL;
Index: src/FilterFactory.cpp
===================================================================
--- src/FilterFactory.cpp	(revision 3)
+++ src/FilterFactory.cpp	(working copy)
@@ -2,8 +2,10 @@
 
 #include "CvCaptureFilter.h"
 //#include "DsCaptureFilter.h"
-#include "VideoWrapperFilter.h"
-#include "DSVLCaptureFilter.h"
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include "VideoWrapperFilter.h"
+	#include "DSVLCaptureFilter.h"
+#endif
 
 #include "BrightnessContrastFilter.h"
 #include "MonoFilter.h"
@@ -25,10 +27,12 @@
 	if(strcmp(type, "cvcapture") == 0)
 	{
 		newFilter = (Filter *)new CvCaptureFilter((char*)label);
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 	} else if(strcmp(type, "vwcapture") == 0) {
 		newFilter = (Filter *)new VideoWrapperFilter((char*)label);
 	} else if(strcmp(type, "dsvlcapture") == 0) {
 		newFilter = (Filter *)new DSVLCaptureFilter((char*)label);
+#endif
 	} else if(strcmp(type, "mono") == 0) {
 		newFilter = (Filter *)new MonoFilter((char*)label);
 	} else if(strcmp(type, "rectify") == 0) {
Index: src/MonoFilter.cpp
===================================================================
--- src/MonoFilter.cpp	(revision 3)
+++ src/MonoFilter.cpp	(working copy)
@@ -31,11 +31,11 @@
 	// Note: the destination must have one channel.
 	if(source->nChannels != 1 && destination->nChannels == 1) 
 	{
-		if(strcmpi(source->colorModel, "BGRA") == 0)
+		if(strcasecmp(source->colorModel, "BGRA") == 0)
 			cvCvtColor(source, destination, CV_BGRA2GRAY);
-		else if(strcmpi(source->colorModel, "BGR") == 0)
+		else if(strcasecmp(source->colorModel, "BGR") == 0)
 			cvCvtColor(source, destination, CV_BGR2GRAY);
-		else if(strcmpi(source->colorModel, "RGB") == 0) 
+		else if(strcasecmp(source->colorModel, "RGB") == 0) 
 			cvCvtColor(source, destination, CV_RGB2GRAY);
 
 		
Index: src/test.cpp
===================================================================
--- src/test.cpp	(revision 3)
+++ src/test.cpp	(working copy)
@@ -5,7 +5,9 @@
 #include <cxcore.h>
 #include <highgui.h>
 
-#include<tchar.h>
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <tchar.h>
+#endif
 
 #define RECTIFY_LEVEL	40
 
@@ -15,14 +17,15 @@
 
 #include <filterbrightnesscontrast.h>
 
-
-using namespace touchscreen;
-
-
 IplImage *src_image = 0, *dst_image = 0;
 
+using namespace touchlib;
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 int _tmain(int argc, _TCHAR* argv[])
+#elif defined(__APPLE__)
+int main(int argc, char* argv[])
+#endif
 {
     // NOTE: just uncomment this line in order to get the capture from the webcam
     //CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
Index: src/sampleapp.cpp
===================================================================
--- src/sampleapp.cpp	(revision 3)
+++ src/sampleapp.cpp	(working copy)
@@ -2,9 +2,10 @@
 #include <cxcore.h>
 #include <highgui.h>
 
-#include <tchar.h>
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <tchar.h>
+#endif
 
-
 #include "TouchScreenDevice.h"
 
 using namespace touchlib;
@@ -101,8 +102,11 @@
     IplImage *window_img;
 };
 
-
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 int _tmain(int argc, _TCHAR* argv[])
+#elif defined(__APPLE__)
+int main(int argc, char* argv[])
+#endif
 {
 	// FIXME: in the future we will call a static method on TouchScreenDevice
 	// in order to get an ITouchScreen (singleton pattern) as opposed to directly
@@ -115,7 +119,11 @@
 	char* configFileName = "config.xml";
 	if(!screen->loadConfig(configFileName))
 	{
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 		screen->pushFilter("capture", "capture1");
+#elif defined(__APPLE__)
+		screen->pushFilter("cvcapture", "capture1");
+#endif
 		screen->pushFilter("mono", "mono2");
 		screen->pushFilter("smooth", "smooth3");
 		screen->pushFilter("backgroundremove", "background4");
@@ -125,8 +133,8 @@
 
 		screen->setParameter("rectify6", "level", "25");
 
-		//screen->setParameter("capture1", "source", "cam");
-		screen->setParameter("capture1", "source", "../tests/simple-2point.avi");
+		screen->setParameter("capture1", "source", "cam");
+		//screen->setParameter("capture1", "source", "../tests/simple-2point.avi");
 		//screen->setParameter("capture1", "source", "../tests/hard-5point.avi");
 
 		screen->setParameter("bc5", "brightness", "0.1");
@@ -138,11 +146,13 @@
 	screen->registerListener((ITouchListener *)&app);
 
 	// Note: Begin processing should only be called after the screen is set up
-	screen->beginProcessing();
+	//screen->beginProcessing();
 
 	bool ok=true;
 	do
 	{
+		screen->process();
+		
 		screen->getEvents();
 		app.draw();
 		//printf("*");
Index: src/touchtest.cpp
===================================================================
--- src/touchtest.cpp	(revision 3)
+++ src/touchtest.cpp	(working copy)
@@ -2,9 +2,10 @@
 #include <cxcore.h>
 #include <highgui.h>
 
-#include <tchar.h>
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	#include <tchar.h>
+#endif
 
-
 #include "TouchScreenDevice.h"
 
 using namespace touchlib;
@@ -101,8 +102,11 @@
     IplImage *window_img;
 };
 
-
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 int _tmain(int argc, _TCHAR* argv[])
+#else
+int main(int argc, char* argv[])
+#endif
 {
 	// FIXME: in the future we will call a static method on TouchScreenDevice
 	// in order to get an ITouchScreen (singleton pattern) as opposed to directly
Index: src/CTouchScreen.cpp
===================================================================
--- src/CTouchScreen.cpp	(revision 3)
+++ src/CTouchScreen.cpp	(working copy)
@@ -1,13 +1,19 @@
 
 #include "CTouchScreen.h"
 #include "FilterFactory.h"
-#include "process.h"
 #include "tinyxml.h"
+#include <highgui.h>
 
+
 using namespace touchlib;
 
-HANDLE CTouchScreen::hThread = 0;
-HANDLE CTouchScreen::eventListMutex = 0;
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	HANDLE CTouchScreen::hThread = 0;
+	HANDLE CTouchScreen::eventListMutex = 0;
+#elif defined(__APPLE__)
+	pthread_t CTouchScreen::hThread;
+	pthread_mutex_t CTouchScreen::eventListMutex;
+#endif
 
 // FIXME: Maybe some of this calibration stuff should be moved to the config app
 // Let the config app collect the points and set them en-masse..?
@@ -18,15 +24,19 @@
 
 	tracker.registerListener((ITouchListener *)this);
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 	eventListMutex = CreateMutex(NULL, 0, NULL);
+#elif defined(__APPLE__)
+	pthread_mutex_init(&eventListMutex, NULL);
+#endif
 
 	screenScale = 0.75;
 
 	initScreenPoints();
 	initCameraPoints();
 
-	debugMode = true;
-	bTracking = false;
+	debugMode = false;
+	bTracking = true;
 
 	screenMesh.recalcBoundingBox();
 
@@ -60,8 +70,15 @@
 {
 	unsigned int i;
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 	if(hThread)
 		TerminateThread(hThread, 0);
+#elif defined(__APPLE__)
+	if(hThread)
+		pthread_cancel(hThread);
+	
+	pthread_mutex_destroy(&eventListMutex);
+#endif
 
 	for(i=0; i<filterChain.size(); i++)
 		delete filterChain[i];
@@ -126,8 +143,8 @@
 
 bool CTouchScreen::process()
 {
-	while(1)
-	{
+	// while(1)
+	// {
 
 		if(filterChain.size() == 0)
 			return false;
@@ -148,9 +165,10 @@
 
 			if(bTracking == true)
 			{
-				//printf("Tracking 1\n");
+				printf("Tracking 1\n");
 				tracker.findBlobs(frame, labelImg);
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 				DWORD dw = WaitForSingleObject(eventListMutex, INFINITE);
 				//dw == WAIT_OBJECT_0
 				if(dw == WAIT_TIMEOUT || dw == WAIT_FAILED) {
@@ -166,13 +184,26 @@
 
 					ReleaseMutex(eventListMutex);
 				}
+#elif defined(__APPLE__)
+				pthread_mutex_lock(&eventListMutex);
+				
+				tracker.ProcessResults();
+				
+				pthread_mutex_unlock(&eventListMutex);
+#endif
 
 			}
 			//return true;
 		}
+		
+		// cvWaitKey(32);
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 		Sleep(16);
-	}
+#elif defined(__APPLE__)
+		//sleep(16);
+#endif
+	// }
 }
 
 
@@ -514,22 +545,30 @@
 
 }
 
-
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 void CTouchScreen::_processEntryPoint(void *obj)
+#elif defined(__APPLE__)
+void* CTouchScreen::_processEntryPoint(void *obj)
+#endif
 {
 	((CTouchScreen *)obj)->process();
 }
 
-
 void CTouchScreen::beginProcessing()
 {
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 	hThread = (HANDLE)_beginthread(_processEntryPoint, 0, this);
+#elif defined(__APPLE__)
+	pthread_create(&hThread, NULL, _processEntryPoint, this);
+#endif
 }
 
 
 void CTouchScreen::getEvents()
 {
 	unsigned int i=0;
+
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
 	DWORD dw = WaitForSingleObject(eventListMutex, INFINITE);
 	
 	// dw == WAIT_OBJECT_0
@@ -537,31 +576,34 @@
 		// handle time-out error
 		//throw TimeoutExcp();
 		return;
+	}
+#elif defined(__APPLE__)
+	pthread_mutex_lock(&eventListMutex);
+#endif
 
-	} else {
-
-		for(i=0; i<eventList.size(); i++)
+	for(i=0; i<eventList.size(); i++)
+	{
+		switch(eventList[i].type)
 		{
-			switch(eventList[i].type)
-			{
-			case TOUCH_PRESS:
-				doTouchEvent(eventList[i].data);
-				break;
-			case TOUCH_RELEASE:
-				doUntouchEvent(eventList[i].data);
-				break;
-			case TOUCH_UPDATE:
-				doUpdateEvent(eventList[i].data);
-				break;
-			};
-		}
-
-		eventList.clear();
-
-		ReleaseMutex(eventListMutex);
+		case TOUCH_PRESS:
+			doTouchEvent(eventList[i].data);
+			break;
+		case TOUCH_RELEASE:
+			doUntouchEvent(eventList[i].data);
+			break;
+		case TOUCH_UPDATE:
+			doUpdateEvent(eventList[i].data);
+			break;
+		};
 	}
 
+	eventList.clear();
 
+#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
+	ReleaseMutex(eventListMutex);
+#elif defined(__APPLE__)
+	pthread_mutex_unlock(&eventListMutex);
+#endif
 }
 
 
Index: src/Makefile
===================================================================
--- src/Makefile	(revision 0)
+++ src/Makefile	(revision 0)
@@ -0,0 +1,107 @@
+CFLAG = -O -I../include -I../tinyxml -I/usr/local/include -I/usr/local/include/opencv -g
+LDFLAG = -L../lib -L../tinyxml/lib -L/usr/local/lib -ltouchlib -ltinyxml -lcv -lcvaux -lcxcore -lhighgui -framework Carbon -framework GLUT -framework OpenGL -lobjc
+
+AR = ar
+ARFLAGS = -r
+RANLIB = ranlib $@
+
+IPATH = ../include
+
+all: ../lib/libtouchlib.a
+
+clean:
+	rm -f *.o ../lib/libtouchlib.a ../bin/configapp ../bin/touchtest ../bin/test ../bin/sampleapp
+
+TOUCHLIB_FILES = \
+	CBlobTracker.o \
+	CTouchScreen.o \
+	TouchScreenDevice.o \
+	BackgroundFilter.o \
+	BrightnessContrastFilter.o \
+	CvCaptureFilter.o \
+	filter.o \
+	FilterFactory.o \
+	MonoFilter.o \
+	RectifyFilter.o \
+	ResizeFilter.o \
+	SmoothingFilter.o
+
+../lib/libtouchlib.a: ${TOUCHLIB_FILES}
+	${AR} ${ARFLAGS} $@ ${TOUCHLIB_FILES}
+	${RANLIB}
+
+../bin/configapp: configapp.o ../lib/libtouchlib.a
+	g++ -o ../bin/configapp configapp.o ${LDFLAG}
+
+../bin/touchtest: touchtest.o ../lib/libtouchlib.a
+	g++ -o ../bin/touchtest touchtest.o ${LDFLAG}
+
+../bin/test: test.o ../lib/libtouchlib.a
+	g++ -o ../bin/test test.o ${LDFLAG}
+
+../bin/sampleapp: sampleapp.o ../lib/libtouchlib.a
+	g++ -o ../bin/sampleapp sampleapp.o ${LDFLAG}
+
+BackgroundFilter.o: BackgroundFilter.cpp ${IPATH}/BackgroundFilter.h
+	g++ -c -o BackgroundFilter.o ${CFLAG} BackgroundFilter.cpp
+
+BrightnessContrastFilter.o: BrightnessContrastFilter.cpp ${IPATH}/BrightnessContrastFilter.h
+	g++ -c -o BrightnessContrastFilter.o ${CFLAG} BrightnessContrastFilter.cpp
+
+CBlobTracker.o: CBlobTracker.cpp ${IPATH}/CBlobTracker.h
+	g++ -c -o CBlobTracker.o ${CFLAG} CBlobTracker.cpp
+
+CTouchScreen.o: CTouchScreen.cpp ${IPATH}/CTouchScreen.h ../tinyxml/lib/libtinyxml.a
+	g++ -c -o CTouchScreen.o ${CFLAG} CTouchScreen.cpp
+
+configapp.o: configapp.cpp ${IPATH}/Image.h ${IPATH}/ITouchListener.h
+	g++ -c -o configapp.o ${CFLAG} configapp.cpp
+
+CaptureFilter.o: CaptureFilter.cpp ${IPATH}/CaptureFilter.h
+	g++ -c -o CaptureFilter.o ${CFLAG} CaptureFilter.cpp
+
+CvCaptureFilter.o: CvCaptureFilter.cpp ${IPATH}/CvCaptureFilter.h
+	g++ -c -o CvCaptureFilter.o ${CFLAG} CvCaptureFilter.cpp
+
+filter.o: filter.cpp ${IPATH}/filter.h
+	g++ -c -o filter.o ${CFLAG} filter.cpp
+
+filterbrightnesscontrast.o: filterbrightnesscontrast.cpp ${IPATH}/filterbrightnesscontrast.h
+	g++ -c -o filterbrightnesscontrast.o ${CFLAG} filterbrightnesscontrast.cpp
+
+FilterFactory.o: FilterFactory.cpp ${IPATH}/FilterFactory.h
+	g++ -c -o FilterFactory.o ${CFLAG} FilterFactory.cpp
+
+MonoFilter.o: MonoFilter.cpp ${IPATH}/MonoFilter.h
+	g++ -c -o MonoFilter.o ${CFLAG} MonoFilter.cpp
+
+mousedriver.o: mousedriver.cpp ${IPATH}/mousedriver.h
+	g++ -c -o mousedriver.o ${CFLAG} mousedriver.cpp
+
+RectifyFilter.o: RectifyFilter.cpp ${IPATH}/RectifyFilter.h
+	g++ -c -o RectifyFilter.o ${CFLAG} RectifyFilter.cpp
+
+ResizeFilter.o: ResizeFilter.cpp ${IPATH}/ResizeFilter.h
+	g++ -c -o ResizeFilter.o ${CFLAG} ResizeFilter.cpp
+
+sampleapp.o: sampleapp.cpp
+	g++ -c -o sampleapp.o ${CFLAG} sampleapp.cpp
+
+SmoothingFilter.o: SmoothingFilter.cpp ${IPATH}/SmoothingFilter.h
+	g++ -c -o SmoothingFilter.o ${CFLAG} SmoothingFilter.cpp
+
+test.o: test.cpp
+	g++ -c -o test.o ${CFLAG} test.cpp
+
+textures.o: textures.cpp ${IPATH}/textures.h
+	g++ -c -o textures.o ${CFLAG} textures.cpp
+
+TouchScreenDevice.o: TouchScreenDevice.cpp ${IPATH}/TouchScreenDevice.h
+	g++ -c -o TouchScreenDevice.o ${CFLAG} TouchScreenDevice.cpp
+
+touchtest.o: touchtest.cpp
+	g++ -c -o touchtest.o ${CFLAG} touchtest.cpp
+
+VideoWrapperFilter.o: VideoWrapperFilter.cpp ${IPATH}/VideoWrapperFilter.h
+	g++ -c -o VideoWrapperFilter.o ${CFLAG} VideoWrapperFilter.cpp
+
Index: README.APPLE
===================================================================
--- README.APPLE	(revision 0)
+++ README.APPLE	(revision 0)
@@ -0,0 +1,21 @@
+Make sure you have XCode installed, then install OpenCV(I installed from their
+latest CVS). Assuming you installed OpenCV to /usr/local, you should just be
+able to run 'make' in this directory to build both the configapp and the
+sampleapp.
+
+I don't think the configapp's calibration works quite right yet because I had
+to combine the two threads in configapp/CTouchScreen to get around some
+problems with HighGUI in OS X. (It has issues updating window images in a different thread than where the keyboard callback is it appears)
+
+Right now, for video input, I'm just using OpenCV with CvCaptureFilter. It's
+fast enough for my testing so far, and it supports Quicktime cameras, and when
+I get around to using this on Linux, V4L ones. I did get VideoWrapper's QT plugin kinda working, but for some reason the image is upside down and it has some interesting Big/Little endian problems on my Intel Mac. It also appears to be
+slower the using the OpenCV camera input from my informal testing.
+
+We don't have a working FTIR screen up yet, that'll be sometime this week, so
+the only real testing I've done so far is with a TV remote pointed at the
+camera.
+
+--
+Dan Willemsen
+dan@csh.rit.edu

Property changes on: tinyxml/lib
___________________________________________________________________
Name: svn:ignore
   + libtinyxml.a


Index: tinyxml/Makefile
===================================================================
--- tinyxml/Makefile	(revision 0)
+++ tinyxml/Makefile	(revision 0)
@@ -0,0 +1,32 @@
+# Makefile created by Dan Willemsen(dan@csh.rit.edu) to
+# compile tinyxml inside the touchlib distribution
+#
+# This Makefile should be resilient enough to use on both
+# Mac OS X and Linux, but it has only been tested on OS X 
+
+CFLAG = -O -g
+
+AR = ar
+ARFLAGS = -r
+RANLIB = ranlib $@
+
+all: lib/libtinyxml.a
+
+clean:
+	rm -f *.o lib/libtinyxml.a
+
+lib/libtinyxml.a: tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o
+	${AR} ${ARFLAGS} $@ tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o
+	${RANLIB}
+
+tinystr.o: tinystr.cpp tinystr.h
+	g++ -c -o tinystr.o ${CFLAG} tinystr.cpp
+
+tinyxml.o: tinyxml.cpp tinyxml.h tinystr.h
+	g++ -c -o tinyxml.o ${CFLAG} tinyxml.cpp
+
+tinyxmlerror.o: tinyxmlerror.cpp tinyxml.h tinystr.h
+	g++ -c -o tinyxmlerror.o ${CFLAG} tinyxmlerror.cpp
+
+tinyxmlparser.o: tinyxmlparser.cpp tinyxml.h tinystr.h
+	g++ -c -o tinyxmlparser.o ${CFLAG} tinyxmlparser.cpp

Property changes on: lib
___________________________________________________________________
Name: svn:ignore
   + libtouchlib.a



Property changes on: bin
___________________________________________________________________
Name: svn:ignore
   + sampleapp
configapp


Index: Makefile
===================================================================
--- Makefile	(revision 0)
+++ Makefile	(revision 0)
@@ -0,0 +1,8 @@
+
+all:
+	(cd tinyxml; make)
+	(cd src; make; make ../bin/configapp; make ../bin/sampleapp)
+
+clean:
+	(cd tinyxml; make clean)
+	(cd src; make clean)
