Skip to content

Commit

Permalink
Move encoder callback
Browse files Browse the repository at this point in the history
- Encoder callback function was moved from ``encoder_update_user`` in ``keymap.c`` to ``encoder_update_kb`` in ``keyboard.c``
  • Loading branch information
Gondolindrim committed Oct 12, 2021
1 parent b228d29 commit 87f3e4a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 36 deletions.
21 changes: 21 additions & 0 deletions keyboards/evolv/evolv.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "evolv.h"

#ifndef MEDIA_KEY_DELAY
# define MEDIA_KEY_DELAY 100
#endif


bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) return false;
static uint32_t held_keycode_timer = 0;
static uint16_t mapped_code = 0;
if (clockwise) {
mapped_code = KC_VOLU;
} else {
mapped_code = KC_VOLD;
}
register_code(mapped_code);
held_keycode_timer = timer_read32();
while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ;
unregister_code(mapped_code);
return true;
}
12 changes: 0 additions & 12 deletions keyboards/evolv/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______)
};

uint32_t held_keycode_timer = 0;
uint16_t mapped_code = 0;
bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) mapped_code = KC_VOLU;
else mapped_code = KC_VOLD;
register_code(mapped_code);
held_keycode_timer = timer_read32();
while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ;
unregister_code(mapped_code);
return true;
}
12 changes: 0 additions & 12 deletions keyboards/evolv/keymaps/iso/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______)
};

uint32_t held_keycode_timer = 0;
uint16_t mapped_code = 0;
bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) mapped_code = KC_VOLU;
else mapped_code = KC_VOLD;
register_code(mapped_code);
held_keycode_timer = timer_read32();
while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ;
unregister_code(mapped_code);
return true;
}
12 changes: 0 additions & 12 deletions keyboards/evolv/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______)
};

uint32_t held_keycode_timer = 0;
uint16_t mapped_code = 0;
bool encoder_update_user(uint8_t index, bool clockwise) {
if (clockwise) mapped_code = KC_VOLU;
else mapped_code = KC_VOLD;
register_code(mapped_code);
held_keycode_timer = timer_read32();
while (timer_elapsed32(held_keycode_timer) < MEDIA_KEY_DELAY) ;
unregister_code(mapped_code);
return true;
}

0 comments on commit 87f3e4a

Please sign in to comment.