[f41b88]: daemons / ir_remote.h  Maximize  Restore  History

Download this file

237 lines (195 with data), 5.9 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
 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* $Id: ir_remote.h,v 1.1 1999/04/29 21:17:03 columbus Exp $ */
/****************************************************************************
** ir_remote.h *************************************************************
****************************************************************************
*
* ir_remote.h - describes and decodes the signals from IR remotes
*
* Copyright (C) 1996,97 Ralph Metzler <rjkm@thp.uni-koeln.de>
* Copyright (C) 1998 Christoph Bartelmus <columbus@hit.handshake.de>
*
*/
#ifndef _IR_REMOTE_H
#define _IR_REMOTE_H
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#ifdef LONG_IR_CODE
typedef unsigned long long ir_code;
#else
typedef unsigned long ir_code;
#endif
#define WBUF_SIZE (256)
#define RBUF_SIZE (256)
#ifdef LIRC_DECODE
#define PULSE_BIT ((unsigned long) 0)
#else
#define PULSE_BIT 0x1000000
#endif
#define REC_SYNC 8
struct sbuf
{
unsigned long data[WBUF_SIZE];
int wptr;
int too_long;
int is_shift;
unsigned long pendingp;
unsigned long pendings;
unsigned long sum;
};
struct rbuf
{
unsigned long data[RBUF_SIZE];
int rptr;
int wptr;
int too_long;
int is_shift;
unsigned long pendingp;
unsigned long pendings;
unsigned long sum;
};
/*
Code with name string
*/
struct ir_ncode {
char *name;
ir_code code;
int length;
unsigned long *signals;
};
/*
struct ir_remote
defines the encoding of a remote control
*/
/* definitions for flags */
/*
Don't forget to take a look at parseFlags in read_config
when adding new flags
*/
#define NR_FLAGS 7
#define SHIFT_ENC 0x0001 /* IR data is shift encoded */
#define SPACE_ENC 0x0002 /* IR data is space encoded */
#define REVERSE 0x0004
#define NO_HEAD_REP 0x0008 /* no header for key repeates */
#define NO_FOOT_REP 0x0010 /* no foot for key repeates */
#define CONST_LENGTH 0x0020 /* signal length+gap is always constant */
#define RAW_CODES 0x0040 /* for internal use only */
#define REPEAT_HEADER 0x0080 /* header is also sent before repeat code */
struct ir_remote
{
char *name; /* name of remote control */
struct ir_ncode *codes;
int bits; /* bits (length of code) */
int flags; /* flags */
int eps; /* eps (_relative_ tolerance) */
int aeps; /* detecing _very short_ pulses is
difficult with relative tolerance
for some remotes,
this is an _absolute_ tolerance
to solve this problem
usually you can say 0 here */
/* pulse and space lengths of: */
int phead,shead; /* header */
int pone,sone; /* 1 */
int pzero,szero; /* 0 */
int plead; /* leading pulse */
int ptrail; /* trailing pulse */
int pfoot,sfoot; /* foot */
int prepeat,srepeat; /* indicate repeating */
int pre_data_bits; /* length of pre_data */
ir_code pre_data; /* data which the remote sends before
actual keycode */
int post_data_bits; /* length of post_data */
ir_code post_data; /* data which the remote sends after
actual keycode */
int pre_p,pre_s; /* signal between pre_data and keycode */
int post_p, post_s; /* signal between keycode and post_code */
unsigned long gap; /* time between signals in usecs */
unsigned long repeat_gap; /* time between two repeat codes
if different from gap */
int repeat_bit; /* 1..bits */
/* end of user editable values */
int repeat_state;
struct ir_ncode *last_code;
int reps;
struct timeval last_send;
unsigned long remaining_gap;/* remember gap for CONST_LENGTH remotes */
struct ir_remote *next;
};
static inline int is_shift(struct ir_remote *remote)
{
if(remote->flags&SHIFT_ENC) return(1);
else return(0);
}
static inline int is_raw(struct ir_remote *remote)
{
if(remote->flags&RAW_CODES) return(1);
else return(0);
}
static inline int is_const(struct ir_remote *remote)
{
if(remote->flags&CONST_LENGTH) return(1);
else return(0);
}
static inline int has_header(struct ir_remote *remote)
{
if(remote->phead>0 && remote->shead>0) return(1);
else return(0);
}
static inline int has_foot(struct ir_remote *remote)
{
if(remote->pfoot>0 && remote->sfoot>0) return(1);
else return(0);
}
static inline int has_repeat(struct ir_remote *remote)
{
if(remote->prepeat>0 && remote->srepeat>0) return(1);
else return(0);
}
static inline int has_repeat_gap(struct ir_remote *remote)
{
if(remote->repeat_gap>0) return(1);
else return(0);
}
static inline int has_pre(struct ir_remote *remote)
{
if(remote->pre_data_bits>0) return(1);
else return(0);
}
static inline int has_post(struct ir_remote *remote)
{
if(remote->post_data_bits>0) return(1);
else return(0);
}
static inline int is_pulse(unsigned long data)
{
return(data&PULSE_BIT ? 1:0);
}
static inline int is_space(unsigned long data)
{
return(!is_pulse(data));
}
/* check if delta is inside exdelta +/- exdelta*eps/100 */
static inline int expect(struct ir_remote *remote,int delta,int exdelta)
{
if(abs(exdelta-delta)<exdelta*remote->eps/100 ||
abs(exdelta-delta)<remote->aeps)
return 1;
return 0;
}
struct ir_remote *get_ir_remote(char *name);
struct ir_ncode *get_ir_code(struct ir_remote *remote,char *name);
inline unsigned long time_left(struct timeval *current,struct timeval *last,
unsigned long gap);
void send_command(struct ir_remote *remote,struct ir_ncode *code);
void clear_rec_buffer(unsigned long data);
int decode(struct ir_remote *remote);
char *decode_command(unsigned long data);
extern struct ir_remote *repeat_remote;
extern struct ir_ncode *repeat_code;
extern struct ir_remote *last_remote;
extern struct ir_remote *remotes,*free_remotes,*decoding;
extern int return_code;
#endif

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks