Macros for beginner

Hello everyone.

At my work i use MicrosoftOffice with alt-codes a lot (that means, press and hold alt, then type a specific numeric code, then release alt). I use this to enter mathematic symbols, fractions, different spaces etc. in Word-Documents.
Now I would like to have a couple of macros for alt-codes I often use. These macros should work the following: press alt, while alt is pressed, press and release different keypad-numbers, then release alt again.
Unfortunately I am a total beginner in programming a keyboardio. Could someone show me, how I can make a macro like these?

Thank you very much,
kind regards

Hey walrus, I’m not a programmer, and I was able to figure this out. You can do it if you like to tinker.

  1. I’m going to assume that you downloaded the latest version of the firmware and flashed it using Arduino IDE, instructions here: https://github.com/keyboardio/Model01-Firmware

  2. Make sure that you read about creating macros here: https://github.com/keyboardio/Kaleidoscope-Macros

  3. As the instructions say, “To use the plugin, we need to include the header, tell the firmware to use the plugin, place macros on the keymap, and create a special handler function (macroAction) that will tell the plugin what shall happen when macro keys are pressed.”

The following is from my keyboard firmware. It might look confusing at first, but most of those things are already in the firmware. All you have to do is add the macros you want to create, add them somewhere on your keymap, and then tell your keyboard what the macro is supposed to do. For mine, I’ve got a macro for a program launcher (a shortcut I designed to be Ctrl+Cmd+Opt+Shift+L), a macro to activate a program called Moom (Ctrl+Cmd+Opt+Shift+M), a macro to add a reference when I am using Word (Ctrl+Cmd+Opt+Shift+Z), and a macro to add a footnote in Word (Ctrl+Cmd+Opt+Shift+F). Note that for all of these shortcuts, I first defined them either for my operating system or for Microsoft Word. Probably the best thing to do is take a crack at it, and then post your firmware sketch if it doesn’t work.

/* Here is the header (included by default, so you don't have to do anything to this): */
#include <Kaleidoscope.h>
#include <Kaleidoscope-Macros.h>

/* Giving a name to my macros; on your sketch you'll see the default macros named here, and you can just add to the list. I'm pretty sure "enum" is short for "enumerate." */
enum { 
       M_LAUNCH,
       M_MOOM,
       M_ZOTERO,
       M_FOOTNOTE
     };

// In the keymap you will include "M(YourMacroName)" (i.e., instead of Key_Gui I might put "M(M_LAUNCH)" 
First M is to tell that this is a macro, the second M is part of the name of the Macro I have created */

M(M_LAUNCH), M(M_MOOM), M(M_ZOTERO), M(M_FOOTNOTE)

// I put this function right after the keycaps in my firmware; it tells the keyboard what to do when handling my macros:

const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
  switch (macroIndex) {
    
  case M_LAUNCH:
    return MACRODOWN(D(LeftShift), D(LeftAlt), D(LeftControl), D(LeftGui), D(L));
    break;

  case M_MOOM:
    return MACRODOWN(D(LeftShift), D(LeftAlt), D(LeftControl), D(LeftGui), D(Tab));
    break;

  case M_ZOTERO:
    return MACRODOWN(D(LeftShift), D(LeftAlt), D(LeftControl), D(LeftGui), D(Z));
    break;

  case M_FOOTNOTE:
    return MACRODOWN(D(LeftShift), D(LeftAlt), D(LeftControl), D(LeftGui), D(F));
    break;

  }
  return MACRO_NONE;
}

KALEIDOSCOPE_INIT_PLUGINS(Macros);

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

/* You have to include "Macros" in the initialization of your plugins, but again this is done by default */

3 Likes

It occurs to me that for numeric codes, you are probably going to want your keyboard to “tap” those keys rather than hold them all down. So be sure you use T(first_#), T(second_#), etc.

1 Like

Thanks for the tutorial. I hadn’t time to try it out, but it helped me to understand it.
have a nice day.

(Before getting to deep into my spiel, I should mention there’s a plugin for typing unicode symbols directly, and I think it might be one of the core plugins. Kaleidoscope-Unicode)

If you’re open to new things, I use a program in Windows called WinCompose. It follows a different kind of logic for typing arbitrary Unicode characters. You actually type an arbitrary sequence of mnemonically significant keys—any sequence you wish for any output.

It uses the idea of a compose key, which actually has its own keyboard symbol (“⎄”), which I’ll definitely be using if we ever get fully custom key legends.

So you hit your chosen compose key (mine replaces the caps-lock key, with caps-lock accessible via hitting both shift keys), then a sequence: ⎄:) makes a smiley, ⎄", and ⎄". make left and right directional quotes, respectively. I’ve been using directional single quotes (⎄', & ⎄'.) all over this post (this is supposedly typographically correct for apostrophes). I’ve got an em-dash (⎄---) in my first paragraph here. It’s also useful for when I’m typing Esperanto, I kind of emulate the “x system” of typing the “ĉapelliteroj”, where a normal Latin letter is followed by an x (e.g. ⎄cx makes ‘ĉ’, which is also available ‘more sensibly’ by default as ⎄c^).

The real kind of thing compose keys are known for are sensible mnemonics, and I think I just gave a bunch of bad examples. Here’s some better ones: ⎄n~ makes ‘ñ’, ⎄e' makes é, ⎄!? makes ‽. I’m typing ‘⎄’ by typing ⎄[(]). You can make mathematical symbols. ‘≈’ is ⎄~~, ‘≤’ is ⎄<=, ‘∀’ is ⎄AA.

It’s usable ‘out of the box’, but you can add your own compose sequences by using the same kind of file used in Linux to define more sequences (Linux has the compose key functionality built in). Here’s my .XCompose file.

2 Likes