Skip to content

Commit

Permalink
[Keyboard] Add Encoder map support for rart (qmk#18851)
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaadio authored and ChrisChrisLoLo committed Sep 2, 2023
1 parent fc1dd99 commit e4bf768
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 60 deletions.
7 changes: 6 additions & 1 deletion keyboards/rart/rart4x4/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#define RGB_DI_PIN D3
#ifdef RGB_DI_PIN
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define RGBLIGHT_EFFECT_KNIGHT
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_TWINKLE
#define RGBLED_NUM 7
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
Expand Down
24 changes: 8 additions & 16 deletions keyboards/rart/rart4x4/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)
};

bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* First encoder */
if (clockwise) {
tap_code(KC_WH_U);
} else {
tap_code(KC_WH_D);
}
} else if (index == 1) { /* Second encoder */
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
return true;
}
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_PGUP, KC_PGDN) },
[1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }
};
#endif
1 change: 1 addition & 0 deletions keyboards/rart/rart4x4/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VIA_ENABLE = yes
ENCODER_MAP_ENABLE = yes
18 changes: 8 additions & 10 deletions keyboards/rart/rart75/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

};

bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* First encoder */
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
return true;
}
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) },
[1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }
};
#endif
2 changes: 2 additions & 0 deletions keyboards/rart/rart75/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
ENCODER_MAP_ENABLE = yes

9 changes: 9 additions & 0 deletions keyboards/rart/rart75hs/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)

};

#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) },
[1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }
};
#endif
1 change: 1 addition & 0 deletions keyboards/rart/rart75hs/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
ENCODER_MAP_ENABLE = yes
2 changes: 1 addition & 1 deletion keyboards/rart/rart75hs/rart75hs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
}
return true;
}
#endif
#endif
11 changes: 10 additions & 1 deletion keyboards/rart/rart75m/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
),

};
};

#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD) },
[1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }
};
#endif
4 changes: 3 additions & 1 deletion keyboards/rart/rart75m/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
VIA_ENABLE = yes
VIA_ENABLE = yes
LTO_ENABLE = yes
ENCODER_MAP_ENABLE = yes
4 changes: 2 additions & 2 deletions keyboards/rart/rart80/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE

#define LED_CAPS_LOCK_PIN D5
#define LED_CAPS_LOCK_PIN D4
#define LED_PIN_ON_STATE 0

#define BOOTMAGIC_LITE_ROW 0
#define BOOTMAGIC_LITE_COLUMN 1

#define RGB_DI_PIN C0
#define RGB_DI_PIN D5
#ifdef RGB_DI_PIN
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
Expand Down
3 changes: 1 addition & 2 deletions keyboards/rart/rart80/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # Enable N-Key Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
ENCODER_ENABLE = no
AUDIO_ENABLE = no # Audio output
10 changes: 8 additions & 2 deletions keyboards/rart/rartpad/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW

#define NUM_LOCK_LED_PIN D7
#define LED_CAPS_LOCK_PIN D7
#define LED_PIN_ON_STATE 1

/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
Expand All @@ -46,7 +47,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#define RGB_DI_PIN F7
#ifdef RGB_DI_PIN
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define RGBLIGHT_EFFECT_KNIGHT
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_TWINKLE
#define RGBLED_NUM 5
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
Expand Down
24 changes: 8 additions & 16 deletions keyboards/rart/rartpad/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)
};

bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* First encoder */
if (clockwise) {
tap_code(KC_WH_U);
} else {
tap_code(KC_WH_D);
}
} else if (index == 1) { /* Second encoder */
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
return true;
}
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = {
[0] = { ENCODER_CCW_CW(KC_VOLU, KC_VOLD), ENCODER_CCW_CW(KC_PGUP, KC_PGDN) },
[1] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
[3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS), ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }
};
#endif
1 change: 1 addition & 0 deletions keyboards/rart/rartpad/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
ENCODER_MAP_ENABLE = yes
9 changes: 1 addition & 8 deletions keyboards/rart/rartpad/rartpad.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,4 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rartpad.h"

bool led_update_kb(led_t led_state) {
if (led_update_user(led_state)) {
writePin(NUM_LOCK_LED_PIN, led_state.num_lock);
}
return true;
}
#include "rartpad.h"

0 comments on commit e4bf768

Please sign in to comment.