Cocoa / OS X:确定当前选定的键盘是否具有数字键盘

时间:2014-03-19 21:15:07

标签: objective-c macos cocoa

如何确定连接到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;
}

有什么想法吗?

0 个答案:

没有答案