summaryrefslogtreecommitdiff
path: root/make_keycodes.sh
blob: d76d99fd1dbf2e805644bcef05339bd5ef48fefa (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh

if [ "$TZ_SYS_RO_SHARE" = "" ]; then
	TZ_SYS_RO_SHARE="/usr/share"
fi

KEYCODES_PATH="./keycodes/"
DEFAULT_KEYCODES_NAME="evdev"
NEW_KEYCODES_NAME="tizen"
FULL_KEY_LIST="\/\/ For Tizen Keycodes"
CHANGE_STRING="\/\/ @For Tizen Keycodes@"
PLATFORM_BASE_KEYCODE=8
RULE_FILE=${RULE_FILE_PATH}

function generate_light_keycodes(){
	echo "default xkb_keycodes \"evdev\" {" > ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "	minimum = 8;" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "	maximum = 255;" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "	// @For Tizen Keycodes@" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "};" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "xkb_keycodes "pc98" {" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "    include \"evdev(evdev)\"" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
	echo "};" >> ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
}

if [ -e ${KEYMAP_FILE_PATH} ]
then
	echo "We have a key layout file: ${KEYMAP_FILE_PATH}"
else
	echo "We don't have a key layout file: ${KEYMAP_FILE_PATH}"
	exit
fi

echo "Generate a tizen keycodes file"
_light_keymap_mode=false
_light_locale_mode=false

if [ -e ${RULE_FILE} ]
then
	while read STRING
	do
		if [[ $STRING == *"light_keymap="* ]]; then
			_light_keymap_mode=${STRING#*=}
		fi
		if [[ $STRING == *"light_locale="* ]]; then
			_light_locale_mode=${STRING#*=}
		fi
	done < ${RULE_FILE}
fi
echo "light keymap mode: "${_light_keymap_mode}", light locale mode: "${_light_locale_mode}

if [ "${_light_keymap_mode}" == "true" ]; then
	generate_light_keycodes
else
	cp ${KEYCODES_PATH}${DEFAULT_KEYCODES_NAME} ${KEYCODES_PATH}${NEW_KEYCODES_NAME}
fi

LOCALE_PATH=${TZ_SYS_RO_SHARE}/X11/locale/
LOCALE_LIGHT_PATH=${TZ_SYS_RO_SHARE}/X11/locale-light/

if [ -e ${LOCALE_LIGHT_PATH} ]; then
	if [ "${_light_locale_mode}" == "true" ]; then
		rm -rf ${LOCALE_PATH}
		mv ${LOCALE_LIGHT_PATH} ${LOCALE_PATH}
	else
		rm -rf ${LOCALE_LIGHT_PATH}
	fi
fi

echo ${KEYCODES_PATH}${NEW_KEYCODES_NAME}

while read KEYNAME KERNEL_KEYCODE KEYBOARD_OPTS
do
	if [ "${_light_keymap_mode}" == "false" ]; then
		[[ $KEYBOARD_OPTS == *"keyboard"* ]] && continue
	fi
	KERNEL_KEYCODE=$(echo $KERNEL_KEYCODE $PLATFORM_BASE_KEYCODE | awk '{print $1 + $2}')
	KEYCODE="${KERNEL_KEYCODE}"
	FULL_KEY_LIST=${FULL_KEY_LIST}"\n\t<I${KEYCODE}>=${KEYCODE}; \/\/ ${KEYNAME}"
done < ${KEYMAP_FILE_PATH}

echo ${FULL_KEY_LIST}

sed -i "s/${CHANGE_STRING}/${FULL_KEY_LIST}/g" ${KEYCODES_PATH}${NEW_KEYCODES_NAME}

sed -i "s/${DEFAULT_KEYCODES_NAME}/${NEW_KEYCODES_NAME}/g" ${KEYCODES_PATH}${NEW_KEYCODES_NAME}