Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTL_T(LCTL(KC_A)) not working #281

Closed
jasontwong opened this issue Apr 23, 2016 · 9 comments
Closed

CTL_T(LCTL(KC_A)) not working #281

jasontwong opened this issue Apr 23, 2016 · 9 comments

Comments

@jasontwong
Copy link
Contributor

I'm trying to use the code: CTL_T(LCTL(KC_A)) and it doesn't seem to work. The expected functionality would be to do CTRL + A on tap and CTRL on hold. Am I using it incorrectly?

@eltang
Copy link
Contributor

eltang commented Apr 23, 2016

You can't chain those like that! You have to use a custom macro. Here is a simple frame into which you can put your code.

case 0:
    if (record->event.pressed) {
        if (record->tap.count && !record->tap.interrupted) {
            // tap press action
        }
        else {
            record->tap.count = 0;
            // hold press action
        }
    }
    else {
        if (record->tap.count) {
            // tap release action
        }
        else {
            // hold release action
        }
        record->tap.count = 0;
    }
    break;

@jasontwong
Copy link
Contributor Author

I figured you couldn't since it says it takes a kc. I tried implementing the macro but only got the hold portion to work. Can anyone help?

    case 0:
      if (record->event.pressed) {
        if (record->tap.count) {
          if (record->tap.interrupted) {
            record->tap.count = 0;
            // hold press action
            register_code(KC_LCTRL);
          } else {
            // tap press action
            return MACRO( D(LCTRL), T(A), U(LCTRL), END  );
          }
        } else {
          // hold press action
          register_code(KC_LCTRL);
        }
      } else {
        if (record->tap.count) {
          // tap release action
          return MACRO( D(LCTRL), T(A), U(LCTRL), END  );
        } else {
          // hold release action
          unregister_code(KC_LCTRL);
        }
        record->tap.count = 0;
      }
      break;

@eltang
Copy link
Contributor

eltang commented Apr 23, 2016

Oops, I forgot to mention that you have to call the macro in a special way. You have to put F(0) in your keymaps array and put [0] = ACTION_MACRO_TAP(0) in your fn_actions array. Also, notice that the keyboard shortcut will be executed twice if you tap the key to which this macro is bound.

@sboesebeck
Copy link
Contributor

I did similar things with a Macro using the timer functions, and, if you want to use the full keycode (KC_LCTRL) you can use the Macro-Function DOWN instead of D.

Then you can also use international keycodes, e.g. MACRO(DOWN(DE_OSX_AE),TYPE(KC_1),UP(DE_OSX_ACUT)) - you cannot combined keycodes there though. At least as I understand it. Like DE_OSX_QUOT will not work, as it is LSFT(DE_OSX_HASH).

The ErgodoxMacroGenerator actually generates macros for that purpose - at least for me, they work. Have a look at the osx_de and osx_de_experimental keymaps, hope that'll help...

cheers,

Stephan

Am 23.04.2016 um 22:35 schrieb Jason T. Wong notifications@github.com:

I figured you couldn't since it says it takes a kc. I tried implementing the macro but only got the hold portion to work. Can anyone help?

case 0:
  if (record->event.pressed) {
    if (record->tap.count) {
      if (record->tap.interrupted) {
        record->tap.count = 0;
        // hold press action
        register_code(KC_LCTRL);
      } else {
        // tap press action
        return MACRO( D(LCTRL), T(A), U(LCTRL), END  );
      }
    } else {
      // hold press action
      register_code(KC_LCTRL);
    }
  } else {
    if (record->tap.count) {
      // tap release action
      return MACRO( D(LCTRL), T(A), U(LCTRL), END  );
    } else {
      // hold release action
      unregister_code(KC_LCTRL);
    }
    record->tap.count = 0;
  }
  break;


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub #281 (comment)

@jasontwong
Copy link
Contributor Author

Thanks for all the help! I got everything working. I felt really limited when using the massdrop keyboard configurator. Now I'm overwhelmed with options! I'll make a PR to add my keymap.

@eltang
Copy link
Contributor

eltang commented Apr 24, 2016

So what was the problem?

@jasontwong
Copy link
Contributor Author

Sorry, the solution was to use the F(0) combined with ACTION_MACRO_TAP in fn_actions. Working code below.

const uint16_t PROGMEM fn_actions[] = {
  [0] = ACTION_MACRO_TAP(0)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) // this is the function signature -- just copy/paste it into your keymap file as it is.
{
  switch(id) {
    case 0:
      if (record->event.pressed) {
        if (record->tap.count) {
          if (record->tap.interrupted) {
            record->tap.count = 0;
            // hold press action
            register_code(KC_LCTL);
          } else {
            // tap press action
            return MACRO( D(LCTL), T(A), U(LCTL), END  );
          }
        } else {
          // hold press action
          register_code(KC_LCTL);
        }
      } else {
        if (record->tap.count) {
          // tap release action
        } else {
          // hold release action
          unregister_code(KC_LCTL);
        }
        record->tap.count = 0;
      }
      break;
  }
  return MACRO_NONE;
};

@eltang
Copy link
Contributor

eltang commented Apr 24, 2016

Awesome!

@eltang
Copy link
Contributor

eltang commented Apr 26, 2016

@jasontwong I updated the code template.

BlueTufa pushed a commit to BlueTufa/qmk_firmware that referenced this issue Aug 6, 2021
zjg pushed a commit to zjg/qmk_firmware that referenced this issue Dec 2, 2022
* feat: added ik75 still error

- quantum/vial_ensure_keycode.h:164:1: error: static assertion failed: ""
 _Static_assert(KC_LSPO == 0x5CD7, "");

* fix: add via settings

* fix: disable unused matrix for firmware size

- remove matrix that causes error

* feat: use home as default layout

* fix: rotary click is K4F should be 4,15 not 0,14

* refactor: disable some matrix to free some bytes

* feat: remove more bad rgb for bigger memory and add restart button (not bootloader)

* fix: undetected keyboard when pc shutdown

- sometimes need to replug or reflash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants