jag

jagParse_c

public

parser lib for my games

Star0
Watch0

Commit 677d9ec03861

tarball

Jaglekon <58274093+Jaglekon@users.noreply.github.com>2026-08-28 19:14 UTC

5 files changed+53-7
more keys and free buf
Added file: Makefile+14 additions
@@ -0,0 +1,14 @@
1+.PHONY: all debug clean
2+
3+all:
4+ cmake -B build -DCMAKE_BUILD_TYPE=Release
5+ cmake --build build
6+
7+debug:
8+ cmake -B build -DCMAKE_BUILD_TYPE=Debug
9+ cmake --build build
10+
11+new: clean debug
12+
13+clean:
14+ rm -rf build
Modified file: flake.nix+1 additions−1 deletions
@@ -14,7 +14,7 @@
1414 in {
1515 packages.${system}.default = pkgs.stdenv.mkDerivation {
1616 pname = "jag-parse";
17- version = "1.0.2";
17+ version = "1.1.0";
1818
1919 src = ./.;
2020
Modified file: include/jag_parse.h+4 additions−1 deletions
@@ -10,9 +10,12 @@
1010 #define ARROW_LEN 3
1111
1212 typedef enum {
13- NO_KEY, P_KEY, Q_KEY, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW, INCOMPLETE, UNKNOWN
13+ NO_KEY, ESCAPE_KEY, ENTER_KEY, LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW, A_KEY, D_KEY, Q_KEY, P_KEY, S_KEY, W_KEY, INCOMPLETE, UNKNOWN
1414 } keypress;
1515
16+
17+void free_buf();
18+
1619 int add_to_buf(uint8_t *input, uint16_t input_length);
1720
1821 keypress parse_input();
Deleted file: result−1 deletions
@@ -1 +0,0 @@
1-/nix/store/lqi15sh8mmswdlnd09l5xsaxf7a4gc1s-jag_parse-1.0.1
Modified file: source/jag_parse.c+34 additions−4 deletions
@@ -8,6 +8,14 @@ uint16_t end = 0;
88 uint16_t length = 0;
99
1010
11+
12+void free_buf () {
13+ start = 0;
14+ end = 0;
15+ length = 0;
16+}
17+
18+
1119 int add_to_buf(uint8_t *input, uint16_t input_length) {
1220
1321 if (BUF_LEN - length < input_length)
@@ -81,6 +89,8 @@ keypress parse_input() {
8189 length--;
8290
8391 next_position = next_pos(next_position);
92+ } else {
93+ output = ESCAPE_KEY;
8494 }
8595 }
8696
@@ -88,10 +98,30 @@ keypress parse_input() {
8898
8999 length--;
90100
91- if (next_char == 'p') {
92- output = P_KEY;
93- } else if(next_char == 'q') {
94- output = Q_KEY;
101+ switch (next_char) {
102+ case '\n':
103+ output = ENTER_KEY;
104+ break;
105+ case 'a':
106+ output = A_KEY;
107+ break;
108+ case 'd':
109+ output = D_KEY;
110+ break;
111+ case 'p':
112+ output = P_KEY;
113+ break;
114+ case 'q':
115+ output = Q_KEY;
116+ break;
117+ case 's':
118+ output = S_KEY;
119+ break;
120+ case 'w':
121+ output = W_KEY;
122+ break;
123+ default:
124+ break;
95125 }
96126 }