LIRC libraries
LinuxInfraredRemoteControl
input_map.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** input_map.c *************************************************************
3 ****************************************************************************
4 *
5 * input_map.c - button namespace derived from Linux input layer
6 *
7 * Copyright (C) 2008 Christoph Bartelmus <lirc@bartelmus.de>
8 *
9 */
10 
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 
21 #ifdef __linux__
22 #include "lirc/input_map.h"
23 #else
24 typedef unsigned short linux_input_code;
25 #endif
26 
27 struct {
28  char* name;
29  linux_input_code code;
30 } input_map[] = {
31 #include "lirc/input_map.inc"
32  {
33  NULL, 0
34  }
35 };
36 
37 int get_input_code(const char* name, linux_input_code* code)
38 {
39  int i;
40 
41  for (i = 0; input_map[i].name != NULL; i++) {
42  if (strcasecmp(name, input_map[i].name) == 0) {
43  *code = input_map[i].code;
44  return i;
45  }
46  }
47  return -1;
48 }
49 
50 void fprint_namespace(FILE* f)
51 {
52  int i;
53 
54  for (i = 0; input_map[i].name != NULL; i++)
55  fprintf(stdout, "%s\n", input_map[i].name);
56 }
57 
58 int is_in_namespace(const char* name)
59 {
60  linux_input_code dummy;
61 
62  return get_input_code(name, &dummy) == -1 ? 0 : 1;
63 }
char * name
Name of command.
ir_code code
The first code of the command.