• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#
3# Copyright (C) 2015 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the 'License');
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an 'AS IS' BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# pylint: disable=bad-indentation,bad-continuation
18
19from __future__ import print_function
20import os
21import re
22import sys
23
24input_prop_list = []
25ev_list = []
26syn_list = []
27key_list = []
28rel_list = []
29abs_list = []
30sw_list = []
31msc_list = []
32led_list = []
33rep_list = []
34snd_list = []
35mt_tool_list = []
36ff_status_list = []
37ff_list = []
38
39r = re.compile(r'#define\s+(\S+)\s+((?:0x)?\d+)')
40
41with open(sys.argv[1], 'r') as f:
42  for line in f:
43    m = r.match(line)
44    if m:
45      name = m.group(1)
46      if name.startswith("INPUT_PROP_"):
47        input_prop_list.append(name)
48      elif name.startswith("EV_"):
49        ev_list.append(name)
50      elif name.startswith("SYN_"):
51        syn_list.append(name)
52      elif name.startswith("KEY_") or name.startswith("BTN_"):
53        key_list.append(name)
54      elif name.startswith("REL_"):
55        rel_list.append(name)
56      elif name.startswith("ABS_"):
57        abs_list.append(name)
58      elif name.startswith("SW_"):
59        sw_list.append(name)
60      elif name.startswith("MSC_"):
61        msc_list.append(name)
62      elif name.startswith("LED_"):
63        led_list.append(name)
64      elif name.startswith("REP_"):
65        rep_list.append(name)
66      elif name.startswith("SND_"):
67        snd_list.append(name)
68      elif name.startswith("MT_TOOL_"):
69        mt_tool_list.append(name)
70      elif name.startswith("FF_STATUS_"):
71        ff_status_list.append(name)
72      elif name.startswith("FF_"):
73        ff_list.append(name)
74
75def Dump(struct_name, values):
76  print('static struct label %s[] = {' % (struct_name))
77  for value in values:
78    print('    LABEL(%s),' % (value))
79  print('    LABEL_END,')
80  print('};')
81
82Dump("input_prop_labels", input_prop_list)
83Dump("ev_labels", ev_list)
84Dump("syn_labels", syn_list)
85Dump("key_labels", key_list)
86Dump("rel_labels", rel_list)
87Dump("abs_labels", abs_list)
88Dump("sw_labels", sw_list)
89Dump("msc_labels", msc_list)
90Dump("led_labels", led_list)
91Dump("rep_labels", rep_list)
92Dump("snd_labels", snd_list)
93Dump("mt_tool_labels", mt_tool_list)
94Dump("ff_status_labels", ff_status_list)
95Dump("ff_labels", ff_list)
96