From e01b2d518a1a08ce07278ef9a38c7a793c843749 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Mon, 6 May 2019 17:06:43 -0500 Subject: [Keyboard] Sol keyboard conversion to split common (#5773) * Split common conversion * Updated serial and encoder pins * Fixing default folder until r2 * Fixing oled driver on slave split common * Fixing keymap compile errors * Fixing oled inactivity timer on slave split common * Hoisted oled driver task, init, & activity to keyboard.c * Update keyboards/sol/config.h Co-Authored-By: XScorpion2 * Remove TAPPING_FORCE_HOLD --- tmk_core/common/keyboard.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 52546866eb..85d2525480 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -75,6 +75,9 @@ along with this program. If not, see . #ifdef QWIIC_ENABLE # include "qwiic.h" #endif +#ifdef OLED_DRIVER_ENABLE + #include "oled_driver.h" +#endif #ifdef VELOCIKEY_ENABLE #include "velocikey.h" #endif @@ -205,6 +208,9 @@ void keyboard_init(void) { #ifdef QWIIC_ENABLE qwiic_init(); #endif +#ifdef OLED_DRIVER_ENABLE + oled_init(OLED_ROTATION_0); +#endif #ifdef PS2_MOUSE_ENABLE ps2_mouse_init(); #endif @@ -262,7 +268,11 @@ void keyboard_task(void) uint8_t keys_processed = 0; #endif +#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) + uint8_t ret = matrix_scan(); +#else matrix_scan(); +#endif if (is_keyboard_master()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -306,6 +316,15 @@ MATRIX_LOOP_END: qwiic_task(); #endif +#ifdef OLED_DRIVER_ENABLE + oled_task(); +#ifndef OLED_DISABLE_TIMEOUT + // Wake up oled if user is using those fabulous keys! + if (ret) + oled_on(); +#endif +#endif + #ifdef MOUSEKEY_ENABLE // mousekey repeat & acceleration mousekey_task(); -- cgit v1.2.3 From f2c179de58c63b2202a490d283fd8fa216680ce7 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Wed, 21 Aug 2019 15:18:52 +1000 Subject: Remove superfluous JTAG disable code (#6445) * Remove superfluous JTAG disable code * 32A has differently named register * Accidentally some operators * 32A also has different JTAG pins * Wrap disable_jtag() in an ifndef * Document this new define * Rename the define, it conflicts with a LUFA thing Also, move the ifndef wrapping to the call in keyboard_setup() --- tmk_core/common/keyboard.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 85d2525480..8f0257cf66 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -130,10 +130,15 @@ static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata) #endif void disable_jtag(void) { -// To use PORTF disable JTAG with writing JTD bit twice within four cycles. -#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega32U4__)) +// To use PF4-7 (PC2-5 on ATmega32A), disable JTAG by writing JTD bit twice within four cycles. +#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || \ + defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) MCUCR |= _BV(JTD); MCUCR |= _BV(JTD); +#elif defined(__AVR_ATmega32A__) + MCUCSR |= _BV(JTD); + MCUCSR |= _BV(JTD); #endif } @@ -184,7 +189,9 @@ void keyboard_post_init_kb(void) { * FIXME: needs doc */ void keyboard_setup(void) { +#ifndef NO_JTAG_DISABLE disable_jtag(); +#endif matrix_setup(); keyboard_pre_init_kb(); } -- cgit v1.2.3 From b624f32f944acdc59dcb130674c09090c5c404cb Mon Sep 17 00:00:00 2001 From: skullY Date: Fri, 30 Aug 2019 11:19:03 -0700 Subject: clang-format changes --- tmk_core/common/keyboard.c | 138 ++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 76 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 8f0257cf66..f4d2cd7389 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -32,84 +32,82 @@ along with this program. If not, see . #include "backlight.h" #include "action_layer.h" #ifdef BOOTMAGIC_ENABLE -# include "bootmagic.h" +# include "bootmagic.h" #else -# include "magic.h" +# include "magic.h" #endif #ifdef MOUSEKEY_ENABLE -# include "mousekey.h" +# include "mousekey.h" #endif #ifdef PS2_MOUSE_ENABLE -# include "ps2_mouse.h" +# include "ps2_mouse.h" #endif #ifdef SERIAL_MOUSE_ENABLE -# include "serial_mouse.h" +# include "serial_mouse.h" #endif #ifdef ADB_MOUSE_ENABLE -# include "adb.h" +# include "adb.h" #endif #ifdef RGBLIGHT_ENABLE -# include "rgblight.h" +# include "rgblight.h" #endif #ifdef STENO_ENABLE -# include "process_steno.h" +# include "process_steno.h" #endif #ifdef FAUXCLICKY_ENABLE -# include "fauxclicky.h" +# include "fauxclicky.h" #endif #ifdef SERIAL_LINK_ENABLE -# include "serial_link/system/serial_link.h" +# include "serial_link/system/serial_link.h" #endif #ifdef VISUALIZER_ENABLE -# include "visualizer/visualizer.h" +# include "visualizer/visualizer.h" #endif #ifdef POINTING_DEVICE_ENABLE -# include "pointing_device.h" +# include "pointing_device.h" #endif #ifdef MIDI_ENABLE -# include "process_midi.h" +# include "process_midi.h" #endif #ifdef HD44780_ENABLE -# include "hd44780.h" +# include "hd44780.h" #endif #ifdef QWIIC_ENABLE -# include "qwiic.h" +# include "qwiic.h" #endif #ifdef OLED_DRIVER_ENABLE - #include "oled_driver.h" +# include "oled_driver.h" #endif #ifdef VELOCIKEY_ENABLE - #include "velocikey.h" +# include "velocikey.h" #endif #ifdef MATRIX_HAS_GHOST extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; -static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata){ +static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) { matrix_row_t out = 0; for (uint8_t col = 0; col < MATRIX_COLS; col++) { - //read each key in the row data and check if the keymap defines it as a real key - if (pgm_read_byte(&keymaps[0][row][col]) && (rowdata & (1<= QMK_KEYS_PER_SCAN) #endif - // process a key per task call - goto MATRIX_LOOP_END; + // process a key per task call + goto MATRIX_LOOP_END; } } } @@ -315,7 +297,7 @@ void keyboard_task(void) // we can get here with some keys processed now. if (!keys_processed) #endif - action_exec(TICK); + action_exec(TICK); MATRIX_LOOP_END: @@ -325,11 +307,10 @@ MATRIX_LOOP_END: #ifdef OLED_DRIVER_ENABLE oled_task(); -#ifndef OLED_DISABLE_TIMEOUT +# ifndef OLED_DISABLE_TIMEOUT // Wake up oled if user is using those fabulous keys! - if (ret) - oled_on(); -#endif + if (ret) oled_on(); +# endif #endif #ifdef MOUSEKEY_ENABLE @@ -350,7 +331,7 @@ MATRIX_LOOP_END: #endif #ifdef SERIAL_LINK_ENABLE - serial_link_update(); + serial_link_update(); #endif #ifdef VISUALIZER_ENABLE @@ -366,7 +347,9 @@ MATRIX_LOOP_END: #endif #ifdef VELOCIKEY_ENABLE - if (velocikey_enabled()) { velocikey_decelerate(); } + if (velocikey_enabled()) { + velocikey_decelerate(); + } #endif // update LED @@ -380,8 +363,11 @@ MATRIX_LOOP_END: * * FIXME: needs doc */ -void keyboard_set_leds(uint8_t leds) -{ - if (debug_keyboard) { debug("keyboard_set_led: "); debug_hex8(leds); debug("\n"); } +void keyboard_set_leds(uint8_t leds) { + if (debug_keyboard) { + debug("keyboard_set_led: "); + debug_hex8(leds); + debug("\n"); + } led_set(leds); } -- cgit v1.2.3 From cc5edb9eeb2d30400dee278a6f20991389f68afe Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 15 Oct 2019 13:32:52 +0100 Subject: Port DEBUG_MATRIX_SCAN_RATE to core (#7029) * Port DEBUG_MATRIX_SCAN_RATE to core * Remove duplicate DEBUG_MATRIX_SCAN_RATE implementations * Remove duplicate DEBUG_MATRIX_SCAN_RATE implementation from handwired/xealous * Add console logic from ergodox_ez --- tmk_core/common/keyboard.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index f4d2cd7389..9806b5015f 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -82,6 +82,26 @@ along with this program. If not, see . # include "velocikey.h" #endif +// Only enable this if console is enabled to print to +#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) +static uint32_t matrix_timer = 0; +static uint32_t matrix_scan_count = 0; + +void matrix_scan_perf_task(void) { + matrix_scan_count++; + + uint32_t timer_now = timer_read32(); + if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { + dprintf("matrix scan frequency: %d\n", matrix_scan_count); + + matrix_timer = timer_now; + matrix_scan_count = 0; + } +} +#else +# define matrix_scan_perf_task() +#endif + #ifdef MATRIX_HAS_GHOST extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) { @@ -301,6 +321,10 @@ void keyboard_task(void) { MATRIX_LOOP_END: +#ifdef DEBUG_MATRIX_SCAN_RATE + matrix_scan_perf_task(); +#endif + #ifdef QWIIC_ENABLE qwiic_task(); #endif -- cgit v1.2.3 From abfd6ed9613013d3c9f15da8b575a902d9bcf274 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 17 Oct 2019 17:48:58 +0100 Subject: Move tmk_core/common/backlight to quantum/backlight (#6710) * Move tmk_core/common/backlight to quantum/backlight * Add guards to backlight inclusion * Add guards to backlight inclusion * Update backlight guards on clueboard/60 * Use full paths to avoid vpath issues --- tmk_core/common/keyboard.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 9806b5015f..63ace9793c 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -29,8 +29,10 @@ along with this program. If not, see . #include "util.h" #include "sendchar.h" #include "eeconfig.h" -#include "backlight.h" #include "action_layer.h" +#ifdef BACKLIGHT_ENABLE +# include "backlight.h" +#endif #ifdef BOOTMAGIC_ENABLE # include "bootmagic.h" #else -- cgit v1.2.3 From efb21c00ce8090303456dc9c22665a69c3fc298a Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 11 Dec 2019 19:39:30 +0000 Subject: Fix FORCE_NKRO handling (#7601) --- tmk_core/common/keyboard.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 63ace9793c..125f00ccf7 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -254,6 +254,7 @@ void keyboard_init(void) { #endif #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) keymap_config.nkro = 1; + eeconfig_update_keymap(keymap_config.raw); #endif keyboard_post_init_kb(); /* Always keep this last */ } -- cgit v1.2.3 From 85f4c3ebb456c2d6feebf8934ab014436d7f8f17 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 16 Dec 2019 08:31:59 -0800 Subject: [Core] Optimize matrix processing (#7621) Backport of tmk/tmk_keyboard@ad6059adc7039a54d1db75da783068654906a679 --- tmk_core/common/keyboard.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 125f00ccf7..af2b2fd48b 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -297,13 +297,14 @@ void keyboard_task(void) { } #endif if (debug_matrix) matrix_print(); - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - if (matrix_change & ((matrix_row_t)1 << c)) { + matrix_row_t col_mask = 1; + for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { + if (matrix_change & col_mask) { action_exec((keyevent_t){ - .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & ((matrix_row_t)1 << c)), .time = (timer_read() | 1) /* time should not be 0 */ + .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ }); // record a processed key - matrix_prev[r] ^= ((matrix_row_t)1 << c); + matrix_prev[r] ^= col_mask; #ifdef QMK_KEYS_PER_SCAN // only jump out if we have processed "enough" keys. if (++keys_processed >= QMK_KEYS_PER_SCAN) -- cgit v1.2.3 From 320822d75b785401809f45007320e6fb6885b3fd Mon Sep 17 00:00:00 2001 From: Wilba Date: Sat, 4 Jan 2020 07:52:00 +1100 Subject: VIA Configurator Refactor (#7268) * VIA Refactor * Remove old code * review changes * review changes * Fix cannonkeys/satisfaction75/prototype:via build * Add via.h to quantum.h * Move backlight init to after backlight config load * Merge branch 'master' into via_refactor_pr * Update user's rules.mk to new way of enabling VIA * Added id_switch_matrix_state * Review changes --- tmk_core/common/keyboard.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index af2b2fd48b..794a9152fb 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -83,6 +83,9 @@ along with this program. If not, see . #ifdef VELOCIKEY_ENABLE # include "velocikey.h" #endif +#ifdef VIA_ENABLE +# include "via.h" +#endif // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) @@ -217,6 +220,9 @@ __attribute__((weak)) bool is_keyboard_master(void) { return true; } void keyboard_init(void) { timer_init(); matrix_init(); +#ifdef VIA_ENABLE + via_init(); +#endif #ifdef QWIIC_ENABLE qwiic_init(); #endif -- cgit v1.2.3 From ba628a28bcf09421739922d8eeef05e6ca9e9b6b Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 19 Jan 2020 00:59:09 +0000 Subject: Move rgblight and backlight task to common location (#7733) --- tmk_core/common/keyboard.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 794a9152fb..cb4e7637fa 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -335,6 +335,16 @@ MATRIX_LOOP_END: matrix_scan_perf_task(); #endif +#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) + rgblight_task(); +#endif + +#if defined(BACKLIGHT_ENABLE) +# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS) + backlight_task(); +# endif +#endif + #ifdef QWIIC_ENABLE qwiic_task(); #endif -- cgit v1.2.3 From dbbab409812ea7c579760e2973399245c21ff843 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Tue, 10 Mar 2020 17:46:03 +0900 Subject: Refactor rgblight_reconfig.h (#7773) * Moved contents of rgblight_reconfig.h to rgblight_post_config.h. In #3582, rgblight_reconfig.h had to be newly created. Now, the build system of qmk_firmware has a post_cofig feature, so that what was done in rgblight_reconfig.h can now be realized in rgblight_post_config.h. **This commit does not change the build result.** Testing script ```shell # build on master git checkout master echo master > /tmp/master_md5.txt # RGBLIGHT_ENABLE = no make HELIX=verbose helix/rev2:default:clean make HELIX=verbose helix/rev2:default md5 helix_rev2_default.hex >> /tmp/master_md5.txt # RGBLIGHT_ENABLE = yes, with animations make HELIX=verbose helix/rev2/back:default:clean make HELIX=verbose helix/rev2/back:default md5 helix_rev2_back_default.hex >> /tmp/master_md5.txt # RGBLIGHT_ENABLE = yes, without animations make HELIX=verbose,no_ani helix/rev2/back:default:clean make HELIX=verbose,no_ani helix/rev2/back:default md5 helix_rev2_back_default.hex >> /tmp/master_md5.txt # build on refactor_rgblight_reconfig.h git checkout refactor_rgblight_reconfig.h echo refactor_rgblight_reconfig.h > /tmp/branch_md5.txt # RGBLIGHT_ENABLE = no make HELIX=verbose helix/rev2:default:clean make HELIX=verbose helix/rev2:default md5 helix_rev2_default.hex >> /tmp/branch_md5.txt # RGBLIGHT_ENABLE = yes, with animations make HELIX=verbose helix/rev2/back:default:clean make HELIX=verbose helix/rev2/back:default md5 helix_rev2_back_default.hex >> /tmp/branch_md5.txt # RGBLIGHT_ENABLE = yes, without animations make HELIX=verbose,no_ani helix/rev2/back:default:clean make HELIX=verbose,no_ani helix/rev2/back:default md5 helix_rev2_back_default.hex >> /tmp/branch_md5.txt diff -u /tmp/master_md5.txt /tmp/branch_md5.txt ``` Test result: ``` --- /tmp/master_md5.txt 2020-01-03 15:42:22.000000000 +0900 +++ /tmp/branch_md5.txt 2020-01-03 15:42:42.000000000 +0900 @@ -1,4 +1,4 @@ -master +refactor_rgblight_reconfig.h MD5 (helix_rev2_default.hex) = f360032edd522448366d471d8f4f8181 MD5 (helix_rev2_back_default.hex) = 0c663acc6cccc44476b3b969ad22a48f MD5 (helix_rev2_back_default.hex) = e66b1195ff6d38e6e22c975b8ae42fd3 ``` * Expressions that are too long are difficult to read, so wrap them. * Edit the expression again * remove `defined(RGBLIGHT_ANIMATIONS)` in `tmk_core/common/*/suspend.c`, `tmk_core/protocol/*/main.c` move contents of rgblight_reconfig.h to rgblight.h. The following changes were made to rgblight.h. ```diff +#ifdef RGBLIGHT_USE_TIMER void rgblight_task(void); void rgblight_timer_init(void); void rgblight_timer_enable(void); void rgblight_timer_disable(void); void rgblight_timer_toggle(void); +#else +#define rgblight_task() +#define rgblight_timer_init() +#define rgblight_timer_enable() +#define rgblight_timer_disable() +#define rgblight_timer_toggle() +#endif ``` The following changes were made to tmk_core/common/avr/suspend.c, tmk_core/common/chibios/suspend.c, tmk_core/protocol/chibios/main.c, tmk_core/protocol/lufa/lufa.c, tmk_core/protocol/vusb/main.c. ```diff -# ifdef RGBLIGHT_ANIMATIONS rgblight_timer_enable(); -# endif ``` ```diff -#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) +#if defined(RGBLIGHT_ENABLE) rgblight_task(); #endif ``` * remove 'defined(RGBLIGHT_ANIMATIONS)' in tmk_core/common/keyboard.c Co-authored-by: Joel Challis --- tmk_core/common/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index cb4e7637fa..a767d9c877 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -335,7 +335,7 @@ MATRIX_LOOP_END: matrix_scan_perf_task(); #endif -#if defined(RGBLIGHT_ANIMATIONS) && defined(RGBLIGHT_ENABLE) +#if defined(RGBLIGHT_ENABLE) rgblight_task(); #endif -- cgit v1.2.3 From 406dc2fb2d1e657db2d7235885722dd86d07ea08 Mon Sep 17 00:00:00 2001 From: zvecr Date: Sat, 2 May 2020 22:44:36 +0100 Subject: Move encoder_read to common location --- tmk_core/common/keyboard.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a767d9c877..200b1e8722 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -53,6 +53,9 @@ along with this program. If not, see . #ifdef RGBLIGHT_ENABLE # include "rgblight.h" #endif +#ifdef ENCODER_ENABLE +# include "encoder.h" +#endif #ifdef STENO_ENABLE # include "process_steno.h" #endif @@ -249,6 +252,9 @@ void keyboard_init(void) { #ifdef RGBLIGHT_ENABLE rgblight_init(); #endif +#ifdef ENCODER_ENABLE + encoder_init(); +#endif #ifdef STENO_ENABLE steno_init(); #endif @@ -345,6 +351,10 @@ MATRIX_LOOP_END: # endif #endif +#ifdef ENCODER_ENABLE + encoder_read(); +#endif + #ifdef QWIIC_ENABLE qwiic_task(); #endif -- cgit v1.2.3 From c482a2944bf5b025fd70fa9ee53fc2e12369d327 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 3 May 2020 00:39:37 +0100 Subject: Provide a mechanism for split keyboards to process key press on both halves (#9001) --- tmk_core/common/keyboard.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a767d9c877..53d08959e8 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -213,6 +213,13 @@ void keyboard_setup(void) { */ __attribute__((weak)) bool is_keyboard_master(void) { return true; } +/** \brief should_process_keypress + * + * Override this function if you have a condition where keypresses processing should change: + * - splits where the slave side needs to process for rgb/oled functionality + */ +__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); } + /** \brief keyboard_init * * FIXME: needs doc @@ -292,7 +299,7 @@ void keyboard_task(void) { matrix_scan(); #endif - if (is_keyboard_master()) { + if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { matrix_row = matrix_get_row(r); matrix_change = matrix_row ^ matrix_prev[r]; -- cgit v1.2.3 From 1110fe6c6f86a684ba098d9c87665887278b068a Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 2 Jun 2020 16:32:02 -0700 Subject: Move dip switch init to back of the init process (#9233) --- tmk_core/common/keyboard.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 53d08959e8..e2110363a6 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -86,6 +86,9 @@ along with this program. If not, see . #ifdef VIA_ENABLE # include "via.h" #endif +#ifdef DIP_SWITCH_ENABLE +# include "dip_switch.h" +#endif // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) @@ -269,6 +272,10 @@ void keyboard_init(void) { keymap_config.nkro = 1; eeconfig_update_keymap(keymap_config.raw); #endif +#ifdef DIP_SWITCH_ENABLE + dip_switch_init(); +#endif + keyboard_post_init_kb(); /* Always keep this last */ } -- cgit v1.2.3 From d4be07dad368c57669c88ead6c093c9e23086855 Mon Sep 17 00:00:00 2001 From: a-chol Date: Sat, 25 Jul 2020 14:01:15 +0200 Subject: Hid joystick interface (#4226) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan * Update docs/feature_joystick.md Co-Authored-By: Ryan * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol Co-authored-by: José Júnior Co-authored-by: a-chol Co-authored-by: Nick Brassel Co-authored-by: Ryan --- tmk_core/common/keyboard.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 714c3d048f..a45af56dfd 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -74,6 +74,9 @@ along with this program. If not, see . #ifdef MIDI_ENABLE # include "process_midi.h" #endif +#ifdef JOYSTICK_ENABLE +# include "process_joystick.h" +#endif #ifdef HD44780_ENABLE # include "hd44780.h" #endif @@ -420,6 +423,10 @@ MATRIX_LOOP_END: } #endif +#ifdef JOYSTICK_ENABLE + joystick_task(); +#endif + // update LED if (led_status != host_keyboard_leds()) { led_status = host_keyboard_leds(); -- cgit v1.2.3 From e7497b3fba0c2836c9bb5087eee8b15d6ffc1362 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 18 Nov 2020 16:50:32 -0800 Subject: Add references for is_keyboard_left() (#10850) * Add references for is_keyboard_left() * Remove proto from bootmagic_lite.c --- tmk_core/common/keyboard.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a45af56dfd..b0394af003 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -222,6 +222,12 @@ void keyboard_setup(void) { */ __attribute__((weak)) bool is_keyboard_master(void) { return true; } +/** \brief is_keyboard_left + * + * FIXME: needs doc + */ +__attribute__((weak)) bool is_keyboard_left(void) { return true; } + /** \brief should_process_keypress * * Override this function if you have a condition where keypresses processing should change: -- cgit v1.2.3 From c66df1664497546f32662409778731143e45a552 Mon Sep 17 00:00:00 2001 From: James Young <18669334+noroadsleft@users.noreply.github.com> Date: Sat, 28 Nov 2020 12:02:18 -0800 Subject: 2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change --- tmk_core/common/keyboard.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index b0394af003..8c7bdc8b55 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -235,6 +235,20 @@ __attribute__((weak)) bool is_keyboard_left(void) { return true; } */ __attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); } +/** \brief housekeeping_task_kb + * + * Override this function if you have a need to execute code for every keyboard main loop iteration. + * This is specific to keyboard-level functionality. + */ +__attribute__((weak)) void housekeeping_task_kb(void) {} + +/** \brief housekeeping_task_user + * + * Override this function if you have a need to execute code for every keyboard main loop iteration. + * This is specific to user/keymap-level functionality. + */ +__attribute__((weak)) void housekeeping_task_user(void) {} + /** \brief keyboard_init * * FIXME: needs doc @@ -291,6 +305,10 @@ void keyboard_init(void) { dip_switch_init(); #endif +#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) + debug_enable = true; +#endif + keyboard_post_init_kb(); /* Always keep this last */ } @@ -315,6 +333,9 @@ void keyboard_task(void) { uint8_t keys_processed = 0; #endif + housekeeping_task_kb(); + housekeeping_task_user(); + #if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) uint8_t ret = matrix_scan(); #else -- cgit v1.2.3 From a8d0ec0749046b0ab89c18b1b7083b1e8674de2a Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 1 Dec 2020 12:04:42 -0600 Subject: [Split] Sync Timer feature (#10997) A timer that is kept in sync between the halves of a split keyboard --- tmk_core/common/keyboard.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 8c7bdc8b55..a1fbc01da6 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -23,6 +23,7 @@ along with this program. If not, see . #include "led.h" #include "keycode.h" #include "timer.h" +#include "sync_timer.h" #include "print.h" #include "debug.h" #include "command.h" @@ -255,6 +256,7 @@ __attribute__((weak)) void housekeeping_task_user(void) {} */ void keyboard_init(void) { timer_init(); + sync_timer_init(); matrix_init(); #ifdef VIA_ENABLE via_init(); -- cgit v1.2.3 From 79d1db332477963555416d9fff82ecac4399bd52 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 12 Jan 2021 19:48:24 +1100 Subject: Keep track of last matrix activity (#10730) * Allow recording of the last matrix activity time, to simplify implementation of display timeouts and the like. * Add requested changes from code review. * Simplify split matrix last changed. --- tmk_core/common/keyboard.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a1fbc01da6..aea09169fb 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,6 +97,10 @@ along with this program. If not, see . # include "dip_switch.h" #endif +static uint32_t last_matrix_modification_time = 0; +uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } +uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } + // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) static uint32_t matrix_timer = 0; @@ -338,11 +342,8 @@ void keyboard_task(void) { housekeeping_task_kb(); housekeeping_task_user(); -#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) - uint8_t ret = matrix_scan(); -#else - matrix_scan(); -#endif + uint8_t matrix_changed = matrix_scan(); + if (matrix_changed) last_matrix_modification_time = timer_read32(); if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -409,7 +410,7 @@ MATRIX_LOOP_END: oled_task(); # ifndef OLED_DISABLE_TIMEOUT // Wake up oled if user is using those fabulous keys! - if (ret) oled_on(); + if (matrix_changed) oled_on(); # endif #endif -- cgit v1.2.3 From ab375d3d075c105f09a1ddd0e155f178225518bc Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 15 Jan 2021 06:55:07 +1100 Subject: Revert "Keep track of last matrix activity (#10730)" This reverts commit 79d1db332477963555416d9fff82ecac4399bd52. --- tmk_core/common/keyboard.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index aea09169fb..a1fbc01da6 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,10 +97,6 @@ along with this program. If not, see . # include "dip_switch.h" #endif -static uint32_t last_matrix_modification_time = 0; -uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } -uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } - // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) static uint32_t matrix_timer = 0; @@ -342,8 +338,11 @@ void keyboard_task(void) { housekeeping_task_kb(); housekeeping_task_user(); - uint8_t matrix_changed = matrix_scan(); - if (matrix_changed) last_matrix_modification_time = timer_read32(); +#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) + uint8_t ret = matrix_scan(); +#else + matrix_scan(); +#endif if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -410,7 +409,7 @@ MATRIX_LOOP_END: oled_task(); # ifndef OLED_DISABLE_TIMEOUT // Wake up oled if user is using those fabulous keys! - if (matrix_changed) oled_on(); + if (ret) oled_on(); # endif #endif -- cgit v1.2.3 From e702c7f1b4cfa8fe1579498ef2877994baa64056 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 18 Jan 2021 05:01:38 +1100 Subject: Keep track of last matrix activity. (#11552) Co-authored-by: Dasky Co-authored-by: Dasky --- tmk_core/common/keyboard.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a1fbc01da6..aea09169fb 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,6 +97,10 @@ along with this program. If not, see . # include "dip_switch.h" #endif +static uint32_t last_matrix_modification_time = 0; +uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } +uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } + // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) static uint32_t matrix_timer = 0; @@ -338,11 +342,8 @@ void keyboard_task(void) { housekeeping_task_kb(); housekeeping_task_user(); -#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) - uint8_t ret = matrix_scan(); -#else - matrix_scan(); -#endif + uint8_t matrix_changed = matrix_scan(); + if (matrix_changed) last_matrix_modification_time = timer_read32(); if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -409,7 +410,7 @@ MATRIX_LOOP_END: oled_task(); # ifndef OLED_DISABLE_TIMEOUT // Wake up oled if user is using those fabulous keys! - if (ret) oled_on(); + if (matrix_changed) oled_on(); # endif #endif -- cgit v1.2.3 From 1108210f1bee89c29b1bcd6105d0a7b48a53ca04 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 21 Jan 2021 22:24:07 +1100 Subject: Keep track of encoder activity (#11595) * Keep track of encoder activity, provide API for either matrix/encoder. * Fixup build when no RGBLIGHT or Backlight enabled. --- tmk_core/common/keyboard.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index aea09169fb..0ca4546128 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,9 +97,19 @@ along with this program. If not, see . # include "dip_switch.h" #endif +static uint32_t last_input_modification_time = 0; +uint32_t last_input_activity_time(void) { return last_input_modification_time; } +uint32_t last_input_activity_elapsed(void) { return timer_elapsed32(last_input_modification_time); } + static uint32_t last_matrix_modification_time = 0; uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } +void last_matrix_activity_trigger(void) { last_matrix_modification_time = last_input_modification_time = timer_read32(); } + +static uint32_t last_encoder_modification_time = 0; +uint32_t last_encoder_activity_time(void) { return last_encoder_modification_time; } +uint32_t last_encoder_activity_elapsed(void) { return timer_elapsed32(last_encoder_modification_time); } +void last_encoder_activity_trigger(void) { last_encoder_modification_time = last_input_modification_time = timer_read32(); } // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) @@ -338,12 +348,15 @@ void keyboard_task(void) { #ifdef QMK_KEYS_PER_SCAN uint8_t keys_processed = 0; #endif +#ifdef ENCODER_ENABLE + bool encoders_changed = false; +#endif housekeeping_task_kb(); housekeeping_task_user(); uint8_t matrix_changed = matrix_scan(); - if (matrix_changed) last_matrix_modification_time = timer_read32(); + if (matrix_changed) last_matrix_activity_trigger(); if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -399,7 +412,8 @@ MATRIX_LOOP_END: #endif #ifdef ENCODER_ENABLE - encoder_read(); + encoders_changed = encoder_read(); + if (encoders_changed) last_encoder_activity_trigger(); #endif #ifdef QWIIC_ENABLE @@ -409,8 +423,12 @@ MATRIX_LOOP_END: #ifdef OLED_DRIVER_ENABLE oled_task(); # ifndef OLED_DISABLE_TIMEOUT - // Wake up oled if user is using those fabulous keys! + // Wake up oled if user is using those fabulous keys or spinning those encoders! +# ifdef ENCODER_ENABLE + if (matrix_changed || encoders_changed) oled_on(); +# else if (matrix_changed) oled_on(); +# endif # endif #endif -- cgit v1.2.3 From c27f16158d3f9524bb2d608ef4918783e7551637 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Thu, 28 Jan 2021 02:34:50 +0900 Subject: add get_matrix_scan_rate() to tmk_core/common/keyboard.c (#11489) --- tmk_core/common/keyboard.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 8c7bdc8b55..b35620e7fd 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,21 +97,28 @@ along with this program. If not, see . #endif // Only enable this if console is enabled to print to -#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) +#if defined(DEBUG_MATRIX_SCAN_RATE) static uint32_t matrix_timer = 0; static uint32_t matrix_scan_count = 0; +static uint32_t last_matrix_scan_count = 0; void matrix_scan_perf_task(void) { matrix_scan_count++; uint32_t timer_now = timer_read32(); if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { +# if defined(CONSOLE_ENABLE) dprintf("matrix scan frequency: %d\n", matrix_scan_count); - +# endif + last_matrix_scan_count = matrix_scan_count; matrix_timer = timer_now; matrix_scan_count = 0; } } + +uint32_t get_matrix_scan_rate(void) { + return last_matrix_scan_count; +} #else # define matrix_scan_perf_task() #endif -- cgit v1.2.3 From c0de49e393cf481f60f2bbd6c18ecb13d37c6254 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 2 Feb 2021 17:30:33 -0800 Subject: Fix DEBUG_MATRIX_SCAN_RATE on chibiOS when console is enabled (#11776) * Fix DEBUG_MATRIX_SCAN_RATE on chibiOS when console is enabled * update type in dprintf Co-authored-by: Ryan Co-authored-by: Ryan --- tmk_core/common/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index b35620e7fd..f4e9b11840 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -108,7 +108,7 @@ void matrix_scan_perf_task(void) { uint32_t timer_now = timer_read32(); if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { # if defined(CONSOLE_ENABLE) - dprintf("matrix scan frequency: %d\n", matrix_scan_count); + dprintf("matrix scan frequency: %lu\n", matrix_scan_count); # endif last_matrix_scan_count = matrix_scan_count; matrix_timer = timer_now; -- cgit v1.2.3 From b2d0e8a491f347d43b482808a744642fc975afab Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 5 Feb 2021 13:27:24 +0000 Subject: Manually run formatting job (#11797) --- tmk_core/common/keyboard.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index f4e9b11840..7120cdacdf 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -98,8 +98,8 @@ along with this program. If not, see . // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) -static uint32_t matrix_timer = 0; -static uint32_t matrix_scan_count = 0; +static uint32_t matrix_timer = 0; +static uint32_t matrix_scan_count = 0; static uint32_t last_matrix_scan_count = 0; void matrix_scan_perf_task(void) { @@ -111,14 +111,12 @@ void matrix_scan_perf_task(void) { dprintf("matrix scan frequency: %lu\n", matrix_scan_count); # endif last_matrix_scan_count = matrix_scan_count; - matrix_timer = timer_now; - matrix_scan_count = 0; + matrix_timer = timer_now; + matrix_scan_count = 0; } } -uint32_t get_matrix_scan_rate(void) { - return last_matrix_scan_count; -} +uint32_t get_matrix_scan_rate(void) { return last_matrix_scan_count; } #else # define matrix_scan_perf_task() #endif -- cgit v1.2.3 From 7161d650705afb86b0874d95d72d15cf134f4148 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 9 Feb 2021 09:49:05 -0800 Subject: Remove FAUXCLICKY feature (deprecated) (#11829) --- tmk_core/common/keyboard.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 40989ca4c6..a6bde9df85 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -60,9 +60,6 @@ along with this program. If not, see . #ifdef STENO_ENABLE # include "process_steno.h" #endif -#ifdef FAUXCLICKY_ENABLE -# include "fauxclicky.h" -#endif #ifdef SERIAL_LINK_ENABLE # include "serial_link/system/serial_link.h" #endif @@ -312,9 +309,6 @@ void keyboard_init(void) { #ifdef STENO_ENABLE steno_init(); #endif -#ifdef FAUXCLICKY_ENABLE - fauxclicky_init(); -#endif #ifdef POINTING_DEVICE_ENABLE pointing_device_init(); #endif -- cgit v1.2.3 From 1f2fe2eab99548f4bde2a79b03e3303cc9b73214 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 14 Feb 2021 01:44:22 +0000 Subject: Refactor platform logic within print.h (#11863) * Remove GCC check from debug * Remove platform logic from common.mk * Refactor platform logic within print.h * restore debug.c format * headers * Rename function pointer type * review comments * Update tmk_core/common/printf.c Co-authored-by: Nick Brassel * Format Co-authored-by: Nick Brassel --- tmk_core/common/keyboard.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a6bde9df85..299bda2c12 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -229,6 +229,7 @@ void keyboard_setup(void) { #ifndef NO_JTAG_DISABLE disable_jtag(); #endif + print_set_sendchar(sendchar); matrix_setup(); keyboard_pre_init_kb(); } -- cgit v1.2.3 From d1806a26e4ad75fa0e0405283803eba22c1a49ba Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Mon, 15 Feb 2021 18:30:33 -0600 Subject: Split transport mirror (#11046) * Split transport mirror support * Updated RGB Matrix to respond to electrical events instead of key events * split matrix slave fix --- tmk_core/common/keyboard.c | 62 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 299bda2c12..34fed0caba 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -54,6 +54,9 @@ along with this program. If not, see . #ifdef RGBLIGHT_ENABLE # include "rgblight.h" #endif +#ifdef RGB_MATRIX_ENABLE +# include "rgb_matrix.h" +#endif #ifdef ENCODER_ENABLE # include "encoder.h" #endif @@ -304,6 +307,9 @@ void keyboard_init(void) { #ifdef RGBLIGHT_ENABLE rgblight_init(); #endif +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_init(); +#endif #ifdef ENCODER_ENABLE encoder_init(); #endif @@ -328,6 +334,17 @@ void keyboard_init(void) { keyboard_post_init_kb(); /* Always keep this last */ } +/** \brief key_event_task + * + * This function is responsible for calling into other systems when they need to respond to electrical switch press events. + * This is differnet than keycode events as no layer processing, or filtering occurs. + */ +void switch_events(uint8_t row, uint8_t col, bool pressed) { +#if defined(RGB_MATRIX_ENABLE) + process_rgb_matrix(row, col, pressed); +#endif +} + /** \brief Keyboard task: Do keyboard routine jobs * * Do routine keyboard jobs: @@ -358,32 +375,35 @@ void keyboard_task(void) { uint8_t matrix_changed = matrix_scan(); if (matrix_changed) last_matrix_activity_trigger(); - if (should_process_keypress()) { - for (uint8_t r = 0; r < MATRIX_ROWS; r++) { - matrix_row = matrix_get_row(r); - matrix_change = matrix_row ^ matrix_prev[r]; - if (matrix_change) { + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + matrix_row = matrix_get_row(r); + matrix_change = matrix_row ^ matrix_prev[r]; + if (matrix_change) { #ifdef MATRIX_HAS_GHOST - if (has_ghost_in_row(r, matrix_row)) { - continue; - } + if (has_ghost_in_row(r, matrix_row)) { + continue; + } #endif - if (debug_matrix) matrix_print(); - matrix_row_t col_mask = 1; - for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { - if (matrix_change & col_mask) { + if (debug_matrix) matrix_print(); + matrix_row_t col_mask = 1; + for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { + if (matrix_change & col_mask) { + if (should_process_keypress()) { action_exec((keyevent_t){ .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ }); - // record a processed key - matrix_prev[r] ^= col_mask; + } + // record a processed key + matrix_prev[r] ^= col_mask; + + switch_events(r, c, (matrix_row & col_mask)); + #ifdef QMK_KEYS_PER_SCAN - // only jump out if we have processed "enough" keys. - if (++keys_processed >= QMK_KEYS_PER_SCAN) + // only jump out if we have processed "enough" keys. + if (++keys_processed >= QMK_KEYS_PER_SCAN) #endif - // process a key per task call - goto MATRIX_LOOP_END; - } + // process a key per task call + goto MATRIX_LOOP_END; } } } @@ -405,6 +425,10 @@ MATRIX_LOOP_END: rgblight_task(); #endif +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_task(); +#endif + #if defined(BACKLIGHT_ENABLE) # if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS) backlight_task(); -- cgit v1.2.3 From abe189377cd7af09041b54a7b3b19775f9ce8647 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 26 Feb 2021 17:07:05 +1100 Subject: [BUG] Massdrop develop rgb fix (#12022) * Allow for disabling RGB_MATRIX on Massdrop boards. * Fixup init sequence. * Make some functions static as they've got very generic names. --- tmk_core/common/keyboard.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 34fed0caba..ce3255c069 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -307,9 +307,6 @@ void keyboard_init(void) { #ifdef RGBLIGHT_ENABLE rgblight_init(); #endif -#ifdef RGB_MATRIX_ENABLE - rgb_matrix_init(); -#endif #ifdef ENCODER_ENABLE encoder_init(); #endif -- cgit v1.2.3