-
-
Notifications
You must be signed in to change notification settings - Fork 39.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix encoder_init call order in keyboard_init #19140
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned I'm happy to adjust my approach.
In my investigation slave_state
was receiving values of 17 and 46 for both from the slave, then alter values of 0 and 46 (as the right side is master for me and thus would not change)
I have no idea where the 17 value is coming from. Doing a full memcopy of encoder_value
makes my issue go away entirely.
I realized a while after I made this change that it will obviously break the I spent a little more time playing around and noted that
both fixed the issue as well |
be9e533
to
1eb2b62
Compare
I opted to go with All unit tests pass with out modification, and this reliably fixes the issue. I have tested by flashing my slave half with this change and my master half with out this change. My moving the usb cable between the halfs I get a burst on the slave and no burst on the right. I'd really love to understand why this fixes the issue. My current uneducated guess is that |
Hmm, there might be some problems in the initialization order:
|
@sigprof That is a great insight! I can confrim that moving Would this be preferable? If so I can update my PR here with the adjustment to the call order in diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index 83ade7829a..37675ded0b 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -353,6 +353,9 @@ void keyboard_init(void) {
#endif
#ifdef SPLIT_KEYBOARD
split_pre_init();
+#endif
+#ifdef ENCODER_ENABLE
+ encoder_init();
#endif
matrix_init();
quantum_init();
@@ -374,9 +377,6 @@ void keyboard_init(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_init();
#endif
-#ifdef ENCODER_ENABLE
- encoder_init();
-#endif
#ifdef STENO_ENABLE_ALL
steno_init();
#endif |
Yes, please do so. |
1eb2b62
to
6005981
Compare
encoder_init initializes thisCount which is used in encoder_state_raw memcpy. quantum_init was calling encoder_state_raw though the initialization of bootmatgic calling matrix_scan. This caused undefined behavior resulting in bad values being sent over transport. Adjusting the call order of encoder_init allows for correct behavior of encoder_state_raw
6005981
to
8a62d2c
Compare
@tzarc I have updated the diff to change the call order of |
… ko-kyria * 'ko-kyria' of https://github.com/ohlin/qmk_firmware: (603 commits) Fix Czech sendstring LUT (qmk#19193) fix typo (qmk#19189) new keyboard rb1 (qmk#18164) Fix RWIN typo within keycode list (qmk#19155) [Docs] Update reference_info_json.md (qmk#18817) Add piantor (qmk#18920) 2022 Nov 26 changelog. (qmk#19164) Fix API errors in handwired/tractyl_manuform/5x6_right/arduinomicro (qmk#19166) Revert lib/usbhost changes (qmk#19165) Fix encoder_init call order in keyboard_init (qmk#19140) Change `RGB_MATRIX_STARTUP_*` defines to `RGB_MATRIX_DEFAULT_*` (qmk#19079) Fixup installation procedure for different Fedora versions. (qmk#19159) Joystick feature improvements (qmk#19052) Change `LED_MATRIX_STARTUP_*` defines to `LED_MATRIX_DEFAULT_*` (qmk#19080) Fix build failures for `bastardkb/tbk` and `jels/boaty` (qmk#19152) Fix annepro2/c18:iso_default (qmk#19147) jsonify some info.json (qmk#19146) Fixup aurora/corne on develop (qmk#19144) Additional DD backlight config (qmk#19124) [Keymap] komidore64 planck rev6 (qmk#19036) ...
Description
From the insight of sigprof it was discovered that
encoder_init
initializesthisCount
which is used inencoder_state_raw
memcpy
.quantum_init
was callingencoder_state_raw
though the initialization ofbootmatgic
callingmatrix_scan
. This caused undefined behavior resulting in bad values being sent over transport. Adjustingthe call order of
encoder_init
allows for correct behavior ofencoder_state_raw
Types of Changes
Issues Fixed or Closed by This PR
Checklist