Skip to content
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

Add process_keycode handlers for new RGB Matrix and Underglow keycodes #23896

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions quantum/process_keycode/process_rgb_matrix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#include "process_rgb_matrix.h"
#include "rgb_matrix.h"
#include "action_util.h"
#include "keycodes.h"
#include "modifiers.h"

bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
#ifdef RGB_TRIGGER_ON_KEYDOWN
if (record->event.pressed) {
#else
if (!record->event.pressed) {
#endif
bool shifted = get_mods() & MOD_MASK_SHIFT;
switch (keycode) {
case QK_RGB_MATRIX_ON:
rgb_matrix_enable();
return false;
case QK_RGB_MATRIX_OFF:
rgb_matrix_disable();
return false;
case QK_RGB_MATRIX_TOGGLE:
rgb_matrix_toggle();
return false;
case QK_RGB_MATRIX_MODE_NEXT:
if (shifted) {
rgb_matrix_step_reverse();
} else {
rgb_matrix_step();
}
return false;
case QK_RGB_MATRIX_MODE_PREVIOUS:
if (shifted) {
rgb_matrix_step();
} else {
rgb_matrix_step_reverse();
}
return false;
case QK_RGB_MATRIX_HUE_UP:
if (shifted) {
rgb_matrix_decrease_hue();
} else {
rgb_matrix_increase_hue();
}
return false;
case QK_RGB_MATRIX_HUE_DOWN:
if (shifted) {
rgb_matrix_increase_hue();
} else {
rgb_matrix_decrease_hue();
}
return false;
case QK_RGB_MATRIX_SATURATION_UP:
if (shifted) {
rgb_matrix_decrease_sat();
} else {
rgb_matrix_increase_sat();
}
return false;
case QK_RGB_MATRIX_SATURATION_DOWN:
if (shifted) {
rgb_matrix_increase_sat();
} else {
rgb_matrix_decrease_sat();
}
return false;
case QK_RGB_MATRIX_VALUE_UP:
if (shifted) {
rgb_matrix_decrease_val();
} else {
rgb_matrix_increase_val();
}
return false;
case QK_RGB_MATRIX_VALUE_DOWN:
if (shifted) {
rgb_matrix_increase_val();
} else {
rgb_matrix_decrease_val();
}
return false;
case QK_RGB_MATRIX_SPEED_UP:
if (shifted) {
rgb_matrix_decrease_speed();
} else {
rgb_matrix_increase_speed();
}
return false;
case QK_RGB_MATRIX_SPEED_DOWN:
if (shifted) {
rgb_matrix_increase_speed();
} else {
rgb_matrix_decrease_speed();
}
return false;
}
}

return true;
}
10 changes: 10 additions & 0 deletions quantum/process_keycode/process_rgb_matrix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <stdint.h>
#include <stdbool.h>
#include "action.h"

bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
91 changes: 91 additions & 0 deletions quantum/process_keycode/process_underglow.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#include "process_underglow.h"
#include "rgblight.h"
#include "action_util.h"
#include "keycodes.h"
#include "modifiers.h"

bool process_underglow(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
switch (keycode) {
case QK_UNDERGLOW_TOGGLE:
rgblight_toggle();
return false;
case QK_UNDERGLOW_MODE_NEXT:
if (shifted) {
rgblight_step_reverse();
} else {
rgblight_step();
}
return false;
case QK_UNDERGLOW_MODE_PREVIOUS:
if (shifted) {
rgblight_step();
} else {
rgblight_step_reverse();
}
return false;
case QK_UNDERGLOW_HUE_UP:
if (shifted) {
rgblight_decrease_hue();
} else {
rgblight_increase_hue();
}
return false;
case QK_UNDERGLOW_HUE_DOWN:
if (shifted) {
rgblight_increase_hue();
} else {
rgblight_decrease_hue();
}
return false;
case QK_UNDERGLOW_SATURATION_UP:
if (shifted) {
rgblight_decrease_sat();
} else {
rgblight_increase_sat();
}
return false;
case QK_UNDERGLOW_SATURATION_DOWN:
if (shifted) {
rgblight_increase_sat();
} else {
rgblight_decrease_sat();
}
return false;
case QK_UNDERGLOW_VALUE_UP:
if (shifted) {
rgblight_decrease_val();
} else {
rgblight_increase_val();
}
return false;
case QK_UNDERGLOW_VALUE_DOWN:
if (shifted) {
rgblight_increase_hue();
} else {
rgblight_decrease_hue();
}
return false;
case QK_UNDERGLOW_SPEED_UP:
if (shifted) {
rgblight_decrease_speed();
} else {
rgblight_increase_speed();
}
return false;
case QK_UNDERGLOW_SPEED_DOWN:
if (shifted) {
rgblight_increase_speed();
} else {
rgblight_decrease_speed();
}
return false;
}
}

return true;
}
10 changes: 10 additions & 0 deletions quantum/process_keycode/process_underglow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2024 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <stdint.h>
#include <stdbool.h>
#include "action.h"

bool process_underglow(uint16_t keycode, keyrecord_t *record);
Loading