Generate one file.
This commit is contained in:
parent
b805e35ca7
commit
b840935530
1
src/protocols/rdp/keymaps/.gitignore
vendored
1
src/protocols/rdp/keymaps/.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
# Autogenerated code
|
||||
*.c
|
||||
*.h
|
||||
|
@ -34,35 +34,28 @@ sub keymap_symbol {
|
||||
return 'guac_rdp_keymap_' . $_;
|
||||
}
|
||||
|
||||
sub keymap_file {
|
||||
my $_ = shift;
|
||||
s/-/_/g;
|
||||
return 'rdp_keymap_' . $_;
|
||||
}
|
||||
#
|
||||
# rdp_keymap.c
|
||||
#
|
||||
|
||||
@keymaps = ();
|
||||
|
||||
#
|
||||
# rdp_keymap_*.c
|
||||
#
|
||||
open OUTPUT, ">", "rdp_keymaps.c";
|
||||
print OUTPUT
|
||||
'#include "config.h"' . "\n"
|
||||
. '#include "rdp_keymap.h"' . "\n"
|
||||
. '#include <freerdp/input.h>' . "\n"
|
||||
. "\n"
|
||||
. '#ifdef HAVE_FREERDP_LOCALE_KEYBOARD_H' . "\n"
|
||||
. '#include <freerdp/locale/keyboard.h>' . "\n"
|
||||
. '#else' . "\n"
|
||||
. '#include <freerdp/kbd/layouts.h>' . "\n"
|
||||
. '#endif' . "\n"
|
||||
. "\n";
|
||||
|
||||
for $filename (@ARGV) {
|
||||
|
||||
# Header
|
||||
$src = '/* Autogenerated from ' . $filename . ' */' . "\n"
|
||||
. "\n"
|
||||
. '#include "config.h"' . "\n"
|
||||
. '#include "rdp_keymap.h"' . "\n"
|
||||
. '#include <freerdp/input.h>' . "\n"
|
||||
. "\n"
|
||||
. '#ifdef HAVE_FREERDP_LOCALE_KEYBOARD_H' . "\n"
|
||||
. '#include <freerdp/locale/keyboard.h>' . "\n"
|
||||
. '#else' . "\n"
|
||||
. '#include <freerdp/kbd/layouts.h>' . "\n"
|
||||
. '#endif' . "\n"
|
||||
. "\n"
|
||||
. 'static guac_rdp_keysym_desc __keymap[] = {' . "\n";
|
||||
|
||||
$content = "";
|
||||
$parent = "";
|
||||
$layout_name = "";
|
||||
$freerdp = "";
|
||||
@ -175,38 +168,38 @@ for $filename (@ARGV) {
|
||||
# Write keysym/scancode pairs
|
||||
for ($i=0; $i<=$#keysyms; $i++) {
|
||||
|
||||
$src .= " {"
|
||||
. " .keysym = " . $keysyms[$i] . ","
|
||||
. " .scancode = " . $scancodes[$i];
|
||||
$content .= " {"
|
||||
. " .keysym = " . $keysyms[$i] . ","
|
||||
. " .scancode = " . $scancodes[$i];
|
||||
|
||||
# Set requirements
|
||||
if ($set_shift && !$set_altgr) {
|
||||
$src .= ", .set_keysyms = GUAC_KEYSYMS_SHIFT";
|
||||
$content .= ", .set_keysyms = GUAC_KEYSYMS_SHIFT";
|
||||
}
|
||||
elsif (!$set_shift && $set_altgr) {
|
||||
$src .= ", .set_keysyms = GUAC_KEYSYMS_ALTGR";
|
||||
$content .= ", .set_keysyms = GUAC_KEYSYMS_ALTGR";
|
||||
}
|
||||
elsif ($set_shift && $set_altgr) {
|
||||
$src .= ", .set_keysyms = GUAC_KEYSYMS_SHIFT_ALTGR";
|
||||
$content .= ", .set_keysyms = GUAC_KEYSYMS_SHIFT_ALTGR";
|
||||
}
|
||||
|
||||
# Clear requirements
|
||||
if ($clear_shift && !$clear_altgr) {
|
||||
$src .= ", .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT";
|
||||
$content .= ", .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT";
|
||||
}
|
||||
elsif (!$clear_shift && $clear_altgr) {
|
||||
$src .= ", .clear_keysyms = GUAC_KEYSYMS_ALTGR";
|
||||
$content .= ", .clear_keysyms = GUAC_KEYSYMS_ALTGR";
|
||||
}
|
||||
elsif ($clear_shift && $clear_altgr) {
|
||||
$src .= ", .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT_ALTGR";
|
||||
$content .= ", .clear_keysyms = GUAC_KEYSYMS_ALL_SHIFT_ALTGR";
|
||||
}
|
||||
|
||||
# Flags
|
||||
if ($ext_flags) {
|
||||
$src .= ", .flags = KBD_FLAGS_EXTENDED";
|
||||
$content .= ", .flags = KBD_FLAGS_EXTENDED";
|
||||
}
|
||||
|
||||
$src .= " },\n";
|
||||
$content .= " },\n";
|
||||
|
||||
}
|
||||
|
||||
@ -221,94 +214,52 @@ for $filename (@ARGV) {
|
||||
}
|
||||
close INPUT;
|
||||
|
||||
# Map footer
|
||||
$src .= ' {0}' . "\n"
|
||||
. '};' . "\n";
|
||||
# Header
|
||||
$sym = keymap_symbol($layout_name);
|
||||
print OUTPUT
|
||||
"\n"
|
||||
. '/* Autogenerated from ' . $filename . ' */' . "\n"
|
||||
. 'static guac_rdp_keysym_desc __' . $sym . '[] = {' . "\n"
|
||||
. $content
|
||||
. ' {0}' . "\n"
|
||||
. '};' . "\n";
|
||||
|
||||
# Desc header
|
||||
$keymap_sym = keymap_symbol($layout_name);
|
||||
$src .= "\n"
|
||||
. 'const guac_rdp_keymap ' . $keymap_sym . '[] = { ' . "\n";
|
||||
print OUTPUT "\n"
|
||||
. 'static const guac_rdp_keymap ' . $sym . ' = { ' . "\n";
|
||||
|
||||
# Layout name
|
||||
$src .= " .name = \"$layout_name\",\n";
|
||||
print OUTPUT " .name = \"$layout_name\",\n";
|
||||
|
||||
# Parent layout (if any)
|
||||
if ($parent) {
|
||||
$src .= " .parent = $parent,\n";
|
||||
print OUTPUT " .parent = $parent,\n";
|
||||
}
|
||||
|
||||
# FreeRDP layout (if any)
|
||||
if ($freerdp) {
|
||||
$src .= " .freerdp_keyboard_layout = $freerdp,\n";
|
||||
print OUTPUT " .freerdp_keyboard_layout = $freerdp,\n";
|
||||
}
|
||||
|
||||
# Desc footer
|
||||
$src .= ' .mapping = __keymap' . "\n"
|
||||
print OUTPUT
|
||||
' .mapping = __' . $sym . "\n"
|
||||
. '};' . "\n";
|
||||
|
||||
$keymaps[++$#keymaps] = $layout_name;
|
||||
$filename = keymap_file($layout_name) . '.c';
|
||||
|
||||
# Write output
|
||||
open OUTPUT, ">", "$filename";
|
||||
print OUTPUT "$src";
|
||||
close OUTPUT;
|
||||
print STDERR "Generated \"$filename\".\n";
|
||||
$keymaps[++$#keymaps] = $sym;
|
||||
print STDERR "Added: $layout_name\n";
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# rdp_keymaps.h
|
||||
#
|
||||
print OUTPUT "\n"
|
||||
. 'const guac_rdp_keymap guac_rdp_keymaps[] = {' . "\n";
|
||||
|
||||
print STDERR "Writing main keymap header... (\"rdp_keymaps.h\")\n";
|
||||
open OUTPUT, ">", "rdp_keymaps.h";
|
||||
|
||||
# Header
|
||||
print OUTPUT
|
||||
'#ifndef _GUAC_RDP_KEYMAPS' . "\n"
|
||||
. '#define _GUAC_RDP_KEYMAPS' . "\n"
|
||||
. "\n"
|
||||
. '#include "rdp_keymap.h"' . "\n"
|
||||
. "\n"
|
||||
. 'extern const guac_rdp_keymap* guac_rdp_keymaps[];' . "\n";
|
||||
|
||||
# Write list of keymaps
|
||||
foreach $keymap (@keymaps) {
|
||||
$sym = keymap_symbol($keymap);
|
||||
print OUTPUT "extern const guac_rdp_keymap $sym;\n";
|
||||
print OUTPUT " $keymap,\n";
|
||||
}
|
||||
|
||||
# Footer
|
||||
print OUTPUT
|
||||
"\n"
|
||||
. '#endif' . "\n";
|
||||
' NULL' . "\n"
|
||||
. '};' . "\n";
|
||||
|
||||
close OUTPUT;
|
||||
|
||||
#
|
||||
# rdp_keymaps.c
|
||||
#
|
||||
|
||||
print STDERR "Writing main keymap source... (\"rdp_keymaps.c\")\n";
|
||||
open OUTPUT, ">", "rdp_keymaps.c";
|
||||
|
||||
# Header
|
||||
print OUTPUT
|
||||
'#include "rdp_keymaps.h"' . "\n"
|
||||
. "\n"
|
||||
. 'const guac_rdp_keymap* guac_rdp_keymaps[] = {' . "\n";
|
||||
|
||||
# Write list of keymaps
|
||||
foreach $keymap (@keymaps) {
|
||||
$sym = keymap_symbol($keymap);
|
||||
print OUTPUT " &$sym,\n";
|
||||
}
|
||||
|
||||
# Footer
|
||||
print OUTPUT
|
||||
' NULL' . "\n"
|
||||
. '};' . "\n";
|
||||
|
||||
close OUTPUT;
|
||||
|
Loading…
Reference in New Issue
Block a user