add mappings for media keys

This commit is contained in:
sasha0552 2024-04-03 14:11:11 +00:00 committed by GitHub
parent e73f26c7c1
commit c07d6e793e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 162 additions and 22 deletions

View File

@ -1,11 +1,29 @@
#!/bin/sh
if ! command -v setxkbmap >/dev/null
# Run the keymap extraction in a clean X session
if [ "$1" != _IN_XVFB_SESSION_ ]; then
# All commands available?
ok=1
for cmd in setxkbmap xvfb-run xauth; do
if ! command -v $cmd >/dev/null
then
echo "error, setxkbmap not found"
echo "Error. $cmd not found" >&2
ok=
fi
done
if [ -z "$ok" ]; then
exit 1
fi
xvfb-run --auto-servernum --server-args="-noreset" $0 _IN_XVFB_SESSION_
exit $?
fi
OLD_SETTINGS=$(setxkbmap -query -verbose 4 | sed "s/^\([a-z]\+\):\s*\(.*\)$/-\1 \2/;s/^-options/-option \"\" -option/;s/,/ -option /g" | xargs -d \\n)
# Use evdev rules for these mappings
setxkbmap -rules evdev
# English - US 'en-us' 0x00000409
setxkbmap -model pc104 -layout us
./xrdp-genkeymap ../instfiles/km-00000409.ini
@ -15,7 +33,6 @@ setxkbmap -model pc104 -layout dvorak
./xrdp-genkeymap ../instfiles/km-00010409.ini
# English - US 'dvp' 0x19360409
OLD_SETTINGS=$(setxkbmap -query -verbose 4 | sed "s/^\([a-z]\+\):\s*\(.*\)$/-\1 \2/;s/^-options/-option \"\" -option/;s/,/ -option /g" | xargs -d \\n)
setxkbmap -rules xfree86 -model pc105 -layout us -variant dvp -option "" -option compose:102 -option caps:shift -option numpad:sg -option numpad:shift3 -option keypad:hex -option keypad:atm -option kpdl:semi -option lv3:ralt_alt
./xrdp-genkeymap ../instfiles/km-19360409.ini
setxkbmap ${OLD_SETTINGS}
@ -52,5 +69,5 @@ setxkbmap -model pc104 -layout se
setxkbmap -model pc104 -layout pt
./xrdp-genkeymap ../instfiles/km-00000816.ini
# set back to en-us
setxkbmap -model pc104 -layout us
# set back to entry settings
setxkbmap ${OLD_SETTINGS}

View File

@ -26,7 +26,7 @@
#include <config_ac.h>
#endif
int xfree86_to_evdev[137 - 8 + 1] =
int xfree86_to_evdev[255 - 8 + 1] =
{
/* MDSW */ 203,
/* ESC */ 9,
@ -141,9 +141,9 @@ int xfree86_to_evdev[137 - 8 + 1] =
/* FK13 */ 191,
/* FK14 */ 192,
/* FK15 */ 193,
/* FK16 */ 194,
/* FK17 */ 195,
/* KPDC */ 0,
/* XF86AudioMute */ 121,
/* XF86AudioLowerVolume */ 122,
/* XF86AudioRaiseVolume */ 123,
/* LVL3 */ 92,
/* ALT */ 204,
/* KPEQ */ 125,
@ -156,6 +156,124 @@ int xfree86_to_evdev[137 - 8 + 1] =
/* AE13 */ 132,
/* I06 */ 0,
/* I07 */ 0,
/* Cancel */ 136,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
/* XF86Launch1 */ 156,
/* XF86Launch2 */ 157,
0,
0,
0,
0,
0,
/* XF86Mail */ 163,
/* XF86Favorites */ 164,
0,
/* XF86Back */ 166,
/* XF86Forward */ 167,
0,
0,
0,
/* XF86AudioNext */ 171,
/* XF86AudioPlay */ 172,
/* XF86AudioPrev */ 173,
/* XF86AudioStop */ 174,
0,
0,
0,
0,
0,
/* XF86HomePage */ 180,
/* XF86Reload */ 181,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
/* XF86Search */ 225,
0,
0,
0,
0,
0,
0,
0,
0,
/* XF86AudioMedia */ 234,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
};

View File

@ -137,7 +137,7 @@ int main(int argc, char **argv)
fprintf(outf, "[%s]\n", sections[idx]);
e.state = states[idx];
for (i = 8; i < 137; i++) /* Keycodes */
for (i = 8; i < 256; i++) /* Keycodes */
{
if (is_evdev)
{
@ -148,6 +148,10 @@ int main(int argc, char **argv)
e.keycode = i;
}
nbytes = XLookupString(&e, text, 255, &ks, NULL);
if (ks == NoSymbol)
{
continue;
}
text[nbytes] = 0;
char_count = mbstowcs(wtext, text, 255);
unicode = 0;

View File

@ -40,14 +40,14 @@ static struct codepair g_map[] =
{ 0, 0 }, { 9, 0 }, { 10, 0 }, { 11, 0 }, { 12, 0 }, /* 0 - 4 */
{ 13, 0 }, { 14, 0 }, { 15, 0 }, { 16, 0 }, { 17, 0 }, /* 5 - 9 */
{ 18, 0 }, { 19, 0 }, { 20, 0 }, { 21, 0 }, { 22, 0 }, /* 10 - 14 */
{ 23, 0 }, { 24, 0 }, { 25, 0 }, { 26, 0 }, { 27, 0 }, /* 15 - 19 */
{ 23, 0 }, { 24, 173 }, { 25, 0 }, { 26, 0 }, { 27, 0 }, /* 15 - 19 */
{ 28, 0 }, { 29, 0 }, { 30, 0 }, { 31, 0 }, { 32, 0 }, /* 20 - 24 */
{ 33, 0 }, { 34, 0 }, { 35, 0 }, { 36, 108 }, { 37, 109 }, /* 25 - 29 */
{ 38, 0 }, { 39, 0 }, { 40, 0 }, { 41, 0 }, { 42, 0 }, /* 30 - 34 */
{ 43, 0 }, { 44, 0 }, { 45, 0 }, { 46, 0 }, { 47, 0 }, /* 35 - 39 */
{ 33, 171 }, { 34, 0 }, { 35, 0 }, { 36, 108 }, { 37, 109 }, /* 25 - 29 */
{ 38, 0 }, { 39, 0 }, { 40, 121 }, { 41, 0 }, { 42, 172 }, /* 30 - 34 */
{ 43, 0 }, { 44, 174 }, { 45, 0 }, { 46, 0 }, { 47, 0 }, /* 35 - 39 */
{ 48, 0 }, { 49, 0 }, { 50, 0 }, { 51, 0 }, { 52, 0 }, /* 40 - 44 */
{ 53, 0 }, { 54, 0 }, { 55, 0 }, { 56, 0 }, { 57, 0 }, /* 45 - 49 */
{ 58, 0 }, { 59, 0 }, { 60, 0 }, { 61, 112 }, { 62, 0 }, /* 50 - 54 */
{ 53, 0 }, { 54, 122 }, { 55, 0 }, { 56, 123 }, { 57, 0 }, /* 45 - 49 */
{ 58, 180 }, { 59, 0 }, { 60, 0 }, { 61, 112 }, { 62, 0 }, /* 50 - 54 */
{ 63, 111 }, { 64, 113 }, { 65, 0 }, { 66, 0 }, { 67, 0 }, /* 55 - 59 */
{ 68, 0 }, { 69, 0 }, { 70, 0 }, { 71, 0 }, { 72, 0 }, /* 60 - 64 */
{ 73, 0 }, { 74, 0 }, { 75, 0 }, { 76, 0 }, { 77, 0 }, /* 65 - 69 */
@ -57,9 +57,9 @@ static struct codepair g_map[] =
{ 93, 0 }, { 94, 0 }, { 95, 0 }, { 96, 0 }, { 97, 0 }, /* 85 - 89 */
{ 98, 0 }, { 0, 115 }, { 0, 116 }, { 0, 117 }, { 102, 0 }, /* 90 - 94 */
{ 103, 0 }, { 104, 0 }, { 105, 0 }, { 106, 0 }, { 107, 0 }, /* 95 - 99 */
{ 108, 0 }, { 109, 0 }, { 110, 0 }, { 111, 0 }, { 112, 0 }, /* 100 - 104 */
{ 113, 0 }, { 114, 0 }, { 115, 0 }, { 116, 0 }, { 117, 0 }, /* 105 - 109 */
{ 118, 0 }, { 119, 0 }, { 120, 0 }, { 121, 0 }, { 122, 0 }, /* 110 - 114 */
{ 108, 0 }, { 109, 225 }, { 110, 164 }, { 111, 181 }, { 112, 136 }, /* 100 - 104 */
{ 113, 167 }, { 114, 166 }, { 115, 0 }, { 116, 163 }, { 117, 234 }, /* 105 - 109 */
{ 118, 156 }, { 119, 157 }, { 120, 0 }, { 121, 0 }, { 122, 0 }, /* 110 - 114 */
{ 123, 0 }, { 124, 0 }, { 125, 0 }, { 126, 0 }, { 127, 0 }, /* 115 - 119 */
{ 128, 0 }, { 129, 0 }, { 130, 0 }, { 131, 0 }, { 132, 0 }, /* 120 - 124 */
{ 133, 0 }, { 134, 0 }, { 135, 0 } /* 125 - 127 */
@ -189,6 +189,7 @@ km_read_section(int fd, const char *section_name, struct xrdp_key_info *keymap)
values = list_create();
values->auto_free = 1;
g_memset(keymap, '\0', sizeof(*keymap));
if (file_read_section(fd, section_name, names, values) == 0)
{
for (index = names->count - 1; index >= 0; index--)