Index: code/trunk/src/external/ois/mac/CMakeLists.txt
===================================================================
--- code/trunk/src/external/ois/mac/CMakeLists.txt	(revision 5929)
+++ code/trunk/src/external/ois/mac/CMakeLists.txt	(revision 8351)
@@ -3,14 +3,16 @@
   MacHIDManager.h
   MacInputManager.h
+  MacJoyStick.h
   MacKeyboard.h
   MacMouse.h
   MacPrereqs.h
 
-COMPILATION_BEGIN OISMacCompilation.cpp
+#COMPILATION_BEGIN OISMacCompilation.cpp
   MacHelpers.cpp
   MacHIDManager.cpp
   MacInputManager.cpp
+  MacJoyStick.cpp
   MacKeyboard.cpp
   MacMouse.cpp
-COMPILATION_END
+#COMPILATION_END
 )
Index: code/trunk/src/external/ois/mac/MacHIDManager.cpp
===================================================================
--- code/trunk/src/external/ois/mac/MacHIDManager.cpp	(revision 5929)
+++ code/trunk/src/external/ois/mac/MacHIDManager.cpp	(revision 8351)
@@ -20,6 +20,7 @@
  
  3. This notice may not be removed or altered from any source distribution.
-*/
+ */
 #include "mac/MacHIDManager.h"
+#include "mac/MacJoyStick.h"
 #include "OISException.h"
 #include "OISObject.h"
@@ -42,5 +43,5 @@
 {
 	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+	
 	if(temp && CFGetTypeID(temp) == CFArrayGetTypeID())
 		return (CFArrayRef)temp;
@@ -53,5 +54,5 @@
 {
 	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+	
 	if(temp && CFGetTypeID(temp) == CFStringGetTypeID())
 		return (CFStringRef)temp;
@@ -64,5 +65,5 @@
 {
 	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
-
+	
 	if(temp && CFGetTypeID(temp) == CFNumberGetTypeID())
 		return (CFNumberRef)temp;
@@ -83,5 +84,5 @@
 {
 	CFTypeRef temp = CFArrayGetValueAtIndex(array, idx);
-
+	
 	if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID())
 		return (CFDictionaryRef)temp;
@@ -93,8 +94,8 @@
 int getInt32(CFNumberRef ref)
 {
-   int r = 0;
-   if (r) 
-      CFNumberGetValue(ref, kCFNumberIntType, &r);
-   return r;
+	int r = 0;
+	if (r) 
+		CFNumberGetValue(ref, kCFNumberIntType, &r);
+	return r;
 }
 
@@ -111,69 +112,96 @@
 //------------------------------------------------------------------------------------------------------//
 void MacHIDManager::initialize()
+{
+	//Make the search more specific by adding usage flags
+	int usage = kHIDUsage_GD_Joystick;
+	int page = kHIDPage_GenericDesktop;
+	
+	io_iterator_t iterator = lookUpDevices(usage, page);
+	
+	if(iterator)
+		iterateAndOpenDevices(iterator);
+	
+	//Doesn't support multiple usage flags, iterate twice
+	usage = kHIDUsage_GD_GamePad;
+	iterator = lookUpDevices(usage, page);
+	
+	if(iterator)
+		iterateAndOpenDevices(iterator);
+}
+
+//------------------------------------------------------------------------------------------------------//
+io_iterator_t MacHIDManager::lookUpDevices(int usage, int page)
 {
 	CFMutableDictionaryRef deviceLookupMap = IOServiceMatching(kIOHIDDeviceKey);
 	if(!deviceLookupMap)
 		OIS_EXCEPT(E_General, "Could not setup HID device search parameters");
-
-	//Make the search more specific by adding usage flags
-	int usage = kHIDUsage_GD_GamePad | kHIDUsage_GD_Joystick,
-	    page  = kHIDPage_GenericDesktop;
-
-	CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage),
-				pageRef  = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
-
+	
+	CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage);
+	CFNumberRef pageRef  = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
+	
 	CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsageKey), usageRef);
 	CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsagePageKey), pageRef);
-
+	
 	//IOServiceGetMatchingServices consumes the map so we do not have to release it ourself
 	io_iterator_t iterator = 0;
 	IOReturn result = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceLookupMap, &iterator);
-	if (result == kIOReturnSuccess && iterator)
-	{
-		io_object_t hidDevice = 0;
-		while ((hidDevice = IOIteratorNext(iterator)) !=0)
+	
+	CFRelease(usageRef);
+	CFRelease(pageRef);
+	
+	if(result == kIOReturnSuccess)
+	{
+		return iterator;
+	}
+	//TODO: Throw exception instead?
+	else
+	{
+		return 0;
+	}
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator)
+{
+	io_object_t hidDevice = 0;
+	while ((hidDevice = IOIteratorNext(iterator)) !=0)
+	{
+		//Get the current registry items property map
+		CFMutableDictionaryRef propertyMap = 0;
+		if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
 		{
-			//Get the current registry items property map
-			CFMutableDictionaryRef propertyMap = 0;
-			if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
+			//Go through device to find all needed info
+			HidInfo* hid = enumerateDeviceProperties(propertyMap);
+			
+			if(hid)
 			{
-				//Go through device to find all needed info
-				HidInfo* hid = enumerateDeviceProperties(propertyMap);
-				if(hid)
-					mDeviceList.push_back(hid);
-					
 				//todo - we need to hold an open interface so we do not have to enumerate again later
 				//should be able to watch for device removals also
-
-				/// Testing opening / closing interface
-				//IOCFPlugInInterface **pluginInterface = NULL;
-				//SInt32 score = 0;
-				//if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
-				//{
-				//	IOHIDDeviceInterface **interface;
-				//	HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
-				//	if(pluginResult == S_OK)
-				//		cout << "Successfully created plugin interface for device\n";
-				//	else
-				//		cout << "Not able to create plugin interface\n";
-
-				//	IODestroyPlugInInterface(pluginInterface);
-
-				//	if ((*interface)->open(interface, 0) == KERN_SUCCESS)
-				//		cout << "Opened interface.\n";
-				//	else
-				//		cout << "Failed to open\n";
-
-				//	(*interface)->close(interface);
-				//}
-				//
+				
+				// Testing opening / closing interface
+				IOCFPlugInInterface **pluginInterface = NULL;
+				SInt32 score = 0;
+				if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
+				{
+					IOHIDDeviceInterface **interface;
+					
+					HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
+					
+					if(pluginResult != S_OK)
+						OIS_EXCEPT(E_General, "Not able to create plugin interface");
+					
+					IODestroyPlugInInterface(pluginInterface);
+					
+					hid->interface = interface;
+					
+					//Check for duplicates - some devices have multiple usage
+					if(std::find(mDeviceList.begin(), mDeviceList.end(), hid) == mDeviceList.end())
+						mDeviceList.push_back(hid);
+				}
 			}
 		}
-
-		IOObjectRelease(iterator);
-	}
-
-	CFRelease(usageRef);
-	CFRelease(pageRef);
+	}
+	
+	IOObjectRelease(iterator);
 }
 
@@ -188,11 +216,11 @@
 	if (str)
 		info->vendor = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
-
+	
 	str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDProductKey);
 	if (str)
 		info->productKey = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
-		
+	
 	info->combinedKey = info->vendor + " " + info->productKey;
-
+	
 	//Go through all items in this device (i.e. buttons, hats, sticks, axes, etc)
 	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(propertyMap, kIOHIDElementKey);
@@ -200,5 +228,5 @@
 		for (int i = 0; i < CFArrayGetCount(array); i++)
 			parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i));
-
+	
 	return info;
 }
@@ -209,5 +237,5 @@
 	if(!properties)
 		return;
-
+	
 	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
 	if (array)
@@ -227,32 +255,32 @@
 					switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
 					{
-					case kHIDPage_GenericDesktop:
-						switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+						case kHIDPage_GenericDesktop:
+							switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
 						{
-						case kHIDUsage_GD_Pointer:
-							cout << "\tkHIDUsage_GD_Pointer\n";
-							parseDevicePropertiesGroup(element);
+							case kHIDUsage_GD_Pointer:
+								cout << "\tkHIDUsage_GD_Pointer\n";
+								parseDevicePropertiesGroup(element);
+								break;
+							case kHIDUsage_GD_X:
+							case kHIDUsage_GD_Y:
+							case kHIDUsage_GD_Z:
+							case kHIDUsage_GD_Rx:
+							case kHIDUsage_GD_Ry:
+							case kHIDUsage_GD_Rz:
+								cout << "\tAxis\n";
+								break;
+							case kHIDUsage_GD_Slider:
+							case kHIDUsage_GD_Dial:
+							case kHIDUsage_GD_Wheel:
+								cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
+								break;
+							case kHIDUsage_GD_Hatswitch:
+								cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+								break;
+						}
 							break;
-						case kHIDUsage_GD_X:
-						case kHIDUsage_GD_Y:
-						case kHIDUsage_GD_Z:
-						case kHIDUsage_GD_Rx:
-						case kHIDUsage_GD_Ry:
-						case kHIDUsage_GD_Rz:
-							cout << "\tAxis\n";
+						case kHIDPage_Button:
+							cout << "\tkHIDPage_Button\n";
 							break;
-						case kHIDUsage_GD_Slider:
-						case kHIDUsage_GD_Dial:
-						case kHIDUsage_GD_Wheel:
-							cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
-							break;
-						case kHIDUsage_GD_Hatswitch:
-							cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
-							break;
-						}
-						break;
-					case kHIDPage_Button:
-						cout << "\tkHIDPage_Button\n";
-						break;
 					}
 				}
@@ -267,5 +295,5 @@
 	if(!properties)
 		return;
-
+	
 	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
 	if(array)
@@ -278,27 +306,27 @@
 				switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
 				{
-				case kHIDPage_GenericDesktop:
-					switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+					case kHIDPage_GenericDesktop:
+						switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
 					{
-					case kHIDUsage_GD_X:
-					case kHIDUsage_GD_Y:
-					case kHIDUsage_GD_Z:
-					case kHIDUsage_GD_Rx:
-					case kHIDUsage_GD_Ry:
-					case kHIDUsage_GD_Rz:
-						cout << "\t\tAxis\n";
+						case kHIDUsage_GD_X:
+						case kHIDUsage_GD_Y:
+						case kHIDUsage_GD_Z:
+						case kHIDUsage_GD_Rx:
+						case kHIDUsage_GD_Ry:
+						case kHIDUsage_GD_Rz:
+							cout << "\t\tAxis\n";
+							break;
+						case kHIDUsage_GD_Slider:
+						case kHIDUsage_GD_Dial:
+						case kHIDUsage_GD_Wheel:
+							cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
+							break;
+						case kHIDUsage_GD_Hatswitch:
+							cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+							break;
+					}
 						break;
-					case kHIDUsage_GD_Slider:
-					case kHIDUsage_GD_Dial:
-					case kHIDUsage_GD_Wheel:
-						cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
+					case kHIDPage_Button:
 						break;
-					case kHIDUsage_GD_Hatswitch:
-						cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
-						break;
-					}
-					break;
-				case kHIDPage_Button:
-					break;
 				}
 			}
@@ -317,5 +345,5 @@
 			ret.insert(std::make_pair((*it)->type, (*it)->combinedKey));
 	}
-
+	
 	return ret;
 }
@@ -326,5 +354,5 @@
 	int ret = 0;
 	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+	
 	for(; it != end; ++it)
 	{
@@ -341,5 +369,5 @@
 	int ret = 0;
 	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+	
 	for(; it != end; ++it)
 	{
@@ -347,5 +375,5 @@
 			ret++;
 	}
-
+	
 	return ret;
 }
@@ -355,5 +383,5 @@
 {
 	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
-
+	
 	for(; it != end; ++it)
 	{
@@ -367,8 +395,8 @@
 //--------------------------------------------------------------------------------//
 Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool bufferMode, 
-									  const std::string & vendor)
+									const std::string & vendor)
 {
 	Object *obj = 0;
-
+	
 	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
 	for(; it != end; ++it)
@@ -376,11 +404,25 @@
 		if((*it)->inUse == false && (*it)->type == iType && (vendor == "" || (*it)->combinedKey == vendor))
 		{
-			//create device
+			switch(iType)
+			{
+				case OISJoyStick:
+                {
+					int totalDevs = totalDevices(iType);
+					int freeDevs = freeDevices(iType);
+					int devID = totalDevs - freeDevs;
+					
+					obj = new MacJoyStick((*it)->combinedKey, bufferMode, *it, creator, devID);
+					(*it)->inUse = true;
+					return obj;
+                }
+				case OISTablet:
+					//Create MacTablet
+					break;
+				default:
+					break;
+			}
 		}
 	}
-
-	if( obj == 0 )
-		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
-
+	
 	return obj;
 }
Index: code/trunk/src/external/ois/mac/MacHIDManager.h
===================================================================
--- code/trunk/src/external/ois/mac/MacHIDManager.h	(revision 5929)
+++ code/trunk/src/external/ois/mac/MacHIDManager.h	(revision 8351)
@@ -70,4 +70,7 @@
 
 		void initialize();
+		
+		void iterateAndOpenDevices(io_iterator_t iterator);
+		io_iterator_t lookUpDevices(int usage, int page);
 
 		//FactoryCreator Overrides
Index: code/trunk/src/external/ois/mac/MacInputManager.cpp
===================================================================
--- code/trunk/src/external/ois/mac/MacInputManager.cpp	(revision 5929)
+++ code/trunk/src/external/ois/mac/MacInputManager.cpp	(revision 8351)
@@ -188,5 +188,8 @@
 	}
 	default:
+	{
+		obj = mHIDManager->createObject(creator, iType, bufferMode, vendor);
 		break;
+	}
 	}
 
Index: code/trunk/src/external/ois/mac/MacJoyStick.cpp
===================================================================
--- code/trunk/src/external/ois/mac/MacJoyStick.cpp	(revision 8351)
+++ code/trunk/src/external/ois/mac/MacJoyStick.cpp	(revision 8351)
@@ -0,0 +1,325 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that
+ you wrote the original software. If you use this software in a product,
+ an acknowledgment in the product documentation would be appreciated but is
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+
+#include "mac/MacJoyStick.h"
+#include "mac/MacHIDManager.h"
+#include "mac/MacInputManager.h"
+#include "OISEvents.h"
+#include "OISException.h"
+
+#include <cassert>
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+MacJoyStick::MacJoyStick(const std::string &vendor, bool buffered, HidInfo* info, InputManager* creator, int devID) : 
+JoyStick(vendor, buffered, devID, creator), mInfo(info)
+{
+	
+}
+
+//--------------------------------------------------------------------------------------------------//
+MacJoyStick::~MacJoyStick()
+{
+	//TODO: check if the queue has been started first?
+	//(*mQueue)->stop(mQueue); 
+	(*mQueue)->dispose(mQueue); 
+	(*mQueue)->Release(mQueue); 
+	
+	
+	//TODO: check if the interface has been opened first?
+	(*mInfo->interface)->close(mInfo->interface);
+	(*mInfo->interface)->Release(mInfo->interface); 
+}
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::_initialize()
+{
+	assert(mInfo && "Given HidInfo invalid");
+	assert(mInfo->interface && "Joystick interface invalid");
+	
+	//TODO: Is this necessary?
+	//Clear old state
+	mState.mAxes.clear();
+	
+	if ((*mInfo->interface)->open(mInfo->interface, 0) != KERN_SUCCESS)
+		OIS_EXCEPT(E_General, "MacJoyStick::_initialize() >> Could not initialize joy device!");
+	
+	mState.clear();
+	
+	_enumerateCookies();
+	
+	mState.mButtons.resize(mInfo->numButtons);
+	mState.mAxes.resize(mInfo->numAxes);
+	
+	mQueue = _createQueue();
+}
+
+class FindAxisCookie : public std::unary_function<std::pair<IOHIDElementCookie, AxisInfo>&, bool>
+{
+public:
+	FindAxisCookie(IOHIDElementCookie cookie) : m_Cookie(cookie) {}
+	bool operator()(const std::pair<IOHIDElementCookie, AxisInfo>& pair) const
+	{
+		return pair.first == m_Cookie;
+	}
+private:
+	IOHIDElementCookie m_Cookie;
+};
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::capture()
+{
+	assert(mQueue && "Queue must be initialized before calling MacJoyStick::capture()");
+	
+	AbsoluteTime zeroTime = {0,0}; 
+	
+	IOHIDEventStruct event; 
+	IOReturn result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0); 
+	while(result == kIOReturnSuccess)
+	{
+		switch(event.type)
+		{
+			case kIOHIDElementTypeInput_Button:
+			{
+				std::vector<IOHIDElementCookie>::iterator buttonIt = std::find(mCookies.buttonCookies.begin(), mCookies.buttonCookies.end(), event.elementCookie);
+				int button = std::distance(mCookies.buttonCookies.begin(), buttonIt);
+				mState.mButtons[button] = (event.value == 1);
+				
+				if(mBuffered && mListener)
+				{
+					if(event.value == 0)
+						mListener->buttonPressed(JoyStickEvent(this, mState), button);
+					else if(event.value == 1)
+						mListener->buttonReleased(JoyStickEvent(this, mState), button);
+				}
+				break;
+			}
+			case kIOHIDElementTypeInput_Misc:
+				//TODO: It's an axis! - kind of - for gamepads - or should this be a pov?
+			case kIOHIDElementTypeInput_Axis:
+				std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = std::find_if(mCookies.axisCookies.begin(), mCookies.axisCookies.end(), FindAxisCookie(event.elementCookie));
+				int axis = std::distance(mCookies.axisCookies.begin(), axisIt);
+				
+				//Copied from LinuxJoyStickEvents.cpp, line 149
+				const AxisInfo& axisInfo = axisIt->second;
+				float proportion = (float) (event.value - axisInfo.max) / (float) (axisInfo.min - axisInfo.max);
+				mState.mAxes[axis].abs = -JoyStick::MIN_AXIS - (JoyStick::MAX_AXIS * 2 * proportion);
+				
+				if(mBuffered && mListener) mListener->axisMoved(JoyStickEvent(this, mState), axis);
+				break;
+		}
+		
+		result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0);
+	}
+}
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
+
+//--------------------------------------------------------------------------------------------------//
+Interface* MacJoyStick::queryInterface(Interface::IType type)
+{
+	//Thought about using covariant return type here.. however,
+	//some devices may allow LED light changing, or other interface stuff
+	
+	//f( ff_device && type == Interface::ForceFeedback )
+	//return ff_device;
+	//else
+	return 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void MacJoyStick::_enumerateCookies()
+{
+	assert(mInfo && "Given HidInfo invalid");
+	assert(mInfo->interface && "Joystick interface invalid");
+	
+	CFTypeRef                               object; 
+	long                                    number; 
+	IOHIDElementCookie                      cookie; 
+	long                                    usage; 
+	long                                    usagePage;
+	int										min;
+	int										max;
+
+	CFDictionaryRef                         element; 
+	
+	// Copy all elements, since we're grabbing most of the elements 
+	// for this device anyway, and thus, it's faster to iterate them 
+	// ourselves. When grabbing only one or two elements, a matching 
+	// dictionary should be passed in here instead of NULL. 
+	CFArrayRef elements; 
+	IOReturn success = reinterpret_cast<IOHIDDeviceInterface122*>(*mInfo->interface)->copyMatchingElements(mInfo->interface, NULL, &elements); 
+	
+	if (success == kIOReturnSuccess)
+	{ 
+		const CFIndex numOfElements = CFArrayGetCount(elements);
+		for (CFIndex i = 0; i < numOfElements; ++i) 
+		{ 
+			element = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(elements, i));
+			
+			//Get cookie 
+			object = (CFDictionaryGetValue(element, 
+										   CFSTR(kIOHIDElementCookieKey))); 
+			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) 
+				continue; 
+			if(!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, 
+								 &number)) 
+				continue; 
+			cookie = (IOHIDElementCookie) number; 
+			
+			//Get usage 
+			object = CFDictionaryGetValue(element, 
+										  CFSTR(kIOHIDElementUsageKey)); 
+			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) 
+				continue; 
+			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, 
+								  &number)) 
+				continue; 
+			usage = number; 
+			
+			//Get min
+			object = CFDictionaryGetValue(element,
+										  CFSTR(kIOHIDElementMinKey)); // kIOHIDElementMinKey or kIOHIDElementScaledMinKey?, no idea ...
+			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
+				continue;
+			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType,
+								  &number))
+				continue;
+			min = number;
+			
+			//Get max
+			object = CFDictionaryGetValue(element,
+										  CFSTR(kIOHIDElementMaxKey)); // kIOHIDElementMaxKey or kIOHIDElementScaledMaxKey?, no idea ...
+			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
+				continue;
+			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType,
+								  &number))
+				continue;
+			max = number;			
+			
+			//Get usage page 
+			object = CFDictionaryGetValue(element, 
+										  CFSTR(kIOHIDElementUsagePageKey)); 
+			
+			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) 
+				continue; 
+			
+			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, 
+								  &number)) 
+				continue; 
+			
+			usagePage = number;
+			switch(usagePage)
+			{
+				case kHIDPage_GenericDesktop:
+					switch(usage)
+				{
+					case kHIDUsage_GD_Pointer:
+						break;
+					case kHIDUsage_GD_X:
+					case kHIDUsage_GD_Y:
+					case kHIDUsage_GD_Z:
+					case kHIDUsage_GD_Rx:
+					case kHIDUsage_GD_Ry:
+					case kHIDUsage_GD_Rz:
+						mCookies.axisCookies.insert(std::make_pair(cookie, AxisInfo(min, max)));
+						break;
+					case kHIDUsage_GD_Slider:
+					case kHIDUsage_GD_Dial:
+					case kHIDUsage_GD_Wheel:
+						break;
+					case kHIDUsage_GD_Hatswitch:
+						break;
+				}
+					break;
+				case kHIDPage_Button:
+					mCookies.buttonCookies.push_back(cookie);
+					break;
+			}		
+		}
+		
+		mInfo->numButtons = mCookies.buttonCookies.size();
+		mInfo->numAxes = mCookies.axisCookies.size();
+
+	} 
+	else 
+	{ 
+		OIS_EXCEPT(E_General, "JoyStick elements could not be copied: copyMatchingElements failed with error: " + success); 
+	}
+	
+}
+
+//--------------------------------------------------------------------------------------------------//
+IOHIDQueueInterface** MacJoyStick::_createQueue(unsigned int depth)
+{	
+	assert(mInfo && "Given HidInfo invalid");
+	assert(mInfo->interface && "Joystick interface invalid");
+	
+	IOHIDQueueInterface** queue = (*mInfo->interface)->allocQueue(mInfo->interface); 
+	
+	if (queue) 
+	{		
+		//create the queue 
+		IOReturn result = (*queue)->create(queue, 0, depth); 
+		
+		if(result == kIOReturnSuccess)
+		{		
+			//add elements to the queue
+			std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = mCookies.axisCookies.begin();
+			for(; axisIt != mCookies.axisCookies.end(); ++axisIt)
+			{
+				result = (*queue)->addElement(queue, axisIt->first, 0);
+			}
+			
+			std::vector<IOHIDElementCookie>::iterator buttonIt = mCookies.buttonCookies.begin();
+			for(; buttonIt != mCookies.buttonCookies.end(); ++buttonIt)
+			{
+				result = (*queue)->addElement(queue, (*buttonIt), 0);
+			}
+
+			//start data delivery to queue 
+			result = (*queue)->start(queue); 
+			if(result == kIOReturnSuccess)
+			{
+				return queue;
+			}
+			else
+			{
+				OIS_EXCEPT(E_General, "Queue could not be started.");
+			}
+		}
+		else
+		{
+			OIS_EXCEPT(E_General, "Queue could not be created.");
+		}
+	}
+	else
+	{
+		OIS_EXCEPT(E_General, "Queue allocation failed.");
+	}
+}
Index: code/trunk/src/external/ois/mac/MacJoyStick.h
===================================================================
--- code/trunk/src/external/ois/mac/MacJoyStick.h	(revision 8351)
+++ code/trunk/src/external/ois/mac/MacJoyStick.h	(revision 8351)
@@ -0,0 +1,76 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that
+ you wrote the original software. If you use this software in a product,
+ an acknowledgment in the product documentation would be appreciated but is
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+#ifndef MAC_Joystick_H
+#define MAC_Joystick_H
+#include "OISJoyStick.h"
+#include "mac/MacPrereqs.h"
+#include "mac/MacHIDManager.h"
+
+namespace OIS
+{
+	struct AxisInfo
+	{
+		int min;
+		int max;
+		
+		AxisInfo(int min, int max)
+			: min(min), max(max) {}
+	};
+	
+	typedef struct cookie_struct 
+	{ 
+		std::map<IOHIDElementCookie, AxisInfo> axisCookies; 			
+		std::vector<IOHIDElementCookie> buttonCookies; 
+	} cookie_struct_t; 
+	
+	//class HidDeviceInfo
+	
+	class MacJoyStick : public JoyStick
+	{
+	public:
+		MacJoyStick(const std::string& vendor, bool buffered, HidInfo* info, InputManager* creator, int devID);
+		
+		virtual ~MacJoyStick();
+		
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+		
+		/** @copydoc Object::capture */
+		virtual void capture();
+		
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type);
+		
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+		
+		void _enumerateCookies();
+		
+		IOHIDQueueInterface** _createQueue(unsigned int depth = 8);
+	protected:
+		HidInfo* mInfo;
+		cookie_struct_t mCookies;
+		IOHIDQueueInterface** mQueue;
+	};
+}
+#endif
Index: code/trunk/src/external/ois/mac/MacKeyboard.cpp
===================================================================
--- code/trunk/src/external/ois/mac/MacKeyboard.cpp	(revision 5929)
+++ code/trunk/src/external/ois/mac/MacKeyboard.cpp	(revision 8351)
@@ -199,17 +199,9 @@
 	char macChar;
 	
-	// TODO clean this up
 	if (mTextMode == Unicode)
 	{
 		//get string size
 		UInt32 stringsize;
-		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, 0, &stringsize, NULL);
-		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text );
 		status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text );
-		std::cout << "String length: " << stringsize << std::endl;
-		
-		//wstring unitext;
-		//for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
-		//wcout << "Unicode out: " << unitext << endl;
 		
 		if(stringsize > 0)
