adium/adium
Clone
Summary
Browse
Changes
Graph
Update build.sh to find the 10.6 SDK with Xcode 4.3. However, hardcode CC to gcc (from MacPorts).
2012-05-08, Thijs Alkemade
67a03e758cf8
Update build.sh to find the 10.6 SDK with Xcode 4.3. However, hardcode CC to gcc (from MacPorts).
Building at least GLib with clang never worked right for me.
//
// SGKeyCodeTranslator.m
// SGHotKeyCenter
//
// Created by Justin Williams on 7/26/09.
// Copyright 2009 Second Gear. All rights reserved.
//
#import "SGKeyCodeTranslator.h"
@implementation
SGKeyCodeTranslator
@synthesize
keyboardLayout
;
+
(
id
)
currentTranslator
{
static
SGKeyCodeTranslator
*
currentTranslator
=
nil
;
TISInputSourceRef
currentKeyboardLayout
=
TISCopyCurrentKeyboardLayoutInputSource
();
if
(
currentTranslator
==
nil
)
{
currentTranslator
=
[[
SGKeyCodeTranslator
alloc
]
initWithKeyboardLayout
:
currentKeyboardLayout
];
}
else
if
([
currentTranslator
keyboardLayout
]
!=
currentKeyboardLayout
)
{
[
currentTranslator
release
];
currentTranslator
=
[[
SGKeyCodeTranslator
alloc
]
initWithKeyboardLayout
:
currentKeyboardLayout
];
}
return
currentTranslator
;
}
-
(
id
)
initWithKeyboardLayout:
(
TISInputSourceRef
)
theLayout
{
if
((
self
=
[
super
init
])
!=
nil
)
{
keyboardLayout
=
theLayout
;
CFDataRef
uchr
=
TISGetInputSourceProperty
(
keyboardLayout
,
kTISPropertyUnicodeKeyLayoutData
);
if
(
!
uchr
)
{
AILogWithSignature
(
@"Selected keyboard layout %@ has no UCHR data!"
,
TISGetInputSourceProperty
(
keyboardLayout
,
kTISPropertyInputSourceID
));
}
else
{
keyboardLayoutData
=
(
const
UCKeyboardLayout
*
)
CFDataGetBytePtr
(
uchr
);
}
}
return
self
;
}
-
(
NSString
*
)
translateKeyCode:
(
short
)
keyCode
{
UniCharCount
maxStringLength
=
4
,
actualStringLength
;
UniChar
unicodeString
[
4
];
UCKeyTranslate
(
keyboardLayoutData
,
keyCode
,
kUCKeyActionDisplay
,
0
,
LMGetKbdType
(),
kUCKeyTranslateNoDeadKeysBit
,
&
deadKeyState
,
maxStringLength
,
&
actualStringLength
,
unicodeString
);
return
[
NSString
stringWithCharacters
:
unicodeString
length
:
1
];
}
@end