Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

5
QMK help
Post Body

Hi all,

I have a redox keyboard and I'm trying to setup QMK. I have basic functionality working, but I'm trying to achieve the following :

  1. Use a key to act as a layer modifier on hold, and use the same key to toggle to a new layer when tapped.
  2. I'd like to send the "c" keycode when a tap a key, and send the "รง" keycode when I hold the same key. I've tried adding this function to keymap.c

#define TAPPING_TERM 200

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    switch (keycode) {
        case FOO:
            if (record->tap.count && record->event.pressed) {
                tap_code16(FR_CCED);
            } else if (record->event.pressed) {
                tap_code16(FR_C);
            }
            return false;
    }
    return true;
}

When I hit "c", I get the letter as expected, but nothing happens when I hold the same key.

What am I doing wrong?

Thanks

EDIT : Got it working! Thanks for everyone's help.

1) I used tapping toggle (TT) to get QMK to change layer whilst holding a key, and toggle to a layer when tapping the same key. To get this to work properly, I had to set "#define TAPPING_TOGGLE 1" in config.h because the default value is 5 taps to toggle to another layer, and set KC_TRNS in the same key location on the toggle destination layer as the original layer, so that tapping the same key brings you back to the original one correctly.

2) Followed the example code here : https://getreuer.info/posts/keyboards/triggers/index.html#tap-vs.-long-press

#define CUST_TAP_MOD_C LT(0, FR_C)

static bool process_tap_or_long_press_key(
    keyrecord_t* record, uint16_t long_press_keycode) {
  if (record->tap.count == 0) {  // Key is being held.
    if (record->event.pressed) {
      tap_code16(long_press_keycode);
    }
    return false;  // Skip default handling.
  }
  return true;  // Continue default handling.
}

bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  switch (keycode) {
    case CUST_TAP_MOD_C:  // C on tap, รง on hold
      return process_tap_or_long_press_key(record, FR_CCED);
  }

  return true;
}

Author
Account Strength
70%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,474
Link Karma
353
Comment Karma
1,093
Profile updated: 1 day ago
Posts updated: 3 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago