-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparse_config.h
More file actions
90 lines (77 loc) · 2.56 KB
/
parse_config.h
File metadata and controls
90 lines (77 loc) · 2.56 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
Copyright (C) 2021 Michel Stempin <michel.stempin@funkey-project.com>
This file is part of the FunKey S GPIO keyboard daemon.
This is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
*/
/**
* @file parse_config.h
* This file contains the configuration parsing functions
*/
#ifndef _PARSE_H_
#define _PARSE_H_
#include <stdint.h>
#include <stdbool.h>
#include "mapping_list.h"
/* Definition of the different hardware GPIOs */
#define GPIOS \
X(GPIO_RIGHT, "RIGHT") \
X(GPIO_DOWN, "DOWN") \
X(GPIO_L, "L") \
X(GPIO_UP, "UP") \
X(GPIO_LEFT, "LEFT") \
X(GPIO_MENU, "MENU") \
X(GPIO_START, "START") \
X(GPIO_FN, "FN") \
X(GPIO_NU1, "") \
X(GPIO_NU2, "") \
X(GPIO_NU3, "") \
X(GPIO_X, "X") \
X(GPIO_A, "A") \
X(GPIO_Y, "Y") \
X(GPIO_B, "B") \
X(GPIO_R, "R") \
X(GPIO_LAST, NULL)
/* Enumeration of the different hardware GPIOs */
#undef X
#define X(a, b) a,
typedef enum {GPIOS} button_t;
/* Definition of the different parse states */
#define PARSE_STATES \
X(STATE_INIT, "INIT") \
X(STATE_MAP, "MAP") \
X(STATE_UNMAP, "UNMAP") \
X(STATE_CLEAR, "CLEAR") \
X(STATE_LOAD, "LOAD") \
X(STATE_SLEEP, "SLEEP") \
X(STATE_KEYUP, "KEYUP") \
X(STATE_KEYDOWN, "KEYDOWN") \
X(STATE_KEYPRESS, "KEYPRESS") \
X(STATE_TYPE, "TYPE") \
X(STATE_FUNCTION, "FUNCTION") \
X(STATE_KEY, "KEY") \
X(STATE_COMMAND, "COMMAND")\
X(STATE_DUMP, "DUMP") \
X(STATE_SAVE, "SAVE") \
X(STATE_INVALID, "INVALID")
/* Enumeration of the different parse states */
#undef X
#define X(a, b) a,
typedef enum {PARSE_STATES} parse_state_t;
const char *gpio_name(uint8_t gpio);
const char *keycode_name(int keycode);
bool parse_config_line(char *line, mapping_list_t *list,
uint32_t *monitored_gpio_mask);
bool parse_config_file(const char *name, mapping_list_t *list,
uint32_t *monitored_gpio_mask);
#endif //_PARSE_H_