diff options
-rw-r--r-- | DomeKey/HeadphoneKey.h | 1 | ||||
-rw-r--r-- | DomeKey/HeadphoneKey.m | 15 | ||||
-rw-r--r-- | DomeKey/KeyboardSimulator.m | 1 |
3 files changed, 17 insertions, 0 deletions
diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h index 2a74fc1..22e7238 100644 --- a/DomeKey/HeadphoneKey.h +++ b/DomeKey/HeadphoneKey.h @@ -10,6 +10,7 @@ #import <DDHidLib/DDHidAppleMikey.h> #import "dome_key_map.h" +#import "KeyboardSimulator.h" typedef enum KeyPress : BOOL { KeyPressDown = YES, diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index 1d815b2..e955128 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -67,6 +67,21 @@ { NSLog(@"%@", _key_buffer); + NSUInteger count = [_key_buffer count]; + HeadphoneButton trigger[count]; + + for (int i = 0; i < count; i++) { + trigger[i] = (HeadphoneButton)[[_key_buffer objectAtIndex:i] intValue]; + } + + const CKeyActionResult *result = c_run_key_action(trigger, count); + + if (*result->kind == MapKind_Map) { + for (int i = 0; i < strlen(result->action); i++) { + [KeyboardSimulator simpleKeyPressWithKey:result->action[i]]; + } + } + [_key_buffer removeAllObjects]; } diff --git a/DomeKey/KeyboardSimulator.m b/DomeKey/KeyboardSimulator.m index 1465920..6e9d38e 100644 --- a/DomeKey/KeyboardSimulator.m +++ b/DomeKey/KeyboardSimulator.m @@ -18,6 +18,7 @@ NSNumber *key_number = charToKeyCode(aChar); if (key_number == nil) { + NSLog(@"charToKeyCode returned nil"); return; } CGKeyCode key_code = (CGKeyCode)[key_number intValue]; |