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

compile error for .h file #8

Open
tompi opened this issue Aug 31, 2024 · 4 comments
Open

compile error for .h file #8

tompi opened this issue Aug 31, 2024 · 4 comments

Comments

@tompi
Copy link

tompi commented Aug 31, 2024

Hey, probably me doing something stupid... my keymap.c file(converted by qmk tool) looks like this:

#include QMK_KEYBOARD_H
#if __has_include("keymap.h")
#    include "keymap.h"
#endif



enum custom_keycodes {
    SMTD_KEYCODES_BEGIN = SAFE_RANGE,
    CKC_A, // reads as C(ustom) + KC_A, but you may give any name here
    CKC_R,
    CKC_S,
    CKC_T,
    CKC_N,
    CKC_E,
    CKC_I,
    CKC_O,
    SMTD_KEYCODES_END
}

#include "sm_td.h"

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    if (!process_smtd(keycode, record)) {
        return false;
    }
    return true;
}

void on_smtd_action(uint16_t keycode, smtd_action action, uint8_t tap_count) { 
    switch (keycode) {
        SMTD_MT(CKC_A, KC_A, KC_LEFT_GUI)
        SMTD_MT(CKC_R, KC_R, KC_LEFT_ALT)
        SMTD_MT(CKC_S, KC_S, KC_LEFT_CTRL)
        SMTD_MT(CKC_T, KC_T, KC_LSFT)
        SMTD_MT(CKC_N, KC_N, KC_RSFT)
        SMTD_MT(CKC_E, KC_E, KC_REFT_CTRL)
        SMTD_MT(CKC_I, KC_I, KC_REFT_ALT)
        SMTD_MT(CKC_O, KC_O, KC_REFT_GUI)
    }
}

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    [0] = LAYOUT_split_3x5_3(KC_Q, KC_W, KC_F, KC_P, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, CKC_A, CKC_R, CKC_S, CKC_T, KC_G, KC_M, CKC_N, CKC_E, CKC_I, CKC_O, KC_Z, KC_X, KC_C, KC_D, LT(5,KC_V), LT(1,KC_K), KC_H, KC_COMM, KC_DOT, KC_SLSH, LT(6,KC_ESC), LT(3,KC_SPC), LT(5,KC_TAB), LT(1,KC_DEL), LT(2,KC_BSPC), LT(4,KC_ENT)),
    [1] = LAYOUT_split_3x5_3(KC_VOLU, KC_WH_L, KC_MS_U, KC_WH_U, KC_WH_R, KC_NO, KC_NO, KC_NO, KC_NO, QK_RBT, KC_MS_L, KC_BTN2, KC_BTN1, KC_MS_R, KC_MUTE, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLD, KC_MNXT, KC_MS_D, KC_WH_D, KC_MPLY, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_NO),
    [2] = LAYOUT_split_3x5_3(NK_TOGG, KC_HOME, KC_DEL, KC_PGUP, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_LEFT, KC_UP, KC_RGHT, KC_NO, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_END, KC_DOWN, KC_PGDN, KC_NO, KC_NO, KC_BTN1, KC_BTN2, KC_BTN3, KC_BTN4, KC_NO, KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_NO),
    [3] = LAYOUT_split_3x5_3(KC_NO, KC_NO, KC_NO, KC_NO, KC_WH_U, KC_AT, KC_UNDS, KC_PIPE, KC_GRV, KC_PERC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_TOG, KC_HASH, KC_TAB, KC_EXLM, KC_DQUO, KC_DLR, KC_BTN4, KC_BTN3, KC_BTN2, KC_BTN1, KC_WH_D, KC_TILD, KC_QUOT, KC_BSLS, KC_SLSH, KC_AMPR, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, KC_NO),
    [4] = LAYOUT_split_3x5_3(KC_GRV, KC_CIRC, KC_LT, KC_GT, KC_SCLN, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_LCBR, KC_RCBR, KC_LPRN, KC_RPRN, KC_AT, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MINS, KC_EXLM, KC_LBRC, KC_RBRC, KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_NO),
    [5] = LAYOUT_split_3x5_3(QK_RBT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_F4, KC_F5, KC_F6, KC_F11, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_F1, KC_F2, KC_F3, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
    [6] = LAYOUT_split_3x5_3(RGB_SPI, RGB_VAI, RGB_SAI, RGB_HUI, RGB_MOD, KC_PPLS, KC_P7, KC_P8, KC_P9, KC_PAST, EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS, RGB_TOG, KC_PMNS, KC_P4, KC_P5, KC_P6, KC_PSLS, RGB_SPD, RGB_VAD, RGB_SAD, RGB_HUD, RGB_RMOD, KC_PDOT, KC_P1, KC_P2, KC_P3, KC_PEQL, KC_NO, KC_NO, KC_NO, KC_0, KC_COMM, KC_P0)
};

#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {

};
#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)

When trying to make, I get this error:

make cheapino:tompi:flash
QMK Firmware 0.26.0
Making cheapino with keymap tompi and target flash

arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling: quantum/keymap_introspection.c                                                          In file included from ./keyboards/cheapino/keymaps/tompi/keymap.c:21,
                 from quantum/keymap_introspection.c:5:
./keyboards/cheapino/keymaps/tompi/sm_td.h:96:9: error: expected ';', identifier or '(' before 'enum'
   96 | typedef enum {
      |         ^~~~
./keyboards/cheapino/keymaps/tompi/sm_td.h:103:67: error: expected declaration specifiers or '...' before 'smtd_timeout'

P.S. I also think you got a typo on the readme, in the code for on_smtd_action, you close the scope at once {}, I guess the "}" should not be there?

@stasmarkin
Copy link
Owner

stasmarkin commented Aug 31, 2024

P.S. I also think you got a typo on the readme, in the code for on_smtd_action

You are right! Thank you for pointing that out.

expected ';', identifier or '(' before 'enum'

Well, that was tricky. Since #include "sm_td.h" comes right after custom_keycodes enum definition, the compiler expects some extra params for custom_keycodes (like typedef or something).
The easiest thing to fix it is just add ; after custom_keycodes definition, like this:

enum custom_keycodes {
    SMTD_KEYCODES_BEGIN = SAFE_RANGE,
    CKC_A, // reads as C(ustom) + KC_A, but you may give any name here
    CKC_R,
    CKC_S,
    CKC_T,
    CKC_N,
    CKC_E,
    CKC_I,
    CKC_O,
    SMTD_KEYCODES_END
};

That must fix this issue.

Thank you for reporting this problem, I've updated README accordingly . And sorry for inconvenience, I'm not that fluent in C, so sometimes I do stupid mistakes that have to be fixed with ugly workarounds. I will fix nicely whole include thing in next version.

@tompi
Copy link
Author

tompi commented Sep 1, 2024

Thank you, that fixed it.

Got it running now, but unfortunately it seems rolling seems worse, like "ne", where e doubles as shift very often results in capital e now, I probably need to tweak some settings...

@tompi tompi closed this as completed Sep 1, 2024
@stasmarkin
Copy link
Owner

Try adding that to your keymap.c that:

uint32_t get_smtd_timeout(uint16_t keycode, smtd_timeout timeout) {
    if (keycode == CKC_N && timeout == SMTD_TIMEOUT_RELEASE) return 35;

    return get_smtd_timeout_default(timeout);
}

By default SMTD_TIMEOUT_RELEASE is 50. So you need to find a number, that would work for you. The smaller the number, the less accurate the N macro will be for other combos. So you need the biggest number that will work for you for N+E keystrokes.

@stasmarkin stasmarkin reopened this Sep 1, 2024
@stasmarkin
Copy link
Owner

Please, don't close an issues :) I will aggregate opened issues and update documentation with them

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

2 participants