aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/command.c1
-rw-r--r--common/host.h1
-rw-r--r--common/util.c10
-rw-r--r--common/util.h3
4 files changed, 13 insertions, 2 deletions
diff --git a/common/command.c b/common/command.c
index 8ca16b910..6d4e4c642 100644
--- a/common/command.c
+++ b/common/command.c
@@ -234,6 +234,7 @@ static bool command_common(uint8_t code)
234 break; 234 break;
235#ifdef NKRO_ENABLE 235#ifdef NKRO_ENABLE
236 case KC_N: 236 case KC_N:
237 clear_keyboard(); //Prevents stuck keys.
237 keyboard_nkro = !keyboard_nkro; 238 keyboard_nkro = !keyboard_nkro;
238 if (keyboard_nkro) 239 if (keyboard_nkro)
239 print("NKRO: enabled\n"); 240 print("NKRO: enabled\n");
diff --git a/common/host.h b/common/host.h
index c59fbfee6..7c4f06601 100644
--- a/common/host.h
+++ b/common/host.h
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#define HOST_H 19#define HOST_H
20 20
21#include <stdint.h> 21#include <stdint.h>
22#include <stdbool.h>
22#include "report.h" 23#include "report.h"
23#include "host_driver.h" 24#include "host_driver.h"
24 25
diff --git a/common/util.c b/common/util.c
index 644301fe8..9d8fb9321 100644
--- a/common/util.c
+++ b/common/util.c
@@ -22,7 +22,7 @@ uint8_t bitpop(uint8_t bits)
22{ 22{
23 uint8_t c; 23 uint8_t c;
24 for (c = 0; bits; c++) 24 for (c = 0; bits; c++)
25 bits &= bits -1; 25 bits &= bits - 1;
26 return c; 26 return c;
27/* 27/*
28 const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; 28 const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
@@ -30,6 +30,14 @@ uint8_t bitpop(uint8_t bits)
30*/ 30*/
31} 31}
32 32
33uint8_t bitpop16(uint16_t bits)
34{
35 uint8_t c;
36 for (c = 0; bits; c++)
37 bits &= bits - 1;
38 return c;
39}
40
33// most significant on-bit - return highest location of on-bit 41// most significant on-bit - return highest location of on-bit
34uint8_t biton(uint8_t bits) 42uint8_t biton(uint8_t bits)
35{ 43{
diff --git a/common/util.h b/common/util.h
index 87636c971..c3734487f 100644
--- a/common/util.h
+++ b/common/util.h
@@ -16,7 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#ifndef UTIL_H 18#ifndef UTIL_H
19#define UTIL_H 1 19#define UTIL_H
20 20
21#include <stdint.h> 21#include <stdint.h>
22 22
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29 29
30 30
31uint8_t bitpop(uint8_t bits); 31uint8_t bitpop(uint8_t bits);
32uint8_t bitpop16(uint16_t bits);
32uint8_t biton(uint8_t bits); 33uint8_t biton(uint8_t bits);
33 34
34#endif 35#endif