-
Notifications
You must be signed in to change notification settings - Fork 0
/
ichb.h
executable file
·118 lines (92 loc) · 2.46 KB
/
ichb.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
#ifndef ICHB__
#define ICHB__
#include <stdio.h> // for 'FILE *'
#include <sys/types.h> // for '__u16'
// -----------------------------------------------------------------------------
typedef enum _eCommandId
{
#ifdef BEEP
cmdBeepAck,
cmdBeepNak,
cmdBeepKey,
#endif
cmdLs,
cmdMax
} ICHB_CommandId;
// -----------------------------------------------------------------------------
typedef enum _eKeySequenceId
{
ks001,
ks002,
ks003,
ks004,
ks005,
ks006,
ksMax
} ICHB_KeySequenceId;
// -----------------------------------------------------------------------------
typedef struct _sMatch
{
ICHB_KeySequenceId ksId;
ICHB_CommandId cmdId;
__u16 *matchPointer;
} ICHB_Match;
// -----------------------------------------------------------------------------
typedef enum _eForkResult
{
forkError = -1,
forkChild = 0
} ICHB_ForkResult;
// -----------------------------------------------------------------------------
typedef enum _eMatchState
{
stateInit,
stateCollect,
stateReset,
stateExecute
} ICHB_MatchState;
// -----------------------------------------------------------------------------
typedef struct _sICanHasButtons
{
char const * inputDeviceName;
FILE *pInputDevice;
int fdInputDevice;
int grabInputDevice;
unsigned long readErrorStreak;
__u16 lastScanCode;
ICHB_MatchState matchState;
} ICHB_Instance;
// -----------------------------------------------------------------------------
typedef enum _eOpenResult
{
openOk,
openFailed,
} ICHB_OpenResult;
// -----------------------------------------------------------------------------
typedef enum _eReadResult
{
readKey,
readIgnored,
readError
} ICHB_ReadResult;
// -----------------------------------------------------------------------------
typedef enum _eMachineResult
{
haltMachine,
chainStateSwitch
} ICHB_MachineResult;
// -----------------------------------------------------------------------------
#ifdef BEEP
#define BEEP_ACK ICHB_Exec(cmdBeepAck)
#define BEEP_NAK ICHB_Exec(cmdBeepNak)
#define BEEP_KEY ICHB_Exec(cmdBeepKey)
#else
#define BEEP_ACK
#define BEEP_NAK
#define BEEP_KEY
#endif
// -----------------------------------------------------------------------------
#define ENOPRINT(msg) ICHB_ErrorPrint(__func__, msg, 1)
#define EPRINT(msg) ICHB_ErrorPrint(__func__, msg, 0)
// -----------------------------------------------------------------------------
#endif // ICHB__