diff options
author | jack <[email protected]> | 2023-03-11 10:24:19 -0700 |
---|---|---|
committer | jack <[email protected]> | 2023-03-11 10:24:19 -0700 |
commit | 67869303060ca3aa4056d0275890c19da24c366b (patch) | |
tree | a6cfbac8fff7007b19519c9c04f148d4f687be9f | |
parent | 60e0c4c39bc1fec334ade53c484bd2cf3d4244c0 (diff) | |
download | qmk_me-67869303060ca3aa4056d0275890c19da24c366b.tar.gz qmk_me-67869303060ca3aa4056d0275890c19da24c366b.zip |
clean up function calls and keylogger, add macro
-rw-r--r-- | keymaps/kyria/keymap.c | 2 | ||||
-rw-r--r-- | keymaps/onekey/halconf.h | 5 | ||||
-rw-r--r-- | keymaps/onekey/keymap.c | 59 | ||||
-rw-r--r-- | keymaps/onekey/mcuconf.h | 6 | ||||
-rw-r--r-- | keymaps/onekey/rules.mk | 1 | ||||
-rw-r--r-- | waffle/oled.c | 26 | ||||
-rw-r--r-- | waffle/oled.h | 1 | ||||
-rw-r--r-- | waffle/tapping.c | 27 | ||||
-rw-r--r-- | waffle/waffle.h | 1 |
9 files changed, 110 insertions, 18 deletions
diff --git a/keymaps/kyria/keymap.c b/keymaps/kyria/keymap.c index 4ab111c..993cc3f 100644 --- a/keymaps/kyria/keymap.c +++ b/keymaps/kyria/keymap.c @@ -11,7 +11,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_Y, KC_U, KC_I, KC_O, KC_P, KC_NO, KC_H, HRMR(KC_J, KC_K, KC_L, KC_SCLN), KC_NO, - KC_NO, KC_MPLY, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_NO, + KC_NO, NUKE, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_NO, KC_NO, KC_BSPC, PSTRSE, PNP, KC_NO ), diff --git a/keymaps/onekey/halconf.h b/keymaps/onekey/halconf.h new file mode 100644 index 0000000..9b8ab5d --- /dev/null +++ b/keymaps/onekey/halconf.h @@ -0,0 +1,5 @@ +// Copyright 2022 jack (@waffle87) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once +#define HAL_USE_I2C TRUE +#include_next <halconf.h> diff --git a/keymaps/onekey/keymap.c b/keymaps/onekey/keymap.c new file mode 100644 index 0000000..e4164ed --- /dev/null +++ b/keymaps/onekey/keymap.c @@ -0,0 +1,59 @@ +// Copyright 2022 jack (@waffle87) +// SPDX-License-Identifier: GPL-2.0-or-later +#include"waffle.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + LAYOUT_ortho_1x1(KC_A) +}; + +#ifdef OLED_ENABLE + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + if (!is_keyboard_master()) { + return OLED_ROTATION_180; + } + return rotation; +} + +static void render_logo(void) { + static const char PROGMEM logo[] = { + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00 + }; + oled_write_P(logo, false); +} + +void render_layer_state(void) { + oled_write_P(PSTR("Layer: "), false); + switch (get_highest_layer(layer_state)) { + case 0: + oled_write_ln_P(PSTR("Default"), false); + break; + case 1: + oled_write_ln_P(PSTR("Lower"), false); + break; + case 2: + oled_write_ln_P(PSTR("Raise"), false); + break; + case 3: + oled_write_ln_P(PSTR("Adjust"), false); + break; + default: + oled_write_ln_P(PSTR("Undefined"), false); + } +} +bool oled_task_keymap(void) { + static bool finished_timer = false; + if (!finished_timer && last_input_activity_elapsed() < 8000) { + oled_write(PSTR("eeeeeeee"), false); + } else { + if (!finished_timer) { + oled_clear(); + finished_timer = true; + } + oled_write(PSTR("hhhhhhhhhhhh"), false); + } + return false; +} +#endif diff --git a/keymaps/onekey/mcuconf.h b/keymaps/onekey/mcuconf.h new file mode 100644 index 0000000..8dbed49 --- /dev/null +++ b/keymaps/onekey/mcuconf.h @@ -0,0 +1,6 @@ +// Copyright 2022 jack (@waffle87) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once +#include_next <mcuconf.h> +#undef STM32_I2C_USE_I2C1 +#define STM32_I2C_USE_I2C1 TRUE diff --git a/keymaps/onekey/rules.mk b/keymaps/onekey/rules.mk new file mode 100644 index 0000000..dd68e9d --- /dev/null +++ b/keymaps/onekey/rules.mk @@ -0,0 +1 @@ +OLED_ENABLE = yes diff --git a/waffle/oled.c b/waffle/oled.c index 4b2cdcb..a89ee7e 100644 --- a/waffle/oled.c +++ b/waffle/oled.c @@ -90,8 +90,8 @@ void keylock_status(led_t led_usb_state) { oled_write_ln(blink ? PSTR("% _") : PSTR("% "), false); } -static uint16_t log_timer = 0; -char keylog_str[5] = {0}; +char keylog_str[5] = {}; +static uint16_t keylog_timer = 0; const char code_to_name[60] = { ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', @@ -102,14 +102,15 @@ const char code_to_name[60] = { }; void add_keylog(uint16_t keycode) { - if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) - keycode = keycode & 0xFF; - for (uint8_t i = 4; i > 0; i--) + for (uint8_t i = ARRAY_SIZE(keylog_str) - 1; i > 0; i--) keylog_str[i] = keylog_str[i - 1]; - if (keycode < 60) - keylog_str[0] = code_to_name[keycode]; - keylog_str[4] = 0; - log_timer = timer_read(); + if (keycode < ARRAY_SIZE(code_to_name)) + keylog_str[0] = code_to_name[keycode & 0xFF]; + keylog_timer = timer_read(); +} + +void render_keylog(void) { + oled_write(keylog_str, false); } void render_keylogger(void) { oled_write(keylog_str, false); } @@ -225,10 +226,6 @@ void layer_anim(void) { } #endif -__attribute__((weak)) bool oled_task_keymap(void) { - return true; -} - bool oled_task_user(void) { if (is_keyboard_master()) { if (timer_elapsed32(oled_timer) > 180000) { @@ -237,8 +234,7 @@ bool oled_task_user(void) { } else oled_on(); } - if (!oled_task_keymap()) - return false; + oled_task_keymap(); return false; } diff --git a/waffle/oled.h b/waffle/oled.h index 20f3081..95eb74e 100644 --- a/waffle/oled.h +++ b/waffle/oled.h @@ -21,6 +21,7 @@ void bongo(void); //solid-filled bongo cat (0 or 180 rotation) void wpm_graph(void); //wpm graph for 128x64 oled (memory intensive) void layer_anim(void); void oled_timer_reset(void); +bool oled_task_keymap(void); #ifdef BONGO_CAT static const char PROGMEM bongo_idle[5][512] = { { diff --git a/waffle/tapping.c b/waffle/tapping.c index 5e89d52..1294384 100644 --- a/waffle/tapping.c +++ b/waffle/tapping.c @@ -137,8 +137,9 @@ tap_dance_action_t tap_dance_actions[] = { bool process_record_user(uint16_t keycode, keyrecord_t *record) { - if (!process_record_unicode(keycode, record)) - return false; +#ifdef UNICODE_COMMON_ENABLE + process_record_unicode(keycode, record); +#endif #ifdef OLED_ENABLE if (record->event.pressed) { oled_timer_reset(); @@ -150,6 +151,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) SEND_STRING("../"); break; + case NUKE: + if (record->event.pressed) { + tap_code16(C(KC_A)); + SEND_STRING("\b```suggestion\n```"); + } + break; INTERCEPT_MOD_TAP(LALT_T, KC_EXLM) INTERCEPT_MOD_TAP(LGUI_T, KC_AT) INTERCEPT_MOD_TAP(LCTL_T, KC_HASH) @@ -170,3 +177,19 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; } + +bool caps_word_press_user(uint16_t keycode) { + switch (keycode) { + case KC_A ... KC_Z: + case KC_MINS: + add_weak_mods(MOD_BIT(KC_LSFT)); + return true; + case KC_1 ... KC_0: + case KC_BSPC: + case KC_DEL: + case KC_UNDS: + return true; + case KC_LPRN: return false; + default: return false; + } +} diff --git a/waffle/waffle.h b/waffle/waffle.h index c48670c..629a87e 100644 --- a/waffle/waffle.h +++ b/waffle/waffle.h @@ -37,6 +37,7 @@ enum tapdances { enum custom_keycodes { UPDIR = QK_USER, + NUKE, TABLE1, TABLE2, KC_NOMODE, |