summaryrefslogtreecommitdiff
path: root/utils/nwztools/plattools/nwz_lib.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-10-19 17:03:52 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2016-10-19 17:09:04 +0200
commitba91ff10e8c974e50e429d072641ac5e0acdd72e (patch)
treea8ef07988845f67e22dfed9bef3602126e831da0 /utils/nwztools/plattools/nwz_lib.h
parent13d892eef1c78d14314b7d3a2cb9035e9ba1420c (diff)
downloadrockbox-ba91ff10e8c974e50e429d072641ac5e0acdd72e.tar.gz
rockbox-ba91ff10e8c974e50e429d072641ac5e0acdd72e.zip
nwztools: add a new plattools directory with code to run on the device
This is code is intended to development into a library of code for the NWZ that will be useful to write the "bootloader" on those device. At the same time, it comes with test programs that are easy to run in firmware upgrade mode and also provide a great test bench for the library. At the moment, two test programs are available: - test_display: simply prints two messages using /usr/bin/lcdmsg - test_keys: displays input key event Change-Id: I9d214894ffc9127b528fcdd3eb5d6b61f4e657a7
Diffstat (limited to 'utils/nwztools/plattools/nwz_lib.h')
-rw-r--r--utils/nwztools/plattools/nwz_lib.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/utils/nwztools/plattools/nwz_lib.h b/utils/nwztools/plattools/nwz_lib.h
new file mode 100644
index 0000000000..e9d885d87a
--- /dev/null
+++ b/utils/nwztools/plattools/nwz_lib.h
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _NWZLIB_H_
22#define _NWZLIB_H_
23
24#include <stdio.h>
25#include <stdbool.h>
26#include <stdarg.h>
27#include <unistd.h>
28#include <sys/types.h>
29#include <sys/wait.h>
30#include <linux/input.h>
31#include <fcntl.h>
32
33#include "nwz_keys.h"
34
35/* run a program and exit with nonzero status in case of error
36 * argument list must be NULL terminated */
37void nwz_run(const char *file, const char *args[], bool wait);
38
39/* invoke /usr/bin/lcdmsg to display a message using the small font, optionally
40 * clearing the screen before */
41void nwz_lcdmsg(bool clear, int x, int y, const char *msg);
42void nwz_lcdmsgf(bool clear, int x, int y, const char *format, ...);
43
44/* open icx_key input device and return file descriptor */
45int nwz_key_open(void);
46void nwz_key_close(int fd);
47/* return HOLD status: 0 or 1, or -1 on error */
48int nwz_key_get_hold_status(int fd);
49/* wait for an input event (and return 1), or a timeout (return 0), or error (-1)
50 * set the timeout to -1 to block */
51int nwz_key_wait_event(int fd, long tmo_us);
52/* read an event from the device (may block unless you waited for an event before),
53 * return 1 on success, <0 on error */
54int nwz_key_read_event(int fd, struct input_event *evt);
55/* return keycode from event */
56int nwz_key_event_get_keycode(struct input_event *evt);
57/* return press/released status from event */
58bool nwz_key_event_is_press(struct input_event *evt);
59/* return HOLD status from event */
60bool nwz_key_event_get_hold_status(struct input_event *evt);
61/* get keycode name */
62const char *nwz_key_get_name(int keycode);
63
64#endif /* _NWZLIB_H_ */