From bdc773a5591134909cc030f3cceef514e8fc6c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C4=85tkowski?= Date: Sat, 29 Apr 2023 22:09:55 +0200 Subject: [PATCH 1/3] Switch to ENCODER_MAP, define left side as mastter --- keyboards/sofle/keymaps/via/config.h | 1 + keyboards/sofle/keymaps/via/encoder.c | 39 --------------------------- keyboards/sofle/keymaps/via/keymap.c | 10 +++++-- keyboards/sofle/keymaps/via/rules.mk | 1 + 4 files changed, 10 insertions(+), 41 deletions(-) delete mode 100644 keyboards/sofle/keymaps/via/encoder.c diff --git a/keyboards/sofle/keymaps/via/config.h b/keyboards/sofle/keymaps/via/config.h index 2806b70b0f7d..d9c26dad1af1 100644 --- a/keyboards/sofle/keymaps/via/config.h +++ b/keyboards/sofle/keymaps/via/config.h @@ -21,6 +21,7 @@ see https://docs.qmk.fm/#/feature_split_keyboard?id=setting-handedness for more options. */ +#define MASTER_LEFT #if defined(KEYBOARD_sofle_rev1) // Add RGB underglow and top facing lighting diff --git a/keyboards/sofle/keymaps/via/encoder.c b/keyboards/sofle/keymaps/via/encoder.c deleted file mode 100644 index 831b3b2f3c47..000000000000 --- a/keyboards/sofle/keymaps/via/encoder.c +++ /dev/null @@ -1,39 +0,0 @@ - /* Copyright 2020 Josef Adamcik - * Modification for VIA support and RGB underglow by Jens Bonk-Wiltfang - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -//Setting up what encoder rotation does. If your encoder can be pressed as a button, that function can be set in Via. - -#ifdef ENCODER_ENABLE - -bool encoder_update_user(uint8_t index, bool clockwise) { - if (index == 0) { - if (clockwise) { - tap_code(KC_VOLU); - } else { - tap_code(KC_VOLD); - } - } else if (index == 1) { - if (clockwise) { - tap_code(KC_PGDN); - } else { - tap_code(KC_PGUP); - } - } - return true; -} - -#endif diff --git a/keyboards/sofle/keymaps/via/keymap.c b/keyboards/sofle/keymaps/via/keymap.c index 4c83e58f7d12..31e2e096c0d2 100644 --- a/keyboards/sofle/keymaps/via/keymap.c +++ b/keyboards/sofle/keymaps/via/keymap.c @@ -17,9 +17,15 @@ #include QMK_KEYBOARD_H #include "oled.c" -#include "encoder.c" -//Default keymap. This can be changed in Via. Use oled.c and encoder.c to change beavior that Via cannot change. +#if defined ENCODER_ENABLE && defined ENCODER_MAP_ENABLE +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { + [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_PGDN, KC_PGUP) }, + [1] = { ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) }, + [2] = { ENCODER_CCW_CW(RGB_HUD, RGB_HUI), ENCODER_CCW_CW(RGB_SAD, RGB_SAI) }, + [3] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_RMOD, RGB_MOD)} +}; +#endif const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* diff --git a/keyboards/sofle/keymaps/via/rules.mk b/keyboards/sofle/keymaps/via/rules.mk index db254512afc1..b57a417092df 100644 --- a/keyboards/sofle/keymaps/via/rules.mk +++ b/keyboards/sofle/keymaps/via/rules.mk @@ -6,3 +6,4 @@ EXTRAKEY_ENABLE = yes VIA_ENABLE = yes LTO_ENABLE = yes RGBLIGHT_ENABLE = yes +ENCODER_MAP_ENABLE = yes \ No newline at end of file From 8c7e349e303e84ac0e9b195b7cce950a3cc54b92 Mon Sep 17 00:00:00 2001 From: IreuN Date: Sat, 29 Apr 2023 23:16:54 +0200 Subject: [PATCH 2/3] Update config.h Removed MASTER_LEFT, revised comment. --- keyboards/sofle/keymaps/via/config.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/keyboards/sofle/keymaps/via/config.h b/keyboards/sofle/keymaps/via/config.h index d9c26dad1af1..68996809e71d 100644 --- a/keyboards/sofle/keymaps/via/config.h +++ b/keyboards/sofle/keymaps/via/config.h @@ -17,11 +17,9 @@ #pragma once -/* The way how "handedness" is decided (which half is which), +/* By default left side is selected as master, see https://docs.qmk.fm/#/feature_split_keyboard?id=setting-handedness -for more options. -*/ -#define MASTER_LEFT +for more options. */ #if defined(KEYBOARD_sofle_rev1) // Add RGB underglow and top facing lighting From 704631577e68538240d080975e1d0f7e0729abb6 Mon Sep 17 00:00:00 2001 From: IreuN Date: Sat, 29 Apr 2023 23:20:38 +0200 Subject: [PATCH 3/3] Simplified if defined clause. --- keyboards/sofle/keymaps/via/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/sofle/keymaps/via/keymap.c b/keyboards/sofle/keymaps/via/keymap.c index 31e2e096c0d2..bbb4c648263c 100644 --- a/keyboards/sofle/keymaps/via/keymap.c +++ b/keyboards/sofle/keymaps/via/keymap.c @@ -18,7 +18,7 @@ #include QMK_KEYBOARD_H #include "oled.c" -#if defined ENCODER_ENABLE && defined ENCODER_MAP_ENABLE +#ifdef ENCODER_MAP_ENABLE const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU), ENCODER_CCW_CW(KC_PGDN, KC_PGUP) }, [1] = { ENCODER_CCW_CW(_______, _______), ENCODER_CCW_CW(_______, _______) },