Author Topic: New to QMK, looking for some help with macros  (Read 4142 times)

0 Members and 1 Guest are viewing this topic.

Offline clee290

  • Thread Starter
  • Posts: 43
New to QMK, looking for some help with macros
« on: Thu, 06 July 2017, 15:15:39 »
Some context: I'm using a program called Synergy, which is a network-based KVM. Within the program's settings, I've created toggles to switch between my machines (toggles are Ctrl+[ and Ctrl+]).

What I'm looking to do is create a macro that will activate one of the toggles and also switch to another keyboard layer.

This is what I have so far: 
Code: [Select]
case 1:
                return MACRO(D(LCTL), T(LBRC), U(LCTL), END);

So far, that macro works. This does Ctrl+[ and switches to my Mac, so I've been trying to add something to get my keyboard to switch to my Mac layer.

I've tried this:
Code: [Select]
case 1:
                return MACRO(D(LCTL), T(LBRC), U(LCTL), T(TO(MAC)), END);

And it didn't work. I also tried defining it. I added
Code: [Select]
#define KC_TOMAC TO(MAC) to my keymap file, but it didn't work. Maybe I'm supposed to put the definition somewhere else? Again, I'm new to QMK, so I'm sure that I'm doing something wrong. Hopefully someone has some suggestions for me to try.

Offline hernianrunner

  • Posts: 2
  • Location: Japan
Re: New to QMK, looking for some help with macros
« Reply #1 on: Thu, 06 July 2017, 16:34:20 »
MACRO contains key up, key down, wait, etc... but not swiching layers.
See tmk_core\common\action_macro.c.

Call layer_on() or layer_off() to activate/deactivate layer, within your action_get_macro function().

Quote
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
   switch(id) {
      case SOME_ID:
        if (record->event.pressed) {
             layer_on(/* activate layer id */);
             layer_off(/* deactivate layer id */);
             return MACRO( /* your key sequence */ END);

I'm not sure, but this modification helps you, maybe.


Offline clee290

  • Thread Starter
  • Posts: 43
Re: New to QMK, looking for some help with macros
« Reply #2 on: Thu, 06 July 2017, 17:16:19 »
MACRO contains key up, key down, wait, etc... but not swiching layers.
See tmk_core\common\action_macro.c.

Call layer_on() or layer_off() to activate/deactivate layer, within your action_get_macro function().

Quote
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
   switch(id) {
      case SOME_ID:
        if (record->event.pressed) {
             layer_on(/* activate layer id */);
             layer_off(/* deactivate layer id */);
             return MACRO( /* your key sequence */ END);

I'm not sure, but this modification helps you, maybe.

Thanks for the reply! Yea, that's what I sort of figured. That's why I tried to define it as a keycode, but maybe I did it wrong or put it in the wrong file (might try in the keycode.h file).

And thanks for the suggestion, I'll give this a try later as well!

Offline clee290

  • Thread Starter
  • Posts: 43
Re: New to QMK, looking for some help with macros
« Reply #3 on: Thu, 06 July 2017, 18:46:07 »
MACRO contains key up, key down, wait, etc... but not swiching layers.
See tmk_core\common\action_macro.c.

Call layer_on() or layer_off() to activate/deactivate layer, within your action_get_macro function().

Quote
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
   switch(id) {
      case SOME_ID:
        if (record->event.pressed) {
             layer_on(/* activate layer id */);
             layer_off(/* deactivate layer id */);
             return MACRO( /* your key sequence */ END);

I'm not sure, but this modification helps you, maybe.

Thanks for the reply! Yea, that's what I sort of figured. That's why I tried to define it as a keycode, but maybe I did it wrong or put it in the wrong file (might try in the keycode.h file).

And thanks for the suggestion, I'll give this a try later as well!

Your method worked! Just wanted to thank you again for the help!