2021-08-17 23:34:55 +02:00
|
|
|
#!/usr/bin/env python3
|
2015-03-26 00:40:13 +01:00
|
|
|
#
|
|
|
|
# Copyright (C) 2015 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an 'AS IS' BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
# pylint: disable=bad-indentation,bad-continuation
|
|
|
|
|
2021-08-17 23:34:55 +02:00
|
|
|
|
2015-03-26 00:40:13 +01:00
|
|
|
import os
|
|
|
|
import re
|
2016-02-08 23:09:10 +01:00
|
|
|
import sys
|
2015-03-26 00:40:13 +01:00
|
|
|
|
|
|
|
input_prop_list = []
|
|
|
|
ev_list = []
|
|
|
|
syn_list = []
|
|
|
|
key_list = []
|
|
|
|
rel_list = []
|
|
|
|
abs_list = []
|
|
|
|
sw_list = []
|
|
|
|
msc_list = []
|
|
|
|
led_list = []
|
|
|
|
rep_list = []
|
|
|
|
snd_list = []
|
|
|
|
mt_tool_list = []
|
|
|
|
ff_status_list = []
|
|
|
|
ff_list = []
|
|
|
|
|
|
|
|
r = re.compile(r'#define\s+(\S+)\s+((?:0x)?\d+)')
|
|
|
|
|
2016-06-29 23:12:29 +02:00
|
|
|
for arg in sys.argv[1:]:
|
|
|
|
with open(arg, 'r') as f:
|
|
|
|
for line in f:
|
|
|
|
m = r.match(line)
|
|
|
|
if m:
|
|
|
|
name = m.group(1)
|
|
|
|
if name.startswith("INPUT_PROP_"):
|
|
|
|
input_prop_list.append(name)
|
|
|
|
elif name.startswith("EV_"):
|
|
|
|
ev_list.append(name)
|
|
|
|
elif name.startswith("SYN_"):
|
|
|
|
syn_list.append(name)
|
|
|
|
elif name.startswith("KEY_") or name.startswith("BTN_"):
|
|
|
|
key_list.append(name)
|
|
|
|
elif name.startswith("REL_"):
|
|
|
|
rel_list.append(name)
|
|
|
|
elif name.startswith("ABS_"):
|
|
|
|
abs_list.append(name)
|
|
|
|
elif name.startswith("SW_"):
|
|
|
|
sw_list.append(name)
|
|
|
|
elif name.startswith("MSC_"):
|
|
|
|
msc_list.append(name)
|
|
|
|
elif name.startswith("LED_"):
|
|
|
|
led_list.append(name)
|
|
|
|
elif name.startswith("REP_"):
|
|
|
|
rep_list.append(name)
|
|
|
|
elif name.startswith("SND_"):
|
|
|
|
snd_list.append(name)
|
|
|
|
elif name.startswith("MT_TOOL_"):
|
|
|
|
mt_tool_list.append(name)
|
|
|
|
elif name.startswith("FF_STATUS_"):
|
|
|
|
ff_status_list.append(name)
|
|
|
|
elif name.startswith("FF_"):
|
|
|
|
ff_list.append(name)
|
2015-03-26 00:40:13 +01:00
|
|
|
|
|
|
|
def Dump(struct_name, values):
|
2016-02-23 20:54:35 +01:00
|
|
|
print('static struct label %s[] = {' % (struct_name))
|
2015-03-26 00:40:13 +01:00
|
|
|
for value in values:
|
2016-02-23 20:54:35 +01:00
|
|
|
print(' LABEL(%s),' % (value))
|
|
|
|
print(' LABEL_END,')
|
|
|
|
print('};')
|
2015-03-26 00:40:13 +01:00
|
|
|
|
|
|
|
Dump("input_prop_labels", input_prop_list)
|
|
|
|
Dump("ev_labels", ev_list)
|
|
|
|
Dump("syn_labels", syn_list)
|
|
|
|
Dump("key_labels", key_list)
|
|
|
|
Dump("rel_labels", rel_list)
|
|
|
|
Dump("abs_labels", abs_list)
|
|
|
|
Dump("sw_labels", sw_list)
|
|
|
|
Dump("msc_labels", msc_list)
|
|
|
|
Dump("led_labels", led_list)
|
|
|
|
Dump("rep_labels", rep_list)
|
|
|
|
Dump("snd_labels", snd_list)
|
|
|
|
Dump("mt_tool_labels", mt_tool_list)
|
|
|
|
Dump("ff_status_labels", ff_status_list)
|
|
|
|
Dump("ff_labels", ff_list)
|