summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/visualizer/visualizer.c58
-rw-r--r--quantum/visualizer/visualizer.h9
2 files changed, 65 insertions, 2 deletions
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index 54f6faaa42..5826d909e4 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -53,10 +53,13 @@ SOFTWARE.
#define "Visualizer thread priority not defined"
#endif
+// mods status
+#include "action_util.h"
static visualizer_keyboard_status_t current_status = {
.layer = 0xFFFFFFFF,
.default_layer = 0xFFFFFFFF,
+ .mods = 0xFF,
.leds = 0xFFFFFFFF,
.suspended = false,
};
@@ -64,6 +67,7 @@ static visualizer_keyboard_status_t current_status = {
static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) {
return status1->layer == status2->layer &&
status1->default_layer == status2->default_layer &&
+ status1->mods == status2->mods &&
status1->leds == status2->leds &&
status1->suspended == status2->suspended;
}
@@ -307,6 +311,45 @@ bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_s
gdispFlush();
return false;
}
+
+static void format_mods_bitmap_string(uint8_t mods, char* buffer) {
+ *buffer = ' ';
+ ++buffer;
+
+ for (int i = 0; i<8; i++)
+ {
+ uint32_t mask = (1u << i);
+ if (mods & mask) {
+ *buffer = '1';
+ } else {
+ *buffer = '0';
+ }
+ ++buffer;
+
+ if (i==3) {
+ *buffer = ' ';
+ ++buffer;
+ }
+ }
+ *buffer = 0;
+}
+
+bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+
+ const char* title = "Modifier states";
+ const char* mods_header = " CSAG CSAG ";
+ char status_buffer[12];
+
+ gdispClear(White);
+ gdispDrawString(0, 0, title, state->font_fixed5x8, Black);
+ gdispDrawString(0, 10, mods_header, state->font_fixed5x8, Black);
+ format_mods_bitmap_string(state->status.mods, status_buffer);
+ gdispDrawString(0, 20, status_buffer, state->font_fixed5x8, Black);
+
+ gdispFlush();
+ return false;
+}
#endif // LCD_ENABLE
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
@@ -350,6 +393,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
visualizer_keyboard_status_t initial_status = {
.default_layer = 0xFFFFFFFF,
.layer = 0xFFFFFFFF,
+ .mods = 0xFF,
.leds = 0xFFFFFFFF,
.suspended = false,
};
@@ -499,7 +543,18 @@ void update_status(bool changed) {
#endif
}
-void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
+uint8_t visualizer_get_mods() {
+ uint8_t mods = get_mods();
+
+#ifndef NO_ACTION_ONESHOT
+ if (!has_oneshot_mods_timed_out()) {
+ mods |= get_oneshot_mods();
+ }
+#endif
+ return mods;
+}
+
+void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds) {
// Note that there's a small race condition here, the thread could read
// a state where one of these are set but not the other. But this should
// not really matter as it will be fixed during the next loop step.
@@ -523,6 +578,7 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
visualizer_keyboard_status_t new_status = {
.layer = state,
.default_layer = default_state,
+ .mods = mods,
.leds = leds,
.suspended = current_status.suspended,
};
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h
index 53e250725c..315af50228 100644
--- a/quantum/visualizer/visualizer.h
+++ b/quantum/visualizer/visualizer.h
@@ -34,10 +34,14 @@ SOFTWARE.
#include "lcd_backlight.h"
#endif
+// use this function to merget both real_mods and oneshot_mods in a uint16_t
+uint8_t visualizer_get_mods(void);
+
// This need to be called once at the start
void visualizer_init(void);
// This should be called at every matrix scan
-void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds);
+void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uint32_t leds);
+
// This should be called when the keyboard goes to suspend state
void visualizer_suspend(void);
// This should be called when the keyboard wakes up from suspend state
@@ -61,6 +65,7 @@ struct keyframe_animation_t;
typedef struct {
uint32_t layer;
uint32_t default_layer;
+ uint8_t mods;
uint32_t leds; // See led.h for available statuses
bool suspended;
} visualizer_keyboard_status_t;
@@ -129,6 +134,8 @@ bool keyframe_set_backlight_color(keyframe_animation_t* animation, visualizer_st
bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state);
// Displays a bitmap (0/1) of all the currently active layers
bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state);
+// Displays a bitmap (0/1) of all the currently active mods
+bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);