Skip to content

Commit

Permalink
Add a typing indicator for some reason
Browse files Browse the repository at this point in the history
  • Loading branch information
plodah committed Aug 17, 2024
1 parent f88393e commit 291fcfe
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions users/plodah/functions/indicators.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ bool plodah_indicator_handler(void) {
}
# endif // DYNAMIC_MACRO_ENABLE && PLODAH_DMAC_INDIC_INDEX

# ifdef PLODAH_TYPINGINDICATOR_RGBINDEX
if(!rgb_matrix_get_flags()){
rgb_matrix_set_color(PLODAH_TYPINGINDICATOR_RGBINDEX, RGB_OFF);
}
if(plodah_typingindicator_active){
rgb_matrix_set_color(PLODAH_TYPINGINDICATOR_RGBINDEX, PLODAH_TYPINGINDICATOR_RGBCOLOR);
}
# endif // PLODAH_TYPINGINDICATOR_RGBINDEX

# ifdef PLODAH_MODS_INDIC_LALT_INDEX
if (!rgb_matrix_get_flags()) {
rgb_matrix_set_color(PLODAH_MODS_INDIC_LALT_INDEX, RGB_OFF);
Expand Down
4 changes: 4 additions & 0 deletions users/plodah/functions/kc_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

bool kc_handler(uint16_t keycode, keyrecord_t *record) {

# if defined(PLODAH_TYPINGINDICATOR_RGBINDEX)
plodah_typingindicator_start();
# endif // PLODAH_TYPINGINDICATOR_RGBINDEX

switch (keycode) {
// Static version keycode
case PL_VERS:
Expand Down
23 changes: 23 additions & 0 deletions users/plodah/functions/typing_indicator.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
bool plodah_typingindicator_active = false;
uint16_t plodah_typingindicator_timer = 0;

#ifndef PLODAH_TYPINGINDICATOR_RGBCOLOR
# define PLODAH_TYPINGINDICATOR_RGBCOLOR RGB_RED
#endif //PLODAH_TYPINGINDICATOR_RGBCOLOR

#ifndef PLODAH_TYPINGINDICATOR_DURATION
# define PLODAH_TYPINGINDICATOR_DURATION 1000
#endif //PLODAH_TYPINGINDICATOR_DURATION

void plodah_typingindicator_start(void){
plodah_typingindicator_timer = timer_read();
plodah_typingindicator_active = true;
}

void plodah_typingindicator_check(void){
if(plodah_typingindicator_active){
if(timer_elapsed(plodah_typingindicator_timer) > PLODAH_TYPINGINDICATOR_DURATION){
plodah_typingindicator_active = false;
}
}
}
10 changes: 10 additions & 0 deletions users/plodah/plodah.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
};
#endif

//============================//
// TYPING INDICATOR //
//============================//
#if defined(PLODAH_TYPINGINDICATOR_RGBINDEX)
# include "functions/typing_indicator.c"
#endif // PLODAH_TYPINGINDICATOR_RGBINDEX

//===========================//
// CUSTOM KEYCODES //
//===========================//
Expand Down Expand Up @@ -92,6 +99,9 @@ void matrix_scan_user(void) {
# if defined(AUTOCORRECT_ENABLE) && defined(RGB_MATRIX_ENABLE)
plodah_autocorrect_indicator_check();
# endif // AUTOCORRECT_ENABLE && RGB_MATRIX_ENABLE
# if defined (PLODAH_TYPINGINDICATOR_RGBINDEX)
plodah_typingindicator_check();
# endif // PLODAH_TYPINGINDICATOR_RGBINDEX
}

//==========================//
Expand Down

0 comments on commit 291fcfe

Please sign in to comment.