Skip to content

Commit

Permalink
[Keymap] Drashna Keymap Updates (qmk#14842)
Browse files Browse the repository at this point in the history
* Fix issues with user split transport code
* Improve OLED (More font stuff, improved keylogger, etc)
* Add `KEYLOCK` macro to disable USB, borrowed from command feature.
* Convert Kyria fully to proton C (no more AVR kyria)
* Add Work Louder Work Board keymap
  • Loading branch information
drashna authored Oct 16, 2021
1 parent 3f11666 commit 00862a9
Show file tree
Hide file tree
Showing 11 changed files with 766 additions and 1,023 deletions.
2 changes: 1 addition & 1 deletion layouts/community/ergodox/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_MAKE, _______, _______, _______, _______, _______, UC_MOD, KC_NUKE, _________________ADJUST_R1_________________, KC_RST,
VRSN, _________________ADJUST_L1_________________, _______, _______, _________________ADJUST_R1_________________, EEP_RST,
_______, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, RGB_IDL,
_______, _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, TG_MODS,
KEYLOCK, _________________ADJUST_L3_________________, _______, _______, _________________ADJUST_R3_________________, TG_MODS,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______,
_______, _______,
Expand Down
2 changes: 1 addition & 1 deletion layouts/community/ortho_4x12/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RST,
VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST,
TH_LVL, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL,
HPT_TOG, _______, _______, _______, _______, KC_NUKE, _______, _______, _______, _______, _______, TG_MODS
KEYLOCK, _______, _______, _______, _______, KC_NUKE, _______, _______, _______, _______, _______, TG_MODS
)

};
Expand Down
2 changes: 1 addition & 1 deletion layouts/community/ortho_5x12/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_MAKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_RST,
VRSN, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, EEP_RST,
_______, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, RGB_IDL,
_______, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, TG_MODS,
KEYLOCK, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, TG_MODS,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
)
};
Expand Down
2 changes: 1 addition & 1 deletion layouts/community/split_3x6_3/drashna/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_ADJUST] = LAYOUT_split_3x6_3_wrapper( \
KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET,
VRSN, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, EEP_RST,
MG_NKRO, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL,
KEYLOCK, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, RGB_IDL,
HPT_TOG, KC_NUKE, _______, _______, TG_MODS, HPT_FBK
)
};
Expand Down
5 changes: 4 additions & 1 deletion users/drashna/drashna.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ void shutdown_user(void) {
#ifdef RGB_MATRIX_ENABLE
rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
rgb_matrix_update_pwm_buffers();

#endif // RGB_MATRIX_ENABLE
#ifdef OLED_ENABLE
oled_off();
#endif

shutdown_keymap();
}

Expand Down
1,684 changes: 693 additions & 991 deletions users/drashna/drashna_font.h

Large diffs are not rendered by default.

36 changes: 24 additions & 12 deletions users/drashna/oled_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "drashna.h"

extern bool host_driver_disabled;

#ifndef KEYLOGGER_LENGTH
// # ifdef OLED_DISPLAY_128X64
# define KEYLOGGER_LENGTH ((uint8_t)(OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH))
Expand All @@ -29,24 +31,24 @@ static char keylog_str[KEYLOGGER_LENGTH + 1] = {0};
static uint16_t log_timer = 0;

// clang-format off
static const char PROGMEM code_to_name[0xFF] = {
static const char PROGMEM code_to_name[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B c D E F
' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
'3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x
' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
']','\\', '#', ';','\'', '`', ',', '.', '/', 128, '1', '2', '3', '4', '5', '6', // 3x
'7', '8', '9', '0', '1', '2', 'P', 'S', 19, ' ', 17, 30, 16, 16, 31, 26, // 4x
27, 25, 24, 'N', '/', '*', '-', '+', 23, '1', '2', '3', '4', '5', '6', '7', // 5x
'8', '9', '0', '.','\\', 'A', 0, '=', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
' ', ' ', ' ', ' ', ' ', 0, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx
'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 24, 26, 24, // Ex
25,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D, 24, 25, 27, 26, ' ', ' ', ' ' // Fx
};
// clang-format on

Expand Down Expand Up @@ -148,8 +150,8 @@ void render_keylock_status(uint8_t led_usb_state) {
oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
// oled_write_P(PSTR(" "), false);
// oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
}

void render_matrix_scan_rate(void) {
Expand Down Expand Up @@ -292,12 +294,22 @@ void render_user_status(void) {

static const char PROGMEM rgb_layer_status[2][3] = {{0xEE, 0xEF, 0}, {0xF0, 0xF1, 0}};
oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
static const char PROGMEM nukem_good[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
oled_write_P(nukem_good[0], userspace_config.nuke_switch);
static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
oled_write_P(cat_mode[0], host_driver_disabled);
#if defined(UNICODE_ENABLE)
static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
#endif
if (userspace_config.nuke_switch) {
#if !defined(OLED_DISPLAY_128X64)
oled_write_P(PSTR(" "), false);
#endif
static const char PROGMEM nukem_good[2] = {0xFA, 0};
oled_write_P(nukem_good, false);
#if !defined(OLED_DISPLAY_128X64)
oled_advance_page(true);
#endif
}
#if defined(OLED_DISPLAY_128X64)
oled_advance_page(true);
#endif
Expand Down
19 changes: 18 additions & 1 deletion users/drashna/process_records.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "version.h"

uint16_t copy_paste_timer;

bool host_driver_disabled = false;
// Defines actions tor my global custom keycodes. Defined in drashna.h file
// Then runs the _keymap's record handier if not processed here

Expand Down Expand Up @@ -198,6 +198,23 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re
eeconfig_update_user(userspace_config.raw);
}
}
break;
case KEYLOCK: {
static host_driver_t *host_driver = 0;

if (record->event.pressed) {
if (host_get_driver()) {
host_driver = host_get_driver();
clear_keyboard();
host_set_driver(0);
host_driver_disabled = true;
} else {
host_set_driver(host_driver);
host_driver_disabled = false;
}
}
break;
}
#endif
}
return true;
Expand Down
1 change: 1 addition & 0 deletions users/drashna/process_records.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum userspace_custom_keycodes {
UC_TABL, // ┬─┬ノ( º _ ºノ)
UC_SHRG, // ¯\_(ツ)_/¯
UC_DISA, // ಠ_ಠ
KEYLOCK, // Locks keyboard by unmounting driver
NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes
};

Expand Down
20 changes: 12 additions & 8 deletions users/drashna/transport_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ extern bool tap_toggling;
extern bool swap_hands;
#endif
extern userspace_config_t userspace_config;
extern bool host_driver_disabled;

uint16_t transport_keymap_config = 0;
uint32_t transport_userspace_config = 0;
uint32_t transport_userspace_config = 0, transport_user_state = 0;

user_runtime_config_t user_state;

void user_state_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
if (initiator2target_buffer_size == sizeof(user_state)) {
memcpy(&user_state, initiator2target_buffer, initiator2target_buffer_size);
if (initiator2target_buffer_size == sizeof(transport_user_state)) {
memcpy(&transport_user_state, initiator2target_buffer, initiator2target_buffer_size);
}
}
void user_keymap_sync(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
Expand Down Expand Up @@ -79,9 +80,13 @@ void user_transport_update(void) {
#ifdef SWAP_HANDS_ENABLE
user_state.swap_hands = swap_hands;
#endif
user_state.host_driver_disabled = host_driver_disabled;

transport_user_state = user_state.raw;
} else {
keymap_config.raw = transport_keymap_config;
userspace_config.raw = transport_userspace_config;
user_state.raw = transport_user_state;
#ifdef UNICODE_ENABLE
unicode_config.input_mode = user_state.unicode_mode;
#endif
Expand All @@ -91,22 +96,21 @@ void user_transport_update(void) {
#ifdef SWAP_HANDS_ENABLE
swap_hands = user_state.swap_hands;
#endif
host_driver_disabled = user_state.host_driver_disabled;
}
}

void user_transport_sync(void) {
if (is_keyboard_master()) {
// Keep track of the last state, so that we can tell if we need to propagate to slave
static user_runtime_config_t last_user_state;
static uint16_t last_keymap = 0;
static uint32_t last_config = 0;
static uint32_t last_sync[3];
static uint32_t last_config = 0, last_sync[3], last_user_state = 0;
bool needs_sync = false;

// Check if the state values are different
if (memcmp(&user_state, &last_user_state, sizeof(user_state))) {
if (memcmp(&transport_user_state, &last_user_state, sizeof(transport_user_state))) {
needs_sync = true;
memcpy(&last_user_state, &user_state, sizeof(user_state));
memcpy(&last_user_state, &transport_user_state, sizeof(transport_user_state));
}
// Send to slave every 500ms regardless of state change
if (timer_elapsed32(last_sync[0]) > 250) {
Expand Down
16 changes: 10 additions & 6 deletions users/drashna/transport_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@

#include "drashna.h"

__attribute__((aligned(8))) typedef struct {
bool audio_enable;
bool audio_clicky_enable;
bool tap_toggling;
bool unicode_mode;
bool swap_hands;
typedef union {
uint32_t raw;
struct {
bool audio_enable :1;
bool audio_clicky_enable :1;
bool tap_toggling :1;
bool unicode_mode :1;
bool swap_hands :1;
bool host_driver_disabled :1;
};
} user_runtime_config_t;

extern user_runtime_config_t user_state;
Expand Down

0 comments on commit 00862a9

Please sign in to comment.