Home | History | Annotate | Download | only in ois-v1-4svn
      1 Index: Mac/XCode-2.2/OIS.xcodeproj/project.pbxproj
      2 ===================================================================
      3 --- Mac/XCode-2.2/OIS.xcodeproj/project.pbxproj	(revision 34)
      4 +++ Mac/XCode-2.2/OIS.xcodeproj/project.pbxproj	(working copy)
      5 @@ -3,7 +3,7 @@
      6  	archiveVersion = 1;
      7  	classes = {
      8  	};
      9 -	objectVersion = 42;
     10 +	objectVersion = 44;
     11  	objects = {
     12  
     13  /* Begin PBXAggregateTarget section */
     14 @@ -40,12 +40,12 @@
     15  		0043D8890C35664A007ACDF6 /* OISPrereqs.h in Headers */ = {isa = PBXBuildFile; fileRef = 0043D87C0C35664A007ACDF6 /* OISPrereqs.h */; settings = {ATTRIBUTES = (Public, ); }; };
     16  		0043D8960C3566C1007ACDF6 /* OISEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8900C3566C1007ACDF6 /* OISEffect.cpp */; };
     17  		0043D8970C3566C1007ACDF6 /* OISForceFeedback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8910C3566C1007ACDF6 /* OISForceFeedback.cpp */; };
     18 -		0043D8980C3566C1007ACDF6 /* OISInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8920C3566C1007ACDF6 /* OISInputManager.cpp */; };
     19 +		0043D8980C3566C1007ACDF6 /* OISInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8920C3566C1007ACDF6 /* OISInputManager.cpp */; settings = {COMPILER_FLAGS = "-x objective-c++"; }; };
     20  		0043D8990C3566C1007ACDF6 /* OISJoyStick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8930C3566C1007ACDF6 /* OISJoyStick.cpp */; };
     21  		0043D89A0C3566C1007ACDF6 /* OISKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8940C3566C1007ACDF6 /* OISKeyboard.cpp */; };
     22  		0043D89B0C3566C1007ACDF6 /* OISObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8950C3566C1007ACDF6 /* OISObject.cpp */; };
     23  		0043D8A00C3566C9007ACDF6 /* MacHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D89C0C3566C9007ACDF6 /* MacHelpers.cpp */; };
     24 -		0043D8A10C3566C9007ACDF6 /* MacInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D89D0C3566C9007ACDF6 /* MacInputManager.cpp */; };
     25 +		0043D8A10C3566C9007ACDF6 /* MacInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D89D0C3566C9007ACDF6 /* MacInputManager.cpp */; settings = {COMPILER_FLAGS = "-x objective-c++"; }; };
     26  		0043D8A20C3566C9007ACDF6 /* MacKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D89E0C3566C9007ACDF6 /* MacKeyboard.cpp */; };
     27  		0043D8A30C3566C9007ACDF6 /* MacMouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D89F0C3566C9007ACDF6 /* MacMouse.cpp */; };
     28  		0043D8C70C35680D007ACDF6 /* OIS.h in Headers */ = {isa = PBXBuildFile; fileRef = 0043D8700C35664A007ACDF6 /* OIS.h */; };
     29 @@ -80,7 +80,7 @@
     30  		0043D8E40C356819007ACDF6 /* MacMouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D89F0C3566C9007ACDF6 /* MacMouse.cpp */; };
     31  		0043D8E50C356819007ACDF6 /* OISEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8900C3566C1007ACDF6 /* OISEffect.cpp */; };
     32  		0043D8E60C356819007ACDF6 /* OISForceFeedback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8910C3566C1007ACDF6 /* OISForceFeedback.cpp */; };
     33 -		0043D8E70C356819007ACDF6 /* OISInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8920C3566C1007ACDF6 /* OISInputManager.cpp */; };
     34 +		0043D8E70C356819007ACDF6 /* OISInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8920C3566C1007ACDF6 /* OISInputManager.cpp */; settings = {COMPILER_FLAGS = "-x objective-c++"; }; };
     35  		0043D8E80C356819007ACDF6 /* OISJoyStick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8930C3566C1007ACDF6 /* OISJoyStick.cpp */; };
     36  		0043D8E90C356819007ACDF6 /* OISKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8940C3566C1007ACDF6 /* OISKeyboard.cpp */; };
     37  		0043D8EA0C356819007ACDF6 /* OISObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8950C3566C1007ACDF6 /* OISObject.cpp */; };
     38 @@ -90,11 +90,10 @@
     39  		0043D8EE0C35681A007ACDF6 /* MacMouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D89F0C3566C9007ACDF6 /* MacMouse.cpp */; };
     40  		0043D8EF0C35681A007ACDF6 /* OISEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8900C3566C1007ACDF6 /* OISEffect.cpp */; };
     41  		0043D8F00C35681A007ACDF6 /* OISForceFeedback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8910C3566C1007ACDF6 /* OISForceFeedback.cpp */; };
     42 -		0043D8F10C35681A007ACDF6 /* OISInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8920C3566C1007ACDF6 /* OISInputManager.cpp */; };
     43 +		0043D8F10C35681A007ACDF6 /* OISInputManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8920C3566C1007ACDF6 /* OISInputManager.cpp */; settings = {COMPILER_FLAGS = "-x objective-c++"; }; };
     44  		0043D8F20C35681A007ACDF6 /* OISJoyStick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8930C3566C1007ACDF6 /* OISJoyStick.cpp */; };
     45  		0043D8F30C35681A007ACDF6 /* OISKeyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8940C3566C1007ACDF6 /* OISKeyboard.cpp */; };
     46  		0043D8F40C35681A007ACDF6 /* OISObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0043D8950C3566C1007ACDF6 /* OISObject.cpp */; };
     47 -		0043D8F50C356828007ACDF6 /* OIS-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0043D85F0C356509007ACDF6 /* OIS-Info.plist */; };
     48  		0043D8F70C356840007ACDF6 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0043D8F60C356840007ACDF6 /* Carbon.framework */; };
     49  		0043D8F80C356840007ACDF6 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0043D8F60C356840007ACDF6 /* Carbon.framework */; };
     50  		0043D8F90C356840007ACDF6 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0043D8F60C356840007ACDF6 /* Carbon.framework */; };
     51 @@ -124,6 +123,21 @@
     52  		4AEB08FC0D73DA81007CD406 /* OISConsole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0082F2880C827BF500E926BE /* OISConsole.cpp */; };
     53  		4AEB090C0D73DABC007CD406 /* OIS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0043D85D0C356509007ACDF6 /* OIS.framework */; };
     54  		4AEB09240D73DBC8007CD406 /* OIS.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0043D85D0C356509007ACDF6 /* OIS.framework */; };
     55 +		9C0B132B125E954800E10CB7 /* CocoaInputManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1325125E954800E10CB7 /* CocoaInputManager.mm */; };
     56 +		9C0B132C125E954800E10CB7 /* CocoaJoyStick.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1326125E954800E10CB7 /* CocoaJoyStick.mm */; };
     57 +		9C0B132D125E954800E10CB7 /* CocoaKeyboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1327125E954800E10CB7 /* CocoaKeyboard.mm */; };
     58 +		9C0B132E125E954800E10CB7 /* CocoaMouse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1328125E954800E10CB7 /* CocoaMouse.mm */; };
     59 +		9C0B1331125E955000E10CB7 /* CocoaInputManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1325125E954800E10CB7 /* CocoaInputManager.mm */; };
     60 +		9C0B1332125E955000E10CB7 /* CocoaJoyStick.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1326125E954800E10CB7 /* CocoaJoyStick.mm */; };
     61 +		9C0B1333125E955000E10CB7 /* CocoaKeyboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1327125E954800E10CB7 /* CocoaKeyboard.mm */; };
     62 +		9C0B1334125E955000E10CB7 /* CocoaMouse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1328125E954800E10CB7 /* CocoaMouse.mm */; };
     63 +		9C0B1337125E955000E10CB7 /* CocoaInputManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1325125E954800E10CB7 /* CocoaInputManager.mm */; };
     64 +		9C0B1338125E955000E10CB7 /* CocoaJoyStick.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1326125E954800E10CB7 /* CocoaJoyStick.mm */; };
     65 +		9C0B1339125E955000E10CB7 /* CocoaKeyboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1327125E954800E10CB7 /* CocoaKeyboard.mm */; };
     66 +		9C0B133A125E955000E10CB7 /* CocoaMouse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C0B1328125E954800E10CB7 /* CocoaMouse.mm */; };
     67 +		9C7C9A0D126136E20026234E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C0B12C4125E3B3400E10CB7 /* Cocoa.framework */; };
     68 +		9C7C9A0E126136E30026234E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C0B12C4125E3B3400E10CB7 /* Cocoa.framework */; };
     69 +		9C7C9A0F126136E30026234E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C0B12C4125E3B3400E10CB7 /* Cocoa.framework */; };
     70  /* End PBXBuildFile section */
     71  
     72  /* Begin PBXContainerItemProxy section */
     73 @@ -222,6 +236,16 @@
     74  		4ADFD2A80CDE7BAC006031E4 /* MacHIDManager.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = MacHIDManager.cpp; path = ../../src/mac/MacHIDManager.cpp; sourceTree = SOURCE_ROOT; };
     75  		4AEB08F60D73DA6D007CD406 /* ConsoleTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ConsoleTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
     76  		4AEB08F80D73DA6D007CD406 /* ConsoleTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ConsoleTest-Info.plist"; sourceTree = "<group>"; };
     77 +		9C0B12C4125E3B3400E10CB7 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
     78 +		9C0B1325125E954800E10CB7 /* CocoaInputManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CocoaInputManager.mm; path = ../../src/mac/CocoaInputManager.mm; sourceTree = SOURCE_ROOT; };
     79 +		9C0B1326125E954800E10CB7 /* CocoaJoyStick.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CocoaJoyStick.mm; path = ../../src/mac/CocoaJoyStick.mm; sourceTree = SOURCE_ROOT; };
     80 +		9C0B1327125E954800E10CB7 /* CocoaKeyboard.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CocoaKeyboard.mm; path = ../../src/mac/CocoaKeyboard.mm; sourceTree = SOURCE_ROOT; };
     81 +		9C0B1328125E954800E10CB7 /* CocoaMouse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CocoaMouse.mm; path = ../../src/mac/CocoaMouse.mm; sourceTree = SOURCE_ROOT; };
     82 +		9C0B133B125E959000E10CB7 /* CocoaHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocoaHelpers.h; path = ../../includes/mac/CocoaHelpers.h; sourceTree = SOURCE_ROOT; };
     83 +		9C0B133D125E959000E10CB7 /* CocoaInputManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocoaInputManager.h; path = ../../includes/mac/CocoaInputManager.h; sourceTree = SOURCE_ROOT; };
     84 +		9C0B133E125E959000E10CB7 /* CocoaJoyStick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocoaJoyStick.h; path = ../../includes/mac/CocoaJoyStick.h; sourceTree = SOURCE_ROOT; };
     85 +		9C0B133F125E959000E10CB7 /* CocoaKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocoaKeyboard.h; path = ../../includes/mac/CocoaKeyboard.h; sourceTree = SOURCE_ROOT; };
     86 +		9C0B1340125E959000E10CB7 /* CocoaMouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocoaMouse.h; path = ../../includes/mac/CocoaMouse.h; sourceTree = SOURCE_ROOT; };
     87  /* End PBXFileReference section */
     88  
     89  /* Begin PBXFrameworksBuildPhase section */
     90 @@ -231,6 +255,7 @@
     91  			files = (
     92  				0043D8F70C356840007ACDF6 /* Carbon.framework in Frameworks */,
     93  				4ADFD0130CDD94B2006031E4 /* IOKit.framework in Frameworks */,
     94 +				9C7C9A0E126136E30026234E /* Cocoa.framework in Frameworks */,
     95  			);
     96  			runOnlyForDeploymentPostprocessing = 0;
     97  		};
     98 @@ -240,6 +265,7 @@
     99  			files = (
    100  				0043D8F80C356840007ACDF6 /* Carbon.framework in Frameworks */,
    101  				4ADFD0100CDD948B006031E4 /* IOKit.framework in Frameworks */,
    102 +				9C7C9A0D126136E20026234E /* Cocoa.framework in Frameworks */,
    103  			);
    104  			runOnlyForDeploymentPostprocessing = 0;
    105  		};
    106 @@ -249,6 +275,7 @@
    107  			files = (
    108  				0043D8F90C356840007ACDF6 /* Carbon.framework in Frameworks */,
    109  				4ADFD0110CDD948C006031E4 /* IOKit.framework in Frameworks */,
    110 +				9C7C9A0F126136E30026234E /* Cocoa.framework in Frameworks */,
    111  			);
    112  			runOnlyForDeploymentPostprocessing = 0;
    113  		};
    114 @@ -327,6 +354,7 @@
    115  			children = (
    116  				4AC4C3930CDD840500603F93 /* IOKit.framework */,
    117  				0043D8F60C356840007ACDF6 /* Carbon.framework */,
    118 +				9C0B12C4125E3B3400E10CB7 /* Cocoa.framework */,
    119  			);
    120  			name = "External Frameworks and Libraries";
    121  			sourceTree = "<group>";
    122 @@ -334,6 +362,11 @@
    123  		0043D86B0C3565E0007ACDF6 /* OSX */ = {
    124  			isa = PBXGroup;
    125  			children = (
    126 +				9C0B133B125E959000E10CB7 /* CocoaHelpers.h */,
    127 +				9C0B133D125E959000E10CB7 /* CocoaInputManager.h */,
    128 +				9C0B133E125E959000E10CB7 /* CocoaJoyStick.h */,
    129 +				9C0B133F125E959000E10CB7 /* CocoaKeyboard.h */,
    130 +				9C0B1340125E959000E10CB7 /* CocoaMouse.h */,
    131  				0043D88A0C35665B007ACDF6 /* MacPrereqs.h */,
    132  				0043D88B0C35665B007ACDF6 /* MacInputManager.h */,
    133  				0043D88C0C35665B007ACDF6 /* MacHelpers.h */,
    134 @@ -369,6 +402,10 @@
    135  		0043D86D0C3565F7007ACDF6 /* OSX */ = {
    136  			isa = PBXGroup;
    137  			children = (
    138 +				9C0B1325125E954800E10CB7 /* CocoaInputManager.mm */,
    139 +				9C0B1326125E954800E10CB7 /* CocoaJoyStick.mm */,
    140 +				9C0B1327125E954800E10CB7 /* CocoaKeyboard.mm */,
    141 +				9C0B1328125E954800E10CB7 /* CocoaMouse.mm */,
    142  				249631C31066333900EFD0E1 /* MacJoyStick.cpp */,
    143  				0043D89C0C3566C9007ACDF6 /* MacHelpers.cpp */,
    144  				4ADFD2A80CDE7BAC006031E4 /* MacHIDManager.cpp */,
    145 @@ -481,7 +518,6 @@
    146  			buildConfigurationList = 0043D8610C356509007ACDF6 /* Build configuration list for PBXNativeTarget "OIS" */;
    147  			buildPhases = (
    148  				0043D8580C356509007ACDF6 /* Headers */,
    149 -				0043D8590C356509007ACDF6 /* Resources */,
    150  				0043D85A0C356509007ACDF6 /* Sources */,
    151  				0043D85B0C356509007ACDF6 /* Frameworks */,
    152  			);
    153 @@ -568,8 +604,15 @@
    154  		0043D84E0C3564F8007ACDF6 /* Project object */ = {
    155  			isa = PBXProject;
    156  			buildConfigurationList = 0043D84F0C3564F8007ACDF6 /* Build configuration list for PBXProject "OIS" */;
    157 -			compatibilityVersion = "Xcode 2.4";
    158 +			compatibilityVersion = "Xcode 3.0";
    159 +			developmentRegion = English;
    160  			hasScannedForEncodings = 0;
    161 +			knownRegions = (
    162 +				English,
    163 +				Japanese,
    164 +				French,
    165 +				German,
    166 +			);
    167  			mainGroup = 0043D84C0C3564F8007ACDF6;
    168  			productRefGroup = 0043D85E0C356509007ACDF6 /* Products */;
    169  			projectDirPath = "";
    170 @@ -586,14 +629,6 @@
    171  /* End PBXProject section */
    172  
    173  /* Begin PBXResourcesBuildPhase section */
    174 -		0043D8590C356509007ACDF6 /* Resources */ = {
    175 -			isa = PBXResourcesBuildPhase;
    176 -			buildActionMask = 2147483647;
    177 -			files = (
    178 -				0043D8F50C356828007ACDF6 /* OIS-Info.plist in Resources */,
    179 -			);
    180 -			runOnlyForDeploymentPostprocessing = 0;
    181 -		};
    182  		4AEB08F20D73DA6D007CD406 /* Resources */ = {
    183  			isa = PBXResourcesBuildPhase;
    184  			buildActionMask = 2147483647;
    185 @@ -621,6 +656,10 @@
    186  				4ADFD2A90CDE7BAC006031E4 /* MacHIDManager.cpp in Sources */,
    187  				249631C71066334D00EFD0E1 /* MacJoyStick.cpp in Sources */,
    188  				4ACD7A530CEF903600D72CD9 /* OISException.cpp in Sources */,
    189 +				9C0B132B125E954800E10CB7 /* CocoaInputManager.mm in Sources */,
    190 +				9C0B132C125E954800E10CB7 /* CocoaJoyStick.mm in Sources */,
    191 +				9C0B132D125E954800E10CB7 /* CocoaKeyboard.mm in Sources */,
    192 +				9C0B132E125E954800E10CB7 /* CocoaMouse.mm in Sources */,
    193  			);
    194  			runOnlyForDeploymentPostprocessing = 0;
    195  		};
    196 @@ -641,6 +680,10 @@
    197  				4ADFD2AA0CDE7BAC006031E4 /* MacHIDManager.cpp in Sources */,
    198  				249631C81066335600EFD0E1 /* MacJoyStick.cpp in Sources */,
    199  				4ACD7A540CEF903600D72CD9 /* OISException.cpp in Sources */,
    200 +				9C0B1331125E955000E10CB7 /* CocoaInputManager.mm in Sources */,
    201 +				9C0B1332125E955000E10CB7 /* CocoaJoyStick.mm in Sources */,
    202 +				9C0B1333125E955000E10CB7 /* CocoaKeyboard.mm in Sources */,
    203 +				9C0B1334125E955000E10CB7 /* CocoaMouse.mm in Sources */,
    204  			);
    205  			runOnlyForDeploymentPostprocessing = 0;
    206  		};
    207 @@ -661,6 +704,10 @@
    208  				4ADFD2AB0CDE7BAC006031E4 /* MacHIDManager.cpp in Sources */,
    209  				249631C91066335D00EFD0E1 /* MacJoyStick.cpp in Sources */,
    210  				4ACD7A550CEF903600D72CD9 /* OISException.cpp in Sources */,
    211 +				9C0B1337125E955000E10CB7 /* CocoaInputManager.mm in Sources */,
    212 +				9C0B1338125E955000E10CB7 /* CocoaJoyStick.mm in Sources */,
    213 +				9C0B1339125E955000E10CB7 /* CocoaKeyboard.mm in Sources */,
    214 +				9C0B133A125E955000E10CB7 /* CocoaMouse.mm in Sources */,
    215  			);
    216  			runOnlyForDeploymentPostprocessing = 0;
    217  		};
    218 @@ -714,13 +761,13 @@
    219  		0043D8500C3564F8007ACDF6 /* Debug */ = {
    220  			isa = XCBuildConfiguration;
    221  			buildSettings = {
    222 -				ARCHS = (
    223 -					ppc,
    224 -					i386,
    225 -				);
    226 +				ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
    227 +				ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
    228  				COPY_PHASE_STRIP = YES;
    229  				GCC_SYMBOLS_PRIVATE_EXTERN = YES;
    230 -				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
    231 +				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
    232 +				GCC_WARN_UNUSED_VARIABLE = YES;
    233 +				SDKROOT = macosx;
    234  				USER_HEADER_SEARCH_PATHS = ../../includes;
    235  			};
    236  			name = Debug;
    237 @@ -728,13 +775,12 @@
    238  		0043D8510C3564F8007ACDF6 /* Release */ = {
    239  			isa = XCBuildConfiguration;
    240  			buildSettings = {
    241 -				ARCHS = (
    242 -					ppc,
    243 -					i386,
    244 -				);
    245 +				ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
    246 +				ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
    247  				COPY_PHASE_STRIP = YES;
    248  				GCC_SYMBOLS_PRIVATE_EXTERN = YES;
    249 -				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
    250 +				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
    251 +				SDKROOT = macosx;
    252  				USER_HEADER_SEARCH_PATHS = ../../includes;
    253  			};
    254  			name = Release;
    255 @@ -744,16 +790,13 @@
    256  			buildSettings = {
    257  				COPY_PHASE_STRIP = YES;
    258  				DYLIB_COMPATIBILITY_VERSION = 1.0;
    259 -				DYLIB_CURRENT_VERSION = 1.0;
    260 +				DYLIB_CURRENT_VERSION = 1.3;
    261  				FRAMEWORK_VERSION = A;
    262  				GCC_DYNAMIC_NO_PIC = NO;
    263  				GCC_ENABLE_FIX_AND_CONTINUE = YES;
    264  				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
    265  				GCC_MODEL_TUNING = G5;
    266  				GCC_OPTIMIZATION_LEVEL = 0;
    267 -				GCC_PRECOMPILE_PREFIX_HEADER = YES;
    268 -				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
    269 -				GCC_VERSION = 4.0;
    270  				INFOPLIST_FILE = "OIS-Info.plist";
    271  				INSTALL_PATH = "@executable_path/../Frameworks";
    272  				OTHER_LDFLAGS = (
    273 @@ -762,6 +805,7 @@
    274  				);
    275  				PREBINDING = NO;
    276  				PRODUCT_NAME = OIS;
    277 +				VALID_ARCHS = "i386 x86_64";
    278  				ZERO_LINK = YES;
    279  			};
    280  			name = Debug;
    281 @@ -771,14 +815,11 @@
    282  			buildSettings = {
    283  				COPY_PHASE_STRIP = YES;
    284  				DYLIB_COMPATIBILITY_VERSION = 1.0;
    285 -				DYLIB_CURRENT_VERSION = 1.0;
    286 +				DYLIB_CURRENT_VERSION = 1.3;
    287  				FRAMEWORK_VERSION = A;
    288  				GCC_ENABLE_FIX_AND_CONTINUE = NO;
    289  				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
    290  				GCC_MODEL_TUNING = G5;
    291 -				GCC_PRECOMPILE_PREFIX_HEADER = YES;
    292 -				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
    293 -				GCC_VERSION = 4.0;
    294  				INFOPLIST_FILE = "OIS-Info.plist";
    295  				INSTALL_PATH = "@executable_path/../Frameworks";
    296  				OTHER_LDFLAGS = (
    297 @@ -802,9 +843,6 @@
    298  				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
    299  				GCC_MODEL_TUNING = G5;
    300  				GCC_OPTIMIZATION_LEVEL = 0;
    301 -				GCC_PRECOMPILE_PREFIX_HEADER = YES;
    302 -				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
    303 -				GCC_VERSION = 4.0;
    304  				INSTALL_PATH = "@executable_path/../Frameworks";
    305  				OTHER_LDFLAGS = (
    306  					"-framework",
    307 @@ -825,9 +863,6 @@
    308  				GCC_ENABLE_FIX_AND_CONTINUE = NO;
    309  				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
    310  				GCC_MODEL_TUNING = G5;
    311 -				GCC_PRECOMPILE_PREFIX_HEADER = YES;
    312 -				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
    313 -				GCC_VERSION = 4.0;
    314  				INSTALL_PATH = "@executable_path/../Frameworks";
    315  				OTHER_LDFLAGS = (
    316  					"-framework",
    317 @@ -848,9 +883,6 @@
    318  				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
    319  				GCC_MODEL_TUNING = G5;
    320  				GCC_OPTIMIZATION_LEVEL = 0;
    321 -				GCC_PRECOMPILE_PREFIX_HEADER = YES;
    322 -				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
    323 -				GCC_VERSION = 4.0;
    324  				INSTALL_PATH = /usr/local/lib;
    325  				OTHER_LDFLAGS = (
    326  					"-framework",
    327 @@ -869,9 +901,6 @@
    328  				GCC_ENABLE_FIX_AND_CONTINUE = NO;
    329  				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
    330  				GCC_MODEL_TUNING = G5;
    331 -				GCC_PRECOMPILE_PREFIX_HEADER = YES;
    332 -				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h";
    333 -				GCC_VERSION = 4.0;
    334  				INSTALL_PATH = /usr/local/lib;
    335  				OTHER_LDFLAGS = (
    336  					"-framework",
    337 Index: includes/mac/MacMouse.h
    338 ===================================================================
    339 --- includes/mac/MacMouse.h	(revision 34)
    340 +++ includes/mac/MacMouse.h	(working copy)
    341 @@ -1,3 +1,26 @@
    342 +/*
    343 + The zlib/libpng License
    344 + 
    345 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    346 + 
    347 + This software is provided 'as-is', without any express or implied warranty. In no event will
    348 + the authors be held liable for any damages arising from the use of this software.
    349 + 
    350 + Permission is granted to anyone to use this software for any purpose, including commercial
    351 + applications, and to alter it and redistribute it freely, subject to the following
    352 + restrictions:
    353 + 
    354 + 1. The origin of this software must not be misrepresented; you must not claim that
    355 + you wrote the original software. If you use this software in a product,
    356 + an acknowledgment in the product documentation would be appreciated but is
    357 + not required.
    358 + 
    359 + 2. Altered source versions must be plainly marked as such, and must not be
    360 + misrepresented as being the original software.
    361 + 
    362 + 3. This notice may not be removed or altered from any source distribution.
    363 + */
    364 +
    365  #ifndef OIS_MacMouse_H
    366  #define OIS_MacMouse_H
    367  
    368 Index: includes/mac/CocoaMouse.h
    369 ===================================================================
    370 --- includes/mac/CocoaMouse.h	(revision 0)
    371 +++ includes/mac/CocoaMouse.h	(revision 0)
    372 @@ -0,0 +1,75 @@
    373 +/*
    374 + The zlib/libpng License
    375 + 
    376 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    377 + 
    378 + This software is provided 'as-is', without any express or implied warranty. In no event will
    379 + the authors be held liable for any damages arising from the use of this software.
    380 + 
    381 + Permission is granted to anyone to use this software for any purpose, including commercial
    382 + applications, and to alter it and redistribute it freely, subject to the following
    383 + restrictions:
    384 + 
    385 + 1. The origin of this software must not be misrepresented; you must not claim that
    386 + you wrote the original software. If you use this software in a product,
    387 + an acknowledgment in the product documentation would be appreciated but is
    388 + not required.
    389 + 
    390 + 2. Altered source versions must be plainly marked as such, and must not be
    391 + misrepresented as being the original software.
    392 + 
    393 + 3. This notice may not be removed or altered from any source distribution.
    394 + */
    395 +#ifndef OIS_CocoaMouse_H
    396 +#define OIS_CocoaMouse_H
    397 +
    398 +#include "OISMouse.h"
    399 +#include "mac/CocoaHelpers.h"
    400 +
    401 +#include <Cocoa/Cocoa.h>
    402 +
    403 +@class CocoaMouseView;
    404 +
    405 +using namespace OIS;
    406 +
    407 +namespace OIS
    408 +{
    409 +	class CocoaMouse : public Mouse
    410 +    {
    411 +	public:
    412 +		CocoaMouse( InputManager* creator, bool buffered );
    413 +		virtual ~CocoaMouse();
    414 +		
    415 +		/** @copydoc Object::setBuffered */
    416 +		virtual void setBuffered(bool buffered);
    417 +
    418 +		/** @copydoc Object::capture */
    419 +		virtual void capture();
    420 +
    421 +		/** @copydoc Object::queryInterface */
    422 +		virtual Interface* queryInterface(Interface::IType type) {return 0;}
    423 +
    424 +		/** @copydoc Object::_initialize */
    425 +		virtual void _initialize();
    426 +        
    427 +        MouseState * getMouseStatePtr() { return &(mState); }
    428 +
    429 +	protected:
    430 +        CocoaMouseView *mResponder;
    431 +	};
    432 +}
    433 +
    434 +@interface CocoaMouseView : NSView
    435 +{
    436 +    CocoaMouse *oisMouseObj;
    437 +    MouseState mTempState;
    438 +    bool mNeedsToRegainFocus;
    439 +    bool mMouseWarped;
    440 +}
    441 +
    442 +- (void)setOISMouseObj:(CocoaMouse *)obj;
    443 +- (void)capture;
    444 +
    445 +@end
    446 +
    447 +#endif // OIS_CocoaMouse_H
    448 Index: includes/mac/CocoaInputManager.h
    449 ===================================================================
    450 --- includes/mac/CocoaInputManager.h	(revision 0)
    451 +++ includes/mac/CocoaInputManager.h	(revision 0)
    452 @@ -0,0 +1,98 @@
    453 +/*
    454 + The zlib/libpng License
    455 + 
    456 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    457 + 
    458 + This software is provided 'as-is', without any express or implied warranty. In no event will
    459 + the authors be held liable for any damages arising from the use of this software.
    460 + 
    461 + Permission is granted to anyone to use this software for any purpose, including commercial
    462 + applications, and to alter it and redistribute it freely, subject to the following
    463 + restrictions:
    464 + 
    465 + 1. The origin of this software must not be misrepresented; you must not claim that
    466 + you wrote the original software. If you use this software in a product,
    467 + an acknowledgment in the product documentation would be appreciated but is
    468 + not required.
    469 + 
    470 + 2. Altered source versions must be plainly marked as such, and must not be
    471 + misrepresented as being the original software.
    472 + 
    473 + 3. This notice may not be removed or altered from any source distribution.
    474 + */
    475 +
    476 +#ifndef OIS_CocoaInputManager_H
    477 +#define OIS_CocoaInputManager_H
    478 +
    479 +#include "OISInputManager.h"
    480 +#include "OISFactoryCreator.h"
    481 +#include <Cocoa/Cocoa.h>
    482 +
    483 +namespace OIS
    484 +{
    485 +    class MacHIDManager;
    486 +    
    487 +    class CocoaInputManager : public InputManager, public FactoryCreator
    488 +    {
    489 +    public:
    490 +        CocoaInputManager();
    491 +        virtual ~CocoaInputManager();
    492 +        
    493 +		//InputManager Overrides
    494 +		/** @copydoc InputManager::_initialize */
    495 +		void _initialize( ParamList &paramList );
    496 +
    497 +		//FactoryCreator Overrides
    498 +		/** @copydoc FactoryCreator::deviceList */
    499 +		DeviceList freeDeviceList();
    500 +
    501 +		/** @copydoc FactoryCreator::totalDevices */
    502 +		int totalDevices(Type iType);
    503 +
    504 +		/** @copydoc FactoryCreator::freeDevices */
    505 +		int freeDevices(Type iType);
    506 +
    507 +		/** @copydoc FactoryCreator::vendorExist */
    508 +		bool vendorExist(Type iType, const std::string & vendor);
    509 +
    510 +		/** @copydoc FactoryCreator::createObject */
    511 +		Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
    512 +
    513 +		/** @copydoc FactoryCreator::destroyObject */
    514 +		void destroyObject(Object* obj);
    515 +
    516 +		//Internal Items
    517 +		//! Internal method, used for flaggin keyboard as available/unavailable for creation
    518 +		void _setKeyboardUsed(bool used) {keyboardUsed = used; }
    519 +
    520 +		//! Internal method, used for flaggin mouse as available/unavailable for creation
    521 +		void _setMouseUsed(bool used) { mouseUsed = used; }
    522 +
    523 +        //! method for getting window
    524 +        NSWindow * _getWindow() {return mWindow;}
    525 +        
    526 +    protected:        
    527 +        void _parseConfigSettings( ParamList& paramList );
    528 +        
    529 +        void _enumerateDevices();
    530 +        
    531 +        static const std::string iName;
    532 +        
    533 +        // Mac stuff
    534 +		NSWindow *mWindow;
    535 +        
    536 +        // settings
    537 +        bool mHideMouse;
    538 +        bool mUseRepeat;
    539 +
    540 +		//! Used to know if we used up keyboard
    541 +		bool keyboardUsed;
    542 +
    543 +		//! Used to know if we used up mouse
    544 +		bool mouseUsed;
    545 +		
    546 +		//! HID Manager class handling devices other than keyboard/mouse
    547 +		MacHIDManager *mHIDManager;
    548 +    };
    549 +}
    550 +#endif
    551 Index: includes/mac/MacHIDManager.h
    552 ===================================================================
    553 --- includes/mac/MacHIDManager.h	(revision 34)
    554 +++ includes/mac/MacHIDManager.h	(working copy)
    555 @@ -1,25 +1,25 @@
    556  /*
    557   The zlib/libpng License
    558   
    559 - Copyright (c) 2007 Phillip
    560 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    561   
    562   This software is provided 'as-is', without any express or implied warranty. In no event will
    563   the authors be held liable for any damages arising from the use of this software.
    564   
    565 - Permission is granted to anyone to use this software for any purpose, including commercial 
    566 + Permission is granted to anyone to use this software for any purpose, including commercial
    567   applications, and to alter it and redistribute it freely, subject to the following
    568   restrictions:
    569   
    570 - 1. The origin of this software must not be misrepresented; you must not claim that 
    571 - you wrote the original software. If you use this software in a product, 
    572 - an acknowledgment in the product documentation would be appreciated but is 
    573 + 1. The origin of this software must not be misrepresented; you must not claim that
    574 + you wrote the original software. If you use this software in a product,
    575 + an acknowledgment in the product documentation would be appreciated but is
    576   not required.
    577   
    578 - 2. Altered source versions must be plainly marked as such, and must not be 
    579 + 2. Altered source versions must be plainly marked as such, and must not be
    580   misrepresented as being the original software.
    581   
    582   3. This notice may not be removed or altered from any source distribution.
    583 -*/
    584 + */
    585  #ifndef OIS_MacHIDManager_Header
    586  #define OIS_MacHIDManager_Header
    587  
    588 Index: includes/mac/MacKeyboard.h
    589 ===================================================================
    590 --- includes/mac/MacKeyboard.h	(revision 34)
    591 +++ includes/mac/MacKeyboard.h	(working copy)
    592 @@ -1,25 +1,25 @@
    593  /*
    594   The zlib/libpng License
    595   
    596 - Copyright (c) 2006 Chris Snyder 
    597 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    598   
    599   This software is provided 'as-is', without any express or implied warranty. In no event will
    600   the authors be held liable for any damages arising from the use of this software.
    601   
    602 - Permission is granted to anyone to use this software for any purpose, including commercial 
    603 + Permission is granted to anyone to use this software for any purpose, including commercial
    604   applications, and to alter it and redistribute it freely, subject to the following
    605   restrictions:
    606   
    607 - 1. The origin of this software must not be misrepresented; you must not claim that 
    608 - you wrote the original software. If you use this software in a product, 
    609 - an acknowledgment in the product documentation would be appreciated but is 
    610 + 1. The origin of this software must not be misrepresented; you must not claim that
    611 + you wrote the original software. If you use this software in a product,
    612 + an acknowledgment in the product documentation would be appreciated but is
    613   not required.
    614   
    615 - 2. Altered source versions must be plainly marked as such, and must not be 
    616 + 2. Altered source versions must be plainly marked as such, and must not be
    617   misrepresented as being the original software.
    618   
    619   3. This notice may not be removed or altered from any source distribution.
    620 -*/
    621 + */
    622  #ifndef OIS_MacKeyboard_H
    623  #define OIS_MacKeyboard_H
    624  
    625 Index: includes/mac/MacHelpers.h
    626 ===================================================================
    627 --- includes/mac/MacHelpers.h	(revision 34)
    628 +++ includes/mac/MacHelpers.h	(working copy)
    629 @@ -57,37 +57,18 @@
    630                           MAC_MOUSEMOVED,
    631                           MAC_MOUSESCROLL};
    632      typedef enum Mac_EventType MacEventType;
    633 -    
    634 -    
    635 +
    636      // only used by MacKeyboard
    637      typedef class Mac_KeyStackEvent
    638      {
    639          friend class MacKeyboard;
    640 -        
    641 -        
    642 +
    643      private:
    644          Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {}
    645          
    646          MacEventType Type;
    647          KeyEvent Event;
    648      } MacKeyStackEvent;
    649 - 
    650 -    
    651 -
    652 -    // only used by MacMouse
    653 -    typedef class Mac_MouseStackEvent
    654 -    {
    655 -        friend class MacMouse;
    656 -        
    657 -    private:
    658 -        Mac_MouseStackEvent( MouseEvent event, MacEventType type,  MouseButtonID button) : Event(event), Type(type), Button(button) {}
    659 -        
    660 -        MacEventType Type;
    661 -        MouseEvent Event;
    662 -		MouseButtonID Button;
    663 -        
    664 -    } MacMouseStackEvent;
    665 -        
    666  }
    667  
    668  
    669 Index: includes/mac/CocoaJoyStick.h
    670 ===================================================================
    671 --- includes/mac/CocoaJoyStick.h	(revision 0)
    672 +++ includes/mac/CocoaJoyStick.h	(revision 0)
    673 @@ -0,0 +1,76 @@
    674 +/*
    675 + The zlib/libpng License
    676 + 
    677 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    678 + 
    679 + This software is provided 'as-is', without any express or implied warranty. In no event will
    680 + the authors be held liable for any damages arising from the use of this software.
    681 + 
    682 + Permission is granted to anyone to use this software for any purpose, including commercial
    683 + applications, and to alter it and redistribute it freely, subject to the following
    684 + restrictions:
    685 + 
    686 + 1. The origin of this software must not be misrepresented; you must not claim that
    687 + you wrote the original software. If you use this software in a product,
    688 + an acknowledgment in the product documentation would be appreciated but is
    689 + not required.
    690 + 
    691 + 2. Altered source versions must be plainly marked as such, and must not be
    692 + misrepresented as being the original software.
    693 + 
    694 + 3. This notice may not be removed or altered from any source distribution.
    695 + */
    696 +#ifndef Cocoa_Joystick_H
    697 +#define Cocoa_Joystick_H
    698 +
    699 +#include "OISJoyStick.h"
    700 +#include "mac/MacHIDManager.h"
    701 +
    702 +namespace OIS
    703 +{
    704 +	struct AxisInfo
    705 +	{
    706 +		int min;
    707 +		int max;
    708 +		
    709 +		AxisInfo(int min, int max)
    710 +			: min(min), max(max) {}
    711 +	};
    712 +	
    713 +	typedef struct cookie_struct 
    714 +	{ 
    715 +		std::map<IOHIDElementCookie, AxisInfo> axisCookies; 			
    716 +		std::vector<IOHIDElementCookie> buttonCookies; 
    717 +	} cookie_struct_t; 
    718 +	
    719 +	//class HidDeviceInfo
    720 +	
    721 +	class CocoaJoyStick : public JoyStick
    722 +	{
    723 +	public:
    724 +		CocoaJoyStick(const std::string& vendor, bool buffered, HidInfo* info, InputManager* creator, int devID);
    725 +		
    726 +		virtual ~CocoaJoyStick();
    727 +		
    728 +		/** @copydoc Object::setBuffered */
    729 +		virtual void setBuffered(bool buffered);
    730 +		
    731 +		/** @copydoc Object::capture */
    732 +		virtual void capture();
    733 +		
    734 +		/** @copydoc Object::queryInterface */
    735 +		virtual Interface* queryInterface(Interface::IType type);
    736 +		
    737 +		/** @copydoc Object::_initialize */
    738 +		virtual void _initialize();
    739 +		
    740 +		void _enumerateCookies();
    741 +		
    742 +		IOHIDQueueInterface** _createQueue(unsigned int depth = 8);
    743 +	protected:
    744 +		HidInfo* mInfo;
    745 +		cookie_struct_t mCookies;
    746 +		IOHIDQueueInterface** mQueue;
    747 +	};
    748 +}
    749 +#endif
    750 Index: includes/mac/CocoaKeyboard.h
    751 ===================================================================
    752 --- includes/mac/CocoaKeyboard.h	(revision 0)
    753 +++ includes/mac/CocoaKeyboard.h	(revision 0)
    754 @@ -0,0 +1,117 @@
    755 +/*
    756 + The zlib/libpng License
    757 + 
    758 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    759 + 
    760 + This software is provided 'as-is', without any express or implied warranty. In no event will
    761 + the authors be held liable for any damages arising from the use of this software.
    762 + 
    763 + Permission is granted to anyone to use this software for any purpose, including commercial
    764 + applications, and to alter it and redistribute it freely, subject to the following
    765 + restrictions:
    766 + 
    767 + 1. The origin of this software must not be misrepresented; you must not claim that
    768 + you wrote the original software. If you use this software in a product,
    769 + an acknowledgment in the product documentation would be appreciated but is
    770 + not required.
    771 + 
    772 + 2. Altered source versions must be plainly marked as such, and must not be
    773 + misrepresented as being the original software.
    774 + 
    775 + 3. This notice may not be removed or altered from any source distribution.
    776 + */
    777 +
    778 +#ifndef OIS_CocoaKeyboard_H
    779 +#define OIS_CocoaKeyboard_H
    780 +
    781 +#include "OISKeyboard.h"
    782 +#include "mac/CocoaHelpers.h"
    783 +
    784 +#include <list>
    785 +#include <Cocoa/Cocoa.h>
    786 +
    787 +@class CocoaKeyboardView;
    788 +
    789 +using namespace OIS;
    790 +using namespace std;
    791 +
    792 +namespace OIS
    793 +{
    794 +    typedef class Cocoa_KeyStackEvent
    795 +    {
    796 +        friend class CocoaKeyboard;
    797 +        
    798 +    public:
    799 +        Cocoa_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {}
    800 +        const MacEventType type()   { return Type; }
    801 +        const KeyEvent event()      { return Event; }
    802 +    private:
    803 +        MacEventType Type;
    804 +        KeyEvent Event;
    805 +    } CocoaKeyStackEvent;
    806 +    
    807 +    class CocoaKeyboard : public Keyboard
    808 +    {
    809 +    public:
    810 +        CocoaKeyboard( InputManager* creator, bool buffered, bool repeat );
    811 +        virtual ~CocoaKeyboard();
    812 +
    813 +        // Sets buffered mode
    814 +        virtual void setBuffered( bool buffered );
    815 +
    816 +        // Unbuffered keydown check
    817 +        virtual bool isKeyDown( KeyCode key ) const;
    818 +
    819 +        // This will send listener events if buffered is on.
    820 +        // Note that in the mac implementation, unbuffered input is
    821 +        // automatically updated without calling this.
    822 +        virtual void capture();
    823 +
    824 +        // Copies the current key buffer
    825 +        virtual void copyKeyStates( char keys[256] ) const;
    826 +
    827 +        // Returns a description of the given key
    828 +        virtual std::string& getAsString( KeyCode key );
    829 +
    830 +        virtual Interface* queryInterface( Interface::IType type ) { return 0; }
    831 +
    832 +        // Public but reserved for internal use:
    833 +        virtual void _initialize();
    834 +        
    835 +        unsigned int & _getModifiers() { return mModifiers; }
    836 +
    837 +    protected:
    838 +        CocoaKeyboardView *mResponder;
    839 +        std::string getString;
    840 +    };
    841 +}
    842 +
    843 +typedef std::map<unsigned short, KeyCode> VirtualtoOIS_KeyMap;
    844 +typedef std::list<OIS::CocoaKeyStackEvent> eventStack;
    845 +
    846 +@interface CocoaKeyboardView : NSResponder
    847 +{
    848 +    CocoaKeyboard *oisKeyboardObj;
    849 +    VirtualtoOIS_KeyMap keyConversion;
    850 +
    851 +    char KeyBuffer[256];
    852 +    NSUInteger prevModMask;
    853 +    
    854 +    // buffered events, fifo stack
    855 +    eventStack pendingEvents;
    856 +    bool useRepeat;
    857 +}
    858 +
    859 +- (void)setOISKeyboardObj:(CocoaKeyboard *)obj;
    860 +- (void)populateKeyConversion;
    861 +- (void)capture;
    862 +- (void)injectEvent:(KeyCode)kc eventTime:(unsigned int)time eventType:(MacEventType)type;
    863 +- (void)injectEvent:(KeyCode)kc eventTime:(unsigned int)time eventType:(MacEventType)type eventText:(unsigned int)txt;
    864 +- (void)copyKeyStates:(char [256])keys;
    865 +- (bool)isKeyDown:(KeyCode)key;
    866 +- (void)setUseRepeat:(bool)repeat;
    867 +- (VirtualtoOIS_KeyMap)keyConversionMap;
    868 +
    869 +@end
    870 +
    871 +#endif
    872 Index: includes/mac/CocoaHelpers.h
    873 ===================================================================
    874 --- includes/mac/CocoaHelpers.h	(revision 0)
    875 +++ includes/mac/CocoaHelpers.h	(revision 0)
    876 @@ -0,0 +1,46 @@
    877 +/*
    878 + The zlib/libpng License
    879 + 
    880 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    881 + 
    882 + This software is provided 'as-is', without any express or implied warranty. In no event will
    883 + the authors be held liable for any damages arising from the use of this software.
    884 + 
    885 + Permission is granted to anyone to use this software for any purpose, including commercial
    886 + applications, and to alter it and redistribute it freely, subject to the following
    887 + restrictions:
    888 + 
    889 + 1. The origin of this software must not be misrepresented; you must not claim that
    890 + you wrote the original software. If you use this software in a product,
    891 + an acknowledgment in the product documentation would be appreciated but is
    892 + not required.
    893 + 
    894 + 2. Altered source versions must be plainly marked as such, and must not be
    895 + misrepresented as being the original software.
    896 + 
    897 + 3. This notice may not be removed or altered from any source distribution.
    898 + */
    899 +
    900 +#ifndef OIS_CocoaHelpers_H
    901 +#define OIS_CocoaHelpers_H
    902 +
    903 +#include "OISEvents.h"
    904 +#include "OISKeyboard.h"
    905 +#include "OISMouse.h"
    906 +
    907 +// This is needed for keeping an event stack for keyboard and mouse
    908 +namespace OIS
    909 +{
    910 +    
    911 +    // used in the eventStack to store the type
    912 +    enum Mac_EventType { MAC_KEYUP = 0,
    913 +                         MAC_KEYDOWN = 1,
    914 +                         MAC_KEYREPEAT,
    915 +                         MAC_MOUSEDOWN,
    916 +                         MAC_MOUSEUP,
    917 +                         MAC_MOUSEMOVED,
    918 +                         MAC_MOUSESCROLL};
    919 +    typedef enum Mac_EventType MacEventType;
    920 +}
    921 +
    922 +#endif
    923 Index: demos/OISConsole.cpp
    924 ===================================================================
    925 --- demos/OISConsole.cpp	(revision 34)
    926 +++ demos/OISConsole.cpp	(working copy)
    927 @@ -284,7 +284,7 @@
    928  	//For this demo, show mouse and do not grab (confine to window)
    929  //	pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
    930  //	pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
    931 -#elif defined OIS_APPLE_PLATFORM
    932 +#elif defined OIS_APPLE_PLATFORM && !__LP64__
    933      // create the window rect in global coords
    934      ::Rect windowRect;
    935      windowRect.left = 0;
    936 Index: src/mac/MacKeyboard.cpp
    937 ===================================================================
    938 --- src/mac/MacKeyboard.cpp	(revision 34)
    939 +++ src/mac/MacKeyboard.cpp	(working copy)
    940 @@ -1,26 +1,28 @@
    941  /*
    942   The zlib/libpng License
    943   
    944 - Copyright (c) 2006 Chris Snyder 
    945 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
    946   
    947   This software is provided 'as-is', without any express or implied warranty. In no event will
    948   the authors be held liable for any damages arising from the use of this software.
    949   
    950 - Permission is granted to anyone to use this software for any purpose, including commercial 
    951 + Permission is granted to anyone to use this software for any purpose, including commercial
    952   applications, and to alter it and redistribute it freely, subject to the following
    953   restrictions:
    954   
    955 - 1. The origin of this software must not be misrepresented; you must not claim that 
    956 - you wrote the original software. If you use this software in a product, 
    957 - an acknowledgment in the product documentation would be appreciated but is 
    958 + 1. The origin of this software must not be misrepresented; you must not claim that
    959 + you wrote the original software. If you use this software in a product,
    960 + an acknowledgment in the product documentation would be appreciated but is
    961   not required.
    962   
    963 - 2. Altered source versions must be plainly marked as such, and must not be 
    964 + 2. Altered source versions must be plainly marked as such, and must not be
    965   misrepresented as being the original software.
    966   
    967   3. This notice may not be removed or altered from any source distribution.
    968 -*/
    969 + */
    970  
    971 +#ifndef __LP64__
    972 +
    973  #include "mac/MacKeyboard.h"
    974  #include "mac/MacInputManager.h"
    975  #include "mac/MacHelpers.h"
    976 @@ -141,11 +143,7 @@
    977  	// if not buffered just return, we update the unbuffered automatically
    978  	if ( !mBuffered || !mListener )
    979  		return;
    980 -	
    981 -	//If the mListener returns false, that means that we are probably deleted...
    982 -	//send no more events and just leave as the this pointer is invalid now...
    983 -	bool ret = true;
    984 -	
    985 +
    986  	// run through our event stack
    987  	eventStack::iterator cur_it;
    988  	
    989 @@ -165,8 +163,24 @@
    990  //-------------------------------------------------------------------//
    991  std::string& MacKeyboard::getAsString( KeyCode key )
    992  {
    993 -	getString = "";
    994 -	
    995 +    CGKeyCode deviceKeycode;
    996 +    
    997 +    // Convert OIS KeyCode back into device keycode
    998 +    for(VirtualtoOIS_KeyMap::iterator it = keyConversion.begin(); it != keyConversion.end(); ++it)
    999 +    {
   1000 +        if(it->second == key)
   1001 +            deviceKeycode = it->first;
   1002 +    }
   1003 +    
   1004 +    UniChar unicodeString[1];
   1005 +    UniCharCount actualStringLength = 0;
   1006 +    
   1007 +    CGEventSourceRef sref = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
   1008 +    CGEventRef ref = CGEventCreateKeyboardEvent(sref, deviceKeycode, true);
   1009 +    CGEventKeyboardGetUnicodeString(ref, sizeof(unicodeString) / sizeof(*unicodeString), &actualStringLength, unicodeString);
   1010 +//    NSLog([NSString stringWithFormat:@"%C\n", unicodeString[0]]);
   1011 +    getString = unicodeString[0];
   1012 +
   1013  	return getString;
   1014  }
   1015  
   1016 @@ -206,7 +220,7 @@
   1017  		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, 0, &stringsize, NULL);
   1018  		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text );
   1019  		status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text );
   1020 -		std::cout << "String length: " << stringsize << std::endl;
   1021 +//		std::cout << "String length: " << stringsize << std::endl;
   1022  		
   1023  		//wstring unitext;
   1024  		//for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
   1025 @@ -462,6 +476,4 @@
   1026  	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key?
   1027  }
   1028  
   1029 -
   1030 -
   1031 -
   1032 +#endif
   1033 Index: src/mac/MacHelpers.cpp
   1034 ===================================================================
   1035 --- src/mac/MacHelpers.cpp	(revision 34)
   1036 +++ src/mac/MacHelpers.cpp	(working copy)
   1037 @@ -1,26 +1,28 @@
   1038  /*
   1039   The zlib/libpng License
   1040   
   1041 - Copyright (c) 2006 Chris Snyder 
   1042 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
   1043   
   1044   This software is provided 'as-is', without any express or implied warranty. In no event will
   1045   the authors be held liable for any damages arising from the use of this software.
   1046   
   1047 - Permission is granted to anyone to use this software for any purpose, including commercial 
   1048 + Permission is granted to anyone to use this software for any purpose, including commercial
   1049   applications, and to alter it and redistribute it freely, subject to the following
   1050   restrictions:
   1051   
   1052 - 1. The origin of this software must not be misrepresented; you must not claim that 
   1053 - you wrote the original software. If you use this software in a product, 
   1054 - an acknowledgment in the product documentation would be appreciated but is 
   1055 + 1. The origin of this software must not be misrepresented; you must not claim that
   1056 + you wrote the original software. If you use this software in a product,
   1057 + an acknowledgment in the product documentation would be appreciated but is
   1058   not required.
   1059   
   1060 - 2. Altered source versions must be plainly marked as such, and must not be 
   1061 + 2. Altered source versions must be plainly marked as such, and must not be
   1062   misrepresented as being the original software.
   1063   
   1064   3. This notice may not be removed or altered from any source distribution.
   1065 -*/
   1066 + */
   1067  
   1068 +#ifndef __LP64__
   1069 +
   1070  #include "mac/MacHelpers.h"
   1071  #include "mac/MacKeyboard.h"
   1072  #include "mac/MacMouse.h"
   1073 @@ -156,3 +158,5 @@
   1074      else
   1075          OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!");
   1076  }
   1077 +
   1078 +#endif
   1079 \ No newline at end of file
   1080 Index: src/mac/CocoaMouse.mm
   1081 ===================================================================
   1082 --- src/mac/CocoaMouse.mm	(revision 0)
   1083 +++ src/mac/CocoaMouse.mm	(revision 0)
   1084 @@ -0,0 +1,384 @@
   1085 +/*
   1086 + The zlib/libpng License
   1087 + 
   1088 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
   1089 + 
   1090 + This software is provided 'as-is', without any express or implied warranty. In no event will
   1091 + the authors be held liable for any damages arising from the use of this software.
   1092 + 
   1093 + Permission is granted to anyone to use this software for any purpose, including commercial
   1094 + applications, and to alter it and redistribute it freely, subject to the following
   1095 + restrictions:
   1096 + 
   1097 + 1. The origin of this software must not be misrepresented; you must not claim that
   1098 + you wrote the original software. If you use this software in a product,
   1099 + an acknowledgment in the product documentation would be appreciated but is
   1100 + not required.
   1101 + 
   1102 + 2. Altered source versions must be plainly marked as such, and must not be
   1103 + misrepresented as being the original software.
   1104 + 
   1105 + 3. This notice may not be removed or altered from any source distribution.
   1106 + */
   1107 +#include "mac/CocoaMouse.h"
   1108 +#include "mac/CocoaInputManager.h"
   1109 +#include "mac/CocoaHelpers.h"
   1110 +#include "OISException.h"
   1111 +#include "OISEvents.h"
   1112 +
   1113 +using namespace OIS;
   1114 +
   1115 +//-------------------------------------------------------------------//
   1116 +CocoaMouse::CocoaMouse( InputManager* creator, bool buffered )
   1117 +	: Mouse(creator->inputSystemName(), buffered, 0, creator)
   1118 +{
   1119 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   1120 +
   1121 +	CocoaInputManager *man = static_cast<CocoaInputManager*>(mCreator);
   1122 +    mResponder = [[CocoaMouseView alloc] initWithFrame:[[man->_getWindow() contentView] frame]];
   1123 +    if(!mResponder)
   1124 +        OIS_EXCEPT( E_General, "CocoaMouseView::CocoaMouseView >> Error creating event responder" );
   1125 +    
   1126 +    [[man->_getWindow() contentView] addSubview:mResponder];
   1127 +    [mResponder setOISMouseObj:this];
   1128 +    
   1129 +	static_cast<CocoaInputManager*>(mCreator)->_setMouseUsed(true);
   1130 +
   1131 +    [pool drain];
   1132 +}
   1133 +
   1134 +CocoaMouse::~CocoaMouse()
   1135 +{
   1136 +	// Restore Mouse
   1137 +//	CGAssociateMouseAndMouseCursorPosition(true);
   1138 +	CGDisplayShowCursor(kCGDirectMainDisplay);
   1139 +
   1140 +    if (mResponder)
   1141 +    {
   1142 +        [mResponder release];
   1143 +        mResponder = nil;
   1144 +    }
   1145 +    
   1146 +	static_cast<CocoaInputManager*>(mCreator)->_setMouseUsed(false);
   1147 +}
   1148 +
   1149 +void CocoaMouse::_initialize()
   1150 +{
   1151 +	mState.clear();
   1152 +	CGAssociateMouseAndMouseCursorPosition(false);
   1153 +}
   1154 +
   1155 +void CocoaMouse::setBuffered( bool buffered )
   1156 +{
   1157 +	mBuffered = buffered;
   1158 +}
   1159 +
   1160 +void CocoaMouse::capture()
   1161 +{
   1162 +    [mResponder capture];
   1163 +}
   1164 +
   1165 +@implementation CocoaMouseView
   1166 +
   1167 +- (id)initWithFrame:(NSRect)frame
   1168 +{
   1169 +    self = [super initWithFrame:frame];
   1170 +    if (self) {
   1171 +        mTempState.clear();
   1172 +        mMouseWarped = false;
   1173 +        mNeedsToRegainFocus = false;
   1174 +        
   1175 +        // Hide OS Mouse
   1176 +        CGDisplayHideCursor(kCGDirectMainDisplay);
   1177 +
   1178 +        NSRect clipRect = NSMakeRect(0.0f, 0.0f, 0.0f, 0.0f);
   1179 +        clipRect = [[[self window] contentView] frame];
   1180 +
   1181 +        CGPoint warpPoint;
   1182 +		warpPoint.x = (((frame.origin.x + frame.size.width) - frame.origin.x) / 2) + frame.origin.x;
   1183 +		warpPoint.y = (((frame.origin.y + frame.size.height) - frame.origin.y) / 2) - frame.origin.y;
   1184 +//        warpPoint = CGPointMake(clipRect.size.height, clipRect.size.width);
   1185 +        CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint);
   1186 +
   1187 +        // Use NSTrackingArea to track mouse move events
   1188 +        NSTrackingAreaOptions trackingOptions = 
   1189 +            NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag | 
   1190 +            NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp;
   1191 +        
   1192 +        NSDictionary *trackerData = [NSDictionary dictionaryWithObjectsAndKeys:
   1193 +                                     [NSNumber numberWithInt:0], @"OISMouseTrackingKey", nil];
   1194 +        NSTrackingArea *trackingArea = [[NSTrackingArea alloc]
   1195 +                                        initWithRect:[self frame]// in our case track the entire view
   1196 +                                        options:trackingOptions
   1197 +                                        owner:self
   1198 +                                        userInfo:trackerData];
   1199 +        [self addTrackingArea:trackingArea];
   1200 +        [[self window] setAcceptsMouseMovedEvents:YES];
   1201 +        [trackingArea release];
   1202 +    }
   1203 +    return self;
   1204 +}
   1205 +
   1206 +- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
   1207 +{
   1208 +    return YES;
   1209 +}
   1210 +
   1211 +- (void)setOISMouseObj:(CocoaMouse *)obj
   1212 +{
   1213 +    oisMouseObj = obj;
   1214 +}
   1215 +
   1216 +- (void)capture
   1217 +{
   1218 +	MouseState *state = oisMouseObj->getMouseStatePtr();
   1219 +    state->X.rel = 0;
   1220 +    state->Y.rel = 0;
   1221 +    state->Z.rel = 0;
   1222 +    
   1223 +	if(mTempState.X.rel || mTempState.Y.rel || mTempState.Z.rel)
   1224 +	{
   1225 +//		NSLog(@"%i %i %i", mTempState.X.rel, mTempState.Y.rel, mTempState.Z.rel);
   1226 +        
   1227 +		// Set new relative motion values
   1228 +		state->X.rel = mTempState.X.rel;
   1229 +		state->Y.rel = mTempState.Y.rel;
   1230 +		state->Z.rel = mTempState.Z.rel;
   1231 +		
   1232 +		// Update absolute position
   1233 +		state->X.abs += mTempState.X.rel;
   1234 +		state->Y.abs += mTempState.Y.rel;
   1235 +		
   1236 +		if(state->X.abs > state->width)
   1237 +			state->X.abs = state->width;
   1238 +		else if(state->X.abs < 0)
   1239 +			state->X.abs = 0;
   1240 +        
   1241 +		if(state->Y.abs > state->height)
   1242 +			state->Y.abs = state->height;
   1243 +		else if(state->Y.abs < 0)
   1244 +			state->Y.abs = 0;
   1245 +        
   1246 +		state->Z.abs += mTempState.Z.rel;
   1247 +		
   1248 +		//Fire off event
   1249 +        if ( oisMouseObj->buffered() && oisMouseObj->getEventCallback() )
   1250 +			oisMouseObj->getEventCallback()->mouseMoved(MouseEvent(oisMouseObj, *state));
   1251 +	}
   1252 +    
   1253 +	mTempState.clear();
   1254 +}
   1255 +
   1256 +#pragma mark Left Mouse Event overrides
   1257 +- (void)mouseDown:(NSEvent *)theEvent
   1258 +{
   1259 +    int mouseButton = MB_Left;
   1260 +    NSEventType type = [theEvent type];
   1261 +    MouseState *state = oisMouseObj->getMouseStatePtr();
   1262 +
   1263 +    if(mNeedsToRegainFocus)
   1264 +        return;
   1265 +
   1266 +    if((type == NSLeftMouseDown) && ([theEvent modifierFlags] & NSAlternateKeyMask))
   1267 +    {
   1268 +        mouseButton = MB_Middle;
   1269 +    }
   1270 +    else if((type == NSLeftMouseDown) && ([theEvent modifierFlags] & NSControlKeyMask))
   1271 +    {
   1272 +        mouseButton = MB_Right;
   1273 +    }
   1274 +    else if(type == NSLeftMouseDown)
   1275 +    {
   1276 +        mouseButton = MB_Left;
   1277 +    }
   1278 +    state->buttons |= 1 << mouseButton;
   1279 +    if ( oisMouseObj->buffered() && oisMouseObj->getEventCallback() )
   1280 +        oisMouseObj->getEventCallback()->mousePressed( MouseEvent( oisMouseObj, *state ), (MouseButtonID)mouseButton );
   1281 +}
   1282 +
   1283 +- (void)mouseUp:(NSEvent *)theEvent {
   1284 +    int mouseButton = MB_Left;
   1285 +    NSEventType type = [theEvent type];
   1286 +    MouseState *state = oisMouseObj->getMouseStatePtr();
   1287 +
   1288 +    if((type == NSLeftMouseUp) && ([theEvent modifierFlags] & NSAlternateKeyMask))
   1289 +    {
   1290 +        mouseButton = MB_Middle;
   1291 +    }
   1292 +    else if((type == NSLeftMouseUp) && ([theEvent modifierFlags] & NSControlKeyMask))
   1293 +    {
   1294 +        mouseButton = MB_Right;
   1295 +    }
   1296 +    else if(type == NSLeftMouseUp)
   1297 +    {
   1298 +        mouseButton = MB_Left;
   1299 +    }
   1300 +    state->buttons &= ~(1 << mouseButton);
   1301 +
   1302 +    if ( oisMouseObj->buffered() && oisMouseObj->getEventCallback() )
   1303 +        oisMouseObj->getEventCallback()->mouseReleased( MouseEvent( oisMouseObj, *state ), (MouseButtonID)mouseButton );
   1304 +}
   1305 +
   1306 +
   1307 +- (void)mouseDragged:(NSEvent *)theEvent
   1308 +{
   1309 +    CGPoint delta = CGPointMake([theEvent deltaX], [theEvent deltaY]);
   1310 +    if(mNeedsToRegainFocus)
   1311 +        return;
   1312 +    
   1313 +    // Relative positioning
   1314 +    if(!mMouseWarped)
   1315 +    {
   1316 +        mTempState.X.rel += delta.x;
   1317 +        mTempState.Y.rel += delta.y;
   1318 +    }
   1319 +    
   1320 +    mMouseWarped = false;
   1321 +}
   1322 +
   1323 +#pragma mark Right Mouse Event overrides
   1324 +- (void)rightMouseDown:(NSEvent *)theEvent
   1325 +{
   1326 +    int mouseButton = MB_Right;
   1327 +    NSEventType type = [theEvent type];
   1328 +    MouseState *state = oisMouseObj->getMouseStatePtr();
   1329 +    
   1330 +    if(mNeedsToRegainFocus)
   1331 +        return;
   1332 +    
   1333 +    if(type == NSRightMouseDown)
   1334 +    {	
   1335 +        state->buttons |= 1 << mouseButton;
   1336 +    }
   1337 +
   1338 +    if ( oisMouseObj->buffered() && oisMouseObj->getEventCallback() )
   1339 +        oisMouseObj->getEventCallback()->mousePressed( MouseEvent( oisMouseObj, *state ), (MouseButtonID)mouseButton );
   1340 +}
   1341 +
   1342 +- (void)rightMouseUp:(NSEvent *)theEvent {
   1343 +    int mouseButton = MB_Right;
   1344 +    NSEventType type = [theEvent type];
   1345 +    MouseState *state = oisMouseObj->getMouseStatePtr();
   1346 +    
   1347 +    if(type == NSRightMouseUp)
   1348 +    {	
   1349 +        state->buttons &= ~(1 << mouseButton);
   1350 +    }
   1351 +
   1352 +    if ( oisMouseObj->buffered() && oisMouseObj->getEventCallback() )
   1353 +        oisMouseObj->getEventCallback()->mouseReleased( MouseEvent( oisMouseObj, *state ), (MouseButtonID)mouseButton );
   1354 +}
   1355 +
   1356 +- (void)rightMouseDragged:(NSEvent *)theEvent
   1357 +{
   1358 +    CGPoint delta = CGPointMake([theEvent deltaX], [theEvent deltaY]);
   1359 +    if(mNeedsToRegainFocus)
   1360 +        return;
   1361 +    
   1362 +    // Relative positioning
   1363 +    if(!mMouseWarped)
   1364 +    {
   1365 +        mTempState.X.rel += delta.x;
   1366 +        mTempState.Y.rel += delta.y;
   1367 +    }
   1368 +    
   1369 +    mMouseWarped = false;
   1370 +}
   1371 +
   1372 +#pragma mark Other Mouse Event overrides
   1373 +- (void)otherMouseDown:(NSEvent *)theEvent
   1374 +{
   1375 +    int mouseButton = MB_Middle;
   1376 +    NSEventType type = [theEvent type];
   1377 +    MouseState *state = oisMouseObj->getMouseStatePtr();
   1378 +    
   1379 +    if(mNeedsToRegainFocus)
   1380 +        return;
   1381 +    
   1382 +    if(type == NSOtherMouseDown)
   1383 +    {
   1384 +        state->buttons |= 1 << mouseButton;
   1385 +    }
   1386 +
   1387 +    if ( oisMouseObj->buffered() && oisMouseObj->getEventCallback() )
   1388 +        oisMouseObj->getEventCallback()->mousePressed( MouseEvent( oisMouseObj, *state ), (MouseButtonID)mouseButton );
   1389 +}
   1390 +
   1391 +- (void)otherMouseUp:(NSEvent *)theEvent {
   1392 +    int mouseButton = MB_Middle;
   1393 +    NSEventType type = [theEvent type];
   1394 +    MouseState *state = oisMouseObj->getMouseStatePtr();
   1395 +    
   1396 +    if(type == NSOtherMouseUp)
   1397 +    {
   1398 +        state->buttons &= ~(1 << mouseButton);
   1399 +    }
   1400 +
   1401 +    if ( oisMouseObj->buffered() && oisMouseObj->getEventCallback() )
   1402 +        oisMouseObj->getEventCallback()->mouseReleased( MouseEvent( oisMouseObj, *state ), (MouseButtonID)mouseButton );
   1403 +}
   1404 +
   1405 +- (void)otherMouseDragged:(NSEvent *)theEvent
   1406 +{
   1407 +    CGPoint delta = CGPointMake([theEvent deltaX], [theEvent deltaY]);
   1408 +    if(mNeedsToRegainFocus)
   1409 +        return;
   1410 +    
   1411 +    // Relative positioning
   1412 +    if(!mMouseWarped)
   1413 +    {
   1414 +        mTempState.X.rel += delta.x;
   1415 +        mTempState.Y.rel += delta.y;
   1416 +    }
   1417 +    
   1418 +    mMouseWarped = false;
   1419 +}
   1420 +
   1421 +- (void)scrollWheel:(NSEvent *)theEvent
   1422 +{
   1423 +    if([theEvent deltaY] != 0.0)
   1424 +        mTempState.Z.rel += ([theEvent deltaY] * 60);
   1425 +}
   1426 +
   1427 +- (void)mouseMoved:(NSEvent *)theEvent
   1428 +{
   1429 +    CGPoint delta = CGPointMake([theEvent deltaX], [theEvent deltaY]);
   1430 +    if(mNeedsToRegainFocus)
   1431 +        return;
   1432 +    
   1433 +    // Relative positioning
   1434 +    if(!mMouseWarped)
   1435 +    {
   1436 +        mTempState.X.rel += delta.x;
   1437 +        mTempState.Y.rel += delta.y;
   1438 +    }
   1439 +    
   1440 +    mMouseWarped = false;
   1441 +}
   1442 +
   1443 +- (void)mouseEntered:(NSEvent *)theEvent
   1444 +{
   1445 +	CGDisplayHideCursor(kCGDirectMainDisplay);
   1446 +	CGAssociateMouseAndMouseCursorPosition(false);
   1447 +    if(!mMouseWarped)
   1448 +    {
   1449 +        NSPoint pos = [[self window] mouseLocationOutsideOfEventStream];
   1450 +        NSRect frame = [[[self window] contentView] frame];
   1451 +
   1452 +        // Clear the previous mouse state
   1453 +        MouseState *state = oisMouseObj->getMouseStatePtr();
   1454 +        state->clear();
   1455 +
   1456 +        // Cocoa's coordinate system has the origin in the bottom left so we need to transform the height
   1457 +        mTempState.X.rel = pos.x;
   1458 +        mTempState.Y.rel = frame.size.height - pos.y;
   1459 +    }
   1460 +}
   1461 +
   1462 +- (void)mouseExited:(NSEvent *)theEvent
   1463 +{
   1464 +	CGDisplayShowCursor(kCGDirectMainDisplay);
   1465 +	CGAssociateMouseAndMouseCursorPosition(true);
   1466 +}
   1467 +
   1468 +@end
   1469 Index: src/mac/CocoaInputManager.mm
   1470 ===================================================================
   1471 --- src/mac/CocoaInputManager.mm	(revision 0)
   1472 +++ src/mac/CocoaInputManager.mm	(revision 0)
   1473 @@ -0,0 +1,187 @@
   1474 +/*
   1475 + The zlib/libpng License
   1476 + 
   1477 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
   1478 + 
   1479 + This software is provided 'as-is', without any express or implied warranty. In no event will
   1480 + the authors be held liable for any damages arising from the use of this software.
   1481 + 
   1482 + Permission is granted to anyone to use this software for any purpose, including commercial
   1483 + applications, and to alter it and redistribute it freely, subject to the following
   1484 + restrictions:
   1485 + 
   1486 + 1. The origin of this software must not be misrepresented; you must not claim that
   1487 + you wrote the original software. If you use this software in a product,
   1488 + an acknowledgment in the product documentation would be appreciated but is
   1489 + not required.
   1490 + 
   1491 + 2. Altered source versions must be plainly marked as such, and must not be
   1492 + misrepresented as being the original software.
   1493 + 
   1494 + 3. This notice may not be removed or altered from any source distribution.
   1495 + */
   1496 +
   1497 +#include "mac/CocoaInputManager.h"
   1498 +#include "mac/CocoaKeyboard.h"
   1499 +#include "mac/CocoaMouse.h"
   1500 +#include "mac/MacHIDManager.h"
   1501 +#include "OISException.h"
   1502 +
   1503 +using namespace std;
   1504 +using namespace OIS;
   1505 +
   1506 +//--------------------------------------------------------------------------------//
   1507 +CocoaInputManager::CocoaInputManager() : InputManager("Mac OS X Cocoa Input Manager")
   1508 +{
   1509 +    mHideMouse = true;
   1510 +    mUseRepeat = false;
   1511 +	mWindow = nil;
   1512 +
   1513 +	keyboardUsed = mouseUsed = false;
   1514 +
   1515 +	//Setup our internal factories
   1516 +	mFactories.push_back(this);
   1517 +
   1518 +	mHIDManager = new MacHIDManager();
   1519 +	mFactories.push_back(mHIDManager);
   1520 +}
   1521 +
   1522 +//--------------------------------------------------------------------------------//
   1523 +CocoaInputManager::~CocoaInputManager()
   1524 +{
   1525 +	delete mHIDManager;
   1526 +}
   1527 +
   1528 +//--------------------------------------------------------------------------------//
   1529 +void CocoaInputManager::_initialize( ParamList &paramList )
   1530 +{
   1531 +	_parseConfigSettings( paramList );
   1532 +    
   1533 +	//Enumerate all devices attached
   1534 +	_enumerateDevices();
   1535 +	
   1536 +	mHIDManager->initialize();
   1537 +}
   1538 +
   1539 +//--------------------------------------------------------------------------------//
   1540 +void CocoaInputManager::_parseConfigSettings( ParamList &paramList )
   1541 +{
   1542 +    // Some carbon apps are running in a window, however full screen apps
   1543 +	// do not have a window, so we need to account for that too.
   1544 +	ParamList::iterator i = paramList.find("WINDOW");
   1545 +	if(i != paramList.end())
   1546 +	{
   1547 +		mWindow = (NSWindow *)strtoul(i->second.c_str(), 0, 10);
   1548 +		if(mWindow == 0)
   1549 +		{
   1550 +			mWindow = nil;
   1551 +		}
   1552 +    }
   1553 +	else
   1554 +	{
   1555 +		// else get the main active window.. user might not have access to it through some
   1556 +		// graphics libraries, if that fails then try at the application level.
   1557 +		mWindow = [[NSApplication sharedApplication] keyWindow];
   1558 +	}
   1559 +	
   1560 +	if(mWindow == nil)
   1561 +		OIS_EXCEPT( E_General, "CocoaInputManager::_parseConfigSettings >> Unable to find a window or event target" );
   1562 +    
   1563 +    // Keyboard
   1564 +    if(paramList.find("MacAutoRepeatOn") != paramList.end())
   1565 +	{
   1566 +        if(paramList.find("MacAutoRepeatOn")->second == "true")
   1567 +		{
   1568 +            mUseRepeat = true;
   1569 +        }
   1570 +    }
   1571 +}
   1572 +
   1573 +//--------------------------------------------------------------------------------//
   1574 +void CocoaInputManager::_enumerateDevices()
   1575 +{
   1576 +}
   1577 +
   1578 +//--------------------------------------------------------------------------------//
   1579 +DeviceList CocoaInputManager::freeDeviceList()
   1580 +{
   1581 +	DeviceList ret;
   1582 +
   1583 +	if( keyboardUsed == false )
   1584 +		ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
   1585 +
   1586 +	if( mouseUsed == false )
   1587 +		ret.insert(std::make_pair(OISMouse, mInputSystemName));
   1588 +
   1589 +	return ret;
   1590 +}
   1591 +
   1592 +//--------------------------------------------------------------------------------//
   1593 +int CocoaInputManager::totalDevices(Type iType)
   1594 +{
   1595 +	switch(iType)
   1596 +	{
   1597 +	case OISKeyboard: return 1;
   1598 +	case OISMouse: return 1;
   1599 +	default: return 0;
   1600 +	}
   1601 +}
   1602 +
   1603 +//--------------------------------------------------------------------------------//
   1604 +int CocoaInputManager::freeDevices(Type iType)
   1605 +{
   1606 +	switch(iType)
   1607 +	{
   1608 +	case OISKeyboard: return keyboardUsed ? 0 : 1;
   1609 +	case OISMouse: return mouseUsed ? 0 : 1;
   1610 +	default: return 0;
   1611 +	}
   1612 +}
   1613 +
   1614 +//--------------------------------------------------------------------------------//
   1615 +bool CocoaInputManager::vendorExist(Type iType, const std::string & vendor)
   1616 +{
   1617 +	if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
   1618 +		return true;
   1619 +
   1620 +	return false;
   1621 +}
   1622 +
   1623 +//--------------------------------------------------------------------------------//
   1624 +Object* CocoaInputManager::createObject(InputManager* creator, Type iType, bool bufferMode, 
   1625 +									  const std::string & vendor)
   1626 +{
   1627 +	Object *obj = 0;
   1628 +
   1629 +	switch(iType)
   1630 +	{
   1631 +        case OISKeyboard: 
   1632 +        {
   1633 +            if( keyboardUsed == false )
   1634 +                obj = new CocoaKeyboard(this, bufferMode, mUseRepeat);
   1635 +            break;
   1636 +        }
   1637 +        case OISMouse:
   1638 +        {
   1639 +            if( mouseUsed == false )
   1640 +                obj = new CocoaMouse(this, bufferMode);
   1641 +            break;
   1642 +        }
   1643 +        default:
   1644 +        {
   1645 +            obj = mHIDManager->createObject(creator, iType, bufferMode, vendor);
   1646 +            break;
   1647 +        }
   1648 +	}
   1649 +
   1650 +	if( obj == 0 )
   1651 +		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
   1652 +
   1653 +	return obj;
   1654 +}
   1655 +
   1656 +//--------------------------------------------------------------------------------//
   1657 +void CocoaInputManager::destroyObject(Object* obj)
   1658 +{
   1659 +	delete obj;
   1660 +}
   1661 Index: src/mac/MacMouse.cpp
   1662 ===================================================================
   1663 --- src/mac/MacMouse.cpp	(revision 34)
   1664 +++ src/mac/MacMouse.cpp	(working copy)
   1665 @@ -1,3 +1,28 @@
   1666 +/*
   1667 + The zlib/libpng License
   1668 + 
   1669 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
   1670 + 
   1671 + This software is provided 'as-is', without any express or implied warranty. In no event will
   1672 + the authors be held liable for any damages arising from the use of this software.
   1673 + 
   1674 + Permission is granted to anyone to use this software for any purpose, including commercial
   1675 + applications, and to alter it and redistribute it freely, subject to the following
   1676 + restrictions:
   1677 + 
   1678 + 1. The origin of this software must not be misrepresented; you must not claim that
   1679 + you wrote the original software. If you use this software in a product,
   1680 + an acknowledgment in the product documentation would be appreciated but is
   1681 + not required.
   1682 + 
   1683 + 2. Altered source versions must be plainly marked as such, and must not be
   1684 + misrepresented as being the original software.
   1685 + 
   1686 + 3. This notice may not be removed or altered from any source distribution.
   1687 + */
   1688 +
   1689 +#ifndef __LP64__
   1690 +
   1691  #include "mac/MacMouse.h"
   1692  #include "mac/MacInputManager.h"
   1693  #include "mac/MacHelpers.h"
   1694 @@ -165,7 +190,6 @@
   1695  
   1696  void MacMouse::_mouseCallback( EventRef theEvent )
   1697  {
   1698 -	OSStatus result = eventNotHandledErr;
   1699      UInt32 kind = GetEventKind (theEvent);
   1700  
   1701  	switch(kind)
   1702 @@ -344,3 +368,4 @@
   1703  			break;
   1704  	}    
   1705  }
   1706 +#endif
   1707 Index: src/mac/MacInputManager.cpp
   1708 ===================================================================
   1709 --- src/mac/MacInputManager.cpp	(revision 34)
   1710 +++ src/mac/MacInputManager.cpp	(working copy)
   1711 @@ -1,25 +1,28 @@
   1712  /*
   1713   The zlib/libpng License
   1714   
   1715 - Copyright (c) 2006 Chris Snyder 
   1716 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
   1717   
   1718   This software is provided 'as-is', without any express or implied warranty. In no event will
   1719   the authors be held liable for any damages arising from the use of this software.
   1720   
   1721 - Permission is granted to anyone to use this software for any purpose, including commercial 
   1722 + Permission is granted to anyone to use this software for any purpose, including commercial
   1723   applications, and to alter it and redistribute it freely, subject to the following
   1724   restrictions:
   1725   
   1726 - 1. The origin of this software must not be misrepresented; you must not claim that 
   1727 - you wrote the original software. If you use this software in a product, 
   1728 - an acknowledgment in the product documentation would be appreciated but is 
   1729 + 1. The origin of this software must not be misrepresented; you must not claim that
   1730 + you wrote the original software. If you use this software in a product,
   1731 + an acknowledgment in the product documentation would be appreciated but is
   1732   not required.
   1733   
   1734 - 2. Altered source versions must be plainly marked as such, and must not be 
   1735 + 2. Altered source versions must be plainly marked as such, and must not be
   1736   misrepresented as being the original software.
   1737   
   1738   3. This notice may not be removed or altered from any source distribution.
   1739 -*/
   1740 + */
   1741 +
   1742 +#ifndef __LP64__
   1743 +
   1744  #include "mac/MacInputManager.h"
   1745  #include "mac/MacKeyboard.h"
   1746  #include "mac/MacMouse.h"
   1747 @@ -34,7 +37,7 @@
   1748  using namespace OIS;
   1749  
   1750  //--------------------------------------------------------------------------------//
   1751 -MacInputManager::MacInputManager() : InputManager("Mac OSX Input Manager")
   1752 +MacInputManager::MacInputManager() : InputManager("Mac OS X Input Manager")
   1753  {
   1754      mHideMouse = true;
   1755      mUseRepeat = false;
   1756 @@ -204,3 +207,4 @@
   1757  {
   1758  	delete obj;
   1759  }
   1760 +#endif
   1761 Index: src/mac/CocoaJoyStick.mm
   1762 ===================================================================
   1763 --- src/mac/CocoaJoyStick.mm	(revision 0)
   1764 +++ src/mac/CocoaJoyStick.mm	(revision 0)
   1765 @@ -0,0 +1,325 @@
   1766 +/*
   1767 + The zlib/libpng License
   1768 + 
   1769 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
   1770 + 
   1771 + This software is provided 'as-is', without any express or implied warranty. In no event will
   1772 + the authors be held liable for any damages arising from the use of this software.
   1773 + 
   1774 + Permission is granted to anyone to use this software for any purpose, including commercial
   1775 + applications, and to alter it and redistribute it freely, subject to the following
   1776 + restrictions:
   1777 + 
   1778 + 1. The origin of this software must not be misrepresented; you must not claim that
   1779 + you wrote the original software. If you use this software in a product,
   1780 + an acknowledgment in the product documentation would be appreciated but is
   1781 + not required.
   1782 + 
   1783 + 2. Altered source versions must be plainly marked as such, and must not be
   1784 + misrepresented as being the original software.
   1785 + 
   1786 + 3. This notice may not be removed or altered from any source distribution.
   1787 + */
   1788 +
   1789 +#include "mac/CocoaJoyStick.h"
   1790 +#include "mac/MacHIDManager.h"
   1791 +#include "mac/CocoaInputManager.h"
   1792 +#include "OISEvents.h"
   1793 +#include "OISException.h"
   1794 +
   1795 +#include <cassert>
   1796 +
   1797 +using namespace OIS;
   1798 +
   1799 +//--------------------------------------------------------------------------------------------------//
   1800 +CocoaJoyStick::CocoaJoyStick(const std::string &vendor, bool buffered, HidInfo* info, InputManager* creator, int devID) : 
   1801 +JoyStick(vendor, buffered, devID, creator), mInfo(info)
   1802 +{
   1803 +	
   1804 +}
   1805 +
   1806 +//--------------------------------------------------------------------------------------------------//
   1807 +CocoaJoyStick::~CocoaJoyStick()
   1808 +{
   1809 +	//TODO: check if the queue has been started first?
   1810 +	//(*mQueue)->stop(mQueue); 
   1811 +	(*mQueue)->dispose(mQueue); 
   1812 +	(*mQueue)->Release(mQueue); 
   1813 +	
   1814 +	
   1815 +	//TODO: check if the interface has been opened first?
   1816 +	(*mInfo->interface)->close(mInfo->interface);
   1817 +	(*mInfo->interface)->Release(mInfo->interface); 
   1818 +}
   1819 +
   1820 +//--------------------------------------------------------------------------------------------------//
   1821 +void CocoaJoyStick::_initialize()
   1822 +{
   1823 +	assert(mInfo && "Given HidInfo invalid");
   1824 +	assert(mInfo->interface && "Joystick interface invalid");
   1825 +	
   1826 +	//TODO: Is this necessary?
   1827 +	//Clear old state
   1828 +	mState.mAxes.clear();
   1829 +	
   1830 +	if ((*mInfo->interface)->open(mInfo->interface, 0) != KERN_SUCCESS)
   1831 +		OIS_EXCEPT(E_General, "CocoaJoyStick::_initialize() >> Could not initialize joy device!");
   1832 +	
   1833 +	mState.clear();
   1834 +	
   1835 +	_enumerateCookies();
   1836 +	
   1837 +	mState.mButtons.resize(mInfo->numButtons);
   1838 +	mState.mAxes.resize(mInfo->numAxes);
   1839 +	
   1840 +	mQueue = _createQueue();
   1841 +}
   1842 +
   1843 +class FindAxisCookie : public std::unary_function<std::pair<IOHIDElementCookie, AxisInfo>&, bool>
   1844 +{
   1845 +public:
   1846 +	FindAxisCookie(IOHIDElementCookie cookie) : m_Cookie(cookie) {}
   1847 +	bool operator()(const std::pair<IOHIDElementCookie, AxisInfo>& pair) const
   1848 +	{
   1849 +		return pair.first == m_Cookie;
   1850 +	}
   1851 +private:
   1852 +	IOHIDElementCookie m_Cookie;
   1853 +};
   1854 +
   1855 +//--------------------------------------------------------------------------------------------------//
   1856 +void CocoaJoyStick::capture()
   1857 +{
   1858 +	assert(mQueue && "Queue must be initialized before calling CocoaJoyStick::capture()");
   1859 +	
   1860 +	AbsoluteTime zeroTime = {0,0}; 
   1861 +	
   1862 +	IOHIDEventStruct event; 
   1863 +	IOReturn result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0); 
   1864 +	while(result == kIOReturnSuccess)
   1865 +	{
   1866 +		switch(event.type)
   1867 +		{
   1868 +			case kIOHIDElementTypeInput_Button:
   1869 +			{
   1870 +				std::vector<IOHIDElementCookie>::iterator buttonIt = std::find(mCookies.buttonCookies.begin(), mCookies.buttonCookies.end(), event.elementCookie);
   1871 +				int button = std::distance(mCookies.buttonCookies.begin(), buttonIt);
   1872 +				mState.mButtons[button] = (event.value == 1);
   1873 +				
   1874 +				if(mBuffered && mListener)
   1875 +				{
   1876 +					if(event.value == 0)
   1877 +						mListener->buttonPressed(JoyStickEvent(this, mState), button);
   1878 +					else if(event.value == 1)
   1879 +						mListener->buttonReleased(JoyStickEvent(this, mState), button);
   1880 +				}
   1881 +				break;
   1882 +			}
   1883 +			case kIOHIDElementTypeInput_Misc:
   1884 +				//TODO: It's an axis! - kind of - for gamepads - or should this be a pov?
   1885 +			case kIOHIDElementTypeInput_Axis:
   1886 +				std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = std::find_if(mCookies.axisCookies.begin(), mCookies.axisCookies.end(), FindAxisCookie(event.elementCookie));
   1887 +				int axis = std::distance(mCookies.axisCookies.begin(), axisIt);
   1888 +				
   1889 +				//Copied from LinuxJoyStickEvents.cpp, line 149
   1890 +				const AxisInfo& axisInfo = axisIt->second;
   1891 +				float proportion = (float) (event.value - axisInfo.max) / (float) (axisInfo.min - axisInfo.max);
   1892 +				mState.mAxes[axis].abs = -JoyStick::MIN_AXIS - (JoyStick::MAX_AXIS * 2 * proportion);
   1893 +				
   1894 +				if(mBuffered && mListener) mListener->axisMoved(JoyStickEvent(this, mState), axis);
   1895 +				break;
   1896 +		}
   1897 +		
   1898 +		result = (*mQueue)->getNextEvent(mQueue, &event, zeroTime, 0);
   1899 +	}
   1900 +}
   1901 +
   1902 +//--------------------------------------------------------------------------------------------------//
   1903 +void CocoaJoyStick::setBuffered(bool buffered)
   1904 +{
   1905 +	mBuffered = buffered;
   1906 +}
   1907 +
   1908 +//--------------------------------------------------------------------------------------------------//
   1909 +Interface* CocoaJoyStick::queryInterface(Interface::IType type)
   1910 +{
   1911 +	//Thought about using covariant return type here.. however,
   1912 +	//some devices may allow LED light changing, or other interface stuff
   1913 +	
   1914 +	//f( ff_device && type == Interface::ForceFeedback )
   1915 +	//return ff_device;
   1916 +	//else
   1917 +	return 0;
   1918 +}
   1919 +
   1920 +//--------------------------------------------------------------------------------------------------//
   1921 +void CocoaJoyStick::_enumerateCookies()
   1922 +{
   1923 +	assert(mInfo && "Given HidInfo invalid");
   1924 +	assert(mInfo->interface && "Joystick interface invalid");
   1925 +	
   1926 +	CFTypeRef                               object; 
   1927 +	long                                    number; 
   1928 +	IOHIDElementCookie                      cookie; 
   1929 +	long                                    usage; 
   1930 +	long                                    usagePage;
   1931 +	int										min;
   1932 +	int										max;
   1933 +
   1934 +	CFDictionaryRef                         element; 
   1935 +	
   1936 +	// Copy all elements, since we're grabbing most of the elements 
   1937 +	// for this device anyway, and thus, it's faster to iterate them 
   1938 +	// ourselves. When grabbing only one or two elements, a matching 
   1939 +	// dictionary should be passed in here instead of NULL. 
   1940 +	CFArrayRef elements; 
   1941 +	IOReturn success = reinterpret_cast<IOHIDDeviceInterface122*>(*mInfo->interface)->copyMatchingElements(mInfo->interface, NULL, &elements); 
   1942 +	
   1943 +	if (success == kIOReturnSuccess)
   1944 +	{ 
   1945 +		const CFIndex numOfElements = CFArrayGetCount(elements);
   1946 +		for (CFIndex i = 0; i < numOfElements; ++i) 
   1947 +		{ 
   1948 +			element = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(elements, i));
   1949 +			
   1950 +			//Get cookie 
   1951 +			object = (CFDictionaryGetValue(element, 
   1952 +										   CFSTR(kIOHIDElementCookieKey))); 
   1953 +			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) 
   1954 +				continue; 
   1955 +			if(!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, 
   1956 +								 &number)) 
   1957 +				continue; 
   1958 +			cookie = (IOHIDElementCookie) number; 
   1959 +			
   1960 +			//Get usage 
   1961 +			object = CFDictionaryGetValue(element, 
   1962 +										  CFSTR(kIOHIDElementUsageKey)); 
   1963 +			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) 
   1964 +				continue; 
   1965 +			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, 
   1966 +								  &number)) 
   1967 +				continue; 
   1968 +			usage = number; 
   1969 +			
   1970 +			//Get min
   1971 +			object = CFDictionaryGetValue(element,
   1972 +										  CFSTR(kIOHIDElementMinKey)); // kIOHIDElementMinKey or kIOHIDElementScaledMinKey?, no idea ...
   1973 +			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
   1974 +				continue;
   1975 +			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType,
   1976 +								  &number))
   1977 +				continue;
   1978 +			min = number;
   1979 +			
   1980 +			//Get max
   1981 +			object = CFDictionaryGetValue(element,
   1982 +										  CFSTR(kIOHIDElementMaxKey)); // kIOHIDElementMaxKey or kIOHIDElementScaledMaxKey?, no idea ...
   1983 +			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID())
   1984 +				continue;
   1985 +			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberIntType,
   1986 +								  &number))
   1987 +				continue;
   1988 +			max = number;			
   1989 +			
   1990 +			//Get usage page 
   1991 +			object = CFDictionaryGetValue(element, 
   1992 +										  CFSTR(kIOHIDElementUsagePageKey)); 
   1993 +			
   1994 +			if (object == 0 || CFGetTypeID(object) != CFNumberGetTypeID()) 
   1995 +				continue; 
   1996 +			
   1997 +			if (!CFNumberGetValue((CFNumberRef) object, kCFNumberLongType, 
   1998 +								  &number)) 
   1999 +				continue; 
   2000 +			
   2001 +			usagePage = number;
   2002 +			switch(usagePage)
   2003 +			{
   2004 +				case kHIDPage_GenericDesktop:
   2005 +					switch(usage)
   2006 +				{
   2007 +					case kHIDUsage_GD_Pointer:
   2008 +						break;
   2009 +					case kHIDUsage_GD_X:
   2010 +					case kHIDUsage_GD_Y:
   2011 +					case kHIDUsage_GD_Z:
   2012 +					case kHIDUsage_GD_Rx:
   2013 +					case kHIDUsage_GD_Ry:
   2014 +					case kHIDUsage_GD_Rz:
   2015 +						mCookies.axisCookies.insert(std::make_pair(cookie, AxisInfo(min, max)));
   2016 +						break;
   2017 +					case kHIDUsage_GD_Slider:
   2018 +					case kHIDUsage_GD_Dial:
   2019 +					case kHIDUsage_GD_Wheel:
   2020 +						break;
   2021 +					case kHIDUsage_GD_Hatswitch:
   2022 +						break;
   2023 +				}
   2024 +					break;
   2025 +				case kHIDPage_Button:
   2026 +					mCookies.buttonCookies.push_back(cookie);
   2027 +					break;
   2028 +			}		
   2029 +		}
   2030 +		
   2031 +		mInfo->numButtons = mCookies.buttonCookies.size();
   2032 +		mInfo->numAxes = mCookies.axisCookies.size();
   2033 +
   2034 +	} 
   2035 +	else 
   2036 +	{ 
   2037 +		OIS_EXCEPT(E_General, "JoyStick elements could not be copied: copyMatchingElements failed with error: " + success); 
   2038 +	}
   2039 +	
   2040 +}
   2041 +
   2042 +//--------------------------------------------------------------------------------------------------//
   2043 +IOHIDQueueInterface** CocoaJoyStick::_createQueue(unsigned int depth)
   2044 +{	
   2045 +	assert(mInfo && "Given HidInfo invalid");
   2046 +	assert(mInfo->interface && "Joystick interface invalid");
   2047 +	
   2048 +	IOHIDQueueInterface** queue = (*mInfo->interface)->allocQueue(mInfo->interface); 
   2049 +	
   2050 +	if (queue) 
   2051 +	{		
   2052 +		//create the queue 
   2053 +		IOReturn result = (*queue)->create(queue, 0, depth); 
   2054 +		
   2055 +		if(result == kIOReturnSuccess)
   2056 +		{		
   2057 +			//add elements to the queue
   2058 +			std::map<IOHIDElementCookie, AxisInfo>::iterator axisIt = mCookies.axisCookies.begin();
   2059 +			for(; axisIt != mCookies.axisCookies.end(); ++axisIt)
   2060 +			{
   2061 +				result = (*queue)->addElement(queue, axisIt->first, 0);
   2062 +			}
   2063 +			
   2064 +			std::vector<IOHIDElementCookie>::iterator buttonIt = mCookies.buttonCookies.begin();
   2065 +			for(; buttonIt != mCookies.buttonCookies.end(); ++buttonIt)
   2066 +			{
   2067 +				result = (*queue)->addElement(queue, (*buttonIt), 0);
   2068 +			}
   2069 +
   2070 +			//start data delivery to queue 
   2071 +			result = (*queue)->start(queue); 
   2072 +			if(result == kIOReturnSuccess)
   2073 +			{
   2074 +				return queue;
   2075 +			}
   2076 +			else
   2077 +			{
   2078 +				OIS_EXCEPT(E_General, "Queue could not be started.");
   2079 +			}
   2080 +		}
   2081 +		else
   2082 +		{
   2083 +			OIS_EXCEPT(E_General, "Queue could not be created.");
   2084 +		}
   2085 +	}
   2086 +	else
   2087 +	{
   2088 +		OIS_EXCEPT(E_General, "Queue allocation failed.");
   2089 +	}
   2090 +}
   2091 Index: src/mac/CocoaKeyboard.mm
   2092 ===================================================================
   2093 --- src/mac/CocoaKeyboard.mm	(revision 0)
   2094 +++ src/mac/CocoaKeyboard.mm	(revision 0)
   2095 @@ -0,0 +1,433 @@
   2096 +/*
   2097 + The zlib/libpng License
   2098 + 
   2099 + Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
   2100 + 
   2101 + This software is provided 'as-is', without any express or implied warranty. In no event will
   2102 + the authors be held liable for any damages arising from the use of this software.
   2103 + 
   2104 + Permission is granted to anyone to use this software for any purpose, including commercial
   2105 + applications, and to alter it and redistribute it freely, subject to the following
   2106 + restrictions:
   2107 + 
   2108 + 1. The origin of this software must not be misrepresented; you must not claim that
   2109 + you wrote the original software. If you use this software in a product,
   2110 + an acknowledgment in the product documentation would be appreciated but is
   2111 + not required.
   2112 + 
   2113 + 2. Altered source versions must be plainly marked as such, and must not be
   2114 + misrepresented as being the original software.
   2115 + 
   2116 + 3. This notice may not be removed or altered from any source distribution.
   2117 + */
   2118 +
   2119 +#include "mac/CocoaKeyboard.h"
   2120 +#include "mac/CocoaInputManager.h"
   2121 +#include "mac/CocoaHelpers.h"
   2122 +#include "OISException.h"
   2123 +#include "OISEvents.h"
   2124 +
   2125 +#include <Cocoa/Cocoa.h>
   2126 +
   2127 +#include <list>
   2128 +#include <string>
   2129 +#include <iostream>
   2130 +
   2131 +using namespace OIS;
   2132 +
   2133 +//-------------------------------------------------------------------//
   2134 +CocoaKeyboard::CocoaKeyboard( InputManager* creator, bool buffered, bool repeat )
   2135 +	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
   2136 +{
   2137 +	CocoaInputManager *man = static_cast<CocoaInputManager*>(mCreator);
   2138 +    mResponder = [[CocoaKeyboardView alloc] init];
   2139 +    if(!mResponder)
   2140 +        OIS_EXCEPT( E_General, "CocoaKeyboardView::CocoaKeyboardView >> Error creating event responder" );
   2141 +
   2142 +    [man->_getWindow() makeFirstResponder:mResponder];
   2143 +    [mResponder setUseRepeat:repeat];
   2144 +    [mResponder setOISKeyboardObj:this];
   2145 +
   2146 +	static_cast<CocoaInputManager*>(mCreator)->_setKeyboardUsed(true);
   2147 +}
   2148 +
   2149 +//-------------------------------------------------------------------//
   2150 +CocoaKeyboard::~CocoaKeyboard()
   2151 +{
   2152 +    if (mResponder)
   2153 +    {
   2154 +        [mResponder release];
   2155 +        mResponder = nil;
   2156 +    }
   2157 +
   2158 +	// Free the input managers keyboard
   2159 +	static_cast<CocoaInputManager*>(mCreator)->_setKeyboardUsed(false);
   2160 +}
   2161 +
   2162 +//-------------------------------------------------------------------//
   2163 +void CocoaKeyboard::_initialize()
   2164 +{
   2165 +	mModifiers = 0;
   2166 +}
   2167 +
   2168 +//-------------------------------------------------------------------//
   2169 +bool CocoaKeyboard::isKeyDown( KeyCode key ) const
   2170 +{
   2171 +	return [mResponder isKeyDown:key];
   2172 +}
   2173 +
   2174 +//-------------------------------------------------------------------//
   2175 +void CocoaKeyboard::capture()
   2176 +{
   2177 +    [mResponder capture];
   2178 +}
   2179 +
   2180 +//-------------------------------------------------------------------//
   2181 +std::string& CocoaKeyboard::getAsString( KeyCode key )
   2182 +{
   2183 +	getString = "";
   2184 +    
   2185 +    CGKeyCode deviceKeycode;
   2186 +    
   2187 +    // Convert OIS KeyCode back into device keycode
   2188 +    VirtualtoOIS_KeyMap keyMap = [mResponder keyConversionMap];
   2189 +    for(VirtualtoOIS_KeyMap::iterator it = keyMap.begin(); it != keyMap.end(); ++it)
   2190 +    {
   2191 +        if(it->second == key)
   2192 +            deviceKeycode = it->first;
   2193 +    }
   2194 +
   2195 +    UniChar unicodeString[1];
   2196 +    UniCharCount actualStringLength;
   2197 +
   2198 +    CGEventSourceRef sref = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
   2199 +    CGEventRef ref = CGEventCreateKeyboardEvent(sref, deviceKeycode, true);
   2200 +    CGEventKeyboardGetUnicodeString(ref, sizeof(unicodeString) / sizeof(*unicodeString), &actualStringLength, unicodeString);
   2201 +    getString = unicodeString[0];
   2202 +
   2203 +    return getString;
   2204 +}
   2205 +
   2206 +//-------------------------------------------------------------------//
   2207 +void CocoaKeyboard::setBuffered( bool buffered )
   2208 +{
   2209 +	mBuffered = buffered;
   2210 +}
   2211 +
   2212 +//-------------------------------------------------------------------//
   2213 +void CocoaKeyboard::copyKeyStates( char keys[256] ) const
   2214 +{
   2215 +	[mResponder copyKeyStates:keys];
   2216 +}
   2217 +
   2218 +@implementation CocoaKeyboardView
   2219 +
   2220 +- (id)init
   2221 +{
   2222 +    self = [super init];
   2223 +    if (self) {
   2224 +        [self populateKeyConversion];
   2225 +        memset( &KeyBuffer, 0, 256 );
   2226 +        prevModMask = 0;
   2227 +    }
   2228 +    return self;
   2229 +}
   2230 +
   2231 +- (BOOL)acceptsFirstResponder
   2232 +{
   2233 +    return YES;
   2234 +}
   2235 +
   2236 +- (BOOL)canBecomeKeyView
   2237 +{
   2238 +    return YES;
   2239 +}
   2240 +
   2241 +- (void)setOISKeyboardObj:(CocoaKeyboard *)obj
   2242 +{
   2243 +    oisKeyboardObj = obj;
   2244 +}
   2245 +
   2246 +- (void)capture
   2247 +{
   2248 +	// If not buffered just return, we update the unbuffered automatically
   2249 +	if ( !oisKeyboardObj->buffered() && !oisKeyboardObj->getEventCallback() )
   2250 +		return;
   2251 +
   2252 +	// Run through our event stack
   2253 +	eventStack::iterator cur_it;
   2254 +	
   2255 +	for (cur_it = pendingEvents.begin(); cur_it != pendingEvents.end(); cur_it++)
   2256 +	{
   2257 +		if ( (*cur_it).type() == MAC_KEYDOWN || (*cur_it).type() == MAC_KEYREPEAT)
   2258 +			oisKeyboardObj->getEventCallback()->keyPressed( (*cur_it).event() );
   2259 +		else if ( (*cur_it).type() == MAC_KEYUP )
   2260 +			oisKeyboardObj->getEventCallback()->keyReleased( (*cur_it).event() );
   2261 +	}
   2262 +	
   2263 +	pendingEvents.clear();
   2264 +}
   2265 +
   2266 +- (void)setUseRepeat:(bool)repeat
   2267 +{
   2268 +    useRepeat = repeat;
   2269 +}
   2270 +
   2271 +- (bool)isKeyDown:(KeyCode)key
   2272 +{
   2273 +    return KeyBuffer[key];
   2274 +}
   2275 +
   2276 +- (void)copyKeyStates:(char [256])keys
   2277 +{
   2278 +	memcpy( keys, KeyBuffer, 256 );
   2279 +}
   2280 +
   2281 +- (void)populateKeyConversion
   2282 +{
   2283 +	// Virtual Key Map to KeyCode
   2284 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x12, KC_1));
   2285 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x13, KC_2));
   2286 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x14, KC_3));
   2287 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x15, KC_4));
   2288 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x17, KC_5));
   2289 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x16, KC_6));
   2290 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1A, KC_7));
   2291 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1C, KC_8));
   2292 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x19, KC_9));
   2293 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1D, KC_0));
   2294 +	
   2295 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x33, KC_BACK));  // might be wrong
   2296 +	
   2297 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1B, KC_MINUS));
   2298 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x18, KC_EQUALS));
   2299 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x31, KC_SPACE));
   2300 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2B, KC_COMMA));
   2301 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2F, KC_PERIOD));
   2302 +	
   2303 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2A, KC_BACKSLASH));
   2304 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2C, KC_SLASH));
   2305 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x21, KC_LBRACKET));
   2306 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1E, KC_RBRACKET));
   2307 +	
   2308 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x35, KC_ESCAPE));
   2309 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x39, KC_CAPITAL));
   2310 +	
   2311 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x30, KC_TAB));
   2312 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x24, KC_RETURN));  // double check return/enter
   2313 +	
   2314 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_colon, KC_COLON));	 // no colon?
   2315 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x29, KC_SEMICOLON));
   2316 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x27, KC_APOSTROPHE));
   2317 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x32, KC_GRAVE));
   2318 +	
   2319 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0B, KC_B));
   2320 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x00, KC_A));
   2321 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x08, KC_C));
   2322 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x02, KC_D));
   2323 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0E, KC_E));
   2324 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x03, KC_F));
   2325 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x05, KC_G));
   2326 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x04, KC_H));
   2327 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x22, KC_I));
   2328 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x26, KC_J));
   2329 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x28, KC_K));
   2330 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x25, KC_L));
   2331 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2E, KC_M));
   2332 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2D, KC_N));
   2333 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1F, KC_O));
   2334 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x23, KC_P));
   2335 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0C, KC_Q));
   2336 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0F, KC_R));
   2337 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x01, KC_S));
   2338 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x11, KC_T));
   2339 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x20, KC_U));
   2340 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x09, KC_V));
   2341 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0D, KC_W));
   2342 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x07, KC_X));
   2343 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x10, KC_Y));
   2344 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x06, KC_Z));
   2345 +	
   2346 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7A, KC_F1));
   2347 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x78, KC_F2));
   2348 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x63, KC_F3));
   2349 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x76, KC_F4));
   2350 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x60, KC_F5));
   2351 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x61, KC_F6));
   2352 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x62, KC_F7));
   2353 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x64, KC_F8));
   2354 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x65, KC_F9));
   2355 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6D, KC_F10));
   2356 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x67, KC_F11));
   2357 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6F, KC_F12));
   2358 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x69, KC_F13));
   2359 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6B, KC_F14));
   2360 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x71, KC_F15));
   2361 +	
   2362 +	// Keypad
   2363 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x52, KC_NUMPAD0));
   2364 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x53, KC_NUMPAD1));
   2365 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x54, KC_NUMPAD2));
   2366 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x55, KC_NUMPAD3));
   2367 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x56, KC_NUMPAD4));
   2368 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x57, KC_NUMPAD5));
   2369 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x58, KC_NUMPAD6));
   2370 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x59, KC_NUMPAD7));
   2371 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5B, KC_NUMPAD8));
   2372 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5C, KC_NUMPAD9));
   2373 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x45, KC_ADD));
   2374 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4E, KC_SUBTRACT));
   2375 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x41, KC_DECIMAL));
   2376 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x51, KC_NUMPADEQUALS));
   2377 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4B, KC_DIVIDE));
   2378 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x43, KC_MULTIPLY));
   2379 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4C, KC_NUMPADENTER));
   2380 +	
   2381 +	// Keypad with numlock off
   2382 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_NUMPAD7));  // not sure of these
   2383 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8)); // check on a non-laptop
   2384 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Up, KC_NUMPAD9));
   2385 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Left, KC_NUMPAD4));
   2386 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Begin, KC_NUMPAD5));
   2387 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Right, KC_NUMPAD6));
   2388 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_End, KC_NUMPAD1));
   2389 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Down, KC_NUMPAD2));
   2390 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3));
   2391 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0));
   2392 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL));
   2393 +	
   2394 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7E, KC_UP));
   2395 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7D, KC_DOWN));
   2396 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7B, KC_LEFT));
   2397 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7C, KC_RIGHT));
   2398 +	
   2399 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x74, KC_PGUP));
   2400 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x79, KC_PGDOWN));
   2401 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_HOME));
   2402 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x77, KC_END));
   2403 +	
   2404 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ));		// ??
   2405 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL)); // ??
   2406 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE));		// ??
   2407 +	
   2408 +	
   2409 +	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT));	  // ??
   2410 +	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key?
   2411 +}
   2412 +
   2413 +- (void)injectEvent:(KeyCode)kc eventTime:(unsigned int)time eventType:(MacEventType)type
   2414 +{
   2415 +    [self injectEvent:kc eventTime:time eventType:type eventText:0];
   2416 +}
   2417 +
   2418 +- (void)injectEvent:(KeyCode)kc eventTime:(unsigned int)time eventType:(MacEventType)type eventText:(unsigned int)txt
   2419 +{
   2420 +	// set to 1 if this is either a keydown or repeat
   2421 +	KeyBuffer[kc] = ( type == MAC_KEYUP ) ? 0 : 1;
   2422 +	
   2423 +	if ( oisKeyboardObj->buffered() && oisKeyboardObj->getEventCallback() )
   2424 +		pendingEvents.push_back( CocoaKeyStackEvent( KeyEvent(oisKeyboardObj, kc, txt), type) );
   2425 +}
   2426 +
   2427 +#pragma mark Key Event overrides
   2428 +- (void)keyDown:(NSEvent *)theEvent
   2429 +{
   2430 +	unsigned short virtualKey = [theEvent keyCode];
   2431 +	unsigned int time = (unsigned int)[theEvent timestamp];
   2432 +	KeyCode kc = keyConversion[virtualKey];
   2433 +    
   2434 +	// Record what kind of text we should pass the KeyEvent
   2435 +	unichar text[10];
   2436 +	char macChar;
   2437 +	if (oisKeyboardObj->getTextTranslation() == OIS::Keyboard::Unicode)
   2438 +	{
   2439 +		// Get string size
   2440 +		NSUInteger stringsize = [[theEvent charactersIgnoringModifiers] length];
   2441 +        [[theEvent charactersIgnoringModifiers] getCharacters:text range:NSMakeRange(0, stringsize)];
   2442 +//		NSLog(@"Characters: %ls", text);
   2443 +//		std::cout << "String length: " << stringsize << std::endl;
   2444 +
   2445 +		if(stringsize > 0)
   2446 +		{
   2447 +			// For each unicode char, send an event
   2448 +			for ( unsigned int i = 0; i < stringsize; i++ )
   2449 +			{
   2450 +                [self injectEvent:kc eventTime:time eventType:MAC_KEYDOWN eventText:(unsigned int)text[i]];
   2451 +			}
   2452 +		}
   2453 +	} 
   2454 +	else if (oisKeyboardObj->getTextTranslation() == OIS::Keyboard::Ascii)
   2455 +	{
   2456 +        macChar = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
   2457 +		[self injectEvent:kc eventTime:time eventType:MAC_KEYDOWN eventText:(unsigned int)macChar];
   2458 +	}
   2459 +	else
   2460 +	{
   2461 +		[self injectEvent:kc eventTime:time eventType:MAC_KEYDOWN];
   2462 +	}
   2463 +}
   2464 +
   2465 +- (void)keyUp:(NSEvent *)theEvent
   2466 +{
   2467 +    unsigned short virtualKey = [theEvent keyCode];
   2468 +
   2469 +	KeyCode kc = keyConversion[virtualKey];
   2470 +    [self injectEvent:kc eventTime:[theEvent timestamp] eventType:MAC_KEYUP];
   2471 +}
   2472 +
   2473 +- (void)flagsChanged:(NSEvent *)theEvent
   2474 +{
   2475 +	NSUInteger mods = [theEvent modifierFlags];
   2476 +	
   2477 +	// Find the changed bit
   2478 +	NSUInteger change = prevModMask ^ mods;
   2479 +	MacEventType newstate = ((change & prevModMask) > 0) ? MAC_KEYUP : MAC_KEYDOWN;
   2480 +	unsigned int time = (unsigned int)[theEvent timestamp];
   2481 +	
   2482 +	//cout << "preMask: " << hex << prevModMask << endl;
   2483 +	//cout << "ModMask: " << hex << mods << endl;
   2484 +	//cout << "Change:  " << hex << (change & prevModMask) << endl << endl;
   2485 +	
   2486 +	// TODO test modifiers on a full keyboard to check if different mask for left/right
   2487 +	switch (change)
   2488 +	{
   2489 +		case (NSShiftKeyMask): // shift
   2490 +			oisKeyboardObj->_getModifiers() &= (newstate == MAC_KEYDOWN) ? OIS::Keyboard::Shift : ~OIS::Keyboard::Shift;
   2491 +            [self injectEvent:KC_LSHIFT eventTime:time eventType:newstate];
   2492 +			break;
   2493 +			
   2494 +		case (NSAlternateKeyMask): // option (alt)
   2495 +			oisKeyboardObj->_getModifiers() &= (newstate == MAC_KEYDOWN) ? OIS::Keyboard::Alt : -OIS::Keyboard::Alt;
   2496 +            [self injectEvent:KC_LMENU eventTime:time eventType:newstate];
   2497 +			break;
   2498 +			
   2499 +		case (NSControlKeyMask): // Ctrl
   2500 +			oisKeyboardObj->_getModifiers() += (newstate == MAC_KEYDOWN) ? OIS::Keyboard::Ctrl : -OIS::Keyboard::Ctrl;
   2501 +            [self injectEvent:KC_LCONTROL eventTime:time eventType:newstate];
   2502 +			break;
   2503 +            
   2504 +		case (NSCommandKeyMask): // apple
   2505 +            [self injectEvent:KC_LWIN eventTime:time eventType:newstate];
   2506 +			break;
   2507 +            
   2508 +		case (NSFunctionKeyMask): // fn key
   2509 +            [self injectEvent:KC_APPS eventTime:time eventType:newstate];
   2510 +			break;
   2511 +
   2512 +		case (NSAlphaShiftKeyMask): // caps lock
   2513 +            [self injectEvent:KC_CAPITAL eventTime:time eventType:newstate];
   2514 +			break;
   2515 +	}
   2516 +    
   2517 +    if([theEvent keyCode] == NSClearLineFunctionKey) // numlock
   2518 +        [self injectEvent:KC_NUMLOCK eventTime:time eventType:newstate];
   2519 +	
   2520 +	prevModMask = mods;
   2521 +}
   2522 +
   2523 +- (VirtualtoOIS_KeyMap)keyConversionMap
   2524 +{
   2525 +    return keyConversion;
   2526 +}
   2527 +
   2528 +@end
   2529 Index: src/OISInputManager.cpp
   2530 ===================================================================
   2531 --- src/OISInputManager.cpp	(revision 34)
   2532 +++ src/OISInputManager.cpp	(working copy)
   2533 @@ -35,6 +35,7 @@
   2534  #elif defined OIS_LINUX_PLATFORM
   2535  #  include "linux/LinuxInputManager.h"
   2536  #elif defined OIS_APPLE_PLATFORM
   2537 +#  include "mac/CocoaInputManager.h"
   2538  #  include "mac/MacInputManager.h"
   2539  #elif defined OIS_IPHONE_PLATFORM
   2540  #  include "iphone/iPhoneInputManager.h"
   2541 @@ -113,7 +114,17 @@
   2542  #elif defined OIS_LINUX_PLATFORM
   2543  	im = new LinuxInputManager();
   2544  #elif defined OIS_APPLE_PLATFORM
   2545 -	im = new MacInputManager();
   2546 +	ParamList::iterator i = paramList.find("WINDOW");
   2547 +	if(i != paramList.end())
   2548 +    {
   2549 +        id obj = (id)strtoul(i->second.c_str(), 0, 10);
   2550 +        if(obj && [obj isKindOfClass:[NSWindow class]])
   2551 +            im = new CocoaInputManager();
   2552 +#ifndef __LP64__
   2553 +        else
   2554 +            im = new MacInputManager();
   2555 +#endif
   2556 +    }
   2557  #elif defined OIS_IPHONE_PLATFORM
   2558  	im = new iPhoneInputManager();
   2559  #else
   2560