ddrcode / qmk_userspace

QMK Userspace
0 stars 0 forks source link

Keychron Q10 compilation fails with encoder enabled #2

Open ddrcode opened 1 year ago

ddrcode commented 1 year ago

The Q10 has encoder, which is working as volume controller with the official Keychron's default keymap. The compilation of the userspace fails though when ENCODER_ENABLE and ENCODER_MAP_ENABLE are set to yes in the userspace's rules.mk file

Compiling: users/ddrcode/ddrcode.c                                                                  [OK]
Compiling: keyboards/keychron/q10/q10.c                                                             [OK]
Compiling: keyboards/keychron/q10/matrix.c                                                          [OK]
Compiling: keyboards/keychron/q10/q10_ansi_stm32l432_ec11/q10_ansi_stm32l432_ec11.c                 [OK]
Compiling: quantum/bitwise.c                                                                        [OK]
Compiling: .build/obj_keychron_q10_q10_ansi_stm32l432_ec11/src/default_keyboard.c                   [OK]
Compiling: quantum/keymap_introspection.c                                                          quantum/keymap_introspection.c: In function 'encodermap_layer_count':
quantum/keymap_introspection.c:24:52: error: invalid application of 'sizeof' to incomplete type 'const uint16_t[][1][2]' {aka 'const short unsigned int[][1][2]'}
 #    define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t))))
                                                    ^
quantum/keymap_introspection.c:27:12: note: in expansion of macro 'NUM_ENCODERMAP_LAYERS'
     return NUM_ENCODERMAP_LAYERS;
            ^~~~~~~~~~~~~~~~~~~~~
quantum/keymap_introspection.c: At top level:
quantum/keymap_introspection.c:24:52: error: invalid application of 'sizeof' to incomplete type 'const uint16_t[][1][2]' {aka 'const short unsigned int[][1][2]'}
 #    define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t))))
                                                    ^
quantum/keymap_introspection.c:30:37: note: in expansion of macro 'NUM_ENCODERMAP_LAYERS'
 _Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers");
                                     ^~~~~~~~~~~~~~~~~~~~~
quantum/keymap_introspection.c:14:27: error: expression in static assertion is not an integer
 #define NUM_KEYMAP_LAYERS ((uint8_t)(sizeof(keymaps) / ((MATRIX_ROWS) * (MATRIX_COLS) * sizeof(uint16_t))))
                           ^
quantum/keymap_introspection.c:30:16: note: in expansion of macro 'NUM_KEYMAP_LAYERS'
 _Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers");
                ^~~~~~~~~~~~~~~~~
quantum/keymap_introspection.c: In function 'encodermap_layer_count':
quantum/keymap_introspection.c:28:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1: all warnings being treated as errors
 [ERRORS]
 | 
 | 
 | 
ddrcode commented 1 year ago

I managed to make it working without the encoder map, but with simple callback, as demonstrated in the QMK documentation.

bool encoder_update_user(uint8_t index, bool clockwise) {
    if (index == 0) { 
        if (clockwise) {
            tap_code_delay(KC_VOLU, 10);
        } else {
            tap_code_delay(KC_VOLD, 10);
        }
    }
    return false;
}

The ticket remains open, as the solution is a workaround only.