mirror of
https://github.com/osiweb/unified_retro_keyboard.git
synced 2024-11-22 04:33:19 +00:00
d6edb15734
(WARNING: WIP) Gathered Work-in-progress on alternate keymap defs Exploratory branch. Code is messy and untested. Examining creating a module for each keymap rather than header file.
69 lines
1.3 KiB
C
69 lines
1.3 KiB
C
#include<stdint.h>
|
|
#include "asdf.h"
|
|
#include "asdf_keymaps.h"
|
|
#include "asdf_keymap_defs.h"
|
|
#include "test_asdf_lib.h"
|
|
#include "asdf_arch.h"
|
|
|
|
static uint32_t key_matrix[ASDF_NUM_ROWS] = {};
|
|
|
|
ASDF_KEYMAP_DECLARATIONS;
|
|
|
|
|
|
coord_t *find_code(asdf_keycode_t code)
|
|
{
|
|
uint32_t done = 0;
|
|
static coord_t location = { .row = -1, .col = -1 };
|
|
|
|
for (uint32_t row = 0; !done && (row < ASDF_NUM_ROWS); row++) {
|
|
for (uint32_t col = 0; !done && (col < ASDF_NUM_COLS); col++) {
|
|
if (test_PLAIN_matrix[row][col] == code) {
|
|
done = 1;
|
|
location.row = row;
|
|
location.col = col;
|
|
}
|
|
}
|
|
}
|
|
return &location;
|
|
}
|
|
|
|
|
|
void keyscan_delay(int32_t ticks)
|
|
{
|
|
for (; ticks; ticks--) {
|
|
asdf_keyscan();
|
|
}
|
|
}
|
|
|
|
void press_no_debounce(asdf_keycode_t code)
|
|
{
|
|
coord_t *location = find_code(code);
|
|
key_matrix[location->row] |= (1 << location->col);
|
|
}
|
|
|
|
void release_no_debounce(asdf_keycode_t code)
|
|
{
|
|
coord_t *location = find_code(code);
|
|
key_matrix[location->row] &= ~(1 << location->col);
|
|
}
|
|
|
|
void press(asdf_keycode_t code)
|
|
{
|
|
press_no_debounce(code);
|
|
keyscan_delay(ASDF_DEBOUNCE_TIME_MS);
|
|
}
|
|
|
|
void release(asdf_keycode_t code)
|
|
{
|
|
release_no_debounce(code);
|
|
keyscan_delay(ASDF_DEBOUNCE_TIME_MS);
|
|
}
|
|
|
|
|
|
asdf_cols_t asdf_arch_read_row(uint8_t row)
|
|
{
|
|
return key_matrix[row];
|
|
}
|
|
|
|
|