mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-02-08 12:40:05 +00:00
Added unicode key support to macOS
This commit is contained in:
@@ -236,7 +236,10 @@ void MouseAction(double absX, double absY, int button, short wheel)
|
||||
if (source != NULL) CFRelease(source);
|
||||
}
|
||||
|
||||
void KeyAction(unsigned char vk, int up) {
|
||||
void KeyAction(unsigned char vk, int up)
|
||||
{
|
||||
//ILIBLOGMESSAGEX("NORMAL: %u [%d]", vk, up);
|
||||
|
||||
int i;
|
||||
CGKeyCode keycode;
|
||||
CGEventSourceRef source;
|
||||
@@ -252,20 +255,21 @@ void KeyAction(unsigned char vk, int up) {
|
||||
if (i == g_keymapLen) { return; }
|
||||
if (vk == VK_CAPITAL && up) { g_capsLock = g_capsLock ? 0 : 1; }
|
||||
|
||||
/*
|
||||
if (!strcmp(getCurrentSession(), "<none>")) {
|
||||
// This call is deprecated in OSX 10.6
|
||||
CGPostKeyboardEvent(0, keycode, !up);
|
||||
}
|
||||
else
|
||||
{
|
||||
*/
|
||||
CGEventRef key = CGEventCreateKeyboardEvent(source, keycode, !up);
|
||||
if (g_capsLock) { CGEventSetFlags(key, kCGEventFlagMaskAlphaShift); }
|
||||
CGEventPost(kCGHIDEventTap, key);
|
||||
CFRelease(key);
|
||||
/*
|
||||
}
|
||||
*/
|
||||
CGEventRef key = CGEventCreateKeyboardEvent(source, keycode, !up);
|
||||
if (g_capsLock) { CGEventSetFlags(key, kCGEventFlagMaskAlphaShift); }
|
||||
CGEventPost(kCGHIDEventTap, key);
|
||||
CFRelease(key);
|
||||
|
||||
if (source != NULL) CFRelease(source);
|
||||
}
|
||||
void KeyActionUnicode(uint16_t unicode, int up)
|
||||
{
|
||||
if (up == 0)
|
||||
{
|
||||
//ILIBLOGMESSAGEX("UNICODE: %u [%d]", unicode, up);
|
||||
CGEventRef key = CGEventCreateKeyboardEvent(NULL, 0, true);
|
||||
CGEventKeyboardSetUnicodeString(key, 1, (UniChar*)&unicode);
|
||||
CGEventPost(kCGHIDEventTap, key);
|
||||
CFRelease(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "microstack/ILibParsers.h"
|
||||
|
||||
enum MOUSE_EVENTS {
|
||||
MOUSEEVENTF_LEFTDOWN = 0x0002,
|
||||
@@ -376,5 +377,6 @@ struct keymap_t {
|
||||
|
||||
extern void MouseAction(double absX, double absY, int button, short wheel);
|
||||
extern void KeyAction(unsigned char vk, int up);
|
||||
extern void KeyActionUnicode(uint16_t unicode, int up);
|
||||
|
||||
#endif /* LINUX_EVENTS_H_ */
|
||||
|
||||
@@ -131,6 +131,7 @@ void kvm_send_resolution()
|
||||
|
||||
int kvm_init()
|
||||
{
|
||||
ILibCriticalLogFilename = "KVMSlave.log";
|
||||
int old_height_count = TILE_HEIGHT_COUNT;
|
||||
|
||||
SCREEN_NUM = CGMainDisplayID();
|
||||
@@ -180,6 +181,10 @@ int kvm_server_inputdata(char* block, int blocklen)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MNG_KVM_KEY_UNICODE: // Unicode Key
|
||||
if (size != 7) break;
|
||||
KeyActionUnicode(((((unsigned char)block[5]) << 8) + ((unsigned char)block[6])), block[4]);
|
||||
break;
|
||||
case MNG_KVM_KEY: // Key
|
||||
{
|
||||
if (size != 6 || KVM_AGENT_FD != -1) { break; }
|
||||
|
||||
Reference in New Issue
Block a user