|  |  | @ -200,6 +200,37 @@ static void createKeyTables(void) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | // Retrieve Unicode data for the current keyboard layout | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | // | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | static GLFWbool updateUnicodeDataNS(void) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (_glfw.ns.inputSource) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         CFRelease(_glfw.ns.inputSource); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         _glfw.ns.inputSource = NULL; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         _glfw.ns.unicodeData = nil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (!_glfw.ns.inputSource) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         _glfwInputError(GLFW_PLATFORM_ERROR, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         "Cocoa: Failed to retrieve keyboard layout input source"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return GLFW_FALSE; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     _glfw.ns.unicodeData = TISGetInputSourceProperty(_glfw.ns.inputSource, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                                      kTISPropertyUnicodeKeyLayoutData); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (!_glfw.ns.unicodeData) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         _glfwInputError(GLFW_PLATFORM_ERROR, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         "Cocoa: Failed to retrieve keyboard layout Unicode data"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return GLFW_FALSE; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     return GLFW_TRUE; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | // Load HIToolbox.framework and the TIS symbols we need from it |  |  |  | // Load HIToolbox.framework and the TIS symbols we need from it | 
			
		
	
		
		
			
				
					
					|  |  |  | // This works only because Cocoa has already loaded it properly |  |  |  | // This works only because Cocoa has already loaded it properly | 
			
		
	
		
		
			
				
					
					|  |  |  | // |  |  |  | // | 
			
		
	
	
		
		
			
				
					|  |  | @ -216,6 +247,9 @@ static GLFWbool initializeTIS(void) | 
			
		
	
		
		
			
				
					
					|  |  |  |     CFStringRef* kPropertyUnicodeKeyLayoutData = |  |  |  |     CFStringRef* kPropertyUnicodeKeyLayoutData = | 
			
		
	
		
		
			
				
					
					|  |  |  |         CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, |  |  |  |         CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, | 
			
		
	
		
		
			
				
					
					|  |  |  |                                       CFSTR("kTISPropertyUnicodeKeyLayoutData")); |  |  |  |                                       CFSTR("kTISPropertyUnicodeKeyLayoutData")); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     CFStringRef* kNotifySelectedKeyboardInputSourceChanged = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         CFBundleGetDataPointerForName(_glfw.ns.tis.bundle, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                       CFSTR("kTISNotifySelectedKeyboardInputSourceChanged")); | 
			
		
	
		
		
			
				
					
					|  |  |  |     _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = |  |  |  |     _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource = | 
			
		
	
		
		
			
				
					
					|  |  |  |         CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, |  |  |  |         CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle, | 
			
		
	
		
		
			
				
					
					|  |  |  |                                           CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); |  |  |  |                                           CFSTR("TISCopyCurrentKeyboardLayoutInputSource")); | 
			
		
	
	
		
		
			
				
					|  |  | @ -227,6 +261,7 @@ static GLFWbool initializeTIS(void) | 
			
		
	
		
		
			
				
					
					|  |  |  |                                           CFSTR("LMGetKbdType")); |  |  |  |                                           CFSTR("LMGetKbdType")); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (!kPropertyUnicodeKeyLayoutData || |  |  |  |     if (!kPropertyUnicodeKeyLayoutData || | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         !kNotifySelectedKeyboardInputSourceChanged || | 
			
		
	
		
		
			
				
					
					|  |  |  |         !TISCopyCurrentKeyboardLayoutInputSource || |  |  |  |         !TISCopyCurrentKeyboardLayoutInputSource || | 
			
		
	
		
		
			
				
					
					|  |  |  |         !TISGetInputSourceProperty || |  |  |  |         !TISGetInputSourceProperty || | 
			
		
	
		
		
			
				
					
					|  |  |  |         !LMGetKbdType) |  |  |  |         !LMGetKbdType) | 
			
		
	
	
		
		
			
				
					|  |  | @ -236,22 +271,26 @@ static GLFWbool initializeTIS(void) | 
			
		
	
		
		
			
				
					
					|  |  |  |         return GLFW_FALSE; |  |  |  |         return GLFW_FALSE; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = *kPropertyUnicodeKeyLayoutData; |  |  |  |     _glfw.ns.tis.kPropertyUnicodeKeyLayoutData = | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         *kPropertyUnicodeKeyLayoutData; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     _glfw.ns.tis.kNotifySelectedKeyboardInputSourceChanged = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         *kNotifySelectedKeyboardInputSourceChanged; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     // TODO: Catch kTISNotifySelectedKeyboardInputSourceChanged and update |  |  |  |     return updateUnicodeDataNS(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource(); |  |  |  | @interface GLFWLayoutListener : NSObject | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     if (!_glfw.ns.inputSource) |  |  |  | @end | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         return GLFW_FALSE; |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     _glfw.ns.unicodeData = TISGetInputSourceProperty(_glfw.ns.inputSource, |  |  |  | @implementation GLFWLayoutListener | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                                      kTISPropertyUnicodeKeyLayoutData); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (!_glfw.ns.unicodeData) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         return GLFW_FALSE; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     return GLFW_TRUE; |  |  |  | - (void)selectedKeyboardInputSourceChanged:(NSObject* )object | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     updateUnicodeDataNS(); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | @end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | ////////////////////////////////////////////////////////////////////////// |  |  |  | ////////////////////////////////////////////////////////////////////////// | 
			
		
	
		
		
			
				
					
					|  |  |  | //////                       GLFW platform API                      ////// |  |  |  | //////                       GLFW platform API                      ////// | 
			
		
	
	
		
		
			
				
					|  |  | @ -261,6 +300,13 @@ int _glfwPlatformInit(void) | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init]; |  |  |  |     _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     _glfw.ns.listener = [[GLFWLayoutListener alloc] init]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     [[NSDistributedNotificationCenter defaultCenter] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         addObserver:_glfw.ns.listener | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |            selector:@selector(selectedKeyboardInputSourceChanged:) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                name:(__bridge NSString*)kTISNotifySelectedKeyboardInputSourceChanged | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              object:nil]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | #if defined(_GLFW_USE_CHDIR) |  |  |  | #if defined(_GLFW_USE_CHDIR) | 
			
		
	
		
		
			
				
					
					|  |  |  |     changeToResourcesDirectory(); |  |  |  |     changeToResourcesDirectory(); | 
			
		
	
		
		
			
				
					
					|  |  |  | #endif |  |  |  | #endif | 
			
		
	
	
		
		
			
				
					|  |  | @ -294,6 +340,7 @@ void _glfwPlatformTerminate(void) | 
			
		
	
		
		
			
				
					
					|  |  |  |     { |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |         CFRelease(_glfw.ns.inputSource); |  |  |  |         CFRelease(_glfw.ns.inputSource); | 
			
		
	
		
		
			
				
					
					|  |  |  |         _glfw.ns.inputSource = NULL; |  |  |  |         _glfw.ns.inputSource = NULL; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         _glfw.ns.unicodeData = nil; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (_glfw.ns.eventSource) |  |  |  |     if (_glfw.ns.eventSource) | 
			
		
	
	
		
		
			
				
					|  |  | @ -309,6 +356,16 @@ void _glfwPlatformTerminate(void) | 
			
		
	
		
		
			
				
					
					|  |  |  |         _glfw.ns.delegate = nil; |  |  |  |         _glfw.ns.delegate = nil; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (_glfw.ns.listener) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         [[NSDistributedNotificationCenter defaultCenter] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             removeObserver:_glfw.ns.listener | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                       name:(__bridge NSString*)kTISNotifySelectedKeyboardInputSourceChanged | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     object:nil]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         [_glfw.ns.listener release]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         _glfw.ns.listener = nil; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     [_glfw.ns.cursor release]; |  |  |  |     [_glfw.ns.cursor release]; | 
			
		
	
		
		
			
				
					
					|  |  |  |     _glfw.ns.cursor = nil; |  |  |  |     _glfw.ns.cursor = nil; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |