move osx only code
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <CoreVideo/CoreVideo.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
#import "objc_utils.h"
|
||||
|
||||
#include <deque>
|
||||
@@ -21,6 +22,46 @@
|
||||
@import AppCenterAnalytics;
|
||||
@import AppCenterCrashes;
|
||||
|
||||
NSString* keyCodeToString(NSUInteger keyCode, NSUInteger mods)
|
||||
{
|
||||
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
|
||||
CFDataRef uchr =
|
||||
(CFDataRef)TISGetInputSourceProperty(currentKeyboard,
|
||||
kTISPropertyUnicodeKeyLayoutData);
|
||||
const UCKeyboardLayout *keyboardLayout =
|
||||
(const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
|
||||
|
||||
if(keyboardLayout)
|
||||
{
|
||||
UInt32 deadKeyState = 0;
|
||||
UniCharCount maxStringLength = 255;
|
||||
UniCharCount actualStringLength = 0;
|
||||
UniChar unicodeString[maxStringLength];
|
||||
|
||||
OSStatus status = UCKeyTranslate(keyboardLayout,
|
||||
keyCode, kUCKeyActionDown, mods,
|
||||
LMGetKbdType(), 0,
|
||||
&deadKeyState,
|
||||
maxStringLength,
|
||||
&actualStringLength, unicodeString);
|
||||
|
||||
if (actualStringLength == 0 && deadKeyState)
|
||||
{
|
||||
status = UCKeyTranslate(keyboardLayout,
|
||||
kVK_Space, kUCKeyActionDown, mods,
|
||||
LMGetKbdType(), 0,
|
||||
&deadKeyState,
|
||||
maxStringLength,
|
||||
&actualStringLength, unicodeString);
|
||||
}
|
||||
if(actualStringLength > 0 && status == noErr)
|
||||
return [[NSString stringWithCharacters:unicodeString
|
||||
length:(NSUInteger)actualStringLength] lowercaseString];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@implementation View
|
||||
{
|
||||
NSSharingService *airdrop_service;
|
||||
|
||||
Reference in New Issue
Block a user