1
0
Fork 0

[Keymap] Drashna Keymap Updates (#14842)

* 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
This commit is contained in:
Drashna Jael're 2021-10-15 22:30:23 -07:00 committed by GitHub
parent a8422cca03
commit 9a0addc77e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1035 additions and 1053 deletions

View file

@ -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();
}

File diff suppressed because it is too large Load diff

View file

@ -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))
@ -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
@ -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) {
@ -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

View file

@ -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
@ -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;

View file

@ -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
};

View file

@ -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) {
@ -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
@ -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) {

View file

@ -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;