Simplify alt codes

main
Ashelyn Dawn 3 years ago
parent 3458a8949e
commit 862c72217e

@ -314,45 +314,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case AD_UASH:
if(record->event.pressed) {
bool numlock_enabled = host_keyboard_led_state().num_lock;
if (!numlock_enabled) {
register_code(KC_NUMLOCK);
unregister_code(KC_NUMLOCK);
}
register_code(KC_LALT);
tap_code(KC_KP_0);
tap_code(KC_KP_1);
tap_code(KC_KP_9);
tap_code(KC_KP_8);
unregister_code(KC_LALT);
if (!numlock_enabled) {
register_code(KC_NUMLOCK);
unregister_code(KC_NUMLOCK);
}
send_alt_code(198);
}
return false;
case AD_LASH:
if(record->event.pressed) {
bool numlock_enabled = host_keyboard_led_state().num_lock;
if (!numlock_enabled) {
register_code(KC_NUMLOCK);
unregister_code(KC_NUMLOCK);
}
register_code(KC_LALT);
tap_code(KC_KP_0);
tap_code(KC_KP_2);
tap_code(KC_KP_3);
tap_code(KC_KP_0);
unregister_code(KC_LALT);
if (!numlock_enabled) {
register_code(KC_NUMLOCK);
unregister_code(KC_NUMLOCK);
}
send_alt_code(230);
}
return false;
@ -445,6 +413,7 @@ void set_layer_color(int layer) {
}
}
}
void rgb_matrix_indicators_user(void) {
if (g_suspend_state || disable_layer_color ||
rgb_matrix_get_flags() == LED_FLAG_NONE ||
@ -452,4 +421,42 @@ void rgb_matrix_indicators_user(void) {
return;
}
set_layer_color(get_highest_layer(layer_state));
}
const uint16_t NUMPAD_CODES[] = {
KC_KP_0,
KC_KP_1,
KC_KP_2,
KC_KP_3,
KC_KP_4,
KC_KP_5,
KC_KP_6,
KC_KP_7,
KC_KP_8,
KC_KP_9,
};
void send_alt_code(int code) {
bool numlock_enabled = host_keyboard_led_state().num_lock;
if (!numlock_enabled) {
register_code(KC_NUMLOCK);
unregister_code(KC_NUMLOCK);
}
short digit1 = code / 1000 % 10;
short digit2 = code / 100 % 10;
short digit3 = code / 10 % 10;
short digit4 = code % 10;
register_code(KC_LALT);
tap_code(NUMPAD_CODES[digit1]);
tap_code(NUMPAD_CODES[digit2]);
tap_code(NUMPAD_CODES[digit3]);
tap_code(NUMPAD_CODES[digit4]);
unregister_code(KC_LALT);
if (!numlock_enabled) {
register_code(KC_NUMLOCK);
unregister_code(KC_NUMLOCK);
}
}

@ -22,4 +22,6 @@ enum layout_names {
extern bool g_suspend_state;
extern rgb_config_t rgb_matrix_config;
bool disable_layer_color;
bool disable_layer_color;
void send_alt_code(int);
Loading…
Cancel
Save