如何确定连接到Mac的键盘的物理类型/布局?我正在尝试确定当前选择的键盘是否有数字小键盘,但是看不到明显的kTISPropertyXXXXXXX来识别键/布局的数量,这是一些示例代码。
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
TISInputSourceRef currentKeyLayoutRef;
currentKeyLayoutRef = TISCopyCurrentKeyboardInputSource();
NSLog(@"Basic Info: keyboard_type=%u, layoutName=%@, localizedName=%@, languages: %@\n",
LMGetKbdType(),
TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyInputSourceID),
TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyLocalizedName),
TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyInputSourceLanguages)
);
// NSLog(@"List: %@", TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData));
}
return 0;
}
有什么想法吗?