forked from Ikcelaks/qmk_sequence_transform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey_stack.c
More file actions
31 lines (29 loc) · 933 Bytes
/
Copy pathkey_stack.c
File metadata and controls
31 lines (29 loc) · 933 Bytes
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
// Copyright 2024 Guillaume Stordeur <guillaume.stordeur@gmail.com>
// Copyright 2024 Matt Skalecki <ikcelaks@gmail.com>
// Copyright 2024 QKekos <q.kekos.q@gmail.com>
// SPDX-License-Identifier: Apache-2.0
#include <stdint.h>
#include <stdbool.h>
#include "key_stack.h"
#include "utils.h"
//////////////////////////////////////////////////////////////////////
void st_key_stack_push(st_key_stack_t *s, uint16_t key)
{
if (s->size < s->capacity) {
s->buffer[s->size++] = key;
}
}
//////////////////////////////////////////////////////////////////////
void st_key_stack_pop(st_key_stack_t *s)
{
s->size = st_max(0, s->size - 1);
}
//////////////////////////////////////////////////////////////////////
void st_key_stack_to_str(const st_key_stack_t *s, char *str)
{
char *dst = str;
for (int i = s->size - 1; i >= 0; --i) {
*dst++ = st_keycode_to_char(s->buffer[i]);
}
str[s->size] = 0;
}