Created
January 23, 2019 23:47
-
-
Save dnicolson/7f87f7e05036876be98983f000160486 to your computer and use it in GitHub Desktop.
Support for the corner home button on an iOS keyboard to act as an escape key by analysing Bluetooth packets
This file contains hidden or 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
// clang -framework Carbon iOSKeyboardEscapeKeyEnablerBluetooth.c -o iOSKeyboardEscapeKeyEnablerBluetooth | |
// sudo ./iOSKeyboardEscapeKeyEnablerBluetooth | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <Carbon/Carbon.h> | |
void TriggerEscKey() | |
{ | |
CGEventRef event; | |
event = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)kVK_Escape, true); | |
CGEventPost(kCGSessionEventTap, event); | |
} | |
int main() | |
{ | |
FILE* fp; | |
char path[1035]; | |
fp = popen("sudo /Applications/PacketLogger.app/Contents/Resources/packetlogger 2>/dev/null | grep --line-buffered 'A1.*03.*01 00 00'", "r"); | |
if (fp == NULL) { | |
printf("Failed to run command\n"); | |
exit(1); | |
} | |
while (fgets(path, sizeof(path) - 1, fp) != NULL) { | |
TriggerEscKey(); | |
} | |
pclose(fp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment