Skip to content

Commit

Permalink
skyloong/gk61: Remove overriding of core keycode behaviour (#24655)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored Dec 8, 2024
1 parent 001e190 commit 68f67e2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 217 deletions.
3 changes: 0 additions & 3 deletions keyboards/skyloong/gk61/pro/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@
#define IS31FL3743A_SDB_PIN C1

#define CAPS_LOCK_INDEX 28
#define WIN_MOD_INDEX 16
#define MAC_MOD_INDEX 17
#define WIN_LOCK_INDEX 54
149 changes: 28 additions & 121 deletions keyboards/skyloong/gk61/pro/pro.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Copyright 2023 linlin012 (@linlin012)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "quantum.h"
int FN_WIN = 0;
int FN_MAC = 0;
int L_WIN = 0;
int L_MAC = 0;

#if defined(RGB_MATRIX_ENABLE)
const is31fl3743a_led_t PROGMEM g_is31fl3743a_leds[IS31FL3743A_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
Expand Down Expand Up @@ -83,7 +80,32 @@ const is31fl3743a_led_t PROGMEM g_is31fl3743a_leds[IS31FL3743A_LED_COUNT] = {
{0, SW10_CS13, SW10_CS14, SW10_CS15}
};

#if defined(RGB_MATRIX_ENABLE) /*&& defined(CAPS_LOCK_INDEX)*/
bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
return false;
}

if (host_keyboard_led_state().caps_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 255, 255, 255);
} else {
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 0, 0, 0);
}
}

return false;
}

void suspend_power_down_kb(void) {
gpio_write_pin_low(IS31FL3743A_SDB_PIN);
suspend_power_down_user();
}

void suspend_wakeup_init_kb(void) {
gpio_write_pin_high(IS31FL3743A_SDB_PIN);
suspend_wakeup_init_user();
}
#endif

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) {
Expand All @@ -105,124 +127,9 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
}
return false;
# endif
case TO(0):
if (record->event.pressed) {
L_WIN = 1;
set_single_persistent_default_layer(0); // Save default layer 0 to eeprom
} else {
L_WIN = 0;
}
return true; // continue all further processing of this key

case MO(2):
if (record->event.pressed) {
FN_WIN = 1;
} else {
FN_WIN = 0;
}
return true; // continue all further processing of this key

case TO(1):
if (record->event.pressed) {
L_MAC = 1;
set_single_persistent_default_layer(1); //Save default layer 1 to eeprom
} else {
L_MAC = 0;
}
return true; // continue all further processing of this key

case MO(3):
if (record->event.pressed) {
FN_MAC = 1;
} else {
FN_MAC = 0;
}
return true; // continue all further processing of this key
default:
return true;
}

}

bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
return false;
}

if (host_keyboard_led_state().caps_lock) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 255, 255, 255);
} else {
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(CAPS_LOCK_INDEX, 0, 0, 0);
}
}

switch (get_highest_layer(layer_state)) {
case 0:{
if (L_WIN) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
}else{
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
}
}
} break;

case 1:{
if (L_MAC) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
}
}else{
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
}
} break;


case 2:{
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
} break;

case 3:{
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
}
} break;

default:{
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
}
}
return false;
}

#endif

void suspend_power_down_kb() {
# ifdef RGB_MATRIX_ENABLE
gpio_write_pin_low(IS31FL3743A_SDB_PIN);
# endif
suspend_power_down_user();
}

void suspend_wakeup_init_kb() {
# ifdef RGB_MATRIX_ENABLE
gpio_write_pin_high(IS31FL3743A_SDB_PIN);
# endif
suspend_wakeup_init_user();
return true;
}

void board_init(void) {
Expand Down
4 changes: 0 additions & 4 deletions keyboards/skyloong/gk61/pro_48/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@
#define IS31FL3743A_SDB_PIN A4

#define CAPS_LOCK_INDEX 28
#define WIN_MOD_INDEX 16
#define MAC_MOD_INDEX 17

#define g_suspend_state rgb_matrix_get_suspend_state()
93 changes: 4 additions & 89 deletions keyboards/skyloong/gk61/pro_48/pro_48.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright 2023 linlin012 (@linlin012)
// SPDX-License-Identifier: GPL-2.0-or-later
#include "quantum.h"
_Bool FN_WIN = 0;
_Bool FN_MAC = 0;
_Bool L_WIN = 0;
_Bool L_MAC = 0;

#if defined(RGB_MATRIX_ENABLE) /*&& defined(CAPS_LOCK_INDEX)*/
#if defined(RGB_MATRIX_ENABLE)
const is31fl3743a_led_t PROGMEM g_is31fl3743a_leds[IS31FL3743A_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
Expand Down Expand Up @@ -97,57 +93,9 @@ bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
}
}

switch (get_highest_layer(layer_state)) {
case 2:{
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
} break;
case 3:{
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
}
} break;

case 0:{
if (L_WIN) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
}else{
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
}
}
} break;

case 1:{
if (L_MAC) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 255, 255, 255);
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
}
}else{
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
}
} break;

default:{
if (!rgb_matrix_get_flags()) {
RGB_MATRIX_INDICATOR_SET_COLOR(WIN_MOD_INDEX, 0, 0, 0);
RGB_MATRIX_INDICATOR_SET_COLOR(MAC_MOD_INDEX, 0, 0, 0);
}
}
}
return false;
}


void suspend_power_down_kb(void) {
gpio_write_pin_low(IS31FL3743A_SDB_PIN);
suspend_power_down_user();
Expand Down Expand Up @@ -177,44 +125,11 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
} break;
}
}
return false;
return false;
# endif
case TO(0):
if (record->event.pressed) {
L_WIN = 1;
set_single_persistent_default_layer(0); // Save default layer 0 to eeprom
} else {
L_WIN = 0;
}
return true; // continue all further processing of this key

case MO(2):
if (record->event.pressed) {
FN_WIN = 1;
} else {
FN_WIN = 0;
}
return true; // continue all further processing of this key

case TO(1):
if (record->event.pressed) {
L_MAC = 1;
set_single_persistent_default_layer(1); //Save default layer 1 to eeprom
} else {
L_MAC = 0;
}
return true; // continue all further processing of this key

case MO(3):
if (record->event.pressed) {
FN_MAC = 1;
} else {
FN_MAC = 0;
}
return true; // continue all further processing of this key
default:
return true;
}

return true;
}

void board_init(void) {
Expand Down

0 comments on commit 68f67e2

Please sign in to comment.