diff options
Diffstat (limited to 'qmk/keyboards/sofle_choc')
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/config.h | 7 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c | 31 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/keymap.c | 7 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/lighting.c | 85 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/overrides.c | 1 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/rules.mk | 2 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/star_key.c | 37 | ||||
-rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/star_key.h | 11 |
8 files changed, 132 insertions, 49 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/config.h b/qmk/keyboards/sofle_choc/keymaps/custom/config.h index db8e644..a577473 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/config.h +++ b/qmk/keyboards/sofle_choc/keymaps/custom/config.h @@ -33,7 +33,7 @@ // Triggers RGB keypress events on key down. This makes RGB control feel more // responsive. This may cause RGB to not function properly on some boards -#define RGB_TRIGGER_ON_KEYDOWN +#define RGB_TRIGGER_ON_KEYDOWN // Disable the codes, don’t need them. #define RGB_MATRIX_DISABLE_KEYCODES @@ -66,3 +66,8 @@ //#define HOLD_ON_OTHER_KEY_PRESS #define COMBO_MUST_PRESS_IN_ORDER + +// Prevent the keyboard to go to sleep and requiring a reboot +#define NO_SUSPEND_POWER_DOWN + +#define SPLIT_TRANSACTION_IDS_USER SET_STAR_KEY diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c index c21ba53..2843bbd 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c @@ -1,12 +1,24 @@ #include QMK_KEYBOARD_H #include "keymap_bepo.h" #include "keycodes.h" +#include "star_key.h" + +void keyboard_post_init_user(void) { + rgb_matrix_sethsv_noeeprom(HSV_WHITE); + star_key_init(); +} + +void housekeeping_task_user(void) { + if (is_keyboard_master()) { + sync_star_key(); + } +} /* * Rules and modifier to apply over the keycodes. This includes the keys * redefinitions and the keys to include in the caps_word mecanism. * - * All thoses update are working over the custom keys declared in `keycodes.h` + * All thoses update are working over the custom keys declared in `keycodes.h` */ /* @@ -63,6 +75,7 @@ static uint32_t key_timer; // timer for last keyboard activity, use // 32bit value and function to make longer // idle time possible static uint16_t latest_key = 0L; +static uint8_t star_number = 0; bool process_record_user(uint16_t keycode, keyrecord_t *record) { @@ -72,7 +85,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // know if we are inside a typing sequence or not. key_timer = timer_read32(); latest_key = keycode; - } + if (keycode != KC_O && star_number != 0) { + star_number = 0; + set_star_key(0); + } + } switch (keycode) { case KC_LEFT_SHIFT: @@ -87,7 +104,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; // If a key where released just before, consider we are typing some text - // and not starting a new sequence + // and not starting a new sequence case KEY_E: if (record->event.pressed && timer_elapsed32(key_timer) < TAPPING_TERM) { if (is_caps_word_on()) { @@ -140,7 +157,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { layer_off(1); } return true; + + // Handle the dead key in the ErgoL layout. + // The variable is synchronized over the other side of the keyboard. + case KC_O: + star_number = (star_number + 1) % 3; + set_star_key(star_number != 0); + return true; default: return true; // Process all other keycodes normally } } + diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c b/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c index 44cca3b..34ec825 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c @@ -57,7 +57,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [LAYER_BASE] = LAYOUT( KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KEY_PRC, - BP_DLR, BP_B, BP_EACU, BP_P, BP_O, KC_BSPC, BP_DCIR, BP_V, BP_D, BP_L, BP_J, BP_Z, + BP_DLR, BP_B, BP_EACU, BP_P, BP_O, KC_BSPC, BP_DCIR, BP_V, BP_D, KC_O, BP_J, BP_Z, KC_TAB, BP_A, BP_U, BP_I, KEY_E, KEY_EE, KEY_C, KEY_T, BP_S, BP_R, BP_N, BP_M, KC_LSFT, BP_AGRV,BP_Y, BP_X, BP_DOT, KC_B, KC_MUTE, KC_MPLY,BP_QUOT, BP_Q, BP_G, BP_H, BP_F, KEY_W, KC_LCTL, KC_DELETE,KC_LGUI,LY_SYMBOL,AL_SPC, AL_ENT, LY_SYMBOL,KEY_APP, KEY_INS, KC_RCTL @@ -68,13 +68,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { #define KEY_5 MT(MOD_LCTL, KC_P5) #define KEY_DOWN MT(MOD_RCTL, KC_DOWN) #define KEY_PGDN MT(MOD_RSFT, KC_PGDN) -#define EEPROM QK_CLEAR_EEPROM // This layer is used to access to the numeric keypad, functions keys, and also provide some keys used with KC_LGUI [LAYER_SYMBOLS] = LAYOUT( KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, - EEPROM, KC_NO, KC_P7, KC_P8, KC_P9, KC_TRNS, KC_HOME, KC_UP, KC_END, KC_TRNS, KC_TRNS, S(BP_EQL), - KC_TAB, KC_NO, KC_P4, KEY_5, KC_P6, KC_NO, KC_LEFT, KC_DOWN, KC_RIGHT,KC_TRNS, KC_TRNS, KC_PGUP, + KC_TRNS, KC_NO, KC_P7, KC_P8, KC_P9, KC_TRNS, KC_HOME, KC_UP, KC_END, KC_TRNS, KC_TRNS, S(BP_EQL), + KC_TRNS, KC_NO, KC_P4, KEY_5, KC_P6, KC_NO, KC_LEFT, KC_DOWN, KC_RIGHT,KC_TRNS, KC_TRNS, KC_PGUP, KC_LSFT, KC_NO, KC_P1, KC_P2, KC_P3, KC_NO, KC_MUTE, KC_MPLY,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KEY_PGDN, KC_P0, KC_PDOT, KC_TRNS, LY_SYMBOL,AL_SPC, AL_ENT, LY_SYMBOL,KC_TRNS, KC_RGUI, KC_TRNS ), diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c index 3e4c5b0..3060dce 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c @@ -2,6 +2,10 @@ uint8_t flags = 0; #include "keycodes.h" +// The variable is defined in star_key.h +// The LED is on when the key is pressed. +extern bool is_star; + // Set the color at the given position, but limit the intensity void set_color(uint8_t index, uint8_t h, uint8_t s, uint8_t _) { HSV hsv = {h, s, RGB_MATRIX_MAXIMUM_BRIGHTNESS}; @@ -17,7 +21,7 @@ HSV hsv_of_color(uint8_t h, uint8_t s, uint8_t v) { #define KEY_DOWN MT(MOD_RCTL, KC_DOWN) bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { // Activate effects depending of mods - + // Colors for the mods HSV const colors[] = { hsv_of_color(HSV_BLACK), // 000 @@ -53,44 +57,47 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { counter += 1; } - if (get_highest_layer(layer_state) > 0) { - for (uint8_t row = 0; row < MATRIX_ROWS; ++row) { - for (uint8_t col = 0; col < MATRIX_COLS; ++col) { - uint8_t index = g_led_config.matrix_co[row][col]; - - if (index < led_min || index > led_max || index == NO_LED) - continue; - - uint8_t layer = layer_switch_get_layer((keypos_t){col,row}); - if (layer == 0) - continue; - - uint16_t keycode = keymap_key_to_keycode(layer, (keypos_t){col,row}); - - switch (keycode) { - case KC_F1 ... KC_F11: - rgb_matrix_set_color(index, 128, 128, 128); - break; - case KC_P1 ... KC_P0: - case KEY_5: - rgb_matrix_set_color(index, 100, 100, 0); - break; - case KC_RIGHT: - case KEY_DOWN: - case KC_LEFT ... KC_UP: - case KC_PGUP: - case KC_PGDN: - rgb_matrix_set_color(index, 32, 32, 128); - break; - case KC_HOME: - case KC_END: - rgb_matrix_set_color(index, RGB_SPRINGGREEN); - break; - case AL_SPC: - case AL_ENT: - set_color(index, HSV_BLUE); - break; - } + for (uint8_t row = 0; row < MATRIX_ROWS; ++row) { + for (uint8_t col = 0; col < MATRIX_COLS; ++col) { + uint8_t index = g_led_config.matrix_co[row][col]; + + if (index < led_min || index > led_max || index == NO_LED) + continue; + + uint8_t layer = layer_switch_get_layer((keypos_t){col,row}); + uint16_t keycode = keymap_key_to_keycode(layer, (keypos_t){col,row}); + + if (keycode == KC_O && is_star) { + rgb_matrix_set_color(index, 100, 100, 0); + } + + if (layer == 0) + continue; + + + switch (keycode) { + case KC_F1 ... KC_F11: + rgb_matrix_set_color(index, 128, 128, 128); + break; + case KC_P1 ... KC_P0: + case KEY_5: + rgb_matrix_set_color(index, 100, 100, 0); + break; + case KC_RIGHT: + case KEY_DOWN: + case KC_LEFT ... KC_UP: + case KC_PGUP: + case KC_PGDN: + rgb_matrix_set_color(index, 32, 32, 128); + break; + case KC_HOME: + case KC_END: + rgb_matrix_set_color(index, RGB_SPRINGGREEN); + break; + case AL_SPC: + case AL_ENT: + set_color(index, HSV_BLUE); + break; } } diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/overrides.c b/qmk/keyboards/sofle_choc/keymaps/custom/overrides.c index baab291..3875215 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/overrides.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/overrides.c @@ -28,4 +28,3 @@ const key_override_t w_key_override = const key_override_t e_key_override = ko_make_basic(MOD_MASK_CTRL, KEY_E, RCTL(BP_E)); - diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk b/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk index 2703553..2c9c3c1 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk +++ b/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk @@ -9,4 +9,4 @@ BACKLIGHT_ENABLE = no RGB_MATRIX_ENABLE = yes RGB_MATRIX_DRIVER = ws2812 -SRC += quad_tapdance.c keycodes.c overrides.c lighting.c +SRC += star_key.c quad_tapdance.c keycodes.c overrides.c lighting.c diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.c b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.c new file mode 100644 index 0000000..8c04c00 --- /dev/null +++ b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.c @@ -0,0 +1,37 @@ +#include QMK_KEYBOARD_H +#include "transactions.h" +#include "star_key.h" + +typedef struct _master_to_slave_t { + int is_star; +} master_to_slave_t; + + +bool is_star = 0; +static bool is_synced = 1; + +// Handler for the slave, receive the star information +void user_sync_a_slave_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) { + const master_to_slave_t *m2s = (const master_to_slave_t*)in_data; + is_star = m2s->is_star; +} + +void star_key_init(void) { + if (!is_keyboard_master()) { + transaction_register_rpc(SET_STAR_KEY, user_sync_a_slave_handler); + } +} + +void set_star_key(bool status) { + is_star = status; + is_synced = 0; +} + +void sync_star_key(void) { + if (!is_synced) { + // Send the state to the other side of the keyboard + master_to_slave_t m2s = { is_star }; + transaction_rpc_send(SET_STAR_KEY, sizeof(m2s), &m2s); + is_synced = 1; + } +} diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h new file mode 100644 index 0000000..3b4bb9e --- /dev/null +++ b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h @@ -0,0 +1,11 @@ +#pragma once + +// Initialize the state. +void star_key_init(void); + +// Define the new value for the star key +void set_star_key(bool status); + +// This code is intended to be called from the master. +// Send the star key status to the other side of the keyboard +void sync_star_key(void); |