mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-04-09 15:25:42 +00:00
Solved the problem of not sending codes in RF mode
This commit is contained in:
parent
1eb1205c5a
commit
dbab794c69
@ -28,6 +28,7 @@ extern bool f_bat_hold;
|
|||||||
extern uint16_t no_act_time;
|
extern uint16_t no_act_time;
|
||||||
extern uint8_t rf_sw_temp;
|
extern uint8_t rf_sw_temp;
|
||||||
extern uint16_t rf_sw_press_delay;
|
extern uint16_t rf_sw_press_delay;
|
||||||
|
extern uint16_t rf_linking_time;
|
||||||
extern user_config_t user_config;
|
extern user_config_t user_config;
|
||||||
extern DEV_INFO_STRUCT dev_info;
|
extern DEV_INFO_STRUCT dev_info;
|
||||||
|
|
||||||
@ -35,6 +36,8 @@ extern DEV_INFO_STRUCT dev_info;
|
|||||||
/* qmk process record */
|
/* qmk process record */
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
no_act_time = 0;
|
no_act_time = 0;
|
||||||
|
rf_linking_time = 0;
|
||||||
|
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case RF_DFU:
|
case RF_DFU:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
@ -231,6 +234,8 @@ bool rgb_matrix_indicators_user(void)
|
|||||||
if(f_bat_num_show) {
|
if(f_bat_num_show) {
|
||||||
num_led_show();
|
num_led_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fix power-on brightness is abnormal
|
||||||
rgb_matrix_set_color(RGB_MATRIX_LED_COUNT-1, 0, 0, 0);
|
rgb_matrix_set_color(RGB_MATRIX_LED_COUNT-1, 0, 0, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -253,7 +258,7 @@ void housekeeping_task_user(void) {
|
|||||||
|
|
||||||
uart_receive_pro();
|
uart_receive_pro();
|
||||||
|
|
||||||
uart_send_report_func();
|
uart_send_report_repeat();
|
||||||
|
|
||||||
dev_sts_sync();
|
dev_sts_sync();
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "user_kb.h"
|
#include "user_kb.h"
|
||||||
#include "uart.h" // qmk uart.h
|
#include "uart.h" // qmk uart.h
|
||||||
#include "ansi.h"
|
#include "ansi.h"
|
||||||
|
#include "rf_driver.h"
|
||||||
|
|
||||||
USART_MGR_STRUCT Usart_Mgr;
|
USART_MGR_STRUCT Usart_Mgr;
|
||||||
#define RX_SBYTE Usart_Mgr.RXDBuf[0]
|
#define RX_SBYTE Usart_Mgr.RXDBuf[0]
|
||||||
@ -39,7 +40,6 @@ uint8_t uart_bit_report_buf[32] = {0};
|
|||||||
uint8_t func_tab[32] = {0};
|
uint8_t func_tab[32] = {0};
|
||||||
uint8_t bitkb_report_buf[32] = {0};
|
uint8_t bitkb_report_buf[32] = {0};
|
||||||
uint8_t bytekb_report_buf[8] = {0};
|
uint8_t bytekb_report_buf[8] = {0};
|
||||||
uint8_t mouse_report_buf[5] = {0};
|
|
||||||
uint16_t conkb_report = 0;
|
uint16_t conkb_report = 0;
|
||||||
uint16_t syskb_report = 0;
|
uint16_t syskb_report = 0;
|
||||||
uint8_t sync_lost = 0;
|
uint8_t sync_lost = 0;
|
||||||
@ -64,42 +64,12 @@ void uart_receive_pro(void);
|
|||||||
void break_all_key(void);
|
void break_all_key(void);
|
||||||
uint16_t host_last_consumer_usage(void);
|
uint16_t host_last_consumer_usage(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Uart send consumer keys report.
|
|
||||||
* @note Call in host.c
|
|
||||||
*/
|
|
||||||
void uart_send_consumer_report(void) {
|
|
||||||
no_act_time = 0;
|
|
||||||
conkb_report = host_last_consumer_usage();
|
|
||||||
uart_send_report(CMD_RPT_CONSUME, (uint8_t *)(&conkb_report), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Uart send mouse keys report.
|
|
||||||
* @note Call in host.c
|
|
||||||
*/
|
|
||||||
void uart_send_mouse_report(void) {
|
|
||||||
report_mouse_t mouse_report = mousekey_get_report();
|
|
||||||
|
|
||||||
no_act_time = 0;
|
|
||||||
memcpy(mouse_report_buf, &mouse_report.buttons, 5);
|
|
||||||
uart_send_report(CMD_RPT_MS, mouse_report_buf, 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Uart send system keys report.
|
|
||||||
* @note Call in host.c
|
|
||||||
*/
|
|
||||||
void uart_send_system_report(void) {
|
|
||||||
no_act_time = 0;
|
|
||||||
syskb_report = host_last_system_usage();
|
|
||||||
uart_send_report(CMD_RPT_SYS, (uint8_t *)(&syskb_report), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Uart auto nkey send
|
* @brief Uart auto nkey send
|
||||||
*/
|
*/
|
||||||
bool f_f_bit_kb_act = 0;
|
bool f_bit_kb_act = 0;
|
||||||
static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report, uint8_t size)
|
static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report, uint8_t size)
|
||||||
{
|
{
|
||||||
uint8_t i, j, byte_index;
|
uint8_t i, j, byte_index;
|
||||||
@ -125,8 +95,6 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (byte_index >= 8) {
|
if (byte_index >= 8) {
|
||||||
uart_bit_report_buf[i] |= offset_mask;
|
uart_bit_report_buf[i] |= offset_mask;
|
||||||
f_bit_send = 1;
|
f_bit_send = 1;
|
||||||
@ -137,7 +105,6 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report
|
|||||||
bytekb_report_buf[byte_index] = 0;
|
bytekb_report_buf[byte_index] = 0;
|
||||||
f_byte_send = 1;
|
f_byte_send = 1;
|
||||||
break;
|
break;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (byte_index >= 8) {
|
if (byte_index >= 8) {
|
||||||
@ -152,7 +119,7 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (f_bit_send) {
|
if (f_bit_send) {
|
||||||
f_f_bit_kb_act = 1;
|
f_bit_kb_act = 1;
|
||||||
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
|
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,43 +131,77 @@ static void uart_auto_nkey_send(uint8_t *pre_bit_report, uint8_t *now_bit_report
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Uart send keys report.
|
* @brief Uart send keys report.
|
||||||
* @note Call in host.c
|
|
||||||
*/
|
*/
|
||||||
void uart_send_report_func(void)
|
void uart_send_report_repeat(void)
|
||||||
{
|
{
|
||||||
static uint32_t interval_timer = 0;
|
static uint32_t interval_timer = 0;
|
||||||
|
|
||||||
if (dev_info.link_mode == LINK_USB) return;
|
if (dev_info.link_mode == LINK_USB) return;
|
||||||
keyboard_protocol = 1;
|
keyboard_protocol = 1;
|
||||||
|
|
||||||
if(keymap_config.nkro)
|
if (timer_elapsed32(interval_timer) > 50) {
|
||||||
nkro_report->mods = get_mods() | get_weak_mods();
|
|
||||||
|
|
||||||
if ((dev_info.sys_sw_state == SYS_SW_MAC) && (memcmp(bytekb_report_buf, &keyboard_report->mods, 8))) {
|
|
||||||
no_act_time = 0;
|
|
||||||
keyboard_report->reserved = 0;
|
|
||||||
memcpy(bytekb_report_buf, &keyboard_report->mods, 8);
|
|
||||||
uart_send_report(CMD_RPT_BYTE_KB, bytekb_report_buf, 8);
|
|
||||||
}
|
|
||||||
else if ((dev_info.sys_sw_state == SYS_SW_WIN) && (memcmp(bitkb_report_buf, &nkro_report->mods, NKRO_REPORT_BITS+1))) {
|
|
||||||
no_act_time = 0;
|
|
||||||
uart_auto_nkey_send(bitkb_report_buf, &nkro_report->mods, NKRO_REPORT_BITS+1);
|
|
||||||
memcpy(&bitkb_report_buf[0], &nkro_report->mods, NKRO_REPORT_BITS+1);
|
|
||||||
}
|
|
||||||
else if (timer_elapsed32(interval_timer) > 100) {
|
|
||||||
interval_timer = timer_read32();
|
interval_timer = timer_read32();
|
||||||
if (no_act_time <= 200) {
|
if (no_act_time <= 200) {
|
||||||
uart_send_report(CMD_RPT_BYTE_KB, bytekb_report_buf, 8);
|
uart_send_report(CMD_RPT_BYTE_KB, bytekb_report_buf, 8);
|
||||||
|
wait_us(200);
|
||||||
|
|
||||||
if(f_f_bit_kb_act)
|
if(f_bit_kb_act)
|
||||||
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
|
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
f_f_bit_kb_act = 0;
|
f_bit_kb_act = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uart send consumer keys report.
|
||||||
|
* @note Call in rf_driver.c
|
||||||
|
*/
|
||||||
|
void uart_send_consumer_report(report_extra_t *report) {
|
||||||
|
no_act_time = 0;
|
||||||
|
uart_send_report(CMD_RPT_CONSUME, (uint8_t *)(&report->usage), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uart send mouse keys report.
|
||||||
|
* @note Call in rf_driver.c
|
||||||
|
*/
|
||||||
|
void uart_send_mouse_report(report_mouse_t *report) {
|
||||||
|
no_act_time = 0;
|
||||||
|
uart_send_report(CMD_RPT_MS, &report->buttons, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uart send system keys report.
|
||||||
|
* @note Call in rf_driver.c
|
||||||
|
*/
|
||||||
|
void uart_send_system_report(report_extra_t *report) {
|
||||||
|
no_act_time = 0;
|
||||||
|
uart_send_report(CMD_RPT_SYS, (uint8_t *)(&report->usage), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uart send byte keys report.
|
||||||
|
* @note Call in rf_driver.c
|
||||||
|
*/
|
||||||
|
void uart_send_report_keyboard(report_keyboard_t *report) {
|
||||||
|
no_act_time = 0;
|
||||||
|
report->reserved = 0;
|
||||||
|
uart_send_report(CMD_RPT_BYTE_KB, &report->mods, 8);
|
||||||
|
memcpy(bytekb_report_buf, &report->mods, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uart send bit keys report.
|
||||||
|
* @note Call in rf_driver.c
|
||||||
|
*/
|
||||||
|
void uart_send_report_nkro(report_nkro_t *report) {
|
||||||
|
no_act_time = 0;
|
||||||
|
uart_auto_nkey_send(bitkb_report_buf, &nkro_report->mods, NKRO_REPORT_BITS + 1);
|
||||||
|
memcpy(&bitkb_report_buf[0], &nkro_report->mods, NKRO_REPORT_BITS + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parsing the data received from the RF module.
|
* @brief Parsing the data received from the RF module.
|
||||||
*/
|
*/
|
||||||
@ -468,7 +469,7 @@ void dev_sts_sync(void) {
|
|||||||
if (host_mode != HOST_RF_TYPE) {
|
if (host_mode != HOST_RF_TYPE) {
|
||||||
host_mode = HOST_RF_TYPE;
|
host_mode = HOST_RF_TYPE;
|
||||||
break_all_key();
|
break_all_key();
|
||||||
host_set_driver(0);
|
host_set_driver(&rf_host_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_info.rf_state != RF_CONNECT) {
|
if (dev_info.rf_state != RF_CONNECT) {
|
||||||
|
48
keyboards/nuphy/air75_v2/ansi/rf_driver.c
Normal file
48
keyboards/nuphy/air75_v2/ansi/rf_driver.c
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "host_driver.h"
|
||||||
|
#include "rf_driver.h"
|
||||||
|
#include "host.h"
|
||||||
|
#include "user_kb.h"
|
||||||
|
|
||||||
|
/* Variable declaration */
|
||||||
|
extern DEV_INFO_STRUCT dev_info;
|
||||||
|
|
||||||
|
/* Host driver */
|
||||||
|
static uint8_t rf_keyboard_leds(void);
|
||||||
|
static void rf_send_keyboard(report_keyboard_t *report);
|
||||||
|
static void rf_send_nkro(report_nkro_t *report);
|
||||||
|
static void rf_send_mouse(report_mouse_t *report);
|
||||||
|
static void rf_send_extra(report_extra_t *report);
|
||||||
|
host_driver_t rf_host_driver = {rf_keyboard_leds, rf_send_keyboard, rf_send_nkro, rf_send_mouse, rf_send_extra};
|
||||||
|
|
||||||
|
/* defined in rf.c */
|
||||||
|
extern void uart_send_report_keyboard(report_keyboard_t *report);
|
||||||
|
extern void uart_send_report_nkro(report_nkro_t *report);
|
||||||
|
extern void uart_send_mouse_report(report_mouse_t *report);
|
||||||
|
extern void uart_send_consumer_report(report_extra_t *report);
|
||||||
|
extern void uart_send_system_report(report_extra_t *report);
|
||||||
|
|
||||||
|
static uint8_t rf_keyboard_leds(void) {
|
||||||
|
return dev_info.rf_led;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rf_send_keyboard(report_keyboard_t *report) {
|
||||||
|
keyboard_protocol = 1;
|
||||||
|
uart_send_report_keyboard(report);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rf_send_nkro(report_nkro_t *report) {
|
||||||
|
keyboard_protocol = 1;
|
||||||
|
uart_send_report_nkro(report);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rf_send_mouse(report_mouse_t *report) {
|
||||||
|
uart_send_mouse_report(report);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rf_send_extra(report_extra_t *report) {
|
||||||
|
if (report->report_id == REPORT_ID_CONSUMER) {
|
||||||
|
uart_send_consumer_report(report);
|
||||||
|
} else if (report->report_id == REPORT_ID_SYSTEM) {
|
||||||
|
uart_send_system_report(report);
|
||||||
|
}
|
||||||
|
}
|
3
keyboards/nuphy/air75_v2/ansi/rf_driver.h
Normal file
3
keyboards/nuphy/air75_v2/ansi/rf_driver.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern host_driver_t rf_host_driver;
|
@ -1,6 +1,7 @@
|
|||||||
SRC += side.c
|
SRC += side.c
|
||||||
SRC += rf.c
|
SRC += rf.c
|
||||||
SRC += sleep.c
|
SRC += sleep.c
|
||||||
|
SRC += rf_driver.c
|
||||||
SRC += user_kb.c
|
SRC += user_kb.c
|
||||||
SRC += side_driver.c
|
SRC += side_driver.c
|
||||||
QUANTUM_LIB_SRC += uart.c
|
QUANTUM_LIB_SRC += uart.c
|
||||||
|
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "user_kb.h"
|
#include "user_kb.h"
|
||||||
#include "ansi.h"
|
#include "ansi.h"
|
||||||
#include "usb_main.h"
|
#include "usb_main.h"
|
||||||
|
#include "rf_driver.h"
|
||||||
|
|
||||||
user_config_t user_config;
|
user_config_t user_config;
|
||||||
DEV_INFO_STRUCT dev_info = {
|
DEV_INFO_STRUCT dev_info = {
|
||||||
@ -173,18 +174,20 @@ void long_press_key(void) {
|
|||||||
* @brief Release all keys, clear keyboard report.
|
* @brief Release all keys, clear keyboard report.
|
||||||
*/
|
*/
|
||||||
void break_all_key(void) {
|
void break_all_key(void) {
|
||||||
uint8_t report_buf[16];
|
uint8_t report_buf[NKRO_REPORT_BITS + 1];
|
||||||
bool nkro_temp = keymap_config.nkro;
|
bool nkro_temp = keymap_config.nkro;
|
||||||
|
|
||||||
clear_weak_mods();
|
clear_weak_mods();
|
||||||
clear_mods();
|
clear_mods();
|
||||||
clear_keyboard();
|
clear_keyboard();
|
||||||
|
|
||||||
|
// break nkro key
|
||||||
keymap_config.nkro = 1;
|
keymap_config.nkro = 1;
|
||||||
memset(keyboard_report, 0, sizeof(report_keyboard_t));
|
memset(nkro_report, 0, sizeof(report_nkro_t));
|
||||||
host_keyboard_send(keyboard_report);
|
host_nkro_send(nkro_report);
|
||||||
wait_ms(10);
|
wait_ms(10);
|
||||||
|
|
||||||
|
// break byte key
|
||||||
keymap_config.nkro = 0;
|
keymap_config.nkro = 0;
|
||||||
memset(keyboard_report, 0, sizeof(report_keyboard_t));
|
memset(keyboard_report, 0, sizeof(report_keyboard_t));
|
||||||
host_keyboard_send(keyboard_report);
|
host_keyboard_send(keyboard_report);
|
||||||
@ -193,7 +196,7 @@ void break_all_key(void) {
|
|||||||
keymap_config.nkro = nkro_temp;
|
keymap_config.nkro = nkro_temp;
|
||||||
|
|
||||||
if (dev_info.link_mode != LINK_USB) {
|
if (dev_info.link_mode != LINK_USB) {
|
||||||
memset(report_buf, 0, 16);
|
memset(report_buf, 0, NKRO_REPORT_BITS + 1);
|
||||||
uart_send_report(CMD_RPT_BIT_KB, report_buf, 16);
|
uart_send_report(CMD_RPT_BIT_KB, report_buf, 16);
|
||||||
wait_ms(10);
|
wait_ms(10);
|
||||||
uart_send_report(CMD_RPT_BYTE_KB, report_buf, 8);
|
uart_send_report(CMD_RPT_BYTE_KB, report_buf, 8);
|
||||||
@ -224,8 +227,7 @@ void switch_dev_link(uint8_t mode) {
|
|||||||
rf_link_show_time = 0;
|
rf_link_show_time = 0;
|
||||||
} else {
|
} else {
|
||||||
host_mode = HOST_RF_TYPE;
|
host_mode = HOST_RF_TYPE;
|
||||||
|
host_set_driver(&rf_host_driver);
|
||||||
host_set_driver(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +300,7 @@ void dial_sw_scan(void) {
|
|||||||
f_first = false;
|
f_first = false;
|
||||||
|
|
||||||
if (dev_info.link_mode != LINK_USB) {
|
if (dev_info.link_mode != LINK_USB) {
|
||||||
host_set_driver(0);
|
host_set_driver(&rf_host_driver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,6 +380,7 @@ void timer_pro(void) {
|
|||||||
m_host_driver = host_get_driver();
|
m_host_driver = host_get_driver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// step 10ms
|
||||||
if (timer_elapsed32(interval_timer) < 10)
|
if (timer_elapsed32(interval_timer) < 10)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
@ -413,4 +416,4 @@ void londing_eeprom_data(void) {
|
|||||||
side_rgb = user_config.ee_side_rgb;
|
side_rgb = user_config.ee_side_rgb;
|
||||||
side_colour = user_config.ee_side_colour;
|
side_colour = user_config.ee_side_colour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ typedef struct
|
|||||||
void dev_sts_sync(void);
|
void dev_sts_sync(void);
|
||||||
void rf_uart_init(void);
|
void rf_uart_init(void);
|
||||||
void rf_device_init(void);
|
void rf_device_init(void);
|
||||||
void uart_send_report_func(void);
|
void uart_send_report_repeat(void);
|
||||||
void uart_receive_pro(void);
|
void uart_receive_pro(void);
|
||||||
void uart_send_report(uint8_t report_type, uint8_t *report_buf, uint8_t report_size);
|
void uart_send_report(uint8_t report_type, uint8_t *report_buf, uint8_t report_size);
|
||||||
void side_speed_contol(uint8_t dir);
|
void side_speed_contol(uint8_t dir);
|
||||||
@ -164,4 +164,4 @@ void dial_sw_scan(void);
|
|||||||
void dial_sw_fast_scan(void);
|
void dial_sw_fast_scan(void);
|
||||||
void timer_pro(void);
|
void timer_pro(void);
|
||||||
void londing_eeprom_data(void);
|
void londing_eeprom_data(void);
|
||||||
uint8_t uart_send_cmd(uint8_t cmd, uint8_t ack_cnt, uint8_t delayms);
|
uint8_t uart_send_cmd(uint8_t cmd, uint8_t ack_cnt, uint8_t delayms);
|
||||||
|
Loading…
Reference in New Issue
Block a user