-
Notifications
You must be signed in to change notification settings - Fork 14
/
actkbd.h
169 lines (128 loc) · 3.78 KB
/
actkbd.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* actkbd - A keyboard shortcut daemon
*
* Copyright (c) 2005-2006 Theodoros V. Kalamatianos <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*/
#ifndef _ACTKBD_H_
#define _ACTKBD_H_
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdarg.h>
#include <ctype.h>
#include <getopt.h>
#include <syslog.h>
#include <signal.h>
#include <sys/types.h>
#define UNUSED 0
/* Event types */
#define INVALID 0
#define KEY (1<<0)
#define REP (1<<1)
#define REL (1<<2)
/* Return values */
enum { OK, USAGE, MEMERR, HOSTFAIL, DEVFAIL, READERR, WRITEERR, EVERR, CONFERR,
FORKERR, INTERR, PIDERR, NOMATCH };
/* Verbosity level */
extern int verbose;
/* Maximum number of keys */
extern int maxkey;
/* Device grab state */
extern int grabbed;
/* The device name */
extern char *device;
/* The configuration file name */
extern char *config;
/* Logging function */
int lprintf(const char *fmt, ...);
/* Device initialisation */
int init_dev();
/* Device open function */
int open_dev();
/* Device close function */
int close_dev();
/* Device grab function */
int grab_dev();
/* Device un-grab function */
int ungrab_dev();
/* Keyboard event receiver function */
int get_key(int *key, int *type);
/* Send an event to the input layer */
int snd_key(int key, int type);
/* Set a keyboard LED */
int set_led(int led, int on);
/* Key mask handling */
int get_masksize();
int init_mask(unsigned char **mask);
void free_mask(unsigned char **mask);
int lprint_mask(unsigned char *mask);
int strmask(unsigned char **mask, char *keys);
/* The active key mask */
int init_key_mask();
void free_key_mask();
void clear_key_mask();
int set_key_bit(int bit, int val);
int get_key_bit(int bit);
int cmp_key_mask(unsigned char *mask0, unsigned int attr);
int lprint_key_mask_delim(char c);
int lprint_key_mask();
unsigned char *get_key_mask();
/* The ignored key mask */
int init_ign_mask();
void free_ign_mask();
void clear_ign_mask();
int set_ign_bit(int bit, int val);
int get_ign_bit(int bit);
int cmp_ign_mask(unsigned char *mask0, unsigned int attr);
int lprint_ign_mask_delim(char c);
int lprint_ign_mask();
unsigned char *get_ign_mask();
void copy_key_to_ign_mask();
/* The attribute node struct */
typedef struct _attr_t attr_t;
struct _attr_t {
int type; /* Attribute type */
void *opt; /* Options for this attribute */
attr_t *next; /* The next node */
};
/* Supported attributes */
#define ATTR_EXEC 0
#define ATTR_GRAB 1
#define ATTR_UNGRAB 2
#define ATTR_IGNREL 3
#define ATTR_RCVREL 4
#define ATTR_ALLREL 5
#define ATTR_KEY 6
#define ATTR_REL 7
#define ATTR_REP 8
#define ATTR_LEDON 9
#define ATTR_LEDOFF 10
#define ATTR_SET 11
#define ATTR_UNSET 12
/* The key_cmd struct */
typedef struct {
unsigned char *keys; /* The key mask */
int type; /* The event type */
char *command; /* The command to execute */
unsigned int attr_bits; /* Bitwise attributes */
attr_t *attrs; /* The attribute list */
} key_cmd;
/* The bitwise attribute values */
#define BIT_ATTR_NOEXEC (1<<0) /* Do not call system() */
#define BIT_ATTR_GRABBED (1<<1) /* Match only when the device is grabbed */
#define BIT_ATTR_UNGRABBED (1<<2) /* Match only when the device is not grabbed */
#define BIT_ATTR_NOT (1<<3) /* Match any key except for the specified ones */
#define BIT_ATTR_ALL (1<<4) /* Match if all of the specified keys is pressed */
#define BIT_ATTR_ANY (1<<5) /* Match if any of the specified keys is pressed */
/* Configuration file processing */
int open_config();
int close_config();
int match_key(int type, key_cmd **command);
#endif /* _ACTKBD_H_ */