From 24ebd3c309c5d6cad63bbf1b40de8c17aead0366 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 19 Feb 2025 23:06:02 +0100 Subject: Add state marshalling and unmarshalling functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libterminput_unmarshal_keypress__.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 libterminput_unmarshal_keypress__.c (limited to 'libterminput_unmarshal_keypress__.c') diff --git a/libterminput_unmarshal_keypress__.c b/libterminput_unmarshal_keypress__.c new file mode 100644 index 0000000..68a622d --- /dev/null +++ b/libterminput_unmarshal_keypress__.c @@ -0,0 +1,19 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +int +libterminput_unmarshal_keypress__(struct libterminput_unmarshaller *how, struct libterminput_keypress *what) +{ + what->type = LIBTERMINPUT_KEYPRESS; + if (how->load(how, &what->key, sizeof(what->key)) || + how->load(how, &what->times, sizeof(what->times)) || + how->load(how, &what->mods, sizeof(what->mods))) + return -1; + if (what->key == LIBTERMINPUT_SYMBOL) { + return how->load(how, what->symbol, sizeof(what->symbol)); + } else { + memset(what->symbol, 0, sizeof(what->symbol)); + return 0; + } +} -- cgit v1.2.3-70-g09d2