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;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <iomanip>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Photos/Photos.h>
|
||||
@@ -57,46 +56,6 @@ NSString* StringWToNSString ( const std::wstring& Str )
|
||||
return pString;
|
||||
}
|
||||
|
||||
NSString* keyCodeToString(CGKeyCode 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;
|
||||
}
|
||||
|
||||
std::string base_address;
|
||||
std::atomic_flag handler_executed;
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ void delete_all_files_in_path(const std::string& source_path);
|
||||
void export_mp4(const std::string& rec_path, int width, int height, int tot, void(^progress_callback)(float));
|
||||
void save_image_library(const std::string& path);
|
||||
bool apple_create_dir(const std::string& path);
|
||||
NSString* keyCodeToString(CGKeyCode keyCode, NSUInteger mods);
|
||||
NSString* keyCodeToString(NSUInteger keyCode, NSUInteger mods);
|
||||
std::wstring NSStringToStringW(NSString* Str);
|
||||
NSString* StringWToNSString(const std::wstring& Str);
|
||||
|
||||
Reference in New Issue
Block a user