From db6408c795c872e79cd534d4bd73b6f439f33d1f Mon Sep 17 00:00:00 2001 From: jesse Date: Fri, 22 Nov 2013 02:19:57 -0800 Subject: [PATCH] first attempt at macro functionalit --- ArduinoKeyboard.ino | 9 ++++++++- key_defs.h | 5 ++++- keymaps.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ArduinoKeyboard.ino b/ArduinoKeyboard.ino index 509542e8..c2ccb430 100644 --- a/ArduinoKeyboard.ino +++ b/ArduinoKeyboard.ino @@ -199,7 +199,14 @@ void send_key_events(byte layer) } } } else if (mappedKey.flags & SYNTHETIC_KEY) { - if (mappedKey.rawKey == KEY_MOUSE_BTN_L || mappedKey.rawKey == KEY_MOUSE_BTN_M|| mappedKey.rawKey == KEY_MOUSE_BTN_R) { + if(mappedKey.flags & IS_MACRO) { + if (key_toggled_on (switchState)) { + if (mappedKey.rawKey == 1) { + Keyboard.print("Keyboard.IO keyboard driver v0.00"); + } + } + } + else if (mappedKey.rawKey == KEY_MOUSE_BTN_L || mappedKey.rawKey == KEY_MOUSE_BTN_M|| mappedKey.rawKey == KEY_MOUSE_BTN_R) { if (key_toggled_on (switchState)) { Mouse.press(mappedKey.rawKey); } else if (key_is_pressed(switchState)) { diff --git a/key_defs.h b/key_defs.h index 7da66e92..03fa513d 100644 --- a/key_defs.h +++ b/key_defs.h @@ -8,6 +8,9 @@ #define MOUSE_KEY B01000000 #define SYNTHETIC_KEY B10000000 +// we assert that synthetic keys can never have keys held, so we reuse the _HELD bits +#define IS_MACRO B00000001 + #define MOUSE_UP B0001 #define MOUSE_DN B0010 #define MOUSE_L B0100 @@ -26,7 +29,7 @@ #define NoKey (Key){ KEY_FLAGS,0 } - +#define macroKey1 (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MACRO, 1} #define mouseUpL (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_UP | MOUSE_L } diff --git a/keymaps.h b/keymaps.h index e335827a..56900439 100644 --- a/keymaps.h +++ b/keymaps.h @@ -9,7 +9,7 @@ static const Key keymaps[LAYERS][ROWS][COLS] = { }, { { NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, NoKey, NoKey, Key_6, Key_7, Key_8, Key_9, Key_0, NoKey }, - { Key_Backtick, Key_Q, mouseBtnL, mouseBtnM, mouseBtnR, Key_T, NoKey, NoKey, Key_LCurlyBracket, Key_RCurlyBracket, Key_LSquareBracket, Key_RSquareBracket, Key_P, Key_Equals}, + { Key_Backtick, macroKey1, mouseBtnL, mouseBtnM, mouseBtnR, Key_T, NoKey, NoKey, Key_LCurlyBracket, Key_RCurlyBracket, Key_LSquareBracket, Key_RSquareBracket, Key_P, Key_Equals}, { Key_PageUp, mouseL, mouseUp, mouseDn, mouseR, Key_G, Key_Tab, Key_Return, Key_LArrow, Key_DnArrow, Key_UpArrow, Key_RArrow, Key_Semicolon, Key_Quote}, { Key_PageDn, Key_Z, mouseBtnL, mouseBtnM, mouseBtnR, Key_B, Key_Esc, Key_Return, Key_Pipe, Key_M, Key_Comma, Key_Period, Key_Backslash, Key_Minus}, { Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, NextKeymap, NoKey, NoKey, NoKey, NoKey, NextKeymap, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt }