aboutsummaryrefslogtreecommitdiffstats
path: root/src/hid.c
blob: ea7600c3e92abf51ec50b5696f4bc136c9c4e8a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "hid.h"
#include "split.h"
#include "matrix.h"
#include "keysym.h"
#include "keymap.h"

#include <pico/types.h>

void
hid_init(void)
{
	
}

inline uint
layer_index(uint x, uint y)
{
	if (y < KEY_ROWS)
		return y * KEY_COLS + x;
	else
		return y * KEY_COLS + (KEY_COLS - 1 - x);
}

bool
hid_gen_report(uint8_t *report)
{
	int keycnt;
	uint x, y, p;

	keycnt = 0;
	for (y = 0; y < KEY_ROWS * 2; y++) {
		for (x = 0; x < KEY_COLS; x++) {
			if (!state_matrix[y * KEY_COLS + x])
				continue;
			if (keycnt >= 6) break;
			DEBUG("PRESS %i %", x, y);
			p = layer_index(x, y);
			report[keycnt] = TO_CODE(keymap_layers_de[0][p]);
			keycnt++;
		}
	}

	return keycnt > 0;
}

void
hid_task(void)
{

	/* assemble hid report */
}