Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Cocoa/OS X:确定当前选定的键盘是否有数字键盘_Objective C_Macos_Cocoa - Fatal编程技术网

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

Objective c Cocoa/OS X:确定当前选定的键盘是否有数字键盘,objective-c,macos,cocoa,Objective C,Macos,Cocoa,如何确定连接到Mac的键盘的物理类型/布局?我试图确定当前选择的键盘是否有数字键盘,但看不到明显的KTisPropertyxxxxxx来标识键数/布局,这是一段示例代码 #import <Foundation/Foundation.h> #import <Carbon/Carbon.h> int main(int argc, const char * argv[]) { @autoreleasepool { TISInputSourceRef

如何确定连接到Mac的键盘的物理类型/布局?我试图确定当前选择的键盘是否有数字键盘,但看不到明显的KTisPropertyxxxxxx来标识键数/布局,这是一段示例代码

#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;
}
#导入
#进口
int main(int argc,const char*argv[]
{
@自动释放池{
TIInputSourceRef currentKeyLayoutRef;
currentKeyLayoutRef=TISCopyCurrentKeyboardInputSource();
NSLog(@“基本信息:键盘类型=%u,布局名称=%@,本地化名称=%@,语言:%@\n”,
LMGetKbdType(),
TISGetInputSourceProperty(currentKeyLayoutRef,kTISPropertyInputSourceID),
TISGetInputSourceProperty(currentKeyLayoutRef,kTISPropertyLocalizedName),
TISGetInputSourceProperty(currentKeyLayoutRef、kTISPropertyInputSourceLanguages)
);
//NSLog(@“列表:%@”,TISGetInputSourceProperty(currentKeyLayoutRef,KTisPropertyYunicodeKeyLayoutData));
}
返回0;
}

有什么想法吗?

想知道苹果是如何编写键盘查看器应用程序的,因为它在连接USB/蓝牙键盘时会显示一个扩展键盘,他们只是在USB设备列表中寻找一个非内部键盘,例如ioreg-Src-ioubdevice | grep“USB产品名称”| grep“键盘”| egrep-v“Hub | internal”