diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 498614dd264..c1cdd5d8865 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -881,7 +881,7 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) OPT_DEFS += -DBLUETOOTH_$(strip $(shell echo $(BLUETOOTH_DRIVER) | tr '[:lower:]' '[:upper:]')) NO_USB_STARTUP_CHECK := yes COMMON_VPATH += $(DRIVER_PATH)/bluetooth - SRC += outputselect.c + SRC += outputselect.c process_connection.c ifeq ($(strip $(BLUETOOTH_DRIVER)), bluefruit_le) SPI_DRIVER_REQUIRED = yes diff --git a/quantum/process_keycode/process_connection.c b/quantum/process_keycode/process_connection.c new file mode 100644 index 00000000000..c86f1eda5d4 --- /dev/null +++ b/quantum/process_keycode/process_connection.c @@ -0,0 +1,35 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#include "outputselect.h" +#include "process_connection.h" + +bool process_connection(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch (keycode) { + case QK_OUTPUT_NEXT: + set_output(OUTPUT_AUTO); + return false; + case QK_OUTPUT_USB: + set_output(OUTPUT_USB); + return false; + case QK_OUTPUT_BLUETOOTH: + set_output(OUTPUT_BLUETOOTH); + return false; + + case QK_OUTPUT_PREV: + case QK_OUTPUT_NONE: + case QK_OUTPUT_2P4GHZ: + case QK_BLUETOOTH_PROFILE_NEXT: + case QK_BLUETOOTH_PROFILE_PREV: + case QK_BLUETOOTH_UNPAIR: + case QK_BLUETOOTH_PROFILE1: + case QK_BLUETOOTH_PROFILE2: + case QK_BLUETOOTH_PROFILE3: + case QK_BLUETOOTH_PROFILE4: + case QK_BLUETOOTH_PROFILE5: + // As-yet unimplemented. + return false; + } + } + return true; +} diff --git a/quantum/process_keycode/process_connection.h b/quantum/process_keycode/process_connection.h new file mode 100644 index 00000000000..cc58011bb76 --- /dev/null +++ b/quantum/process_keycode/process_connection.h @@ -0,0 +1,9 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include +#include +#include "action.h" + +bool process_connection(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum.c b/quantum/quantum.c index 011f9d73e4a..fb084da7044 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -21,7 +21,7 @@ #endif #ifdef BLUETOOTH_ENABLE -# include "outputselect.h" +# include "process_connection.h" #endif #ifdef GRAVE_ESC_ENABLE @@ -393,6 +393,9 @@ bool process_record_quantum(keyrecord_t *record) { #endif #ifdef TRI_LAYER_ENABLE process_tri_layer(keycode, record) && +#endif +#ifdef BLUETOOTH_ENABLE + process_connection(keycode, record) && #endif true)) { return false; @@ -431,17 +434,6 @@ bool process_record_quantum(keyrecord_t *record) { velocikey_toggle(); return false; #endif -#ifdef BLUETOOTH_ENABLE - case QK_OUTPUT_AUTO: - set_output(OUTPUT_AUTO); - return false; - case QK_OUTPUT_USB: - set_output(OUTPUT_USB); - return false; - case QK_OUTPUT_BLUETOOTH: - set_output(OUTPUT_BLUETOOTH); - return false; -#endif #ifndef NO_ACTION_ONESHOT case QK_ONE_SHOT_TOGGLE: oneshot_toggle();