qmk_configurator icon indicating copy to clipboard operation
qmk_configurator copied to clipboard

Can I use ANY to map such keys combination?

Open ZaxonXP opened this issue 2 years ago • 15 comments

Information

  • [X] None of the other issue templates apply

Description

I was reading the documentation about QMK Configurator, but I still cannot figure out how to program following sequence:

I need to press and hold the * from the keypad, then press 1 from the keypad, then release the *. Can this be done with ANY command?

Kind regards, Piotr

ZaxonXP avatar Jan 05 '22 12:01 ZaxonXP

This would be a macro command. You can't do this solely in QMK Configurator. What's the use case?

noroadsleft avatar Jan 05 '22 21:01 noroadsleft

I have Keyboard Mouse switch (KM switch) attached to the keyboard and mouse with 4 PC connected. In order to switch between PC's I need to hold asterisk on the keypad and press 1/2/3/4 (to select respective PC) then release all the keys. However I do not know how to program such macro.

ZaxonXP avatar Jan 05 '22 21:01 ZaxonXP

Okay, you can compile this in QMK Configurator, but it can't be set up fully in Configurator.

1. Set up the keymap for your keyboard

Do this as you normally would, then instead of hitting Compile, download/export the keymap.json.

2. Add the macro functionality

When you download the JSON and open it in a text editor, you'll find something like this:

{
  "version": 1,
  "notes": "",
  "documentation": "\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n",
  "keyboard": "handwired/k_numpad17",
  "keymap": "handwired_k_numpad17_layout_numpad_5x4_mine",
  "layout": "LAYOUT_numpad_5x4",
  "layers": [
    [
      "KC_NLCK",
      "KC_PSLS",
      "KC_PAST",
      "KC_PMNS",
      "KC_P7",
      "KC_P8",
      "KC_P9",
      "KC_P4",
      "KC_P5",
      "KC_P6",
      "KC_PPLS",
      "KC_P1",
      "KC_P2",
      "KC_P3",
      "KC_P0",
      "KC_PDOT",
      "KC_PENT"
    ]
  ],
  "author": ""
}

Below the line that says "layout": "LAYOUT_numpad_5x4",, add the following:

  "macros": [
    [
      {"action": "down", "keycodes": ["PAST"]},
      {"action": "tap", "keycodes": ["P1"]},
      {"action": "up","keycodes": ["PAST"]}
    ],
    [
      {"action": "down", "keycodes": ["PAST"]},
      {"action": "tap", "keycodes": ["P2"]},
      {"action": "up","keycodes": ["PAST"]}
    ],
    [
      {"action": "down", "keycodes": ["PAST"]},
      {"action": "tap", "keycodes": ["P3"]},
      {"action": "up","keycodes": ["PAST"]}
    ],
    [
      {"action": "down", "keycodes": ["PAST"]},
      {"action": "tap", "keycodes": ["P4"]},
      {"action": "up","keycodes": ["PAST"]}
    ]
  ],

Then, somewhere in your keymap, assign the following keycodes:

  • MACRO_0
  • MACRO_1
  • MACRO_2
  • MACRO_3

These keycodes correspond to the macros defined – MACRO_0 to the first block (KC_PAST down, tap KC_P1, release KC_PAST), MACRO_1 to the second, and so on.

3. Import and compile

Import the keymap.json back into QMK Configurator, and compile as normal.

noroadsleft avatar Jan 06 '22 03:01 noroadsleft

Does this work with the online editor here? https://config.qmk.fm/#//

I tried this to get copy and paste keys.

{
  "layers": [
    [
      "MACRO_0",
      "MACRO_1"
    ]
  ],
  "macros": [
    [
      {"action": "down", "keycodes": ["LCTL"]},
      {"action": "tap", "keycodes": ["C"]},
      {"action": "up","keycodes": ["LCTL"]}
    ],
    [
      {"action": "down", "keycodes": ["LCTL"]},
      {"action": "tap", "keycodes": ["V"]},
      {"action": "up","keycodes": ["LCTL"]}
    ]
  ]
}

After importing, compiling and flashing the keys don't seem to do anything.

donhilion avatar Feb 19 '22 06:02 donhilion

@donhilion Yours can be done with the native keycodes present on QMK Configurator:

image

Drag the LCTL() keycode (Quantum tab under Mod key combinations) onto the desired keys, then drag C and V, respectively, into the inner boxes on the keymap.

noroadsleft avatar Feb 19 '22 22:02 noroadsleft

That works, thanks! But there remains the question: What is wrong with this configuration or the steps taken?

donhilion avatar Feb 24 '22 08:02 donhilion

@noroadsleft Hi, I have problem with my macro. I wanted to have macro to make "->" arrow, but it doesn't work. I modified my json file like this

"keymap": "esnos",
  "macros": [
    [
      {"action": "tap", "keycodes": ["KC_MINUS", "KC_GT"]}
    ]
  ],
  "layout": "LAYOUT_split_3x5_2",
  "layers": [
    [
      "KC_ESC",

and later in code I have:

      "KC_ENT",
      "QK_MACRO_0",
      "KC_LPRN",
      "KC_RPRN",

and in qmk configurator uploaded json file looks like this: https://imgur.com/a/zaABNMJ but it doesn't work. Also, if I use MACRO_0 instead of QK_MACRO_0, I have this compilation error: gmake: *** ap_introspection.o] Error 1

After uploading firmware to my keyboard, this button doesn't work, it doesn't send any signal according to KeyboardStateView.

Could you please help me? I can't find anybody on internet who have macro with json file.

Esnos33 avatar Mar 09 '23 16:03 Esnos33

@Esnos33,

For your tap action, try this:

       {"action": "tap", "keycodes": ["MINS"]},
       {"action": "tap", "keycodes": ["GT"]}

noroadsleft avatar Mar 09 '23 19:03 noroadsleft

@noroadsleft I have something like this:

  "macros": [
    [
      {"action": "tap", "keycodes": ["MINS"]},
      {"action": "tap", "keycodes": ["GT"]}
    ]

and QK_MACRO_0 in code, but still it doesn't work

Esnos33 avatar Mar 09 '23 21:03 Esnos33

@Esnos33

I want to input "=>" through one key, the same idea as you. I thought this is a bug of qmk configurator. I directly use the qmk firmware to compile that works! In layers, the keycode is set to 'QK_MACRO_0 ' that is correct

The following are my macros.

"macros": [
    [
      {
        "action": "tap",
        "keycodes":["EQL"]
      },
      {
        "action": "down",
        "keycodes":["LSFT"]
      },
      {
        "action": "tap",
        "keycodes":["DOT"]
      },{
        "action": "tap",
        "keycodes":["LSFT"]
      }
    ]
  ]

The qmk firmware overview is here : https://docs.qmk.fm/#/newbs?id=overview For more macros information is here : https://docs.qmk.fm/#/feature_macros?id=macros

Jefferycheng avatar Mar 11 '23 09:03 Jefferycheng

@Jefferycheng Ok, I will try directly compile firmware and see what happens, thanks for answer.

Esnos33 avatar Mar 11 '23 09:03 Esnos33

@Jefferycheng I must admint, whole process is very hard just to have this one arrow, I will use other software to have this arrow

Esnos33 avatar Mar 11 '23 18:03 Esnos33

@Esnos33 I agree with you the whole process is long and complex.

Even though I have run the process before, I often forget how to do this.

So now, I am recording the whole process in my blog here: https://medium.com/p/9b9bc0bad275

Wish this can help you.

Jefferycheng avatar Mar 13 '23 08:03 Jefferycheng

@Jefferycheng It works! Thanks for help, I really appreciate it.

Esnos33 avatar Mar 13 '23 08:03 Esnos33

I've conducted some tests on my end. Here are the observations:

  • When compiled locally, the macro works as expected.
  • When the same file is uploaded to https://config.qmk.fm/, the compilation succeeds, but the keyboard does not recognize the macro.

Sidenote:
@Jefferycheng, the QMK documentation provides a tip on simplifying the process. It suggests assigning a default keyboard and keymaps. This allows you to run the following command: QMK compile -e BUILD_DIR="./builds"

Additional Information:
The entire local build process took me approximately 10 minutes. However, installing QMK from Homebrew took over an hour, which I'm not sure is typical behaviour.

Nairda015 avatar Sep 21 '23 11:09 Nairda015