qmk/tmk_core/common/report.c

271 lines
7.4 KiB
C

/* Copyright 2017 Fred Sundvik
*
* 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 "report.h"
#include "host.h"
#include "keycode_config.h"
#include "debug.h"
#include "util.h"
#include <string.h>
/** \brief has_anykey
*
* FIXME: Needs doc
*/
uint8_t has_anykey(report_keyboard_t* keyboard_report) {
uint8_t cnt = 0;
uint8_t* p = keyboard_report->keys;
uint8_t lp = sizeof(keyboard_report->keys);
#ifdef NKRO_ENABLE
if (keyboard_protocol && keymap_config.nkro) {
p = keyboard_report->nkro.bits;
lp = sizeof(keyboard_report->nkro.bits);
}
#endif
while (lp--) {
if (*p++) cnt++;
}
return cnt;
}
/** \brief get_first_key
*
* FIXME: Needs doc
*/
uint8_t get_first_key(report_keyboard_t* keyboard_report) {
#ifdef NKRO_ENABLE
if (keyboard_protocol &