merge remote

This commit is contained in:
lokher 2023-02-01 16:12:10 +08:00
commit 03a173aced
6 changed files with 48 additions and 26 deletions

View file

@ -30,11 +30,6 @@ extern uint32_t retry_time_buffer;
extern uint8_t retry; extern uint8_t retry;
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
typedef struct {
bool usb : 1;
bool bluetooth : 1;
} nkro_t;
extern nkro_t nkro; extern nkro_t nkro;
#endif #endif
@ -101,7 +96,7 @@ void bluetooth_init(void) {
#ifdef BLUETOOTH_INT_INPUT_PIN #ifdef BLUETOOTH_INT_INPUT_PIN
setPinInputHigh(BLUETOOTH_INT_INPUT_PIN); setPinInputHigh(BLUETOOTH_INT_INPUT_PIN);
#endif #endif
lpm_init(); lpm_init();
rtc_timer_init(); rtc_timer_init();
} }
@ -207,7 +202,7 @@ static void bluetooth_enter_connected(uint8_t host_idx) {
clear_keyboard(); clear_keyboard();
/* Enable NKRO since it may be disabled in pin code entry */ /* Enable NKRO since it may be disabled in pin code entry */
#if defined(NKRO_ENABLE) && defined(BLUETOOTH_NKRO_ENABLE) #if defined(NKRO_ENABLE) && defined(BLUETOOTH_NKRO_ENABLE)
keymap_config.nkro = nkro.bluetooth; keymap_config.nkro = nkro.bluetooth;
#else #else
@ -229,7 +224,7 @@ static void bluetooth_enter_connected(uint8_t host_idx) {
static void bluetooth_enter_disconnected(uint8_t host_idx) { static void bluetooth_enter_disconnected(uint8_t host_idx) {
uint8_t previous_state = bt_state; uint8_t previous_state = bt_state;
bt_state = BLUETOOTH_DISCONNECTED; bt_state = BLUETOOTH_DISCONNECTED;
if (previous_state == BLUETOOTH_CONNECTED) { if (previous_state == BLUETOOTH_CONNECTED) {
lpm_timer_reset(); lpm_timer_reset();
indicator_set(BLUETOOTH_SUSPEND, host_idx); indicator_set(BLUETOOTH_SUSPEND, host_idx);
@ -276,8 +271,8 @@ __attribute__((weak)) void bluetooth_enter_pin_code_entry_kb(void) {}
__attribute__((weak)) void bluetooth_exit_pin_code_entry_kb(void){}; __attribute__((weak)) void bluetooth_exit_pin_code_entry_kb(void){};
/* */ /* */
static void bluetooth_hid_set_protocol(bool report_protocol) { static void bluetooth_hid_set_protocol(bool report_protocol) {
bluetooth_report_protocol = false; bluetooth_report_protocol = false;
} }
uint8_t bluetooth_keyboard_leds(void) { uint8_t bluetooth_keyboard_leds(void) {
@ -338,7 +333,7 @@ void bluetooth_send_keyboard(report_keyboard_t *report) {
//#endif //#endif
} }
} else if (bt_state != BLUETOOTH_RESET) { } else if (bt_state != BLUETOOTH_RESET) {
bluetooth_connect(); bluetooth_connect();
} }
} }
@ -458,6 +453,10 @@ bluetooth_state_t bluetooth_get_state(void) {
__attribute__((weak)) bool process_record_kb_bt(uint16_t keycode, keyrecord_t *record) { return true;}; __attribute__((weak)) bool process_record_kb_bt(uint16_t keycode, keyrecord_t *record) { return true;};
bool process_record_kb(uint16_t keycode, keyrecord_t *record) { bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (!process_record_user(keycode, record)) {
return false;
}
if (get_transport() == TRANSPORT_BLUETOOTH) { if (get_transport() == TRANSPORT_BLUETOOTH) {
lpm_timer_reset(); lpm_timer_reset();
@ -472,6 +471,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
} }
#endif #endif
} }
process_record_kb_bt(keycode, record); return process_record_kb_bt(keycode, record);
return process_record_user(keycode, record); // return process_record_user(keycode, record);
} }

View file

@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "hal.h" #include "hal.h"
#if (HAL_USE_RTC) #if (HAL_USE_RTC)

View file

@ -1,3 +1,18 @@
/* Copyright 2022 @ lokher (https://www.keychron.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 "quantum.h" #include "quantum.h"
#include "bluetooth.h" #include "bluetooth.h"
@ -12,13 +27,6 @@
# define REINIT_LED_DRIVER 1 # define REINIT_LED_DRIVER 1
#endif #endif
#ifdef NKRO_ENABLE
typedef struct {
bool usb : 1;
bool bluetooth : 1;
} nkro_t;
#endif
#if defined(PROTOCOL_CHIBIOS) #if defined(PROTOCOL_CHIBIOS)
extern host_driver_t chibios_driver; extern host_driver_t chibios_driver;
#endif #endif
@ -37,8 +45,8 @@ __attribute__((weak)) void bt_transport_enable(bool enable) {
if (enable) { if (enable) {
if (host_get_driver() != &bluetooth_driver) { if (host_get_driver() != &bluetooth_driver) {
host_set_driver(&bluetooth_driver); host_set_driver(&bluetooth_driver);
/* Disconnect and reconnect to sync the bluetooth state /* Disconnect and reconnect to sync the bluetooth state
* TODO: query bluetooth state to sync * TODO: query bluetooth state to sync
*/ */
bluetooth_disconnect(); bluetooth_disconnect();
@ -55,8 +63,8 @@ __attribute__((weak)) void bt_transport_enable(bool enable) {
} }
} }
/* There is no dedicated pin for USB power on chip such as STM32L432, but USB power /* There is no dedicated pin for USB power on chip such as STM32L432, but USB power
* can be connected and disconnected via registers. * can be connected and disconnected via registers.
* Overwrite these two functions if such chip is used. */ * Overwrite these two functions if such chip is used. */
__attribute__((weak)) void usb_power_connect(void) {} __attribute__((weak)) void usb_power_connect(void) {}
__attribute__((weak)) void usb_power_disconnect(void) {} __attribute__((weak)) void usb_power_disconnect(void) {}
@ -180,3 +188,10 @@ void usb_remote_wakeup(void) {
send_keyboard_report(); send_keyboard_report();
} }
} }
#ifdef BLUETOOTH_NKRO_ENABLE
void keyboard_post_init_user(void) {
keymap_config.raw = eeconfig_read_keymap();
nkro.bluetooth = keymap_config.nkro;
}
#endif

View file

@ -22,6 +22,13 @@ typedef enum {
TRANSPORT_BLUETOOTH, TRANSPORT_BLUETOOTH,
} transport_t; } transport_t;
#ifdef NKRO_ENABLE
typedef struct {
bool usb : 1;
bool bluetooth : 1;
} nkro_t;
#endif
void set_transport(transport_t new_transport); void set_transport(transport_t new_transport);
transport_t get_transport(void); transport_t get_transport(void);

View file

@ -1,6 +1,6 @@
# MCU name # MCU name
MCU = STM32L432 MCU = STM32L432
# Bootloader selection # Bootloader selection
BOOTLOADER = stm32-dfu BOOTLOADER = stm32-dfu

View file

@ -2,7 +2,7 @@
![Keychron K6 Pro](https://cdn.shopify.com/s/files/1/0059/0630/1017/t/5/assets/keychronk6pr0qmkviawirelesscustommechanicalkeyboard-1659094228146.jpg?v=1659094230) ![Keychron K6 Pro](https://cdn.shopify.com/s/files/1/0059/0630/1017/t/5/assets/keychronk6pr0qmkviawirelesscustommechanicalkeyboard-1659094228146.jpg?v=1659094230)
A customizable 87 keys TKL keyboard. A customizable 68 keys TKL keyboard.
* Keyboard Maintainer: [Keychron](https://github.com/keychron) * Keyboard Maintainer: [Keychron](https://github.com/keychron)
* Hardware Supported: Keychron K6 Pro * Hardware Supported: Keychron K6 Pro