Macros / TapDance with Chrysalis 0.4

Hi everyone,

I have been using Chrysalis 0.4 and it has been great. I would like to also use the macro or tapdance plugin, but chrysalis only shows numbers that I can select for each. Do I need to roll my own custom firmware to use these features? Say, create macro #1 in my custom firmware, flash it, then select macro #1 in Chrysalis?

Thanks!

At the moment, yes. We are planning to make it easier than that, but we’re not there yet, so for the time being, to use macros and TapDance, you’ll have to roll your own firmware first, indeed.

2 Likes

Newbie question, how do you do that? I mean, how do I add that to the firmware? An example would be highly appreciated (which file to modify, some sample code, etc.).

What do I have now? A brand new Atreus :smile: Chrysalis installed and a “blank” firmware as the one below. What do I want to do? On my old keyboard I mapped karabiner to map [CapsLock] to [alt+ctrl+cmnd+shift], and I mapped that in Hammerspoon as a “hyper” command. My Atreus does not have a caps lock, so I want to map this to a hold on [?]. Any ideas? Thank you!!

P.S. How the interaction between Chrysalis and Kaleidoscope works?

/* -- mode: c++ --

  • Atreus – Chrysalis-enabled Sketch for the Keyboardio Atreus
  • Copyright (C) 2018, 2019 Keyboard.io, Inc
  • This program is free software; you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation; either version 2 of the License, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details.
  • You should have received a copy of the GNU General Public License along
  • with this program; if not, write to the Free Software Foundation, Inc.,
  • 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */

#ifndef BUILD_INFORMATION
#define BUILD_INFORMATION “locally built”
#endif

#include “Kaleidoscope.h”
#include “Kaleidoscope-EEPROM-Settings.h”
#include “Kaleidoscope-EEPROM-Keymap.h”
#include “Kaleidoscope-FocusSerial.h”
#include “Kaleidoscope-Macros.h”
#include “Kaleidoscope-MouseKeys.h”
#include “Kaleidoscope-OneShot.h”
#include “Kaleidoscope-Qukeys.h”
#include “Kaleidoscope-SpaceCadet.h”

#define MO(n) ShiftToLayer(n)
#define TG(n) LockLayer(n)

enum {
MACRO_QWERTY,
MACRO_VERSION_INFO
};

#define Key_Exclamation LSHIFT(Key_1)
#define Key_At LSHIFT(Key_2)
#define Key_Hash LSHIFT(Key_3)
#define Key_Dollar LSHIFT(Key_4)
#define Key_Percent LSHIFT(Key_5)
#define Key_Caret LSHIFT(Key_6)
#define Key_And LSHIFT(Key_7)
#define Key_Star LSHIFT(Key_8)
#define Key_Plus LSHIFT(Key_Equals)

enum {
QWERTY,
FUN,
UPPER
};

/* INDENT-OFF */
KEYMAPS(
[QWERTY] = KEYMAP_STACKED
(
Key_Q ,Key_W ,Key_E ,Key_R ,Key_T
,Key_A ,Key_S ,Key_D ,Key_F ,Key_G
,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B, Key_Backtick
,Key_Esc ,Key_Tab ,Key_LeftGui ,Key_LeftShift ,Key_Backspace ,Key_LeftControl

             ,Key_Y     ,Key_U      ,Key_I     ,Key_O      ,Key_P
             ,Key_H     ,Key_J      ,Key_K     ,Key_L      ,Key_Semicolon

,Key_Backslash,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash
,Key_LeftAlt ,Key_Space ,MO(FUN) ,Key_Minus ,Key_Quote ,Key_Enter
),

[FUN] = KEYMAP_STACKED
(
Key_Exclamation ,Key_At ,Key_UpArrow ,Key_Dollar ,Key_Percent
,Key_LeftParen ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_RightParen
,Key_LeftBracket ,Key_RightBracket ,Key_Hash ,Key_LeftCurlyBracket ,Key_RightCurlyBracket ,Key_Caret
,TG(UPPER) ,Key_Insert ,Key_LeftGui ,Key_LeftShift ,Key_Delete ,Key_LeftControl

           ,Key_PageUp   ,Key_7 ,Key_8      ,Key_9 ,Key_Backspace
           ,Key_PageDown ,Key_4 ,Key_5      ,Key_6 ,___

,Key_And ,Key_Star ,Key_1 ,Key_2 ,Key_3 ,Key_Plus
,Key_LeftAlt ,Key_Space ,___ ,Key_Period ,Key_0 ,Key_Equals
),

[UPPER] = KEYMAP_STACKED
(
Key_Insert ,Key_Home ,Key_UpArrow ,Key_End ,Key_PageUp
,Key_Delete ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_PageDown
,M(MACRO_VERSION_INFO) ,Consumer_VolumeIncrement ,XXX ,XXX ,___ ,___
,MoveToLayer(QWERTY) ,Consumer_VolumeDecrement ,___ ,___ ,___ ,___

        ,Key_UpArrow   ,Key_F7              ,Key_F8          ,Key_F9         ,Key_F10
        ,Key_DownArrow ,Key_F4              ,Key_F5          ,Key_F6         ,Key_F11

,___ ,XXX ,Key_F1 ,Key_F2 ,Key_F3 ,Key_F12
,___ ,___ ,MoveToLayer(QWERTY) ,Key_PrintScreen ,Key_ScrollLock ,Consumer_PlaySlashPause
)
)
/* INDENT-ON */

KALEIDOSCOPE_INIT_PLUGINS(
EEPROMSettings,
EEPROMKeymap,
Focus,
FocusEEPROMCommand,
FocusSettingsCommand,
Qukeys,
SpaceCadet,
OneShot,
Macros,
MouseKeys
);

const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
switch (macroIndex) {
case MACRO_QWERTY:
// This macro is currently unused, but is kept around for compatibility
// reasons. We used to use it in place of MoveToLayer(QWERTY), but no
// longer do. We keep it so that if someone still has the old layout with
// the macro in EEPROM, it will keep working after a firmware update.
Layer.move(QWERTY);
break;
case MACRO_VERSION_INFO:
if (keyToggledOn(keyState)) {
Macros.type(PSTR("Keyboardio Atreus - Kaleidoscope "));
Macros.type(PSTR(BUILD_INFORMATION));
}
break;
default:
break;
}

return MACRO_NONE;
}

void setup() {
Kaleidoscope.setup();
SpaceCadet.disable();
EEPROMKeymap.setup(10);
}

void loop() {
Kaleidoscope.loop();
}

1 Like

Reading the doc (:tm:) is always a fist thing to do, and the Kaleidoscope documentation is good : you will find the Macro plugin doc in docs/plugins/Kaleidoscope-Macros.md (a web version is here : Macros — Kaleidoscope documentation for simpler access).
Basically, add a MACRO_MYMACRO in the enum and add a case MACRO_MYMACRO: in the switch (macroIndex) does the job.

Depending on the way you make your change, make flash or the Arduino arrow will compile and flash the new firmware on the keyboard.

You can then assign the macro where you want on your keymap !

Good luck, it’s simple when you know how, but sometimes difficult to explain depending from where you came technically :slight_smile:

1 Like

Thanks a lot for the response…doing some progress :smile:

So, I’ve done the following:
a) On Chrysalis, on a key I went ahead and assigned it to MACRO #1 (From the Macros accordion tab). I saved the change to the keyboard.
b)On the firmware (using Arduino, but will switch so I can version control) I made two changes to the original code:
enum {
MACRO_QWERTY,
MACRO_VERSION_INFO,
MACRO_HYPER
};
This is, I added the MACRO_HYPER. Then I modified the macroAction method:
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
switch (macroIndex) {
case MACRO_QWERTY:
// This macro is currently unused, but is kept around for compatibility
// reasons. We used to use it in place of MoveToLayer(QWERTY), but no
// longer do. We keep it so that if someone still has the old layout with
// the macro in EEPROM, it will keep working after a firmware update.
Layer.move(QWERTY);
break;
case MACRO_VERSION_INFO:
if (keyToggledOn(keyState)) {
Macros.type(PSTR("Keyboardio Atreus - Kaleidoscope "));
Macros.type(PSTR(BUILD_INFORMATION));
}
break;
case MACRO_HYPER:
return MACRO(T(U));
break;

  default:
    break;
  }
  return MACRO_NONE;
}

For now, I just intend to “type” a U to understand how it works. However, nothing happens :thinking:

Any ideas?

Thank you, I appreciate you helping me out!

P.S. How can I add formatted code snippets? Will help others later on :wink:

Discourse (i.e. this forum) uses Markdown formatting, so you can use backticks to format something as “code” (preformatted text), like so: `foo`
For multi-line code blocks, use three backticks together at the start and end: ```

1 Like

You can do that with the Qukeys plugin, which is already included in your sketch, Try adding one line to your setup() function:

void setup() {
  QUKEYS(kaleidoscope::plugin::Qukey(0, KeyAddr(2, 11), Key_Hyper));
  Kaleidoscope.setup();
  SpaceCadet.disable();
  EEPROMKeymap.setup(10);
}

[Note: you don’t need to use a plugin to just get a “hyper” (or other) combination modifier. For example, to get a shift + option + command: LSHIFT(LALT(Key_LeftGui)). There are two commonly used ones pre-defined: Key_Meh & Key_Hyper.]

2 Likes

Thank you @merlin and @Rom1deTroyes, your help is greatly appreciated.

Two questions.

a) The macro alternative worked really well. Thanks for that. I was lost about the KeyAddr(x,y), but now is clear and makes al sense. Although the solution works, I am still curious about how to make the macros work. I.e, how can I map the macros from Chrysalis to the Macros from the firmware?

b) I need to write both in English and Spanish. The most challenging aspect of my Atreus has been accents. Before, I would switch my layout (from Mac) to Spanish and [+a would result in á. Now, I don’t have a handy [. What I am thinking is to write a tap dance, that when I type quickly a, I get á. This means I need to map that TapDance to Opt + e + a. Any ideas of how to do that?

I promise to help with a beginners tutorial in Spanish soon :slight_smile: