| Elliott Hughes | c7f3c5c | 2015-03-25 16:40:13 -0700 | [diff] [blame] | 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 |  | 
|  | 19 | import os | 
|  | 20 | import re | 
|  | 21 |  | 
|  | 22 | input_prop_list = [] | 
|  | 23 | ev_list = [] | 
|  | 24 | syn_list = [] | 
|  | 25 | key_list = [] | 
|  | 26 | rel_list = [] | 
|  | 27 | abs_list = [] | 
|  | 28 | sw_list = [] | 
|  | 29 | msc_list = [] | 
|  | 30 | led_list = [] | 
|  | 31 | rep_list = [] | 
|  | 32 | snd_list = [] | 
|  | 33 | mt_tool_list = [] | 
|  | 34 | ff_status_list = [] | 
|  | 35 | ff_list = [] | 
|  | 36 |  | 
|  | 37 | r = re.compile(r'#define\s+(\S+)\s+((?:0x)?\d+)') | 
|  | 38 |  | 
| Elliott Hughes | 608fb70 | 2015-03-25 21:18:43 -0700 | [diff] [blame] | 39 | with open('bionic/libc/kernel/uapi/linux/input.h', 'r') as f: | 
| Elliott Hughes | c7f3c5c | 2015-03-25 16:40:13 -0700 | [diff] [blame] | 40 | for line in f: | 
|  | 41 | m = r.match(line) | 
|  | 42 | if m: | 
|  | 43 | name = m.group(1) | 
|  | 44 | if name.startswith("INPUT_PROP_"): | 
|  | 45 | input_prop_list.append(name) | 
|  | 46 | elif name.startswith("EV_"): | 
|  | 47 | ev_list.append(name) | 
|  | 48 | elif name.startswith("SYN_"): | 
|  | 49 | syn_list.append(name) | 
|  | 50 | elif name.startswith("KEY_") or name.startswith("BTN_"): | 
|  | 51 | key_list.append(name) | 
|  | 52 | elif name.startswith("REL_"): | 
|  | 53 | rel_list.append(name) | 
|  | 54 | elif name.startswith("ABS_"): | 
|  | 55 | abs_list.append(name) | 
|  | 56 | elif name.startswith("SW_"): | 
|  | 57 | sw_list.append(name) | 
|  | 58 | elif name.startswith("MSC_"): | 
|  | 59 | msc_list.append(name) | 
|  | 60 | elif name.startswith("LED_"): | 
|  | 61 | led_list.append(name) | 
|  | 62 | elif name.startswith("REP_"): | 
|  | 63 | rep_list.append(name) | 
|  | 64 | elif name.startswith("SND_"): | 
|  | 65 | snd_list.append(name) | 
|  | 66 | elif name.startswith("MT_TOOL_"): | 
|  | 67 | mt_tool_list.append(name) | 
|  | 68 | elif name.startswith("FF_STATUS_"): | 
|  | 69 | ff_status_list.append(name) | 
|  | 70 | elif name.startswith("FF_"): | 
|  | 71 | ff_list.append(name) | 
|  | 72 |  | 
|  | 73 | def Dump(struct_name, values): | 
|  | 74 | print 'static struct label %s[] = {' % (struct_name) | 
|  | 75 | for value in values: | 
|  | 76 | print '    LABEL(%s),' % (value) | 
|  | 77 | print '    LABEL_END,' | 
|  | 78 | print '};' | 
|  | 79 |  | 
|  | 80 | Dump("input_prop_labels", input_prop_list) | 
|  | 81 | Dump("ev_labels", ev_list) | 
|  | 82 | Dump("syn_labels", syn_list) | 
|  | 83 | Dump("key_labels", key_list) | 
|  | 84 | Dump("rel_labels", rel_list) | 
|  | 85 | Dump("abs_labels", abs_list) | 
|  | 86 | Dump("sw_labels", sw_list) | 
|  | 87 | Dump("msc_labels", msc_list) | 
|  | 88 | Dump("led_labels", led_list) | 
|  | 89 | Dump("rep_labels", rep_list) | 
|  | 90 | Dump("snd_labels", snd_list) | 
|  | 91 | Dump("mt_tool_labels", mt_tool_list) | 
|  | 92 | Dump("ff_status_labels", ff_status_list) | 
|  | 93 | Dump("ff_labels", ff_list) |