Move functions for adding keys from to reports to report.h
This commit is contained in:
parent
017458a07b
commit
fb95d86b39
4 changed files with 45 additions and 35 deletions
|
@ -136,38 +136,6 @@ void send_keyboard_report(void) {
|
||||||
host_keyboard_send(keyboard_report);
|
host_keyboard_send(keyboard_report);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* key */
|
|
||||||
void add_key(uint8_t key)
|
|
||||||
{
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
if (keyboard_protocol && keymap_config.nkro) {
|
|
||||||
add_key_bit(keyboard_report, key);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
add_key_byte(keyboard_report, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void del_key(uint8_t key)
|
|
||||||
{
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
if (keyboard_protocol && keymap_config.nkro) {
|
|
||||||
del_key_bit(keyboard_report, key);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
del_key_byte(keyboard_report, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_keys(void)
|
|
||||||
{
|
|
||||||
// not clear mods
|
|
||||||
for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) {
|
|
||||||
keyboard_report->raw[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* modifier */
|
/* modifier */
|
||||||
uint8_t get_mods(void) { return real_mods; }
|
uint8_t get_mods(void) { return real_mods; }
|
||||||
void add_mods(uint8_t mods) { real_mods |= mods; }
|
void add_mods(uint8_t mods) { real_mods |= mods; }
|
||||||
|
|
|
@ -29,9 +29,17 @@ extern report_keyboard_t *keyboard_report;
|
||||||
void send_keyboard_report(void);
|
void send_keyboard_report(void);
|
||||||
|
|
||||||
/* key */
|
/* key */
|
||||||
void add_key(uint8_t key);
|
inline void add_key(uint8_t key) {
|
||||||
void del_key(uint8_t key);
|
add_key_to_report(keyboard_report, key);
|
||||||
void clear_keys(void);
|
}
|
||||||
|
|
||||||
|
inline void del_key(uint8_t key) {
|
||||||
|
del_key_from_report(keyboard_report, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void clear_keys(void) {
|
||||||
|
clear_keys_from_report(keyboard_report);
|
||||||
|
}
|
||||||
|
|
||||||
/* modifier */
|
/* modifier */
|
||||||
uint8_t get_mods(void);
|
uint8_t get_mods(void);
|
||||||
|
|
|
@ -175,3 +175,33 @@ void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key)
|
||||||
|
{
|
||||||
|
#ifdef NKRO_ENABLE
|
||||||
|
if (keyboard_protocol && keymap_config.nkro) {
|
||||||
|
add_key_bit(keyboard_report, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
add_key_byte(keyboard_report, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key)
|
||||||
|
{
|
||||||
|
#ifdef NKRO_ENABLE
|
||||||
|
if (keyboard_protocol && keymap_config.nkro) {
|
||||||
|
del_key_bit(keyboard_report, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
del_key_byte(keyboard_report, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear_keys_from_report(report_keyboard_t* keyboard_report)
|
||||||
|
{
|
||||||
|
// not clear mods
|
||||||
|
for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) {
|
||||||
|
keyboard_report->raw[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -184,6 +184,10 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code);
|
||||||
void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code);
|
void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key);
|
||||||
|
void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key);
|
||||||
|
void clear_keys_from_report(report_keyboard_t* keyboard_report);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue