File: input_map.c

package info (click to toggle)
lirc 0.9.0~pre1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,844 kB
  • sloc: ansic: 44,120; sh: 11,159; makefile: 430; python: 108; perl: 106
file content (55 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (2)
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
/*      $Id: input_map.c,v 5.1 2008/10/26 15:10:17 lirc Exp $      */

/****************************************************************************
 ** input_map.c *************************************************************
 ****************************************************************************
 *
 * input_map.c - button namespace derived from Linux input layer
 *
 * Copyright (C) 2008 Christoph Bartelmus <lirc@bartelmus.de>
 *
 */

#include <stdlib.h>
#include <string.h>

#include "input_map.h"

struct {
	char *name;
	linux_input_code code;

} input_map[] = {
#include "input_map.inc"
	{
	NULL, 0}
};

int get_input_code(const char *name, linux_input_code * code)
{
	int i;

	for (i = 0; input_map[i].name != NULL; i++) {
		if (strcasecmp(name, input_map[i].name) == 0) {
			*code = input_map[i].code;
			return i;
		}
	}
	return -1;
}

void fprint_namespace(FILE * f)
{
	int i;

	for (i = 0; input_map[i].name != NULL; i++) {
		fprintf(stdout, "%s\n", input_map[i].name);
	}
}

int is_in_namespace(const char *name)
{
	linux_input_code dummy;

	return get_input_code(name, &dummy) == -1 ? 0 : 1;
}