188 lines
3.5 KiB
C
188 lines
3.5 KiB
C
|
#include "betalupi_ergodox.h"
|
||
|
#include "features/beta_rawhid.h"
|
||
|
|
||
|
|
||
|
// Handle a keypress.
|
||
|
// Returns true if we should keep looking for keypresses,
|
||
|
// returns false if we should stop.
|
||
|
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||
|
switch (keycode) {
|
||
|
case LED_LEVEL:
|
||
|
if (record->event.pressed) {
|
||
|
keyboard_config.led_level++;
|
||
|
if (keyboard_config.led_level > 4) {
|
||
|
keyboard_config.led_level = 0;
|
||
|
}
|
||
|
ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 );
|
||
|
eeconfig_update_kb(keyboard_config.raw);
|
||
|
layer_state_set_kb(layer_state);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#ifdef RGB_MATRIX_ENABLE
|
||
|
case TOGGLE_LAYER_COLOR:
|
||
|
if (record->event.pressed) {
|
||
|
keyboard_config.disable_layer_led ^= 1;
|
||
|
if (keyboard_config.disable_layer_led) {
|
||
|
rgb_matrix_set_color_all(0, 0, 0);
|
||
|
}
|
||
|
eeconfig_update_kb(keyboard_config.raw);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case RGB_TOG:
|
||
|
if (record->event.pressed) {
|
||
|
switch (rgb_matrix_get_flags()) {
|
||
|
case LED_FLAG_ALL: {
|
||
|
rgb_matrix_set_flags(LED_FLAG_NONE);
|
||
|
keyboard_config.rgb_matrix_enable = false;
|
||
|
rgb_matrix_set_color_all(0, 0, 0);
|
||
|
}
|
||
|
break;
|
||
|
default: {
|
||
|
rgb_matrix_set_flags(LED_FLAG_ALL);
|
||
|
keyboard_config.rgb_matrix_enable = true;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
eeconfig_update_kb(keyboard_config.raw);
|
||
|
}
|
||
|
|
||
|
hid_send_state();
|
||
|
return false;
|
||
|
|
||
|
case RGB_MOD:
|
||
|
// Tell the host whenever we change animation mode.
|
||
|
hid_send_state();
|
||
|
return true;
|
||
|
#endif
|
||
|
|
||
|
// Custom RGBLIGHT macros
|
||
|
#ifdef RGBLIGHT_ENABLE
|
||
|
#ifdef RGBLIGHT_NO_EEPROM
|
||
|
case LIGHT_TOG:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_toggle_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_MOD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_step_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_HUI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_hue_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_HUD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_hue_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SAI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_sat_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SAD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_sat_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_VAI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_val_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_VAD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_val_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SPI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_speed_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SPD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_speed_noeeprom();
|
||
|
}
|
||
|
break;
|
||
|
#else
|
||
|
case LIGHT_TOG:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_toggle();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_MOD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_step();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_HUI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_hue();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_HUD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_hue();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SAI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_sat();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SAD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_sat();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_VAI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_val();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_VAD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_val();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SPI:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_increase_speed();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case LIGHT_SPD:
|
||
|
if (record->event.pressed) {
|
||
|
rgblight_decrease_speed();
|
||
|
}
|
||
|
break;
|
||
|
#endif
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
return process_record_user(keycode, record);
|
||
|
}
|