summaryrefslogtreecommitdiff
path: root/users/bocaj/bocaj.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/bocaj/bocaj.c')
-rw-r--r--users/bocaj/bocaj.c285
1 files changed, 153 insertions, 132 deletions
diff --git a/users/bocaj/bocaj.c b/users/bocaj/bocaj.c
index 689dbe7b4e..83fe812311 100644
--- a/users/bocaj/bocaj.c
+++ b/users/bocaj/bocaj.c
@@ -1,5 +1,5 @@
/*
-Copyright 2018 Jacob Jerrell <jacob.jerrell@gmail.com> @JacobJerrell
+Copyright 2020 Jacob Jerrell <jacob.jerrell@gmail.com> @JacobJerrell
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,173 +17,194 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "bocaj.h"
+#ifdef KEYBOARD_planck_ez
userspace_config_t userspace_config;
-#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
- #define BOCAJ_UNICODE_MODE UC_OSX
+#endif
+
+bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) {
+ static uint16_t this_timer;
+ if (pressed) {
+ this_timer = timer_read();
+ } else {
+ if (timer_elapsed(this_timer) < TAPPING_TERM) {
+ tap_code(code);
+ } else {
+ register_code(mod_code);
+ tap_code(code);
+ unregister_code(mod_code);
+ }
+ }
+ return false;
+}
+
+bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) {
+ if (pressed) {
+ this_timer = timer_read();
+ } else {
+ if (timer_elapsed(this_timer) < TAPPING_TERM) {
+ tap_code(code);
+ } else {
+ register_code(mod_code);
+ tap_code(code);
+ unregister_code(mod_code);
+ }
+ }
+ return false;
+}
+
+void bootmagic_lite(void) {
+ matrix_scan();
+#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0
+ wait_ms(DEBOUNCING_DELAY * 2);
+#elif defined(DEBOUNCE) && DEBOUNCE > 0
+ wait_ms(DEBOUNCE * 2);
#else
- // set to 2 for UC_WIN, set to 4 for UC_WINC
- #define BOCAJ_UNICODE_MODE 2
+ wait_ms(30);
#endif
+ matrix_scan();
+ if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
+ bootloader_jump();
+ }
+}
-void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
+__attribute__((weak)) void keyboard_pre_init_keymap(void) {}
+void keyboard_pre_init_user(void) {
+#ifdef KEYBOARD_planck_ez
+ userspace_config.raw = eeconfig_read_user();
+#endif
+ keyboard_pre_init_keymap();
+}
// Add reconfigurable functions here, for keymap customization
// This allows for a global, userspace functions, and continued
// customization of the keymap. Use _keymap instead of _user
// functions in the keymaps
-__attribute__ ((weak))
-void matrix_init_keymap(void) {}
-
-__attribute__ ((weak))
-void startup_keymap(void) {}
-
-__attribute__ ((weak))
-void suspend_power_down_keymap(void) {}
+__attribute__((weak)) void matrix_init_keymap(void) {}
-__attribute__ ((weak))
-void suspend_wakeup_init_keymap(void) {}
-
-__attribute__ ((weak))
-void matrix_scan_keymap(void) {}
-
-__attribute__ ((weak))
-bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
- return true;
+// Call user matrix init, set default RGB colors and then
+// call the keymap's init function
+void matrix_init_user(void) {
+ matrix_init_keymap();
}
-__attribute__ ((weak))
-void matrix_scan_secrets(void) {}
-
-__attribute__ ((weak))
-uint32_t layer_state_set_keymap (uint32_t state) {
- return state;
-}
+__attribute__((weak)) void keyboard_post_init_keymap(void) {}
-__attribute__ ((weak))
-uint32_t default_layer_state_set_keymap (uint32_t state) {
- return state;
+void keyboard_post_init_user(void) {
+#if defined(RGB_MATRIX_ENABLE)
+ keyboard_post_init_rgb_matrix();
+#endif
+ keyboard_post_init_keymap();
}
-__attribute__ ((weak))
-void led_set_keymap(uint8_t usb_led) {}
-
-// Call user matrix init, set default RGB colors and then
-// call the keymap's init function
-void matrix_init_user(void) {
- userspace_config.raw = eeconfig_read_user();
+__attribute__((weak)) void shutdown_keymap(void) {}
- #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
- set_unicode_input_mode(BOCAJ_UNICODE_MODE);
- get_unicode_input_mode();
- #endif //UNICODE_ENABLE
+void rgb_matrix_update_pwm_buffers(void);
+void shutdown_user(void) {
+#ifdef RGB_MATRIX_ENABLE
+ rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
+ rgb_matrix_update_pwm_buffers();
- matrix_init_keymap();
+#endif // RGB_MATRIX_ENABLE
+ shutdown_keymap();
}
-void startup_user (void) {
- startup_keymap();
-}
+__attribute__((weak)) void suspend_power_down_keymap(void) {}
-void suspend_power_down_user(void)
-{
- suspend_power_down_keymap();
-}
+void suspend_power_down_user(void) { suspend_power_down_keymap(); }
-void suspend_wakeup_init_user(void)
-{
- suspend_wakeup_init_keymap();
- #ifdef KEYBOARD_ergodox_ez
- wait_ms(10);
- #endif
-}
+__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}
-void eeconfig_init_user(void) {
- userspace_config.raw = 0;
- eeconfig_update_user(userspace_config.raw);
- #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
- set_unicode_input_mode(BOCAJ_UNICODE_MODE);
- get_unicode_input_mode();
- #else
- eeprom_update_byte(EECONFIG_UNICODEMODE, BOCAJ_UNICODE_MODE);
- #endif
-}
+void suspend_wakeup_init_user(void) { suspend_wakeup_init_keymap(); }
+
+__attribute__((weak)) void matrix_scan_secrets(void) {}
+__attribute__((weak)) void matrix_scan_keymap(void) {}
LEADER_EXTERNS();
+
// No global matrix scan code, so just run keymap's matrix
// scan function
void matrix_scan_user(void) {
- static bool has_ran_yet;
- if (!has_ran_yet) {
- has_ran_yet = true;
- startup_user();
- }
- LEADER_DICTIONARY() {
- leading = false;
- leader_end();
-
- // Mac Save (Leader -> s)
- SEQ_ONE_KEY(KC_S) {
- SEND_STRING(SS_LGUI("s"));
+ static bool has_ran_yet;
+ if (!has_ran_yet) {
+ has_ran_yet = true;
+ startup_user();
}
- // Mac copy line down (Leader -> d, d)
- SEQ_TWO_KEYS(KC_D, KC_D) {
- register_code(KC_LSHIFT);
- register_code(KC_HOME);
- unregister_code(KC_HOME);
- unregister_code(KC_LSHIFT);
- SEND_STRING(SS_LGUI("c"));
- tap(KC_END);
- tap(KC_ENTER);
- SEND_STRING(SS_LGUI("v"));
- }
+ LEADER_DICTIONARY() {
+ leading = false;
+ leader_end();
- // Mac copy line up (Leader -> u, u)
- SEQ_TWO_KEYS(KC_U, KC_U) {
- register_code(KC_LSHIFT);
- register_code(KC_HOME);
- unregister_code(KC_HOME);
- unregister_code(KC_LSHIFT);
- SEND_STRING(SS_LGUI("c"));
- tap(KC_UP);
- tap(KC_END);
- tap(KC_ENTER);
- SEND_STRING(SS_LGUI("v"));
- }
+ // Website Refresh / XCode "Run"
+ SEQ_ONE_KEY(KC_R) {
+ SEND_STRING(SS_LGUI("r"));
+ }
- // Mac VS Debug
- SEQ_ONE_KEY(KC_D) {
- tap(KC_F5);
- }
+ SEQ_TWO_KEYS(KC_B, KC_D) {
+ SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " Built at: " QMK_BUILDDATE);
+ }
- // Mac VS Stop Debug
- SEQ_TWO_KEYS(KC_S, KC_D) {
- register_code(KC_LSHIFT);
- tap(KC_F5);
- unregister_code(KC_LSHIFT);
+ #ifndef NO_SECRETS
+ matrix_scan_secrets();
+ #endif // !NO_SECRETS
}
+
+#if defined(RGB_MATRIX_ENABLE)
+ matrix_scan_rgb_matrix();
+#endif
- // Start Diablo 3
- SEQ_ONE_KEY(KC_3) {
- SEND_STRING(SS_LCTRL(" "));
- SEND_STRING("Diablo");
- tap(KC_ENTER);
- }
+ matrix_scan_keymap();
+}
- SEQ_ONE_KEY(KC_B) {
- SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " ");
- tap(KC_ENTER);
- SEND_STRING ("Built at: " QMK_BUILDDATE);
- }
-#ifndef NO_SECRETS
- matrix_scan_secrets();
-#endif // !NO_SECRETS
- }
+__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
+
+// on layer change, no matter where the change was initiated
+// Then runs keymap's layer change check
+layer_state_t layer_state_set_user(layer_state_t state) {
+ state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
+#if defined(RGBLIGHT_ENABLE)
+ state = layer_state_set_rgb_light(state);
+#endif // RGBLIGHT_ENABLE
+ return layer_state_set_keymap(state);
+}
+
+__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
+
+// Runs state check and changes underglow color and animation
+layer_state_t default_layer_state_set_user(layer_state_t state) {
+ state = default_layer_state_set_keymap(state);
+#if 0
+# if defined(RGB_MATRIX_ENABLE)
+ state = default_layer_state_set_rgb(state);
+# endif // RGB_MATRIX_ENABLE
+#endif
+ return state;
+}
+
+__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}
+
+// Any custom LED code goes here.
+// So far, I only have keyboard specific code,
+// So nothing goes here.
+void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
+
+__attribute__((weak)) void eeconfig_init_keymap(void) {}
+
+void eeconfig_init_user(void) {
+#ifdef KEYBOARD_planck_ez
+ userspace_config.raw = 0;
+# if defined(RGB_MATRIX_ENABLE)
+ userspace_config.rgb_layer_change = true;
+# endif
+ eeconfig_update_user(userspace_config.raw);
+#endif
+ eeconfig_init_keymap();
+ keyboard_init();
+}
-#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
- run_diablo_macro_check();
-#endif // TAP_DANCE_ENABLE
+bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
+ value &= 0xF;
+ mask &= 0xF;
- matrix_scan_keymap();
+ return (value & mask) == mask;
}