summaryrefslogtreecommitdiff
path: root/keyboards/work_louder/micro/keymaps/via/keymap.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2023-01-10 16:35:33 -0800
committerGitHub <noreply@github.com>2023-01-10 16:35:33 -0800
commita1676c3b8c3f5f5d713196d99ac358ba5fb021ef (patch)
tree4eef2364fa41fffa200a18c83258900fd53793e9 /keyboards/work_louder/micro/keymaps/via/keymap.c
parent5e5b19cf94d46db06cf43a834b7fd8a112d9e527 (diff)
[Keyboard] Work Louder updates for via v3 (#19555)
Diffstat (limited to 'keyboards/work_louder/micro/keymaps/via/keymap.c')
-rw-r--r--keyboards/work_louder/micro/keymaps/via/keymap.c97
1 files changed, 81 insertions, 16 deletions
diff --git a/keyboards/work_louder/micro/keymaps/via/keymap.c b/keyboards/work_louder/micro/keymaps/via/keymap.c
index d4be308b2a..8cc41e1e50 100644
--- a/keyboards/work_louder/micro/keymaps/via/keymap.c
+++ b/keyboards/work_louder/micro/keymaps/via/keymap.c
@@ -8,25 +8,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_MPLY, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
- RGB_TOG, XXXXXXX, XXXXXXX, 0x5011
+ RGB_TOG, XXXXXXX, XXXXXXX, TO(1)
),
[1] = LAYOUT(
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
- XXXXXXX, XXXXXXX, XXXXXXX, 0x5012
+ XXXXXXX, XXXXXXX, XXXXXXX, TO(2)
),
[2] = LAYOUT(
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
- XXXXXXX, XXXXXXX, XXXXXXX, 0x5013
+ XXXXXXX, XXXXXXX, XXXXXXX, TO(3)
),
[3] = LAYOUT(
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
USER00, USER01, USER03, USER05,
XXXXXXX, USER02, USER04, USER06,
- XXXXXXX, XXXXXXX, XXXXXXX, 0x5010
+ XXXXXXX, XXXXXXX, XXXXXXX, TO(0)
)
};
@@ -49,6 +49,8 @@ typedef union {
work_louder_config_t work_louder_config;
+#define WL_LED_MAX_BRIGHT 75
+
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case USER09:
@@ -57,21 +59,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (work_louder_config.led_level > 4) {
work_louder_config.led_level = 1;
}
- work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4));
+ work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * WL_LED_MAX_BRIGHT / 4));
eeconfig_update_user(work_louder_config.raw);
layer_state_set_kb(layer_state);
}
break;
- case 0x5000 ... 0x500F:
- if (record->event.pressed) {
- layer_move(keycode - 0x5000);
- }
- return false; break;
- case 0x5010 ... 0x501F:
- if (record->event.pressed) {
- layer_move(keycode - 0x5010);
- }
- return false; break;
}
return true;
}
@@ -88,14 +80,87 @@ layer_state_t layer_state_set_user(layer_state_t state) {
void eeconfig_init_user(void) {
work_louder_config.raw = 0;
work_louder_config.led_level = 1;
+ work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * WL_LED_MAX_BRIGHT / 4));
eeconfig_update_user(work_louder_config.raw);
}
void keyboard_post_init_user(void) {
work_louder_config.raw = eeconfig_read_user();
- work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * 255 / 4));
+ work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * WL_LED_MAX_BRIGHT / 4));
}
void suspend_wakeup_init_user(void) {
layer_state_set_user(layer_state);
}
+
+
+enum via_indicator_value {
+ id_wl_brightness = 1,
+ id_wl_layer, // placeholder
+};
+
+void wl_config_set_value(uint8_t *data) {
+ // data = [ value_id, value_data ]
+ uint8_t *value_id = &(data[0]);
+ uint8_t *value_data = &(data[1]);
+
+ switch (*value_id) {
+ case id_wl_brightness:
+ work_louder_config.led_level = (uint8_t)*value_data;
+ work_louder_micro_led_all_set((uint8_t)(work_louder_config.led_level * WL_LED_MAX_BRIGHT / 4));
+ layer_state_set_kb(layer_state);
+ break;
+ // case id_wl_layer:
+ // layer_move(*value_data);
+ // break;
+ }
+}
+
+void wl_config_get_value(uint8_t *data) {
+ // data = [ value_id, value_data ]
+ uint8_t *value_id = &(data[0]);
+ uint8_t *value_data = &(data[1]);
+
+ switch (*value_id) {
+ case id_wl_brightness:
+ *value_data = work_louder_config.led_level;
+ break;
+ // case id_wl_layer:
+ // *value_data = get_highest_layer(layer_state);
+ // break;
+ }
+}
+
+void wl_config_save(void) {
+ eeconfig_update_user(work_louder_config.raw);
+}
+
+void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
+ uint8_t *command_id = &(data[0]);
+ uint8_t *channel_id = &(data[1]);
+ uint8_t *value_id_and_data = &(data[2]);
+
+ if (*channel_id == id_custom_channel) {
+ switch (*command_id) {
+ case id_custom_set_value: {
+ wl_config_set_value(value_id_and_data);
+ break;
+ }
+ case id_custom_get_value: {
+ wl_config_get_value(value_id_and_data);
+ break;
+ }
+ case id_custom_save: {
+ wl_config_save();
+ break;
+ }
+ default: {
+ // Unhandled message.
+ *command_id = id_unhandled;
+ break;
+ }
+ }
+ return;
+ }
+ *command_id = id_unhandled;
+}