--- src/mac/MacKeyboard.cpp	(revision 34)
+++ src/mac/MacKeyboard.cpp	(working copy)
@@ -1,26 +1,28 @@
 /*
  The zlib/libpng License
  
- Copyright (c) 2006 Chris Snyder 
+ 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 
+ 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 
+ 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 
+ 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 __LP64__
+
 #include "mac/MacKeyboard.h"
 #include "mac/MacInputManager.h"
 #include "mac/MacHelpers.h"
@@ -141,11 +143,7 @@
 	// if not buffered just return, we update the unbuffered automatically
 	if ( !mBuffered || !mListener )
 		return;
-	
-	//If the mListener returns false, that means that we are probably deleted...
-	//send no more events and just leave as the this pointer is invalid now...
-	bool ret = true;
-	
+
 	// run through our event stack
 	eventStack::iterator cur_it;
 	
@@ -165,8 +163,24 @@
 //-------------------------------------------------------------------//
 std::string& MacKeyboard::getAsString( KeyCode key )
 {
-	getString = "";
-	
+    CGKeyCode deviceKeycode;
+    
+    // Convert OIS KeyCode back into device keycode
+    for(VirtualtoOIS_KeyMap::iterator it = keyConversion.begin(); it != keyConversion.end(); ++it)
+    {
+        if(it->second == key)
+            deviceKeycode = it->first;
+    }
+    
+    UniChar unicodeString[1];
+    UniCharCount actualStringLength = 0;
+    
+    CGEventSourceRef sref = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
+    CGEventRef ref = CGEventCreateKeyboardEvent(sref, deviceKeycode, true);
+    CGEventKeyboardGetUnicodeString(ref, sizeof(unicodeString) / sizeof(*unicodeString), &actualStringLength, unicodeString);
+//    NSLog([NSString stringWithFormat:@"%C\n", unicodeString[0]]);
+    getString = unicodeString[0];
+
 	return getString;
 }
 
@@ -206,7 +220,7 @@
 		//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;
+//		std::cout << "String length: " << stringsize << std::endl;
 		
 		//wstring unitext;
 		//for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
@@ -462,6 +476,4 @@
 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key?
 }
 
-
-
-
+#endif
