Created
November 16, 2018 18:21
-
-
Save jmercouris/56e841912b70be3f01ece471c9844e64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright © 2017-2018 Atlas Engineer LLC. | |
// Use of this file is governed by the license that can be found in LICENSE. | |
// | |
#import "NextApplication.h" | |
#include <xmlrpc-c/base.h> | |
#include <xmlrpc-c/client.h> | |
#include <xmlrpc-c/config.h> | |
#include "Global.h" | |
@implementation NextApplication | |
- (void)sendEvent:(NSEvent *)event | |
{ | |
if ([event type] == NSEventTypeKeyDown) { | |
NSEventModifierFlags modifierFlags = [event modifierFlags]; | |
char characterCodePressed = [[event charactersIgnoringModifiers] characterAtIndex: 0]; | |
bool controlPressed = (modifierFlags & NSEventModifierFlagControl); | |
bool alternatePressed = (modifierFlags & NSEventModifierFlagOption); | |
bool commandPressed = (modifierFlags & NSEventModifierFlagCommand); | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ | |
xmlrpc_env env = [[Global sharedInstance] getXMLRPCEnv]; | |
const char * const serverUrl = "http://localhost:8081/RPC2"; | |
const char * const methodName = "PUSH-KEY-CHORD"; | |
// Make the remote procedure call | |
xmlrpc_client_call(&env, serverUrl, methodName, | |
"(bbbi)", | |
(xmlrpc_bool) controlPressed, | |
(xmlrpc_bool) alternatePressed, | |
(xmlrpc_bool) commandPressed, | |
(xmlrpc_int) characterCodePressed); | |
//////////////////////////////// | |
// Causes Infinite Loop | |
//////////////////////////////// | |
dispatch_sync(dispatch_get_main_queue(), ^{ | |
[super sendEvent:event]; | |
}); | |
}); | |
return; | |
} else { | |
[super sendEvent:event]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment