LIRC libraries
LinuxInfraredRemoteControl
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
ir_remote.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** ir_remote.c *************************************************************
3 ****************************************************************************
4 *
5 * ir_remote.c - sends and decodes the signals from IR remotes
6 *
7 * Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
8 * Copyright (C) 1998 Christoph Bartelmus (lirc@bartelmus.de)
9 *
10 */
11 
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24 
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <fcntl.h>
28 #include <limits.h>
29 
30 #include <sys/ioctl.h>
31 
32 #include "include/media/lirc.h"
33 #include "lirc/ir_remote.h"
34 #include "lirc/driver.h"
35 #include "lirc/release.h"
36 #include "lirc/lirc_log.h"
37 
39 static struct ir_ncode NCODE_EOF = {
40  "__EOF", LIRC_EOF, 1, NULL, NULL, NULL, 0
41 };
42 
44 static const char* const PACKET_EOF = "0000000008000000 00 __EOF lirc\n";
45 
47 static struct ir_remote lirc_internal_remote = { "lirc" };
48 
49 struct ir_remote* decoding = NULL;
50 
51 struct ir_remote* last_remote = NULL;
52 
53 struct ir_remote* repeat_remote = NULL;
54 
56 
57 static int dyncodes = 0;
58 
59 
61 struct ir_ncode* ncode_dup(struct ir_ncode* ncode)
62 {
63  struct ir_ncode* new_ncode;
64  size_t signal_size;
65  struct ir_code_node* node;
66  struct ir_code_node** node_ptr;
67  struct ir_code_node* new_node;
68 
69  new_ncode = (struct ir_ncode*)malloc(sizeof(struct ir_ncode));
70  if (new_ncode == NULL)
71  return NULL;
72  memcpy(new_ncode, ncode, sizeof(struct ir_ncode));
73  new_ncode->name = ncode->name == NULL ? NULL : strdup(ncode->name);
74  if (ncode->length > 0) {
75  signal_size = ncode->length * sizeof(lirc_t);
76  new_ncode->signals = (lirc_t*)malloc(signal_size);
77  if (new_ncode->signals == NULL)
78  return NULL;
79  memcpy(new_ncode->signals, ncode->signals, signal_size);
80  } else {
81  new_ncode->signals = NULL;
82  }
83  node_ptr = &(new_ncode->next);
84  for (node = ncode->next; node != NULL; node = node->next) {
85  new_node = malloc(sizeof(struct ir_code_node));
86  memcpy(new_node, node, sizeof(struct ir_code_node));
87  *node_ptr = new_node;
88  node_ptr = &(new_node->next);
89  }
90  *node_ptr = NULL;
91  return new_ncode;
92 }
93 
94 
96 void ncode_free(struct ir_ncode* ncode)
97 {
98  struct ir_code_node* node;
99  struct ir_code_node* next;
100 
101  if (ncode == NULL)
102  return;
103  node = ncode->next;
104  while (node != NULL) {
105  next = node->next;
106  if (node != NULL)
107  free(node);
108  node = next;
109  }
110  if (ncode->signals != NULL)
111  free(ncode->signals);
112  free(ncode);
113 }
114 
115 
116 void ir_remote_init(int use_dyncodes)
117 {
118  dyncodes = use_dyncodes;
119 }
120 
121 
122 static lirc_t time_left(struct timeval* current,
123  struct timeval* last,
124  lirc_t gap)
125 {
126  unsigned long secs, diff;
127 
128  secs = current->tv_sec - last->tv_sec;
129  diff = 1000000 * secs + current->tv_usec - last->tv_usec;
130  return (lirc_t)(diff < gap ? gap - diff : 0);
131 }
132 
133 
134 static int match_ir_code(struct ir_remote* remote, ir_code a, ir_code b)
135 {
136  return (remote->ignore_mask | a) == (remote->ignore_mask | b)
137  || (remote->ignore_mask | a) ==
138  (remote->ignore_mask | (b ^ remote->toggle_bit_mask));
139 }
140 
141 
148 void get_frequency_range(const struct ir_remote* remotes,
149  unsigned int* min_freq,
150  unsigned int* max_freq)
151 {
152  const struct ir_remote* scan;
153 
154  /* use remotes carefully, it may be changed on SIGHUP */
155  scan = remotes;
156  if (scan == NULL) {
157  *min_freq = 0;
158  *max_freq = 0;
159  } else {
160  *min_freq = scan->freq;
161  *max_freq = scan->freq;
162  scan = scan->next;
163  }
164  while (scan) {
165  if (scan->freq != 0) {
166  if (scan->freq > *max_freq)
167  *max_freq = scan->freq;
168  else if (scan->freq < *min_freq)
169  *min_freq = scan->freq;
170  }
171  scan = scan->next;
172  }
173 }
174 
175 
185 void get_filter_parameters(const struct ir_remote* remotes,
186  lirc_t* max_gap_lengthp,
187  lirc_t* min_pulse_lengthp,
188  lirc_t* min_space_lengthp,
189  lirc_t* max_pulse_lengthp,
190  lirc_t* max_space_lengthp)
191 {
192  const struct ir_remote* scan = remotes;
193  lirc_t max_gap_length = 0;
194  lirc_t min_pulse_length = 0, min_space_length = 0;
195  lirc_t max_pulse_length = 0, max_space_length = 0;
196 
197  while (scan) {
198  lirc_t val;
199 
200  val = upper_limit(scan, scan->max_gap_length);
201  if (val > max_gap_length)
202  max_gap_length = val;
203  val = lower_limit(scan, scan->min_pulse_length);
204  if (min_pulse_length == 0 || val < min_pulse_length)
205  min_pulse_length = val;
206  val = lower_limit(scan, scan->min_space_length);
207  if (min_space_length == 0 || val > min_space_length)
208  min_space_length = val;
209  val = upper_limit(scan, scan->max_pulse_length);
210  if (val > max_pulse_length)
211  max_pulse_length = val;
212  val = upper_limit(scan, scan->max_space_length);
213  if (val > max_space_length)
214  max_space_length = val;
215  scan = scan->next;
216  }
217  *max_gap_lengthp = max_gap_length;
218  *min_pulse_lengthp = min_pulse_length;
219  *min_space_lengthp = min_space_length;
220  *max_pulse_lengthp = max_pulse_length;
221  *max_space_lengthp = max_space_length;
222 }
223 
224 
231 const struct ir_remote* is_in_remotes(const struct ir_remote* remotes,
232  const struct ir_remote* remote)
233 {
234  while (remotes != NULL) {
235  if (remotes == remote)
236  return remote;
237  remotes = remotes->next;
238  }
239  return NULL;
240 }
241 
242 
243 struct ir_remote* get_ir_remote(const struct ir_remote* remotes,
244  const char* name)
245 {
246  const struct ir_remote* all;
247 
248  /* use remotes carefully, it may be changed on SIGHUP */
249  all = remotes;
250  if (strcmp(name, "lirc") == 0)
251  return &lirc_internal_remote;
252  while (all) {
253  if (strcasecmp(all->name, name) == 0)
254  return (struct ir_remote*)all;
255  all = all->next;
256  }
257  return NULL;
258 }
259 
260 
275 int map_code(const struct ir_remote* remote,
276  struct decode_ctx_t* ctx,
277  int pre_bits,
278  ir_code pre,
279  int bits,
280  ir_code code,
281  int post_bits,
282  ir_code post)
283 
284 {
285  ir_code all;
286 
287  if (pre_bits + bits + post_bits != remote->pre_data_bits +
288  remote->bits + remote->post_data_bits)
289  return 0;
290  all = (pre & gen_mask(pre_bits));
291  all <<= bits;
292  all |= (code & gen_mask(bits));
293  all <<= post_bits;
294  all |= (post & gen_mask(post_bits));
295 
296  ctx->post = (all & gen_mask(remote->post_data_bits));
297  all >>= remote->post_data_bits;
298  ctx->code = (all & gen_mask(remote->bits));
299  all >>= remote->bits;
300  ctx->pre = (all & gen_mask(remote->pre_data_bits));
301 
302  LOGPRINTF(1, "pre: %llx", (__u64)(ctx->pre));
303  LOGPRINTF(1, "code: %llx", (__u64)(ctx->code));
304  LOGPRINTF(1, "post: %llx", (__u64)(ctx->post));
305  LOGPRINTF(1, "code: %016llx\n", code);
306 
307  return 1;
308 }
309 
310 
321 void map_gap(const struct ir_remote* remote,
322  struct decode_ctx_t* ctx,
323  const struct timeval* start,
324  const struct timeval* last,
325  lirc_t signal_length)
326 {
327  // Time gap (us) between a keypress on the remote control and
328  // the next one.
329  lirc_t gap;
330 
331  // Check the time gap between the last keypress and this one.
332  if (start->tv_sec - last->tv_sec >= 2) {
333  // Gap of 2 or more seconds: this is not a repeated keypress.
334  ctx->repeat_flag = 0;
335  gap = 0;
336  } else {
337  // Calculate the time gap in microseconds.
338  gap = time_elapsed(last, start);
339  if (expect_at_most(remote, gap, remote->max_remaining_gap)) {
340  // The gap is shorter than a standard gap
341  // (with relative or aboslute tolerance): this
342  // is a repeated keypress.
343  ctx->repeat_flag = 1;
344  } else {
345  // Standard gap: this is a new keypress.
346  ctx->repeat_flag = 0;
347  }
348  }
349 
350  // Calculate extimated time gap remaining for the next code.
351  if (is_const(remote)) {
352  // The sum (signal_length + gap) is always constant
353  // so the gap is shorter when the code is longer.
354  if (min_gap(remote) > signal_length) {
355  ctx->min_remaining_gap = min_gap(remote) -
356  signal_length;
357  ctx->max_remaining_gap = max_gap(remote) -
358  signal_length;
359  } else {
360  ctx->min_remaining_gap = 0;
361  if (max_gap(remote) > signal_length)
362  ctx->max_remaining_gap = max_gap(remote) -
363  signal_length;
364  else
365  ctx->max_remaining_gap = 0;
366  }
367  } else {
368  // The gap after the signal is always constant.
369  // This is the case of Kanam Accent serial remote.
370  ctx->min_remaining_gap = min_gap(remote);
371  ctx->max_remaining_gap = max_gap(remote);
372  }
373 
374  LOGPRINTF(1, "repeat_flagp: %d", (ctx->repeat_flag));
375  LOGPRINTF(1, "is_const(remote): %d", is_const(remote));
376  LOGPRINTF(1, "remote->gap range: %lu %lu", (__u32)min_gap(
377  remote), (__u32)max_gap(remote));
378  LOGPRINTF(1, "remote->remaining_gap: %lu %lu",
379  (__u32)remote->min_remaining_gap,
380  (__u32)remote->max_remaining_gap);
381  LOGPRINTF(1, "signal length: %lu", (__u32)signal_length);
382  LOGPRINTF(1, "gap: %lu", (__u32)gap);
383  LOGPRINTF(1, "extim. remaining_gap: %lu %lu",
384  (__u32)(ctx->min_remaining_gap),
385  (__u32)(ctx->max_remaining_gap));
386 }
387 
388 
389 struct ir_ncode* get_code_by_name(const struct ir_remote* remote,
390  const char* name)
391 {
392  const struct ir_ncode* all;
393 
394  all = remote->codes;
395  if (all == NULL)
396  return NULL;
397  if (strcmp(remote->name, "lirc") == 0)
398  return strcmp(name, "__EOF") == 0 ? &NCODE_EOF : 0;
399  while (all->name != NULL) {
400  if (strcasecmp(all->name, name) == 0)
401  return (struct ir_ncode*)all;
402  all++;
403  }
404  return 0;
405 }
406 
407 
408 /* find longest matching sequence */
409 void find_longest_match(struct ir_remote* remote,
410  struct ir_ncode* codes,
411  ir_code all,
412  ir_code* next_all,
413  int have_code,
414  struct ir_ncode** found,
415  int* found_code)
416 {
417  struct ir_code_node* search;
418  struct ir_code_node* prev;
419  struct ir_code_node* next;
420  int flag = 1;
421  int sequence_match = 0;
422 
423  search = codes->next;
424  if (search == NULL
425  || (codes->next != NULL && codes->current == NULL)) {
426  codes->current = NULL;
427  return;
428  }
429  while (search != codes->current->next) {
430  prev = NULL; /* means codes->code */
431  next = search;
432  while (next != codes->current) {
433  if (get_ir_code(codes, prev)
434  != get_ir_code(codes, next)) {
435  flag = 0;
436  break;
437  }
438  prev = get_next_ir_code_node(codes, prev);
439  next = get_next_ir_code_node(codes, next);
440  }
441  if (flag == 1) {
442  *next_all = gen_ir_code(remote,
443  remote->pre_data,
444  get_ir_code(codes, prev),
445  remote->post_data);
446  if (match_ir_code(remote, *next_all, all)) {
447  codes->current =
448  get_next_ir_code_node(codes, prev);
449  sequence_match = 1;
450  *found_code = 1;
451  if (!have_code)
452  *found = codes;
453  break;
454  }
455  }
456  search = search->next;
457  }
458  if (!sequence_match)
459  codes->current = NULL;
460 }
461 
462 
463 static struct ir_ncode* get_code(struct ir_remote* remote,
464  ir_code pre,
465  ir_code code,
466  ir_code post,
467  int* repeat_flag,
468  ir_code* toggle_bit_mask_statep)
469 {
470  ir_code pre_mask, code_mask, post_mask, toggle_bit_mask_state, all;
471  int found_code, have_code;
472  struct ir_ncode* codes;
473  struct ir_ncode* found;
474 
475  pre_mask = code_mask = post_mask = 0;
476 
477  if (has_toggle_bit_mask(remote)) {
478  pre_mask = remote->toggle_bit_mask >>
479  (remote->bits + remote->post_data_bits);
480  post_mask = remote->toggle_bit_mask & gen_mask(
481  remote->post_data_bits);
482  }
483  if (has_ignore_mask(remote)) {
484  pre_mask |= remote->ignore_mask >>
485  (remote->bits + remote->post_data_bits);
486  post_mask |= remote->ignore_mask & gen_mask(
487  remote->post_data_bits);
488  }
489  if (has_toggle_mask(remote) && remote->toggle_mask_state % 2) {
490  ir_code* affected;
491  ir_code mask;
492  ir_code mask_bit;
493  int bit, current_bit;
494 
495  affected = &post;
496  mask = remote->toggle_mask;
497  for (bit = current_bit = 0; bit < bit_count(remote);
498  bit++, current_bit++) {
499  if (bit == remote->post_data_bits) {
500  affected = &code;
501  current_bit = 0;
502  }
503  if (bit == remote->post_data_bits + remote->bits) {
504  affected = &pre;
505  current_bit = 0;
506  }
507  mask_bit = mask & 1;
508  (*affected) ^= (mask_bit << current_bit);
509  mask >>= 1;
510  }
511  }
512  if (has_pre(remote)) {
513  if ((pre | pre_mask) != (remote->pre_data | pre_mask)) {
514  LOGPRINTF(1, "bad pre data");
515  LOGPRINTF(2, "%llx %llx", pre, remote->pre_data);
516  return 0;
517  }
518  LOGPRINTF(1, "pre");
519  }
520 
521  if (has_post(remote)) {
522  if ((post | post_mask) != (remote->post_data | post_mask)) {
523  LOGPRINTF(1, "bad post data");
524  LOGPRINTF(2, "%llx %llx", post, remote->post_data);
525  return 0;
526  }
527  LOGPRINTF(1, "post");
528  }
529 
530  all = gen_ir_code(remote, pre, code, post);
531 
532  if (*repeat_flag && has_repeat_mask(remote))
533  all ^= remote->repeat_mask;
534 
535  toggle_bit_mask_state = all & remote->toggle_bit_mask;
536 
537  found = NULL;
538  found_code = 0;
539  have_code = 0;
540  codes = remote->codes;
541  if (codes != NULL) {
542  while (codes->name != NULL) {
543  ir_code next_all;
544 
545  next_all = gen_ir_code(remote,
546  remote->pre_data,
547  get_ir_code(codes,
548  codes->current),
549  remote->post_data);
550  if (match_ir_code(remote, next_all, all) ||
551  (*repeat_flag &&
552  has_repeat_mask(remote) &&
553  match_ir_code(remote,
554  next_all,
555  all ^ remote->repeat_mask))) {
556  found_code = 1;
557  if (codes->next != NULL) {
558  if (codes->current == NULL)
559  codes->current = codes->next;
560  else
561  codes->current =
562  codes->current->next;
563  }
564  if (!have_code) {
565  found = codes;
566  if (codes->current == NULL)
567  have_code = 1;
568  }
569  } else {
570  find_longest_match(remote,
571  codes,
572  all,
573  &next_all,
574  have_code,
575  &found,
576  &found_code);
577  }
578  codes++;
579  }
580  }
581  if (!found_code && dyncodes) {
582  if (remote->dyncodes[remote->dyncode].code != code) {
583  remote->dyncode++;
584  remote->dyncode %= 2;
585  }
586  remote->dyncodes[remote->dyncode].code = code;
587  found = &(remote->dyncodes[remote->dyncode]);
588  found_code = 1;
589  }
590  if (found_code && found != NULL && has_toggle_mask(remote)) {
591  if (!(remote->toggle_mask_state % 2)) {
592  remote->toggle_code = found;
593  LOGPRINTF(1, "toggle_mask_start");
594  } else {
595  if (found != remote->toggle_code) {
596  remote->toggle_code = NULL;
597  return NULL;
598  }
599  remote->toggle_code = NULL;
600  }
601  }
602  *toggle_bit_mask_statep = toggle_bit_mask_state;
603  return found;
604 }
605 
606 
607 static __u64 set_code(struct ir_remote* remote,
608  struct ir_ncode* found,
609  ir_code toggle_bit_mask_state,
610  struct decode_ctx_t* ctx)
611 {
612  struct timeval current;
613  static struct ir_remote* last_decoded = NULL;
614 
615  LOGPRINTF(1, "found: %s", found->name);
616 
617  gettimeofday(&current, NULL);
618  LOGPRINTF(1, "%lx %lx %lx %d %d %d %d %d %d %d",
619  remote, last_remote, last_decoded,
620  remote == last_decoded,
621  found == remote->last_code, found->next != NULL,
622  found->current != NULL, ctx->repeat_flag,
623  time_elapsed(&remote->last_send,
624  &current) < 1000000,
625  (!has_toggle_bit_mask(remote)
626  ||
627  toggle_bit_mask_state ==
628  remote
629  ->toggle_bit_mask_state));
630  if (remote->release_detected) {
631  remote->release_detected = 0;
632  if (ctx->repeat_flag)
633  LOGPRINTF(0,
634  "repeat indicated although release was detected before");
635 
636  ctx->repeat_flag = 0;
637  }
638  if (remote == last_decoded &&
639  (found == remote->last_code
640  || (found->next != NULL && found->current != NULL))
641  && ctx->repeat_flag
642  && time_elapsed(&remote->last_send, &current) < 1000000
643  && (!has_toggle_bit_mask(remote)
644  || toggle_bit_mask_state == remote->toggle_bit_mask_state)) {
645  if (has_toggle_mask(remote)) {
646  remote->toggle_mask_state++;
647  if (remote->toggle_mask_state == 4) {
648  remote->reps++;
649  remote->toggle_mask_state = 2;
650  }
651  } else if (found->current == NULL) {
652  remote->reps++;
653  }
654  } else {
655  if (found->next != NULL && found->current == NULL)
656  remote->reps = 1;
657  else
658  remote->reps = 0;
659  if (has_toggle_mask(remote)) {
660  remote->toggle_mask_state = 1;
661  remote->toggle_code = found;
662  }
663  if (has_toggle_bit_mask(remote))
664  remote->toggle_bit_mask_state = toggle_bit_mask_state;
665  }
666  last_remote = remote;
667  last_decoded = remote;
668  if (found->current == NULL)
669  remote->last_code = found;
670  remote->last_send = current;
671  remote->min_remaining_gap = ctx->min_remaining_gap;
672  remote->max_remaining_gap = ctx->max_remaining_gap;
673 
674  ctx->code = 0;
675  if (has_pre(remote)) {
676  ctx->code |= remote->pre_data;
677  ctx->code = ctx->code << remote->bits;
678  }
679  ctx->code |= found->code;
680  if (has_post(remote)) {
681  ctx->code = ctx->code << remote->post_data_bits;
682  ctx->code |= remote->post_data;
683  }
684  if (remote->flags & COMPAT_REVERSE)
685  /* actually this is wrong: pre, code and post should
686  * be rotated separately but we have to stay
687  * compatible with older software
688  */
689  ctx->code = reverse(ctx->code, bit_count(remote));
690  return ctx->code;
691 }
692 
693 
705 int write_message(char* buffer,
706  size_t size,
707  const char* remote_name,
708  const char* button_name,
709  const char* button_suffix,
710  ir_code code,
711  int reps)
712 
713 {
714  int len;
715 
716  len = snprintf(buffer, size, "%016llx %02x %s%s %s\n",
717  (unsigned long long)code, reps, button_name,
718  button_suffix, remote_name);
719 
720  return len;
721 }
722 
723 
724 char* decode_all(struct ir_remote* remotes)
725 {
726  struct ir_remote* remote;
727  static char message[PACKET_SIZE + 1];
728  struct ir_ncode* ncode;
729  ir_code toggle_bit_mask_state;
730  struct ir_remote* scan;
731  struct ir_ncode* scan_ncode;
732  struct decode_ctx_t ctx;
733 
734  /* use remotes carefully, it may be changed on SIGHUP */
735  decoding = remote = remotes;
736  while (remote) {
737  LOGPRINTF(1, "trying \"%s\" remote", remote->name);
738  if (curr_driver->decode_func(remote, &ctx)) {
739  ncode = get_code(remote,
740  ctx.pre, ctx.code, ctx.post,
741  &ctx.repeat_flag,
742  &toggle_bit_mask_state);
743  if (ncode) {
744  int len;
745  int reps;
746 
747  if (ncode == &NCODE_EOF) {
748  logprintf(LIRC_DEBUG,
749  "decode all: returning EOF");
750  strncpy(message,
751  PACKET_EOF, sizeof(message));
752  return message;
753  }
754  ctx.code = set_code(remote,
755  ncode,
756  toggle_bit_mask_state,
757  &ctx);
758  if ((has_toggle_mask(remote)
759  && remote->toggle_mask_state % 2)
760  || ncode->current != NULL) {
761  decoding = NULL;
762  return NULL;
763  }
764 
765  for (scan = decoding;
766  scan != NULL;
767  scan = scan->next)
768  for (scan_ncode = scan->codes;
769  scan_ncode->name != NULL;
770  scan_ncode++)
771  scan_ncode->current = NULL;
772  if (is_xmp(remote))
773  remote->last_code->current =
774  remote->last_code->next;
775  reps = remote->reps - (ncode->next ? 1 : 0);
776  if (reps > 0) {
777  if (reps <= remote->suppress_repeat) {
778  decoding = NULL;
779  return NULL;
780  }
781  reps -= remote->suppress_repeat;
782  }
783  register_button_press(remote,
784  remote->last_code,
785  ctx.code,
786  reps);
787  len = write_message(message, PACKET_SIZE + 1,
788  remote->name,
789  remote->last_code->name,
790  "",
791  ctx.code,
792  reps);
793  decoding = NULL;
794  if (len >= PACKET_SIZE + 1) {
795  logprintf(LIRC_ERROR,
796  "message buffer overflow");
797  return NULL;
798  } else {
799  return message;
800  }
801  } else {
802  LOGPRINTF(1, "failed \"%s\" remote",
803  remote->name);
804  }
805  }
806  remote->toggle_mask_state = 0;
807  remote = remote->next;
808  }
809  decoding = NULL;
810  last_remote = NULL;
811  LOGPRINTF(1, "decoding failed for all remotes");
812  return NULL;
813 }
814 
815 
816 int send_ir_ncode(struct ir_remote* remote, struct ir_ncode* code, int delay)
817 {
818  int ret;
819 
820  if (delay) {
821  /* insert pause when needed: */
822  if (remote->last_code != NULL) {
823  struct timeval current;
824  unsigned long usecs;
825 
826  gettimeofday(&current, NULL);
827  usecs = time_left(&current,
828  &remote->last_send,
829  remote->min_remaining_gap * 2);
830  if (usecs > 0) {
831  if (repeat_remote == NULL || remote !=
832  repeat_remote
833  || remote->last_code != code)
834  usleep(usecs);
835  }
836  }
837  }
838  ret = curr_driver->send_func(remote, code);
839 
840  if (ret) {
841  gettimeofday(&remote->last_send, NULL);
842  remote->last_code = code;
843  }
844  return ret;
845 }
846 
847 const struct ir_remote* get_decoding(void)
848 {
849  return (const struct ir_remote*)&decoding;
850 }
lirc_t min_remaining_gap
struct ir_remote * last_remote
Definition: ir_remote.c:51
struct ir_ncode * repeat_code
Definition: ir_remote.c:55
int(*const send_func)(struct ir_remote *remote, struct ir_ncode *code)
Definition: driver.h:139
unsigned int freq
lirc_t max_gap_length
void ir_remote_init(int use_dyncodes)
Definition: ir_remote.c:116
ir_code post_data
ir_code repeat_mask
struct ir_ncode * toggle_code
void get_filter_parameters(const struct ir_remote *remotes, lirc_t *max_gap_lengthp, lirc_t *min_pulse_lengthp, lirc_t *min_space_lengthp, lirc_t *max_pulse_lengthp, lirc_t *max_space_lengthp)
Definition: ir_remote.c:185
struct ir_code_node * next
const char * name
lirc_t * signals
struct ir_ncode * get_code_by_name(const struct ir_remote *remote, const char *name)
Definition: ir_remote.c:389
#define COMPAT_REVERSE
struct ir_ncode * last_code
struct ir_remote * get_ir_remote(const struct ir_remote *remotes, const char *name)
Definition: ir_remote.c:243
#define LIRC_EOF
Definition: lirc_config.h:104
__u64 ir_code
int map_code(const struct ir_remote *remote, struct decode_ctx_t *ctx, int pre_bits, ir_code pre, int bits, ir_code code, int post_bits, ir_code post)
Definition: ir_remote.c:275
char * decode_all(struct ir_remote *remotes)
Definition: ir_remote.c:724
#define PACKET_SIZE
Definition: lirc_config.h:98
char * name
struct timeval last_send
struct ir_code_node * current
ir_code toggle_mask
ir_code pre_data
int write_message(char *buffer, size_t size, const char *remote_name, const char *button_name, const char *button_suffix, ir_code code, int reps)
Definition: ir_remote.c:705
const struct ir_remote * is_in_remotes(const struct ir_remote *remotes, const struct ir_remote *remote)
Definition: ir_remote.c:231
lirc_t max_remaining_gap
const struct ir_remote * get_decoding(void)
Definition: ir_remote.c:847
#define LOGPRINTF(level, fmt, args...)
Definition: lirc_log.h:75
void ncode_free(struct ir_ncode *ncode)
Definition: ir_remote.c:96
void map_gap(const struct ir_remote *remote, struct decode_ctx_t *ctx, const struct timeval *start, const struct timeval *last, lirc_t signal_length)
Definition: ir_remote.c:321
int release_detected
lirc_t min_remaining_gap
struct ir_ncode * ncode_dup(struct ir_ncode *ncode)
Definition: ir_remote.c:61
lirc_t max_remaining_gap
void get_frequency_range(const struct ir_remote *remotes, unsigned int *min_freq, unsigned int *max_freq)
Definition: ir_remote.c:148
ir_code code
int(*const decode_func)(struct ir_remote *remote, struct decode_ctx_t *ctx)
Definition: driver.h:153
const struct driver const * curr_driver
Definition: driver.c:26
struct ir_ncode dyncodes[2]
struct ir_remote * repeat_remote
Definition: ir_remote.c:53
ir_code toggle_bit_mask
int send_ir_ncode(struct ir_remote *remote, struct ir_ncode *code, int delay)
Definition: ir_remote.c:816
ir_code ignore_mask