Merge remote-tracking branch 'origin/master' into develop

master
QMK Bot 2021-03-12 07:04:21 +00:00
commit 71f8f5048b
6 changed files with 66 additions and 103 deletions

View File

@ -269,31 +269,3 @@ void unicode_input_start (void) {
unregister_code(KC_LSFT);
unregister_code(KC_LCTL);
};
// Override method to use NEO_A instead of KC_A
uint16_t hex_to_keycode(uint8_t hex)
{
if(hex == 0x0) {
return KC_0;
}
else if(hex >= 0xA) {
switch(hex) {
case 0xA:
return NEO_A;
case 0xB:
return NEO_B;
case 0xC:
return NEO_C;
case 0xD:
return NEO_D;
case 0xE:
return NEO_E;
case 0xF:
return NEO_F;
default:
return KC_NO;
}
}
return KC_1 + (hex - 0x1);
}

View File

@ -158,7 +158,7 @@ __attribute__((weak)) void unicode_input_cancel(void) {
void register_hex(uint16_t hex) {
for (int i = 3; i >= 0; i--) {
uint8_t digit = ((hex >> (i * 4)) & 0xF);
tap_code16(hex_to_keycode(digit));
send_nibble(digit);
}
}
@ -171,10 +171,10 @@ void register_hex32(uint32_t hex) {
uint8_t digit = ((hex >> (i * 4)) & 0xF);
if (digit == 0) {
if (!onzerostart) {
tap_code16(hex_to_keycode(digit));
send_nibble(digit);
}
} else {
tap_code16(hex_to_keycode(digit));
send_nibble(digit);
onzerostart = false;
}
}

View File

@ -352,34 +352,6 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_
void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); }
void tap_random_base64(void) {
#if defined(__AVR_ATmega32U4__)
uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
#else
uint8_t key = rand() % 64;
#endif
switch (key) {
case 0 ... 25:
send_char(key + 'A');
break;
case 26 ... 51:
send_char(key - 26 + 'a');
break;
case 52:
send_char('0');
break;
case 53 ... 61:
send_char(key - 53 + '1');
break;
case 62:
send_char('+');
break;
case 63:
send_char('/');
break;
}
}
void matrix_init_quantum() {
magic();
#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN)
@ -475,40 +447,6 @@ void matrix_scan_quantum() {
# include "hd44780.h"
#endif
// Functions for spitting out values
//
void send_dword(uint32_t number) {
uint16_t word = (number >> 16);
send_word(word);
send_word(number & 0xFFFFUL);
}
void send_word(uint16_t number) {
uint8_t byte = number >> 8;
send_byte(byte);
send_byte(number & 0xFF);
}
void send_byte(uint8_t number) {
uint8_t nibble = number >> 4;
send_nibble(nibble);
send_nibble(number & 0xF);
}
void send_nibble(uint8_t number) { tap_code16(hex_to_keycode(number)); }
__attribute__((weak)) uint16_t hex_to_keycode(uint8_t hex) {
hex = hex & 0xF;
if (hex == 0x0) {
return KC_0;
} else if (hex < 0xA) {
return KC_1 + (hex - 0x1);
} else {
return KC_A + (hex - 0xA);
}
}
void api_send_unicode(uint32_t unicode) {
#ifdef API_ENABLE
uint8_t chunk[4];

View File

@ -206,8 +206,6 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_
void set_single_persistent_default_layer(uint8_t default_layer);
void tap_random_base64(void);
#define IS_LAYER_ON(layer) layer_state_is(layer)
#define IS_LAYER_OFF(layer) !layer_state_is(layer)
@ -235,12 +233,6 @@ void register_code16(uint16_t code);
void unregister_code16(uint16_t code);
void tap_code16(uint16_t code);
void send_dword(uint32_t number);
void send_word(uint16_t number);
void send_byte(uint8_t number);
void send_nibble(uint8_t number);
uint16_t hex_to_keycode(uint8_t hex);
void led_set_user(uint8_t usb_led);
void led_set_kb(uint8_t usb_led);
bool led_update_user(led_t led_state);

View File

@ -250,3 +250,57 @@ void send_char(char ascii_code) {
tap_code(KC_SPACE);
}
}
void send_dword(uint32_t number) {
send_word(number >> 16);
send_word(number & 0xFFFFUL);
}
void send_word(uint16_t number) {
send_byte(number >> 8);
send_byte(number & 0xFF);
}
void send_byte(uint8_t number) {
send_nibble(number >> 4);
send_nibble(number & 0xF);
}
void send_nibble(uint8_t number) {
switch (number & 0xF) {
case 0 ... 9:
send_char(number + '0');
break;
case 10 ... 15:
send_char(number - 10 + 'a');
break;
}
}
void tap_random_base64(void) {
#if defined(__AVR_ATmega32U4__)
uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
#else
uint8_t key = rand() % 64;
#endif
switch (key) {
case 0 ... 25:
send_char(key + 'A');
break;
case 26 ... 51:
send_char(key - 26 + 'a');
break;
case 52:
send_char('0');
break;
case 53 ... 61:
send_char(key - 53 + '1');
break;
case 62:
send_char('+');
break;
case 63:
send_char('/');
break;
}
}

View File

@ -23,10 +23,10 @@
#define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval)
// Look-Up Tables (LUTs) to convert ASCII character to keycode sequence.
extern const uint8_t ascii_to_keycode_lut[128];
extern const uint8_t ascii_to_shift_lut[16];
extern const uint8_t ascii_to_altgr_lut[16];
extern const uint8_t ascii_to_dead_lut[16];
extern const uint8_t ascii_to_keycode_lut[128];
// clang-format off
#define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \
@ -45,3 +45,10 @@ void send_string_with_delay(const char *str, uint8_t interval);
void send_string_P(const char *str);
void send_string_with_delay_P(const char *str, uint8_t interval);
void send_char(char ascii_code);
void send_dword(uint32_t number);
void send_word(uint16_t number);
void send_byte(uint8_t number);
void send_nibble(uint8_t number);
void tap_random_base64(void);