fix: improper usage of keyboard/user-level functions (#22652)
This commit is contained in:
		
							parent
							
								
									05d2b7e2ac
								
							
						
					
					
						commit
						49527afc6a
					
				
					 6 changed files with 182 additions and 161 deletions
				
			
		| 
						 | 
				
			
			@ -17,7 +17,9 @@
 | 
			
		|||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
// Tested and verified working on ext65rev2
 | 
			
		||||
void matrix_io_delay(void) { __asm__ volatile("nop\nnop\nnop\n"); }
 | 
			
		||||
void matrix_io_delay(void) {
 | 
			
		||||
    __asm__ volatile("nop\nnop\nnop\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef OLED_ENABLE
 | 
			
		||||
void board_init(void) {
 | 
			
		||||
| 
						 | 
				
			
			@ -55,21 +57,26 @@ void render_mod_status(uint8_t modifiers) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
bool oled_task_kb(void) {
 | 
			
		||||
    if (!oled_task_user()) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    render_layer_state();
 | 
			
		||||
    render_keylock_status(host_keyboard_led_state());
 | 
			
		||||
    render_mod_status(get_mods() | get_oneshot_mods());
 | 
			
		||||
    return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
void keyboard_pre_init_user(void) {
 | 
			
		||||
void keyboard_pre_init_kb(void) {
 | 
			
		||||
    // Call the keyboard pre init code.
 | 
			
		||||
    // Set our LED pins as output
 | 
			
		||||
    setPinOutput(B4);
 | 
			
		||||
    setPinOutput(B3);
 | 
			
		||||
    setPinOutput(A15);
 | 
			
		||||
    setPinOutput(A14);
 | 
			
		||||
 | 
			
		||||
    keyboard_pre_init_user();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool led_update_kb(led_t led_state) {
 | 
			
		||||
| 
						 | 
				
			
			@ -94,4 +101,3 @@ layer_state_t layer_state_set_kb(layer_state_t state) {
 | 
			
		|||
    return layer_state_set_user(state);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,10 @@
 | 
			
		|||
char wpm_str[10];
 | 
			
		||||
 | 
			
		||||
#ifdef ENCODER_ENABLE
 | 
			
		||||
bool encoder_update_user(uint8_t index, bool clockwise) {
 | 
			
		||||
bool encoder_update_kb(uint8_t index, bool clockwise) {
 | 
			
		||||
    if (!encoder_update_user(index, clockwise)) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    // Right encoder
 | 
			
		||||
    if (index == 0) {
 | 
			
		||||
        if (clockwise) {
 | 
			
		||||
| 
						 | 
				
			
			@ -138,7 +141,10 @@ static void render_anim(void) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// Used to draw on to the oled screen
 | 
			
		||||
bool oled_task_user(void) {
 | 
			
		||||
bool oled_task_kb(void) {
 | 
			
		||||
    if (!oled_task_user()) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    render_anim(); // renders pixelart
 | 
			
		||||
 | 
			
		||||
    oled_set_cursor(0, 0); // sets cursor to (row, column) using charactar spacing (5 rows on 128x32 screen, anything more will overflow back to the top)
 | 
			
		||||
| 
						 | 
				
			
			@ -150,6 +156,6 @@ bool oled_task_user(void) {
 | 
			
		|||
    oled_set_cursor(0, 1);
 | 
			
		||||
    oled_write_P(led_state.caps_lock ? PSTR("CAPS") : PSTR("       "), false);
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,9 @@
 | 
			
		|||
 | 
			
		||||
#ifdef OLED_ENABLE
 | 
			
		||||
bool oled_task_kb(void) {
 | 
			
		||||
    if (!oled_task_user()) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    led_t led_usb_state = host_keyboard_led_state();
 | 
			
		||||
 | 
			
		||||
    render_bongocat();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,8 +18,10 @@
 | 
			
		|||
 | 
			
		||||
/* Encoders */
 | 
			
		||||
#ifdef ENCODER_ENABLE
 | 
			
		||||
    bool encoder_update_user(uint8_t index, bool clockwise) {
 | 
			
		||||
 | 
			
		||||
bool encoder_update_kb(uint8_t index, bool clockwise) {
 | 
			
		||||
    if (!encoder_update_user(index, clockwise)) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (index == 0) {
 | 
			
		||||
        if (clockwise) {
 | 
			
		||||
            tap_code(KC_MNXT);
 | 
			
		||||
| 
						 | 
				
			
			@ -33,6 +35,6 @@
 | 
			
		|||
            tap_code(KC_VOLD);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
        return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -237,12 +237,15 @@ oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
bool oled_task_kb(void) {
 | 
			
		||||
    if (!oled_task_user()) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    render_animation();
 | 
			
		||||
    render_status();
 | 
			
		||||
 | 
			
		||||
    oled_write_ln_P(PSTR("WPM:"), false);
 | 
			
		||||
    oled_write_ln(get_u8_str(get_current_wpm(), '0'), false);
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +18,7 @@
 | 
			
		|||
 | 
			
		||||
// Defines names for use in layer keycodes and the keymap
 | 
			
		||||
enum layer_names {
 | 
			
		||||
  _QWERTY = 0,
 | 
			
		||||
    _QWERTY,
 | 
			
		||||
    _LOWER,
 | 
			
		||||
    _RAISE,
 | 
			
		||||
    _ADJUST
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +27,6 @@ enum layer_names {
 | 
			
		|||
#ifdef OLED_ENABLE
 | 
			
		||||
 | 
			
		||||
void render_status(void) {
 | 
			
		||||
 | 
			
		||||
    // Render to mode icon
 | 
			
		||||
    static const char os_logo[][2][3] PROGMEM = {{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}};
 | 
			
		||||
    if (is_mac_mode()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +71,6 @@ void render_status(void) {
 | 
			
		|||
    oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR("    "), false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void render_logo(void) {
 | 
			
		||||
    static const char PROGMEM qmk_logo[] = {
 | 
			
		||||
        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
 | 
			
		||||
| 
						 | 
				
			
			@ -106,13 +104,16 @@ static void render_rgbled_status(bool full) {
 | 
			
		|||
#    endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool oled_task_user(void) {
 | 
			
		||||
bool oled_task_kb(void) {
 | 
			
		||||
    if (!oled_task_user()) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    if (is_keyboard_master()) {
 | 
			
		||||
        render_status();
 | 
			
		||||
    } else {
 | 
			
		||||
        render_logo();
 | 
			
		||||
        render_rgbled_status(true);
 | 
			
		||||
    }
 | 
			
		||||
  return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue