From 0f4cc4b5a7f780111c3ef2e1d4bba175896f8537 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 23 Nov 2021 15:20:09 +0000 Subject: [build] Include EFI system partition table entry in isohybrid images Add the "--uefi" option when invoking isohybrid on an EFI-bootable image, to create a partition mapping to the EFI system partition embedded within the ISO image. This allows the resulting isohybrid image to be booted on UEFI systems that will not recognise an El Torito boot catalog on a non-CDROM device. Originally-fixed-by: Christian Hesse Signed-off-by: Michael Brown --- src/util/genfsimg | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/util') diff --git a/src/util/genfsimg b/src/util/genfsimg index c13158203..731fa6ce0 100755 --- a/src/util/genfsimg +++ b/src/util/genfsimg @@ -308,6 +308,9 @@ if [ -n "${ISOIMG}" ] ; then ${ISOARGS} "${ISODIR}" if isohybrid --version >/dev/null 2>&1 ; then ISOHYBRIDARGS= + if [ -n "${EFI}" ] ; then + ISOHYBRIDARGS="${ISOHYBRIDARGS} --uefi" + fi if [ -n "${SOURCE_DATE_EPOCH:-}" ] ; then ISOHYBRIDARGS="${ISOHYBRIDARGS} --id ${SOURCE_DATE_EPOCH}" fi -- cgit v1.2.3-55-g7522 From 91c77e2592f5b0e1098d3f341827d7e6925e4a85 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 11 Jan 2022 15:27:14 +0000 Subject: [efi] Do not align VirtualSize for .reloc and .debug sections As of commit f1e9e2b ("[efi] Align EFI image sections by page size"), the VirtualSize fields for the .reloc and .debug sections have been rounded up to the (4kB) image alignment. This breaks the PE relocation logic in the UEFI shim, which requires the VirtualSize field to exactly match the size as recorded in the data directory. Fix by setting the VirtualSize field to the unaligned size of the section, as is already done for normal PE sections (i.e. those other than .reloc and .debug). Signed-off-by: Michael Brown --- src/util/elf2efi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/util') diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c index 8af53aeb4..08d790f1e 100644 --- a/src/util/elf2efi.c +++ b/src/util/elf2efi.c @@ -753,15 +753,13 @@ static struct pe_section * create_reloc_section ( struct pe_header *pe_header, struct pe_relocs *pe_reltab ) { struct pe_section *reloc; - size_t section_rawsz; size_t section_memsz; size_t section_filesz; EFI_IMAGE_DATA_DIRECTORY *relocdir; /* Allocate PE section */ - section_rawsz = output_pe_reltab ( pe_reltab, NULL ); - section_filesz = efi_file_align ( section_rawsz ); - section_memsz = efi_image_align ( section_rawsz ); + section_memsz = output_pe_reltab ( pe_reltab, NULL ); + section_filesz = efi_file_align ( section_memsz ); reloc = xmalloc ( sizeof ( *reloc ) + section_filesz ); memset ( reloc, 0, sizeof ( *reloc ) + section_filesz ); @@ -782,11 +780,12 @@ create_reloc_section ( struct pe_header *pe_header, /* Update file header details */ pe_header->nt.FileHeader.NumberOfSections++; pe_header->nt.OptionalHeader.SizeOfHeaders += sizeof ( reloc->hdr ); - pe_header->nt.OptionalHeader.SizeOfImage += section_memsz; + pe_header->nt.OptionalHeader.SizeOfImage += + efi_image_align ( section_memsz ); relocdir = &(pe_header->nt.OptionalHeader.DataDirectory [EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC]); relocdir->VirtualAddress = reloc->hdr.VirtualAddress; - relocdir->Size = section_rawsz; + relocdir->Size = section_memsz; return reloc; } @@ -824,8 +823,8 @@ create_debug_section ( struct pe_header *pe_header, const char *filename ) { } *contents; /* Allocate PE section */ - section_memsz = efi_image_align ( sizeof ( *contents ) ); - section_filesz = efi_file_align ( sizeof ( *contents ) ); + section_memsz = sizeof ( *contents ); + section_filesz = efi_file_align ( section_memsz ); debug = xmalloc ( sizeof ( *debug ) + section_filesz ); memset ( debug, 0, sizeof ( *debug ) + section_filesz ); contents = ( void * ) debug->contents; @@ -857,7 +856,8 @@ create_debug_section ( struct pe_header *pe_header, const char *filename ) { /* Update file header details */ pe_header->nt.FileHeader.NumberOfSections++; pe_header->nt.OptionalHeader.SizeOfHeaders += sizeof ( debug->hdr ); - pe_header->nt.OptionalHeader.SizeOfImage += section_memsz; + pe_header->nt.OptionalHeader.SizeOfImage += + efi_image_align ( section_memsz ); debugdir = &(pe_header->nt.OptionalHeader.DataDirectory [EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]); debugdir->VirtualAddress = debug->hdr.VirtualAddress; -- cgit v1.2.3-55-g7522 From 53a5de3641ccd0836aac7378cdd37c9757e2db3a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 13 Jan 2022 12:48:38 +0000 Subject: [doc] Update user-visible ipxe.org URIs to use HTTPS Signed-off-by: Michael Brown --- src/Makefile | 2 +- src/arch/x86/interface/syslinux/comboot_call.c | 2 +- src/arch/x86/prefix/romprefix.S | 4 ++-- src/config/branding.h | 24 ++++++++++++------------ src/include/ipxe/srp.h | 2 +- src/usr/autoboot.c | 4 ++-- src/util/niclist.pl | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/util') diff --git a/src/Makefile b/src/Makefile index 69139dc11..4c4abf1aa 100644 --- a/src/Makefile +++ b/src/Makefile @@ -190,7 +190,7 @@ vmware : bin/8086100f.mrom bin/808610d3.mrom bin/10222000.rom bin/15ad07b0.rom @$(ECHO) ' bin/10222000.rom -- vlance/pcnet32' @$(ECHO) ' bin/15ad07b0.rom -- vmxnet3' @$(ECHO) - @$(ECHO) 'For more information, see http://ipxe.org/howto/vmware' + @$(ECHO) 'For more information, see https://ipxe.org/howto/vmware' @$(ECHO) @$(ECHO) '===========================================================' diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index dc308dafe..b75e8ef7c 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -47,7 +47,7 @@ static char __bss16_array ( syslinux_version, [32] ); #define syslinux_version __use_data16 ( syslinux_version ) /** The "SYSLINUX" copyright string */ -static char __data16_array ( syslinux_copyright, [] ) = " http://ipxe.org"; +static char __data16_array ( syslinux_copyright, [] ) = " https://ipxe.org"; #define syslinux_copyright __use_data16 ( syslinux_copyright ) static char __data16_array ( syslinux_configuration_file, [] ) = ""; diff --git a/src/arch/x86/prefix/romprefix.S b/src/arch/x86/prefix/romprefix.S index a9934a725..4e8793c21 100644 --- a/src/arch/x86/prefix/romprefix.S +++ b/src/arch/x86/prefix/romprefix.S @@ -161,7 +161,7 @@ pnpheader: /* Manufacturer string */ mfgstr: - .asciz "http://ipxe.org" + .asciz "https://ipxe.org" .size mfgstr, . - mfgstr /* Product string @@ -607,7 +607,7 @@ get_pmm_decompress_to: * strings PRODUCT_NAME and PRODUCT_SHORT_NAME in config/branding.h. * * While nothing in the GPL prevents you from removing all references - * to iPXE or http://ipxe.org, we prefer you not to do so. + * to iPXE or https://ipxe.org, we prefer you not to do so. * * If you have an OEM-mandated branding requirement that cannot be * satisfied simply by defining PRODUCT_NAME and PRODUCT_SHORT_NAME, diff --git a/src/config/branding.h b/src/config/branding.h index 73f00af95..e503dff9a 100644 --- a/src/config/branding.h +++ b/src/config/branding.h @@ -26,7 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #define PRODUCT_NAME "" #define PRODUCT_SHORT_NAME "iPXE" -#define PRODUCT_URI "http://ipxe.org" +#define PRODUCT_URI "https://ipxe.org" /* * Tag line @@ -44,15 +44,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * (e.g. "Permission denied") and a 32-bit error number. This number * is incorporated into an error URI such as * - * "No such file or directory (http://ipxe.org/2d0c613b)" + * "No such file or directory (https://ipxe.org/2d0c613b)" * * or * - * "Operation not supported (http://ipxe.org/3c092003)" + * "Operation not supported (https://ipxe.org/3c092003)" * * Users may browse to the URI within the error message, which is * provided by a database running on the iPXE web site - * (http://ipxe.org). This database provides details for all possible + * (https://ipxe.org). This database provides details for all possible * errors generated by iPXE, including: * * - the detailed error message (e.g. "Not an OCSP signing @@ -74,13 +74,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * If you have a customer support team and would like your customers * to contact your support team for all problems, instead of using the - * existing support infrastructure provided by http://ipxe.org, then + * existing support infrastructure provided by https://ipxe.org, then * you may define a custom URI to be included within error messages. * * Note that the custom URI is a printf() format string which must * include a format specifier for the 32-bit error number. */ -#define PRODUCT_ERROR_URI "http://ipxe.org/%08x" +#define PRODUCT_ERROR_URI "https://ipxe.org/%08x" /* * Command help messages @@ -88,7 +88,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * iPXE command help messages include a URI constructed from the * command name, such as * - * "See http://ipxe.org/cmd/vcreate for further information" + * "See https://ipxe.org/cmd/vcreate for further information" * * The iPXE web site includes documentation for the commands provided * by the iPXE shell, including: @@ -113,7 +113,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * If you want to provide your own documentation for all of the * commands provided by the iPXE shell, rather than using the existing - * support infrastructure provided by http://ipxe.org, then you may + * support infrastructure provided by https://ipxe.org, then you may * define a custom URI to be included within command help messages. * * Note that the custom URI is a printf() format string which must @@ -124,7 +124,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * iPXE project and prohibit the alteration or removal of any * references to "iPXE". ] */ -#define PRODUCT_COMMAND_URI "http://ipxe.org/cmd/%s" +#define PRODUCT_COMMAND_URI "https://ipxe.org/cmd/%s" /* * Setting help messages @@ -132,7 +132,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * iPXE setting help messages include a URI constructed from the * setting name, such as * - * "http://ipxe.org/cfg/initiator-iqn" + * "https://ipxe.org/cfg/initiator-iqn" * * The iPXE web site includes documentation for the settings used by * iPXE, including: @@ -156,7 +156,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * * If you want to provide your own documentation for all of the * settings used by iPXE, rather than using the existing support - * infrastructure provided by http://ipxe.org, then you may define a + * infrastructure provided by https://ipxe.org, then you may define a * custom URI to be included within setting help messages. * * Note that the custom URI is a printf() format string which must @@ -167,7 +167,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * iPXE project and prohibit the alteration or removal of any * references to "iPXE". ] */ -#define PRODUCT_SETTING_URI "http://ipxe.org/cfg/%s" +#define PRODUCT_SETTING_URI "https://ipxe.org/cfg/%s" #include diff --git a/src/include/ipxe/srp.h b/src/include/ipxe/srp.h index 3abb0995f..1f66a22b2 100644 --- a/src/include/ipxe/srp.h +++ b/src/include/ipxe/srp.h @@ -774,7 +774,7 @@ struct srp_aer_rsp { * The working draft specification for the SRP boot firmware table can * be found at * - * http://ipxe.org/wiki/srp/sbft + * https://ipxe.org/wiki/srp/sbft * ***************************************************************************** */ diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index 62e90ecd0..24043ae69 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -579,8 +579,8 @@ int ipxe ( struct net_device *netdev ) { * defining the string PRODUCT_NAME in config/branding.h. * * While nothing in the GPL prevents you from removing all - * references to iPXE or http://ipxe.org, we prefer you not to - * do so. + * references to iPXE or https://ipxe.org, we prefer you not + * to do so. * */ printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD PRODUCT_SHORT_NAME " %s" diff --git a/src/util/niclist.pl b/src/util/niclist.pl index 2668a1c03..c35a3277e 100755 --- a/src/util/niclist.pl +++ b/src/util/niclist.pl @@ -565,7 +565,7 @@ EOM return join("\n", @output); } -# Output NIC list in DokuWiki format (for http://ipxe.org) +# Output NIC list in DokuWiki format (for https://ipxe.org) sub format_nic_list_dokuwiki { my ($nic_list, $column_names) = @_; my @output; -- cgit v1.2.3-55-g7522 From 3f05a82fec6223a49df300a9cbf80c6245c3f99e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 6 Feb 2022 19:33:20 +0000 Subject: [console] Update genkeymap to work with current databases Rewrite genkeymap.pl in Python with added sanity checks, and update the list of keyboard mappings to remove those no longer supported by the underlying "loadkeys" tool. Signed-off-by: Michael Brown --- src/Makefile | 2 +- src/hci/keymap/keymap_al.c | 1 + src/hci/keymap/keymap_az.c | 2 +- src/hci/keymap/keymap_bg.c | 15 -- src/hci/keymap/keymap_cz.c | 33 +++- src/hci/keymap/keymap_de.c | 13 +- src/hci/keymap/keymap_dk.c | 4 +- src/hci/keymap/keymap_es.c | 2 + src/hci/keymap/keymap_et.c | 1 - src/hci/keymap/keymap_fi.c | 9 - src/hci/keymap/keymap_fr.c | 16 +- src/hci/keymap/keymap_hu.c | 1 + src/hci/keymap/keymap_il.c | 12 ++ src/hci/keymap/keymap_it.c | 1 + src/hci/keymap/keymap_mt.c | 2 +- src/hci/keymap/keymap_nl.c | 4 +- src/hci/keymap/keymap_no-latin1.c | 1 + src/hci/keymap/keymap_no.c | 88 +--------- src/hci/keymap/keymap_pt.c | 31 ++-- src/hci/keymap/keymap_ru.c | 1 + src/hci/keymap/keymap_sr-latin.c | 15 ++ src/hci/keymap/keymap_sr.c | 35 ---- src/hci/keymap/keymap_th.c | 15 -- src/hci/keymap/keymap_wo.c | 55 ------ src/util/genkeymap.pl | 238 -------------------------- src/util/genkeymap.py | 346 ++++++++++++++++++++++++++++++++++++++ 26 files changed, 446 insertions(+), 497 deletions(-) delete mode 100644 src/hci/keymap/keymap_bg.c create mode 100644 src/hci/keymap/keymap_sr-latin.c delete mode 100644 src/hci/keymap/keymap_sr.c delete mode 100644 src/hci/keymap/keymap_th.c delete mode 100644 src/hci/keymap/keymap_wo.c delete mode 100755 src/util/genkeymap.pl create mode 100755 src/util/genkeymap.py (limited to 'src/util') diff --git a/src/Makefile b/src/Makefile index 4c4abf1aa..83642e789 100644 --- a/src/Makefile +++ b/src/Makefile @@ -50,7 +50,7 @@ ELF2EFI64 := ./util/elf2efi64 EFIROM := ./util/efirom EFIFATBIN := ./util/efifatbin EINFO := ./util/einfo -GENKEYMAP := ./util/genkeymap.pl +GENKEYMAP := ./util/genkeymap.py DOXYGEN := doxygen LCAB := lcab QEMUIMG := qemu-img diff --git a/src/hci/keymap/keymap_al.c b/src/hci/keymap/keymap_al.c index caf295e8e..e4418361b 100644 --- a/src/hci/keymap/keymap_al.c +++ b/src/hci/keymap/keymap_al.c @@ -14,6 +14,7 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); struct key_mapping al_mapping[] __keymap = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ + { 0x1c, 0x1d }, /* 0x1c => 0x1d */ { 0x22, 0x7b }, /* '"' => '{' */ { 0x27, 0x5b }, /* '\'' => '[' */ { 0x3c, 0x3b }, /* '<' => ';' */ diff --git a/src/hci/keymap/keymap_az.c b/src/hci/keymap/keymap_az.c index 27ce91e7d..525ab2336 100644 --- a/src/hci/keymap/keymap_az.c +++ b/src/hci/keymap/keymap_az.c @@ -12,7 +12,7 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "az" keyboard mapping */ struct key_mapping az_mapping[] __keymap = { - { 0x23, 0x27 }, /* '#' => '\'' */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x24, 0x3b }, /* '$' => ';' */ { 0x26, 0x3f }, /* '&' => '?' */ { 0x2f, 0x2e }, /* '/' => '.' */ diff --git a/src/hci/keymap/keymap_bg.c b/src/hci/keymap/keymap_bg.c deleted file mode 100644 index 62b6baeac..000000000 --- a/src/hci/keymap/keymap_bg.c +++ /dev/null @@ -1,15 +0,0 @@ -/** @file - * - * "bg" keyboard mapping - * - * This file is automatically generated; do not edit - * - */ - -FILE_LICENCE ( PUBLIC_DOMAIN ); - -#include - -/** "bg" keyboard mapping */ -struct key_mapping bg_mapping[] __keymap = { -}; diff --git a/src/hci/keymap/keymap_cz.c b/src/hci/keymap/keymap_cz.c index 9280f84fd..2b4a21592 100644 --- a/src/hci/keymap/keymap_cz.c +++ b/src/hci/keymap/keymap_cz.c @@ -12,16 +12,35 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "cz" keyboard mapping */ struct key_mapping cz_mapping[] __keymap = { - { 0x21, 0x2b }, /* '!' => '+' */ + { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ + { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ + { 0x1f, 0x1c }, /* 0x1f => 0x1c */ + { 0x21, 0x31 }, /* '!' => '1' */ + { 0x22, 0x21 }, /* '"' => '!' */ + { 0x23, 0x33 }, /* '#' => '3' */ + { 0x24, 0x34 }, /* '$' => '4' */ + { 0x25, 0x35 }, /* '%' => '5' */ + { 0x26, 0x37 }, /* '&' => '7' */ + { 0x28, 0x39 }, /* '(' => '9' */ + { 0x29, 0x30 }, /* ')' => '0' */ + { 0x2a, 0x38 }, /* '*' => '8' */ { 0x2d, 0x3d }, /* '-' => '=' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x31, 0x2b }, /* '1' => '+' */ - { 0x3c, 0x2c }, /* '<' => ',' */ - { 0x3e, 0x2e }, /* '>' => '.' */ - { 0x3f, 0x2d }, /* '?' => '-' */ + { 0x3a, 0x22 }, /* ':' => '"' */ + { 0x3c, 0x3f }, /* '<' => '?' */ + { 0x3e, 0x3a }, /* '>' => ':' */ + { 0x3f, 0x5f }, /* '?' => '_' */ + { 0x40, 0x32 }, /* '@' => '2' */ + { 0x59, 0x5a }, /* 'Y' => 'Z' */ + { 0x5a, 0x59 }, /* 'Z' => 'Y' */ { 0x5d, 0x29 }, /* ']' => ')' */ - { 0x5f, 0x3d }, /* '_' => '=' */ + { 0x5e, 0x36 }, /* '^' => '6' */ + { 0x5f, 0x25 }, /* '_' => '%' */ { 0x60, 0x3b }, /* '`' => ';' */ - { 0x7d, 0x29 }, /* '}' => ')' */ - { 0x7e, 0x3b }, /* '~' => ';' */ + { 0x79, 0x7a }, /* 'y' => 'z' */ + { 0x7a, 0x79 }, /* 'z' => 'y' */ + { 0x7b, 0x2f }, /* '{' => '/' */ + { 0x7c, 0x27 }, /* '|' => '\'' */ + { 0x7d, 0x28 }, /* '}' => '(' */ }; diff --git a/src/hci/keymap/keymap_de.c b/src/hci/keymap/keymap_de.c index ffcf912f1..2559e1538 100644 --- a/src/hci/keymap/keymap_de.c +++ b/src/hci/keymap/keymap_de.c @@ -14,33 +14,26 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); struct key_mapping de_mapping[] __keymap = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ - { 0x22, 0x7d }, /* '"' => '}' */ + { 0x1c, 0x23 }, /* 0x1c => '#' */ + { 0x1d, 0x1e }, /* 0x1d => 0x1e */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ - { 0x27, 0x5d }, /* '\'' => ']' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ - { 0x2b, 0x60 }, /* '+' => '`' */ - { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x2f, 0x2d }, /* '/' => '-' */ - { 0x3a, 0x7b }, /* ':' => '{' */ - { 0x3b, 0x5b }, /* ';' => '[' */ { 0x3c, 0x3b }, /* '<' => ';' */ - { 0x3d, 0x27 }, /* '=' => '\'' */ { 0x3e, 0x3a }, /* '>' => ':' */ { 0x3f, 0x5f }, /* '?' => '_' */ { 0x40, 0x22 }, /* '@' => '"' */ { 0x59, 0x5a }, /* 'Y' => 'Z' */ { 0x5a, 0x59 }, /* 'Z' => 'Y' */ - { 0x5b, 0x40 }, /* '[' => '@' */ { 0x5c, 0x23 }, /* '\\' => '#' */ { 0x5d, 0x2b }, /* ']' => '+' */ { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ - { 0x60, 0x5e }, /* '`' => '^' */ { 0x79, 0x7a }, /* 'y' => 'z' */ { 0x7a, 0x79 }, /* 'z' => 'y' */ - { 0x7b, 0x5c }, /* '{' => '\\' */ { 0x7c, 0x27 }, /* '|' => '\'' */ { 0x7d, 0x2a }, /* '}' => '*' */ }; diff --git a/src/hci/keymap/keymap_dk.c b/src/hci/keymap/keymap_dk.c index e409018c8..05110dc89 100644 --- a/src/hci/keymap/keymap_dk.c +++ b/src/hci/keymap/keymap_dk.c @@ -12,11 +12,12 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "dk" keyboard mapping */ struct key_mapping dk_mapping[] __keymap = { + { 0x1c, 0x27 }, /* 0x1c => '\'' */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ - { 0x2b, 0x60 }, /* '+' => '`' */ { 0x2d, 0x2b }, /* '-' => '+' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3c, 0x3b }, /* '<' => ';' */ @@ -27,5 +28,4 @@ struct key_mapping dk_mapping[] __keymap = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7c, 0x2a }, /* '|' => '*' */ - { 0x7d, 0x5e }, /* '}' => '^' */ }; diff --git a/src/hci/keymap/keymap_es.c b/src/hci/keymap/keymap_es.c index c1fe013a9..51dedfff7 100644 --- a/src/hci/keymap/keymap_es.c +++ b/src/hci/keymap/keymap_es.c @@ -12,6 +12,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "es" keyboard mapping */ struct key_mapping es_mapping[] __keymap = { + { 0x1c, 0x1d }, /* 0x1c => 0x1d */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ diff --git a/src/hci/keymap/keymap_et.c b/src/hci/keymap/keymap_et.c index ad88cecc1..dd0f879b1 100644 --- a/src/hci/keymap/keymap_et.c +++ b/src/hci/keymap/keymap_et.c @@ -26,5 +26,4 @@ struct key_mapping et_mapping[] __keymap = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7c, 0x2a }, /* '|' => '*' */ - { 0x7f, 0x1b }, /* 0x7f => 0x1b */ }; diff --git a/src/hci/keymap/keymap_fi.c b/src/hci/keymap/keymap_fi.c index c8f6c3a06..c489bf0e5 100644 --- a/src/hci/keymap/keymap_fi.c +++ b/src/hci/keymap/keymap_fi.c @@ -12,27 +12,18 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "fi" keyboard mapping */ struct key_mapping fi_mapping[] __keymap = { - { 0x22, 0x5b }, /* '"' => '[' */ { 0x26, 0x2f }, /* '&' => '/' */ - { 0x27, 0x7b }, /* '\'' => '{' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ - { 0x2b, 0x60 }, /* '+' => '`' */ { 0x2d, 0x2b }, /* '-' => '+' */ { 0x2f, 0x2d }, /* '/' => '-' */ - { 0x3a, 0x5c }, /* ':' => '\\' */ - { 0x3b, 0x7c }, /* ';' => '|' */ { 0x3c, 0x3b }, /* '<' => ';' */ - { 0x3d, 0x27 }, /* '=' => '\'' */ { 0x3e, 0x3a }, /* '>' => ':' */ { 0x3f, 0x5f }, /* '?' => '_' */ { 0x40, 0x22 }, /* '@' => '"' */ - { 0x5b, 0x7d }, /* '[' => '}' */ { 0x5c, 0x27 }, /* '\\' => '\'' */ { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ - { 0x7b, 0x5d }, /* '{' => ']' */ { 0x7c, 0x2a }, /* '|' => '*' */ - { 0x7d, 0x5e }, /* '}' => '^' */ }; diff --git a/src/hci/keymap/keymap_fr.c b/src/hci/keymap/keymap_fr.c index fd615a456..8f3b4999d 100644 --- a/src/hci/keymap/keymap_fr.c +++ b/src/hci/keymap/keymap_fr.c @@ -16,13 +16,16 @@ struct key_mapping fr_mapping[] __keymap = { { 0x11, 0x01 }, /* Ctrl-Q => Ctrl-A */ { 0x17, 0x1a }, /* Ctrl-W => Ctrl-Z */ { 0x1a, 0x17 }, /* Ctrl-Z => Ctrl-W */ + { 0x1c, 0x2a }, /* 0x1c => '*' */ + { 0x1d, 0x24 }, /* 0x1d => '$' */ + { 0x1e, 0x1c }, /* 0x1e => 0x1c */ + { 0x1f, 0x1d }, /* 0x1f => 0x1d */ { 0x21, 0x31 }, /* '!' => '1' */ { 0x22, 0x25 }, /* '"' => '%' */ { 0x23, 0x33 }, /* '#' => '3' */ { 0x24, 0x34 }, /* '$' => '4' */ { 0x25, 0x35 }, /* '%' => '5' */ { 0x26, 0x37 }, /* '&' => '7' */ - { 0x27, 0x7c }, /* '\'' => '|' */ { 0x28, 0x39 }, /* '(' => '9' */ { 0x29, 0x30 }, /* ')' => '0' */ { 0x2a, 0x38 }, /* '*' => '8' */ @@ -30,39 +33,28 @@ struct key_mapping fr_mapping[] __keymap = { { 0x2d, 0x29 }, /* '-' => ')' */ { 0x2e, 0x3a }, /* '.' => ':' */ { 0x2f, 0x21 }, /* '/' => '!' */ - { 0x30, 0x40 }, /* '0' => '@' */ { 0x31, 0x26 }, /* '1' => '&' */ - { 0x32, 0x7b }, /* '2' => '{' */ { 0x33, 0x22 }, /* '3' => '"' */ { 0x34, 0x27 }, /* '4' => '\'' */ { 0x35, 0x28 }, /* '5' => '(' */ { 0x36, 0x2d }, /* '6' => '-' */ - { 0x37, 0x7d }, /* '7' => '}' */ { 0x38, 0x5f }, /* '8' => '_' */ - { 0x39, 0x2f }, /* '9' => '/' */ { 0x3a, 0x4d }, /* ':' => 'M' */ { 0x3b, 0x6d }, /* ';' => 'm' */ { 0x3c, 0x2e }, /* '<' => '.' */ { 0x3e, 0x2f }, /* '>' => '/' */ - { 0x3f, 0x5c }, /* '?' => '\\' */ { 0x40, 0x32 }, /* '@' => '2' */ { 0x41, 0x51 }, /* 'A' => 'Q' */ { 0x4d, 0x3f }, /* 'M' => '?' */ { 0x51, 0x41 }, /* 'Q' => 'A' */ { 0x57, 0x5a }, /* 'W' => 'Z' */ { 0x5a, 0x57 }, /* 'Z' => 'W' */ - { 0x5b, 0x5e }, /* '[' => '^' */ { 0x5c, 0x2a }, /* '\\' => '*' */ { 0x5d, 0x24 }, /* ']' => '$' */ { 0x5e, 0x36 }, /* '^' => '6' */ - { 0x5f, 0x5d }, /* '_' => ']' */ - { 0x60, 0x2a }, /* '`' => '*' */ { 0x61, 0x71 }, /* 'a' => 'q' */ { 0x6d, 0x2c }, /* 'm' => ',' */ { 0x71, 0x61 }, /* 'q' => 'a' */ { 0x77, 0x7a }, /* 'w' => 'z' */ { 0x7a, 0x77 }, /* 'z' => 'w' */ - { 0x7b, 0x3c }, /* '{' => '<' */ - { 0x7c, 0x23 }, /* '|' => '#' */ - { 0x7d, 0x3e }, /* '}' => '>' */ }; diff --git a/src/hci/keymap/keymap_hu.c b/src/hci/keymap/keymap_hu.c index 68eff2f4c..a2eadbc62 100644 --- a/src/hci/keymap/keymap_hu.c +++ b/src/hci/keymap/keymap_hu.c @@ -14,6 +14,7 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); struct key_mapping hu_mapping[] __keymap = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x21, 0x27 }, /* '!' => '\'' */ { 0x23, 0x2b }, /* '#' => '+' */ { 0x24, 0x21 }, /* '$' => '!' */ diff --git a/src/hci/keymap/keymap_il.c b/src/hci/keymap/keymap_il.c index 478330c0c..f631f7ac9 100644 --- a/src/hci/keymap/keymap_il.c +++ b/src/hci/keymap/keymap_il.c @@ -12,4 +12,16 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "il" keyboard mapping */ struct key_mapping il_mapping[] __keymap = { + { 0x1d, 0x1b }, /* 0x1d => 0x1b */ + { 0x27, 0x2c }, /* '\'' => ',' */ + { 0x28, 0x29 }, /* '(' => ')' */ + { 0x29, 0x28 }, /* ')' => '(' */ + { 0x2f, 0x2e }, /* '/' => '.' */ + { 0x3c, 0x3e }, /* '<' => '>' */ + { 0x3e, 0x3c }, /* '>' => '<' */ + { 0x5b, 0x5d }, /* '[' => ']' */ + { 0x5d, 0x5b }, /* ']' => '[' */ + { 0x60, 0x3b }, /* '`' => ';' */ + { 0x7b, 0x7d }, /* '{' => '}' */ + { 0x7d, 0x7b }, /* '}' => '{' */ }; diff --git a/src/hci/keymap/keymap_it.c b/src/hci/keymap/keymap_it.c index 5bb05471c..d96102c9e 100644 --- a/src/hci/keymap/keymap_it.c +++ b/src/hci/keymap/keymap_it.c @@ -12,6 +12,7 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "it" keyboard mapping */ struct key_mapping it_mapping[] __keymap = { + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ diff --git a/src/hci/keymap/keymap_mt.c b/src/hci/keymap/keymap_mt.c index 094a6fc60..dfca2ff66 100644 --- a/src/hci/keymap/keymap_mt.c +++ b/src/hci/keymap/keymap_mt.c @@ -12,8 +12,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "mt" keyboard mapping */ struct key_mapping mt_mapping[] __keymap = { + { 0x1c, 0x1e }, /* 0x1c => 0x1e */ { 0x22, 0x40 }, /* '"' => '@' */ - { 0x23, 0x04 }, /* '#' => Ctrl-D */ { 0x40, 0x22 }, /* '@' => '"' */ { 0x5c, 0x23 }, /* '\\' => '#' */ { 0x7c, 0x7e }, /* '|' => '~' */ diff --git a/src/hci/keymap/keymap_nl.c b/src/hci/keymap/keymap_nl.c index ba051705e..2a0fbbcbd 100644 --- a/src/hci/keymap/keymap_nl.c +++ b/src/hci/keymap/keymap_nl.c @@ -12,11 +12,13 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "nl" keyboard mapping */ struct key_mapping nl_mapping[] __keymap = { + { 0x1c, 0x3c }, /* 0x1c => '<' */ + { 0x1d, 0x1c }, /* 0x1d => 0x1c */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x5f }, /* '&' => '_' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x27 }, /* ')' => '\'' */ { 0x2a, 0x28 }, /* '*' => '(' */ - { 0x2b, 0x7e }, /* '+' => '~' */ { 0x2d, 0x2f }, /* '-' => '/' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3b, 0x2b }, /* ';' => '+' */ diff --git a/src/hci/keymap/keymap_no-latin1.c b/src/hci/keymap/keymap_no-latin1.c index 8c3e81b31..655e4cef7 100644 --- a/src/hci/keymap/keymap_no-latin1.c +++ b/src/hci/keymap/keymap_no-latin1.c @@ -12,6 +12,7 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "no-latin1" keyboard mapping */ struct key_mapping no_latin1_mapping[] __keymap = { + { 0x1d, 0x1e }, /* 0x1d => 0x1e */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ diff --git a/src/hci/keymap/keymap_no.c b/src/hci/keymap/keymap_no.c index 45cf9e847..7a2df7c5a 100644 --- a/src/hci/keymap/keymap_no.c +++ b/src/hci/keymap/keymap_no.c @@ -12,94 +12,22 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "no" keyboard mapping */ struct key_mapping no_mapping[] __keymap = { - { 0x02, 0x18 }, /* Ctrl-B => Ctrl-X */ - { 0x03, 0x0a }, /* Ctrl-C => Ctrl-J */ - { 0x04, 0x05 }, /* Ctrl-D => Ctrl-E */ - { 0x06, 0x15 }, /* Ctrl-F => Ctrl-U */ - { 0x07, 0x09 }, /* Ctrl-G => Ctrl-I */ - { 0x08, 0x04 }, /* Ctrl-H => Ctrl-D */ - { 0x0a, 0x08 }, /* Ctrl-J => Ctrl-H */ - { 0x0b, 0x14 }, /* Ctrl-K => Ctrl-T */ - { 0x0c, 0x0e }, /* Ctrl-L => Ctrl-N */ - { 0x0e, 0x02 }, /* Ctrl-N => Ctrl-B */ - { 0x0f, 0x12 }, /* Ctrl-O => Ctrl-R */ - { 0x10, 0x0c }, /* Ctrl-P => Ctrl-L */ - { 0x12, 0x10 }, /* Ctrl-R => Ctrl-P */ - { 0x13, 0x0f }, /* Ctrl-S => Ctrl-O */ - { 0x14, 0x19 }, /* Ctrl-T => Ctrl-Y */ - { 0x15, 0x07 }, /* Ctrl-U => Ctrl-G */ - { 0x16, 0x0b }, /* Ctrl-V => Ctrl-K */ - { 0x18, 0x11 }, /* Ctrl-X => Ctrl-Q */ - { 0x19, 0x06 }, /* Ctrl-Y => Ctrl-F */ - { 0x22, 0x5f }, /* '"' => '_' */ + { 0x1c, 0x27 }, /* 0x1c => '\'' */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ - { 0x27, 0x2d }, /* '\'' => '-' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ - { 0x2b, 0x60 }, /* '+' => '`' */ - { 0x2c, 0x77 }, /* ',' => 'w' */ { 0x2d, 0x2b }, /* '-' => '+' */ - { 0x2e, 0x76 }, /* '.' => 'v' */ - { 0x2f, 0x7a }, /* '/' => 'z' */ - { 0x3a, 0x53 }, /* ':' => 'S' */ - { 0x3b, 0x73 }, /* ';' => 's' */ - { 0x3c, 0x57 }, /* '<' => 'W' */ + { 0x2f, 0x2d }, /* '/' => '-' */ + { 0x3c, 0x3b }, /* '<' => ';' */ { 0x3d, 0x5c }, /* '=' => '\\' */ - { 0x3e, 0x56 }, /* '>' => 'V' */ - { 0x3f, 0x5a }, /* '?' => 'Z' */ + { 0x3e, 0x3a }, /* '>' => ':' */ + { 0x3f, 0x5f }, /* '?' => '_' */ { 0x40, 0x22 }, /* '@' => '"' */ - { 0x42, 0x58 }, /* 'B' => 'X' */ - { 0x43, 0x4a }, /* 'C' => 'J' */ - { 0x44, 0x45 }, /* 'D' => 'E' */ - { 0x45, 0x3a }, /* 'E' => ':' */ - { 0x46, 0x55 }, /* 'F' => 'U' */ - { 0x47, 0x49 }, /* 'G' => 'I' */ - { 0x48, 0x44 }, /* 'H' => 'D' */ - { 0x49, 0x43 }, /* 'I' => 'C' */ - { 0x4a, 0x48 }, /* 'J' => 'H' */ - { 0x4b, 0x54 }, /* 'K' => 'T' */ - { 0x4c, 0x4e }, /* 'L' => 'N' */ - { 0x4e, 0x42 }, /* 'N' => 'B' */ - { 0x4f, 0x52 }, /* 'O' => 'R' */ - { 0x50, 0x4c }, /* 'P' => 'L' */ - { 0x52, 0x50 }, /* 'R' => 'P' */ - { 0x53, 0x4f }, /* 'S' => 'O' */ - { 0x54, 0x59 }, /* 'T' => 'Y' */ - { 0x55, 0x47 }, /* 'U' => 'G' */ - { 0x56, 0x4b }, /* 'V' => 'K' */ - { 0x57, 0x3b }, /* 'W' => ';' */ - { 0x58, 0x51 }, /* 'X' => 'Q' */ - { 0x59, 0x46 }, /* 'Y' => 'F' */ - { 0x5b, 0x27 }, /* '[' => '\'' */ - { 0x5c, 0x3c }, /* '\\' => '<' */ - { 0x5d, 0x7e }, /* ']' => '~' */ + { 0x5c, 0x27 }, /* '\\' => '\'' */ { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x60, 0x7c }, /* '`' => '|' */ - { 0x62, 0x78 }, /* 'b' => 'x' */ - { 0x63, 0x6a }, /* 'c' => 'j' */ - { 0x64, 0x65 }, /* 'd' => 'e' */ - { 0x65, 0x2e }, /* 'e' => '.' */ - { 0x66, 0x75 }, /* 'f' => 'u' */ - { 0x67, 0x69 }, /* 'g' => 'i' */ - { 0x68, 0x64 }, /* 'h' => 'd' */ - { 0x69, 0x63 }, /* 'i' => 'c' */ - { 0x6a, 0x68 }, /* 'j' => 'h' */ - { 0x6b, 0x74 }, /* 'k' => 't' */ - { 0x6c, 0x6e }, /* 'l' => 'n' */ - { 0x6e, 0x62 }, /* 'n' => 'b' */ - { 0x6f, 0x72 }, /* 'o' => 'r' */ - { 0x70, 0x6c }, /* 'p' => 'l' */ - { 0x72, 0x70 }, /* 'r' => 'p' */ - { 0x73, 0x6f }, /* 's' => 'o' */ - { 0x74, 0x79 }, /* 't' => 'y' */ - { 0x75, 0x67 }, /* 'u' => 'g' */ - { 0x76, 0x6b }, /* 'v' => 'k' */ - { 0x77, 0x2c }, /* 'w' => ',' */ - { 0x78, 0x71 }, /* 'x' => 'q' */ - { 0x79, 0x66 }, /* 'y' => 'f' */ - { 0x7b, 0x2a }, /* '{' => '*' */ - { 0x7c, 0x3e }, /* '|' => '>' */ - { 0x7d, 0x5e }, /* '}' => '^' */ + { 0x7c, 0x2a }, /* '|' => '*' */ }; diff --git a/src/hci/keymap/keymap_pt.c b/src/hci/keymap/keymap_pt.c index a8e44b6a3..b993902af 100644 --- a/src/hci/keymap/keymap_pt.c +++ b/src/hci/keymap/keymap_pt.c @@ -12,18 +12,21 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "pt" keyboard mapping */ struct key_mapping pt_mapping[] __keymap = { - { 0x1c, 0x1d }, /* 0x1c => 0x1d */ - { 0x1d, 0x1b }, /* 0x1d => 0x1b */ - { 0x22, 0x5e }, /* '"' => '^' */ - { 0x27, 0x7e }, /* '\'' => '~' */ - { 0x2f, 0x3b }, /* '/' => ';' */ - { 0x3f, 0x3a }, /* '?' => ':' */ - { 0x5b, 0x27 }, /* '[' => '\'' */ - { 0x5c, 0x5d }, /* '\\' => ']' */ - { 0x5d, 0x5b }, /* ']' => '[' */ - { 0x60, 0x27 }, /* '`' => '\'' */ - { 0x7b, 0x60 }, /* '{' => '`' */ - { 0x7c, 0x7d }, /* '|' => '}' */ - { 0x7d, 0x7b }, /* '}' => '{' */ - { 0x7e, 0x22 }, /* '~' => '"' */ + { 0x1e, 0x36 }, /* 0x1e => '6' */ + { 0x26, 0x2f }, /* '&' => '/' */ + { 0x28, 0x29 }, /* '(' => ')' */ + { 0x29, 0x3d }, /* ')' => '=' */ + { 0x2a, 0x28 }, /* '*' => '(' */ + { 0x2d, 0x27 }, /* '-' => '\'' */ + { 0x2f, 0x2d }, /* '/' => '-' */ + { 0x3c, 0x3b }, /* '<' => ';' */ + { 0x3e, 0x3a }, /* '>' => ':' */ + { 0x3f, 0x5f }, /* '?' => '_' */ + { 0x40, 0x22 }, /* '@' => '"' */ + { 0x5b, 0x2b }, /* '[' => '+' */ + { 0x5e, 0x26 }, /* '^' => '&' */ + { 0x5f, 0x3f }, /* '_' => '?' */ + { 0x60, 0x5c }, /* '`' => '\\' */ + { 0x7b, 0x2a }, /* '{' => '*' */ + { 0x7e, 0x7c }, /* '~' => '|' */ }; diff --git a/src/hci/keymap/keymap_ru.c b/src/hci/keymap/keymap_ru.c index 422b6c69f..c120ffd82 100644 --- a/src/hci/keymap/keymap_ru.c +++ b/src/hci/keymap/keymap_ru.c @@ -12,4 +12,5 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "ru" keyboard mapping */ struct key_mapping ru_mapping[] __keymap = { + { 0x0d, 0x0a }, /* Ctrl-M => Ctrl-J */ }; diff --git a/src/hci/keymap/keymap_sr-latin.c b/src/hci/keymap/keymap_sr-latin.c new file mode 100644 index 000000000..9d76e8a6c --- /dev/null +++ b/src/hci/keymap/keymap_sr-latin.c @@ -0,0 +1,15 @@ +/** @file + * + * "sr-latin" keyboard mapping + * + * This file is automatically generated; do not edit + * + */ + +FILE_LICENCE ( PUBLIC_DOMAIN ); + +#include + +/** "sr-latin" keyboard mapping */ +struct key_mapping sr_latin_mapping[] __keymap = { +}; diff --git a/src/hci/keymap/keymap_sr.c b/src/hci/keymap/keymap_sr.c deleted file mode 100644 index 0552f4d90..000000000 --- a/src/hci/keymap/keymap_sr.c +++ /dev/null @@ -1,35 +0,0 @@ -/** @file - * - * "sr" keyboard mapping - * - * This file is automatically generated; do not edit - * - */ - -FILE_LICENCE ( PUBLIC_DOMAIN ); - -#include - -/** "sr" keyboard mapping */ -struct key_mapping sr_mapping[] __keymap = { - { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ - { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ - { 0x26, 0x2f }, /* '&' => '/' */ - { 0x28, 0x29 }, /* '(' => ')' */ - { 0x29, 0x3d }, /* ')' => '=' */ - { 0x2a, 0x28 }, /* '*' => '(' */ - { 0x2b, 0x2a }, /* '+' => '*' */ - { 0x2d, 0x27 }, /* '-' => '\'' */ - { 0x2f, 0x2d }, /* '/' => '-' */ - { 0x3c, 0x3b }, /* '<' => ';' */ - { 0x3d, 0x2b }, /* '=' => '+' */ - { 0x3e, 0x3a }, /* '>' => ':' */ - { 0x3f, 0x5f }, /* '?' => '_' */ - { 0x40, 0x22 }, /* '@' => '"' */ - { 0x59, 0x5a }, /* 'Y' => 'Z' */ - { 0x5a, 0x59 }, /* 'Z' => 'Y' */ - { 0x5e, 0x26 }, /* '^' => '&' */ - { 0x5f, 0x3f }, /* '_' => '?' */ - { 0x79, 0x7a }, /* 'y' => 'z' */ - { 0x7a, 0x79 }, /* 'z' => 'y' */ -}; diff --git a/src/hci/keymap/keymap_th.c b/src/hci/keymap/keymap_th.c deleted file mode 100644 index e8b44d1ed..000000000 --- a/src/hci/keymap/keymap_th.c +++ /dev/null @@ -1,15 +0,0 @@ -/** @file - * - * "th" keyboard mapping - * - * This file is automatically generated; do not edit - * - */ - -FILE_LICENCE ( PUBLIC_DOMAIN ); - -#include - -/** "th" keyboard mapping */ -struct key_mapping th_mapping[] __keymap = { -}; diff --git a/src/hci/keymap/keymap_wo.c b/src/hci/keymap/keymap_wo.c deleted file mode 100644 index b45357612..000000000 --- a/src/hci/keymap/keymap_wo.c +++ /dev/null @@ -1,55 +0,0 @@ -/** @file - * - * "wo" keyboard mapping - * - * This file is automatically generated; do not edit - * - */ - -FILE_LICENCE ( PUBLIC_DOMAIN ); - -#include - -/** "wo" keyboard mapping */ -struct key_mapping wo_mapping[] __keymap = { - { 0x01, 0x11 }, /* Ctrl-A => Ctrl-Q */ - { 0x11, 0x01 }, /* Ctrl-Q => Ctrl-A */ - { 0x17, 0x1a }, /* Ctrl-W => Ctrl-Z */ - { 0x1a, 0x17 }, /* Ctrl-Z => Ctrl-W */ - { 0x21, 0x31 }, /* '!' => '1' */ - { 0x23, 0x33 }, /* '#' => '3' */ - { 0x24, 0x34 }, /* '$' => '4' */ - { 0x25, 0x35 }, /* '%' => '5' */ - { 0x26, 0x37 }, /* '&' => '7' */ - { 0x28, 0x39 }, /* '(' => '9' */ - { 0x29, 0x30 }, /* ')' => '0' */ - { 0x2a, 0x38 }, /* '*' => '8' */ - { 0x2c, 0x3b }, /* ',' => ';' */ - { 0x2d, 0x29 }, /* '-' => ')' */ - { 0x2e, 0x3a }, /* '.' => ':' */ - { 0x2f, 0x21 }, /* '/' => '!' */ - { 0x31, 0x26 }, /* '1' => '&' */ - { 0x33, 0x22 }, /* '3' => '"' */ - { 0x34, 0x27 }, /* '4' => '\'' */ - { 0x35, 0x28 }, /* '5' => '(' */ - { 0x36, 0x2d }, /* '6' => '-' */ - { 0x38, 0x5f }, /* '8' => '_' */ - { 0x3a, 0x4d }, /* ':' => 'M' */ - { 0x3b, 0x6d }, /* ';' => 'm' */ - { 0x3c, 0x2e }, /* '<' => '.' */ - { 0x3e, 0x2f }, /* '>' => '/' */ - { 0x40, 0x32 }, /* '@' => '2' */ - { 0x41, 0x51 }, /* 'A' => 'Q' */ - { 0x4d, 0x3f }, /* 'M' => '?' */ - { 0x51, 0x41 }, /* 'Q' => 'A' */ - { 0x57, 0x5a }, /* 'W' => 'Z' */ - { 0x5a, 0x57 }, /* 'Z' => 'W' */ - { 0x5d, 0x24 }, /* ']' => '$' */ - { 0x5e, 0x36 }, /* '^' => '6' */ - { 0x61, 0x71 }, /* 'a' => 'q' */ - { 0x6d, 0x2c }, /* 'm' => ',' */ - { 0x71, 0x61 }, /* 'q' => 'a' */ - { 0x77, 0x7a }, /* 'w' => 'z' */ - { 0x7a, 0x77 }, /* 'z' => 'w' */ - { 0x7e, 0x25 }, /* '~' => '%' */ -}; diff --git a/src/util/genkeymap.pl b/src/util/genkeymap.pl deleted file mode 100755 index 7a5024bf8..000000000 --- a/src/util/genkeymap.pl +++ /dev/null @@ -1,238 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright (C) 2011 Michael Brown . -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -=head1 NAME - -genkeymap.pl - -=head1 SYNOPSIS - -genkeymap.pl [options] - -Options: - - -f,--from= Set BIOS keymap name (default "us") - -h,--help Display brief help message - -v,--verbose Increase verbosity - -q,--quiet Decrease verbosity - -=cut - -# With reference to: -# -# http://gunnarwrobel.de/wiki/Linux-and-the-keyboard.html - -use Getopt::Long; -use Pod::Usage; -use strict; -use warnings; - -use constant BIOS_KEYMAP => "us"; -use constant BKEYMAP_MAGIC => "bkeymap"; -use constant MAX_NR_KEYMAPS => 256; -use constant NR_KEYS => 128; -use constant KG_SHIFT => 0; -use constant KG_ALTGR => 1; -use constant KG_CTRL => 2; -use constant KG_ALT => 3; -use constant KG_SHIFTL => 4; -use constant KG_KANASHIFT => 4; -use constant KG_SHIFTR => 5; -use constant KG_CTRLL => 6; -use constant KG_CTRLR => 7; -use constant KG_CAPSSHIFT => 8; -use constant KT_LATIN => 0; -use constant KT_FN => 1; -use constant KT_SPEC => 2; -use constant KT_PAD => 3; -use constant KT_DEAD => 4; -use constant KT_CONS => 5; -use constant KT_CUR => 6; -use constant KT_SHIFT => 7; -use constant KT_META => 8; -use constant KT_ASCII => 9; -use constant KT_LOCK => 10; -use constant KT_LETTER => 11; -use constant KT_SLOCK => 12; -use constant KT_SPKUP => 14; - -my $verbosity = 1; -my $from_name = BIOS_KEYMAP; - -# Read named keymaps using "loadkeys -b" -# -sub read_keymaps { - my $name = shift; - my $keymaps = []; - - # Generate binary keymap - open my $pipe, "-|", "loadkeys", "-b", $name - or die "Could not load keymap \"".$name."\": $!\n"; - - # Check magic - read $pipe, my $magic, length BKEYMAP_MAGIC - or die "Could not read from \"".$name."\": $!\n"; - die "Bad magic value from \"".$name."\"\n" - unless $magic eq BKEYMAP_MAGIC; - - # Read list of included keymaps - read $pipe, my $included, MAX_NR_KEYMAPS - or die "Could not read from \"".$name."\": $!\n"; - my @included = unpack ( "C*", $included ); - die "Missing or truncated keymap list from \"".$name."\"\n" - unless @included == MAX_NR_KEYMAPS; - - # Read each keymap in turn - for ( my $keymap = 0 ; $keymap < MAX_NR_KEYMAPS ; $keymap++ ) { - if ( $included[$keymap] ) { - read $pipe, my $keysyms, ( NR_KEYS * 2 ) - or die "Could not read from \"".$name."\": $!\n"; - my @keysyms = unpack ( "S*", $keysyms ); - die "Missing or truncated keymap ".$keymap." from \"".$name."\"\n" - unless @keysyms == NR_KEYS; - push @$keymaps, \@keysyms; - } else { - push @$keymaps, undef; - } - } - - close $pipe; - return $keymaps; -} - -# Translate keysym value to ASCII -# -sub keysym_to_ascii { - my $keysym = shift; - - # Non-existent keysyms have no ASCII equivalent - return unless $keysym; - - # Sanity check - if ( $keysym & 0xf000 ) { - warn "Unexpected keysym ".sprintf ( "0x%04x", $keysym )."\n"; - return; - } - - # Extract type and value - my $type = ( $keysym >> 8 ); - my $value = ( $keysym & 0xff ); - - # Non-simple types have no ASCII equivalent - return unless ( ( $type == KT_LATIN ) || ( $type == KT_ASCII ) || - ( $type == KT_LETTER ) ); - - # High-bit-set characters cannot be generated on a US keyboard - return if $value & 0x80; - - return $value; -} - -# Translate ASCII to descriptive name -# -sub ascii_to_name { - my $ascii = shift; - - if ( $ascii == 0x5c ) { - return "'\\\\'"; - } elsif ( $ascii == 0x27 ) { - return "'\\\''"; - } elsif ( ( $ascii >= 0x20 ) && ( $ascii <= 0x7e ) ) { - return sprintf ( "'%c'", $ascii ); - } elsif ( $ascii <= 0x1a ) { - return sprintf ( "Ctrl-%c", ( 0x40 + $ascii ) ); - } else { - return sprintf ( "0x%02x", $ascii ); - } -} - -# Produce translation table between two keymaps -# -sub translate_keymaps { - my $from = shift; - my $to = shift; - my $map = {}; - - foreach my $keymap ( 0, 1 << KG_SHIFT, 1 << KG_CTRL ) { - for ( my $keycode = 0 ; $keycode < NR_KEYS ; $keycode++ ) { - my $from_ascii = keysym_to_ascii ( $from->[$keymap]->[$keycode] ) - or next; - my $to_ascii = keysym_to_ascii ( $to->[$keymap]->[$keycode] ) - or next; - my $new_map = ( ! exists $map->{$from_ascii} ); - my $update_map = - ( $new_map || ( $keycode < $map->{$from_ascii}->{keycode} ) ); - if ( ( $verbosity > 1 ) && - ( ( $from_ascii != $to_ascii ) || - ( $update_map && ! $new_map ) ) ) { - printf STDERR "In keymap %d: %s => %s%s\n", $keymap, - ascii_to_name ( $from_ascii ), ascii_to_name ( $to_ascii ), - ( $update_map ? ( $new_map ? "" : " (override)" ) - : " (ignored)" ); - } - if ( $update_map ) { - $map->{$from_ascii} = { - to_ascii => $to_ascii, - keycode => $keycode, - }; - } - } - } - return { map { $_ => $map->{$_}->{to_ascii} } keys %$map }; -} - -# Parse command-line options -Getopt::Long::Configure ( 'bundling', 'auto_abbrev' ); -GetOptions ( - 'verbose|v+' => sub { $verbosity++; }, - 'quiet|q+' => sub { $verbosity--; }, - 'from|f=s' => sub { shift; $from_name = shift; }, - 'help|h' => sub { pod2usage ( 1 ); }, -) or die "Could not parse command-line options\n"; -pod2usage ( 1 ) unless @ARGV == 1; -my $to_name = shift; - -# Read and translate keymaps -my $from = read_keymaps ( $from_name ); -my $to = read_keymaps ( $to_name ); -my $map = translate_keymaps ( $from, $to ); - -# Generate output -( my $to_name_c = $to_name ) =~ s/\W/_/g; -printf "/** \@file\n"; -printf " *\n"; -printf " * \"".$to_name."\" keyboard mapping\n"; -printf " *\n"; -printf " * This file is automatically generated; do not edit\n"; -printf " *\n"; -printf " */\n"; -printf "\n"; -printf "FILE_LICENCE ( PUBLIC_DOMAIN );\n"; -printf "\n"; -printf "#include \n"; -printf "\n"; -printf "/** \"".$to_name."\" keyboard mapping */\n"; -printf "struct key_mapping ".$to_name_c."_mapping[] __keymap = {\n"; -foreach my $from_sym ( sort { $a <=> $b } keys %$map ) { - my $to_sym = $map->{$from_sym}; - next if $from_sym == $to_sym; - printf "\t{ 0x%02x, 0x%02x },\t/* %s => %s */\n", $from_sym, $to_sym, - ascii_to_name ( $from_sym ), ascii_to_name ( $to_sym ); -} -printf "};\n"; diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py new file mode 100755 index 000000000..1bb494f83 --- /dev/null +++ b/src/util/genkeymap.py @@ -0,0 +1,346 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2022 Michael Brown . +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +"""Generate iPXE keymaps""" + +from __future__ import annotations + +import argparse +from collections import UserDict +from collections.abc import Sequence, Mapping, MutableMapping +from dataclasses import dataclass +from enum import Flag, IntEnum +import re +import subprocess +from struct import Struct +import textwrap +from typing import ClassVar, Optional + + +class KeyType(IntEnum): + """Key types""" + + LATIN = 0 + FN = 1 + SPEC = 2 + PAD = 3 + DEAD = 4 + CONS = 5 + CUR = 6 + SHIFT = 7 + META = 8 + ASCII = 9 + LOCK = 10 + LETTER = 11 + SLOCK = 12 + DEAD2 = 13 + BRL = 14 + UNKNOWN = 0xf0 + + +class KeyModifiers(Flag): + """Key modifiers""" + + NONE = 0 + SHIFT = 1 + ALTGR = 2 + CTRL = 4 + ALT = 8 + SHIFTL = 16 + SHIFTR = 32 + CTRLL = 64 + CTRLR = 128 + + @property + def complexity(self) -> int: + """Get complexity value of applied modifiers""" + if self == self.NONE: + return 0 + if self == self.SHIFT: + return 1 + if self == self.CTRL: + return 2 + return 3 + bin(self.value).count('1') + + +@dataclass +class Key: + """A single key definition""" + + keycode: int + """Opaque keycode""" + + keysym: int + """Key symbol""" + + modifiers: KeyModifiers + """Applied modifiers""" + + ASCII_TYPES: ClassVar[set[KeyType]] = {KeyType.LATIN, KeyType.ASCII, + KeyType.LETTER} + """Key types with direct ASCII values""" + + @property + def keytype(self) -> Optional[KeyType]: + """Key type""" + try: + return KeyType(self.keysym >> 8) + except ValueError: + return None + + @property + def value(self) -> int: + """Key value""" + return self.keysym & 0xff + + @property + def ascii(self) -> Optional[str]: + """ASCII character""" + if self.keytype in self.ASCII_TYPES: + value = self.value + char = chr(value) + if value and char.isascii(): + return char + return None + + +class KeyMapping(UserDict[KeyModifiers, Sequence[Key]]): + """A keyboard mapping""" + + BKEYMAP_MAGIC: ClassVar[bytes] = b'bkeymap' + """Magic signature for output produced by 'loadkeys -b'""" + + MAX_NR_KEYMAPS: ClassVar[int] = 256 + """Maximum number of keymaps produced by 'loadkeys -b'""" + + NR_KEYS: ClassVar[int] = 128 + """Number of keys in each keymap produced by 'loadkeys -b'""" + + KEY_BACKSPACE: ClassVar[int] = 14 + """Key code for backspace + + Keyboard maps seem to somewhat arbitrarily pick an interpretation + for the backspace key and its various modifiers, according to the + personal preference of the keyboard map transcriber. + """ + + KEY_NON_US: ClassVar[int] = 86 + """Key code 86 + + Key code 86 is somewhat bizarre. It doesn't physically exist on + most US keyboards. The database used by "loadkeys" defines it as + "<>", while most other databases either define it as a duplicate + "\\|" or omit it entirely. + """ + + FIXUPS: ClassVar[Mapping[str, Mapping[KeyModifiers, + Sequence[tuple[int, int]]]]] = { + 'us': { + # Redefine erroneous key 86 as generating "\\|" + KeyModifiers.NONE: [(KEY_NON_US, ord('\\'))], + KeyModifiers.SHIFT: [(KEY_NON_US, ord('|'))], + # Treat Ctrl-Backspace as producing Backspace rather than Ctrl-H + KeyModifiers.CTRL: [(KEY_BACKSPACE, 0x7f)], + }, + } + """Fixups for erroneous keymappings produced by 'loadkeys -b'""" + + @property + def unshifted(self): + """Basic unshifted key mapping""" + return self[KeyModifiers.NONE] + + @property + def shifted(self): + """Basic shifted key mapping""" + return self[KeyModifiers.SHIFT] + + @classmethod + def load(cls, name: str) -> KeyMapping: + """Load keymap using 'loadkeys -b'""" + bkeymap = subprocess.check_output(["loadkeys", "-u", "-b", name]) + if not bkeymap.startswith(cls.BKEYMAP_MAGIC): + raise ValueError("Invalid bkeymap magic signature") + bkeymap = bkeymap[len(cls.BKEYMAP_MAGIC):] + included = bkeymap[:cls.MAX_NR_KEYMAPS] + if len(included) != cls.MAX_NR_KEYMAPS: + raise ValueError("Invalid bkeymap inclusion list") + keymaps = bkeymap[cls.MAX_NR_KEYMAPS:] + keys = {} + for modifiers in map(KeyModifiers, range(cls.MAX_NR_KEYMAPS)): + if included[modifiers.value]: + fmt = Struct('<%dH' % cls.NR_KEYS) + keymap = keymaps[:fmt.size] + if len(keymap) != fmt.size: + raise ValueError("Invalid bkeymap map %#x" % + modifiers.value) + keys[modifiers] = [ + Key(modifiers=modifiers, keycode=keycode, keysym=keysym) + for keycode, keysym in enumerate(fmt.unpack(keymap)) + ] + keymaps = keymaps[len(keymap):] + if keymaps: + raise ValueError("Trailing bkeymap data") + for modifiers, fixups in cls.FIXUPS.get(name, {}).items(): + for keycode, keysym in fixups: + keys[modifiers][keycode] = Key(modifiers=modifiers, + keycode=keycode, keysym=keysym) + return cls(keys) + + @property + def inverse(self) -> MutableMapping[str, Key]: + """Construct inverse mapping from ASCII value to key""" + return { + key.ascii: key + # Give priority to simplest modifier for a given ASCII code + for modifiers in sorted(self.keys(), reverse=True, + key=lambda x: (x.complexity, x.value)) + # Give priority to lowest keycode for a given ASCII code + for key in reversed(self[modifiers]) + # Ignore keys with no ASCII value + if key.ascii + } + + +class BiosKeyMapping(KeyMapping): + """Keyboard mapping as used by the BIOS""" + + @property + def inverse(self) -> MutableMapping[str, Key]: + inverse = super().inverse + assert len(inverse) == 0x7f + assert all(x.modifiers in {KeyModifiers.NONE, KeyModifiers.SHIFT, + KeyModifiers.CTRL} + for x in inverse.values()) + return inverse + + +@dataclass +class KeyRemapping: + """A keyboard remapping""" + + name: str + """Mapping name""" + + source: KeyMapping + """Source keyboard mapping""" + + target: KeyMapping + """Target keyboard mapping""" + + @property + def ascii(self) -> MutableMapping[str, str]: + """Remapped ASCII key table""" + # Construct raw mapping from source ASCII to target ASCII + raw = {source: self.target[key.modifiers][key.keycode].ascii + for source, key in self.source.inverse.items()} + # Eliminate any null mappings, mappings that attempt to remap + # the backspace key, or identity mappings + table = {source: target for source, target in raw.items() + if target + and ord(source) != 0x7f + and ord(target) != 0x7f + and ord(source) != ord(target)} + # Recursively delete any mappings that would produce + # unreachable alphanumerics (e.g. the "il" keymap, which maps + # away the whole lower-case alphabet) + while True: + unreachable = set(table.keys()) - set(table.values()) + delete = {x for x in unreachable if x.isascii() and x.isalnum()} + if not delete: + break + table = {k: v for k, v in table.items() if k not in delete} + # Sanity check: ensure that all numerics are reachable using + # the same shift state + digits = '1234567890' + unshifted = ''.join(table.get(x, x) for x in '1234567890') + shifted = ''.join(table.get(x, x) for x in '!@#$%^&*()') + if digits not in (shifted, unshifted): + raise ValueError("Inconsistent numeric remapping %s / %s" % + (unshifted, shifted)) + return dict(sorted(table.items())) + + @property + def cname(self) -> str: + """C variable name""" + return re.sub(r'\W', '_', self.name) + "_mapping" + + @staticmethod + def ascii_name(char: str) -> str: + """ASCII character name""" + if char == '\\': + name = "'\\\\'" + elif char == '\'': + name = "'\\\''" + elif char.isprintable(): + name = "'%s'" % char + elif ord(char) <= 0x1a: + name = "Ctrl-%c" % (ord(char) + 0x40) + else: + name = "0x%02x" % ord(char) + return name + + @property + def code(self) -> str: + """Generated source code""" + code = textwrap.dedent(f""" + /** @file + * + * "{self.name}" keyboard mapping + * + * This file is automatically generated; do not edit + * + */ + + FILE_LICENCE ( PUBLIC_DOMAIN ); + + #include + + /** "{self.name}" keyboard mapping */ + struct key_mapping {self.cname}[] __keymap = {{ + """).lstrip() + ''.join( + '\t{ 0x%02x, 0x%02x },\t/* %s => %s */\n' % ( + ord(source), ord(target), + self.ascii_name(source), self.ascii_name(target) + ) + for source, target in self.ascii.items() + ) + textwrap.dedent(""" + }; + """).strip() + return code + + +if __name__ == '__main__': + + # Parse command-line arguments + parser = argparse.ArgumentParser(description="Generate iPXE keymaps") + parser.add_argument('--verbose', '-v', action='count', default=0, + help="Increase verbosity") + parser.add_argument('layout', help="Target keyboard layout") + args = parser.parse_args() + + # Load source and target keymaps + source = BiosKeyMapping.load('us') + target = KeyMapping.load(args.layout) + + # Construct remapping + remap = KeyRemapping(name=args.layout, source=source, target=target) + + # Output generated code + print(remap.code) -- cgit v1.2.3-55-g7522 From 0bbd8967830097b9141945ba960e90339c230ccb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 9 Feb 2022 15:43:42 +0000 Subject: [console] Handle remapping of scancode 86 The key with scancode 86 appears in the position between left shift and Z on a US keyboard, where it typically fails to exist entirely. Most US keyboard maps define this nonexistent key as generating "\|", with the notable exception of "loadkeys" which instead reports it as generating "<>". Both of these mapping choices duplicate keys that exist elsewhere in the map, which causes problems for our ASCII-based remapping mechanism. Work around these quirks by treating the key as generating "\|" with the high bit set, and making it subject to remapping. Where the BIOS generates "\|" as expected, this allows us to remap to the correct ASCII value. Signed-off-by: Michael Brown --- src/arch/x86/interface/pcbios/bios_console.c | 9 ++++++++ src/core/keymap.c | 3 +++ src/drivers/usb/usbkbd.c | 8 ++++++- src/drivers/usb/usbkbd.h | 1 + src/hci/keymap/keymap_al.c | 2 ++ src/hci/keymap/keymap_az.c | 2 ++ src/hci/keymap/keymap_by.c | 2 ++ src/hci/keymap/keymap_de.c | 2 ++ src/hci/keymap/keymap_dk.c | 2 ++ src/hci/keymap/keymap_es.c | 2 ++ src/hci/keymap/keymap_et.c | 2 ++ src/hci/keymap/keymap_fi.c | 2 ++ src/hci/keymap/keymap_fr.c | 2 ++ src/hci/keymap/keymap_gr.c | 2 ++ src/hci/keymap/keymap_il.c | 2 ++ src/hci/keymap/keymap_it.c | 2 ++ src/hci/keymap/keymap_mk.c | 2 ++ src/hci/keymap/keymap_nl.c | 2 ++ src/hci/keymap/keymap_no-latin1.c | 2 ++ src/hci/keymap/keymap_no.c | 2 ++ src/hci/keymap/keymap_pl.c | 2 ++ src/hci/keymap/keymap_pt.c | 2 ++ src/hci/keymap/keymap_ru.c | 2 ++ src/hci/keymap/keymap_sg.c | 2 ++ src/hci/keymap/keymap_sr-latin.c | 2 ++ src/hci/keymap/keymap_ua.c | 2 ++ src/include/ipxe/keymap.h | 3 +++ src/util/genkeymap.py | 31 +++++++++++++++++++++++----- 28 files changed, 93 insertions(+), 6 deletions(-) (limited to 'src/util') diff --git a/src/arch/x86/interface/pcbios/bios_console.c b/src/arch/x86/interface/pcbios/bios_console.c index 443513e9e..438a01d07 100644 --- a/src/arch/x86/interface/pcbios/bios_console.c +++ b/src/arch/x86/interface/pcbios/bios_console.c @@ -68,6 +68,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); */ #define SCANCODE_RSHIFT 0x36 +/** Scancode for the "non-US \ and |" key + * + * This is the key that appears between Left Shift and Z on non-US + * keyboards. + */ +#define SCANCODE_NON_US 0x56 + /* Set default console usage if applicable */ #if ! ( defined ( CONSOLE_PCBIOS ) && CONSOLE_EXPLICIT ( CONSOLE_PCBIOS ) ) #undef CONSOLE_PCBIOS @@ -383,6 +390,8 @@ static int bios_getchar ( void ) { if ( character && ( character < 0x80 ) ) { if ( scancode < SCANCODE_RSHIFT ) { return key_remap ( character ); + } else if ( scancode == SCANCODE_NON_US ) { + return key_remap ( character | KEYMAP_PSEUDO ); } else { return character; } diff --git a/src/core/keymap.c b/src/core/keymap.c index a6707a2ce..5054e4769 100644 --- a/src/core/keymap.c +++ b/src/core/keymap.c @@ -48,5 +48,8 @@ unsigned int key_remap ( unsigned int character ) { } } + /* Clear pseudo key flag */ + character &= ~KEYMAP_PSEUDO; + return character; } diff --git a/src/drivers/usb/usbkbd.c b/src/drivers/usb/usbkbd.c index ba4b2d4d7..6954cd69b 100644 --- a/src/drivers/usb/usbkbd.c +++ b/src/drivers/usb/usbkbd.c @@ -114,13 +114,19 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers, }; key = keypad[ keycode - USBKBD_KEY_PAD_1 ]; }; + } else if ( keycode == USBKBD_KEY_NON_US ) { + /* Non-US \ and | */ + key = ( ( modifiers & USBKBD_SHIFT ) ? + ( KEYMAP_PSEUDO | '|' ) : ( KEYMAP_PSEUDO | '\\' ) ); } else { key = 0; } /* Remap key if applicable */ - if ( keycode < USBKBD_KEY_CAPS_LOCK ) + if ( ( keycode < USBKBD_KEY_CAPS_LOCK ) || + ( keycode == USBKBD_KEY_NON_US ) ) { key = key_remap ( key ); + } /* Handle upper/lower case and Ctrl- */ if ( islower ( key ) ) { diff --git a/src/drivers/usb/usbkbd.h b/src/drivers/usb/usbkbd.h index cedebfe71..1a3fea1ba 100644 --- a/src/drivers/usb/usbkbd.h +++ b/src/drivers/usb/usbkbd.h @@ -75,6 +75,7 @@ enum usb_keycode { USBKBD_KEY_PAD_ENTER = 0x58, USBKBD_KEY_PAD_1 = 0x59, USBKBD_KEY_PAD_DOT = 0x63, + USBKBD_KEY_NON_US = 0x64, }; /** USB keyboard LEDs */ diff --git a/src/hci/keymap/keymap_al.c b/src/hci/keymap/keymap_al.c index e4418361b..6b4663489 100644 --- a/src/hci/keymap/keymap_al.c +++ b/src/hci/keymap/keymap_al.c @@ -30,4 +30,6 @@ struct key_mapping al_mapping[] __keymap = { { 0x7c, 0x7d }, /* '|' => '}' */ { 0x7d, 0x27 }, /* '}' => '\'' */ { 0x7e, 0x7c }, /* '~' => '|' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_az.c b/src/hci/keymap/keymap_az.c index 525ab2336..91a243460 100644 --- a/src/hci/keymap/keymap_az.c +++ b/src/hci/keymap/keymap_az.c @@ -21,4 +21,6 @@ struct key_mapping az_mapping[] __keymap = { { 0x40, 0x22 }, /* '@' => '"' */ { 0x5e, 0x3a }, /* '^' => ':' */ { 0x7c, 0x2f }, /* '|' => '/' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_by.c b/src/hci/keymap/keymap_by.c index 514d0b532..43fb746bf 100644 --- a/src/hci/keymap/keymap_by.c +++ b/src/hci/keymap/keymap_by.c @@ -12,4 +12,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "by" keyboard mapping */ struct key_mapping by_mapping[] __keymap = { + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_de.c b/src/hci/keymap/keymap_de.c index 2559e1538..85574d487 100644 --- a/src/hci/keymap/keymap_de.c +++ b/src/hci/keymap/keymap_de.c @@ -36,4 +36,6 @@ struct key_mapping de_mapping[] __keymap = { { 0x7a, 0x79 }, /* 'z' => 'y' */ { 0x7c, 0x27 }, /* '|' => '\'' */ { 0x7d, 0x2a }, /* '}' => '*' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_dk.c b/src/hci/keymap/keymap_dk.c index 05110dc89..4e1d5a739 100644 --- a/src/hci/keymap/keymap_dk.c +++ b/src/hci/keymap/keymap_dk.c @@ -28,4 +28,6 @@ struct key_mapping dk_mapping[] __keymap = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7c, 0x2a }, /* '|' => '*' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_es.c b/src/hci/keymap/keymap_es.c index 51dedfff7..91327ea51 100644 --- a/src/hci/keymap/keymap_es.c +++ b/src/hci/keymap/keymap_es.c @@ -28,4 +28,6 @@ struct key_mapping es_mapping[] __keymap = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7d, 0x2a }, /* '}' => '*' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_et.c b/src/hci/keymap/keymap_et.c index dd0f879b1..493ec93d4 100644 --- a/src/hci/keymap/keymap_et.c +++ b/src/hci/keymap/keymap_et.c @@ -26,4 +26,6 @@ struct key_mapping et_mapping[] __keymap = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7c, 0x2a }, /* '|' => '*' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_fi.c b/src/hci/keymap/keymap_fi.c index c489bf0e5..18f48d47e 100644 --- a/src/hci/keymap/keymap_fi.c +++ b/src/hci/keymap/keymap_fi.c @@ -26,4 +26,6 @@ struct key_mapping fi_mapping[] __keymap = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7c, 0x2a }, /* '|' => '*' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_fr.c b/src/hci/keymap/keymap_fr.c index 8f3b4999d..808cd7945 100644 --- a/src/hci/keymap/keymap_fr.c +++ b/src/hci/keymap/keymap_fr.c @@ -57,4 +57,6 @@ struct key_mapping fr_mapping[] __keymap = { { 0x71, 0x61 }, /* 'q' => 'a' */ { 0x77, 0x7a }, /* 'w' => 'z' */ { 0x7a, 0x77 }, /* 'z' => 'w' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_gr.c b/src/hci/keymap/keymap_gr.c index 42b6418e8..b48142e5e 100644 --- a/src/hci/keymap/keymap_gr.c +++ b/src/hci/keymap/keymap_gr.c @@ -12,4 +12,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "gr" keyboard mapping */ struct key_mapping gr_mapping[] __keymap = { + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_il.c b/src/hci/keymap/keymap_il.c index f631f7ac9..78e7fa970 100644 --- a/src/hci/keymap/keymap_il.c +++ b/src/hci/keymap/keymap_il.c @@ -24,4 +24,6 @@ struct key_mapping il_mapping[] __keymap = { { 0x60, 0x3b }, /* '`' => ';' */ { 0x7b, 0x7d }, /* '{' => '}' */ { 0x7d, 0x7b }, /* '}' => '{' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_it.c b/src/hci/keymap/keymap_it.c index d96102c9e..5a8e2b38d 100644 --- a/src/hci/keymap/keymap_it.c +++ b/src/hci/keymap/keymap_it.c @@ -30,4 +30,6 @@ struct key_mapping it_mapping[] __keymap = { { 0x60, 0x5c }, /* '`' => '\\' */ { 0x7d, 0x2a }, /* '}' => '*' */ { 0x7e, 0x7c }, /* '~' => '|' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_mk.c b/src/hci/keymap/keymap_mk.c index 8f5060778..9f2cff78b 100644 --- a/src/hci/keymap/keymap_mk.c +++ b/src/hci/keymap/keymap_mk.c @@ -12,4 +12,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "mk" keyboard mapping */ struct key_mapping mk_mapping[] __keymap = { + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_nl.c b/src/hci/keymap/keymap_nl.c index 2a0fbbcbd..d248fc8ae 100644 --- a/src/hci/keymap/keymap_nl.c +++ b/src/hci/keymap/keymap_nl.c @@ -33,4 +33,6 @@ struct key_mapping nl_mapping[] __keymap = { { 0x60, 0x40 }, /* '`' => '@' */ { 0x7c, 0x3e }, /* '|' => '>' */ { 0x7d, 0x7c }, /* '}' => '|' */ + { 0xdc, 0x5d }, /* Pseudo-'\\' => ']' */ + { 0xfc, 0x5b }, /* Pseudo-'|' => '[' */ }; diff --git a/src/hci/keymap/keymap_no-latin1.c b/src/hci/keymap/keymap_no-latin1.c index 655e4cef7..d5a721a90 100644 --- a/src/hci/keymap/keymap_no-latin1.c +++ b/src/hci/keymap/keymap_no-latin1.c @@ -32,4 +32,6 @@ struct key_mapping no_latin1_mapping[] __keymap = { { 0x60, 0x7c }, /* '`' => '|' */ { 0x7c, 0x2a }, /* '|' => '*' */ { 0x7d, 0x5e }, /* '}' => '^' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_no.c b/src/hci/keymap/keymap_no.c index 7a2df7c5a..b6190da4a 100644 --- a/src/hci/keymap/keymap_no.c +++ b/src/hci/keymap/keymap_no.c @@ -30,4 +30,6 @@ struct key_mapping no_mapping[] __keymap = { { 0x5f, 0x3f }, /* '_' => '?' */ { 0x60, 0x7c }, /* '`' => '|' */ { 0x7c, 0x2a }, /* '|' => '*' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_pl.c b/src/hci/keymap/keymap_pl.c index 51822e072..224fbde28 100644 --- a/src/hci/keymap/keymap_pl.c +++ b/src/hci/keymap/keymap_pl.c @@ -12,4 +12,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "pl" keyboard mapping */ struct key_mapping pl_mapping[] __keymap = { + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_pt.c b/src/hci/keymap/keymap_pt.c index b993902af..6d850fee8 100644 --- a/src/hci/keymap/keymap_pt.c +++ b/src/hci/keymap/keymap_pt.c @@ -29,4 +29,6 @@ struct key_mapping pt_mapping[] __keymap = { { 0x60, 0x5c }, /* '`' => '\\' */ { 0x7b, 0x2a }, /* '{' => '*' */ { 0x7e, 0x7c }, /* '~' => '|' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_ru.c b/src/hci/keymap/keymap_ru.c index c120ffd82..f7611c30a 100644 --- a/src/hci/keymap/keymap_ru.c +++ b/src/hci/keymap/keymap_ru.c @@ -13,4 +13,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "ru" keyboard mapping */ struct key_mapping ru_mapping[] __keymap = { { 0x0d, 0x0a }, /* Ctrl-M => Ctrl-J */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_sg.c b/src/hci/keymap/keymap_sg.c index 0b0820929..9a515c745 100644 --- a/src/hci/keymap/keymap_sg.c +++ b/src/hci/keymap/keymap_sg.c @@ -38,4 +38,6 @@ struct key_mapping sg_mapping[] __keymap = { { 0x7a, 0x79 }, /* 'z' => 'y' */ { 0x7c, 0x24 }, /* '|' => '$' */ { 0x7d, 0x21 }, /* '}' => '!' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_sr-latin.c b/src/hci/keymap/keymap_sr-latin.c index 9d76e8a6c..1d4588733 100644 --- a/src/hci/keymap/keymap_sr-latin.c +++ b/src/hci/keymap/keymap_sr-latin.c @@ -12,4 +12,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "sr-latin" keyboard mapping */ struct key_mapping sr_latin_mapping[] __keymap = { + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/hci/keymap/keymap_ua.c b/src/hci/keymap/keymap_ua.c index 1106a8b28..50f2e184d 100644 --- a/src/hci/keymap/keymap_ua.c +++ b/src/hci/keymap/keymap_ua.c @@ -12,4 +12,6 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "ua" keyboard mapping */ struct key_mapping ua_mapping[] __keymap = { + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ }; diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h index 62b3bb131..93c9e7314 100644 --- a/src/include/ipxe/keymap.h +++ b/src/include/ipxe/keymap.h @@ -27,6 +27,9 @@ struct key_mapping { /** Define a keyboard mapping */ #define __keymap __table_entry ( KEYMAP, 01 ) +/** Pseudo key flag */ +#define KEYMAP_PSEUDO 0x80 + extern unsigned int key_remap ( unsigned int character ); #endif /* _IPXE_KEYMAP_H */ diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index 1bb494f83..081e314cc 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -219,12 +219,28 @@ class KeyMapping(UserDict[KeyModifiers, Sequence[Key]]): class BiosKeyMapping(KeyMapping): - """Keyboard mapping as used by the BIOS""" + """Keyboard mapping as used by the BIOS + + To allow for remappings of the somewhat interesting key 86, we + arrange for our keyboard drivers to generate this key as "\\|" + with the high bit set. + """ + + KEY_PSEUDO: ClassVar[int] = 0x80 + """Flag used to indicate a fake ASCII value""" + + KEY_NON_US_UNSHIFTED: ClassVar[str] = chr(KEY_PSEUDO | ord('\\')) + """Fake ASCII value generated for unshifted key code 86""" + + KEY_NON_US_SHIFTED: ClassVar[str] = chr(KEY_PSEUDO | ord('|')) + """Fake ASCII value generated for shifted key code 86""" @property def inverse(self) -> MutableMapping[str, Key]: inverse = super().inverse assert len(inverse) == 0x7f + inverse[self.KEY_NON_US_UNSHIFTED] = self.unshifted[self.KEY_NON_US] + inverse[self.KEY_NON_US_SHIFTED] = self.shifted[self.KEY_NON_US] assert all(x.modifiers in {KeyModifiers.NONE, KeyModifiers.SHIFT, KeyModifiers.CTRL} for x in inverse.values()) @@ -251,12 +267,13 @@ class KeyRemapping: raw = {source: self.target[key.modifiers][key.keycode].ascii for source, key in self.source.inverse.items()} # Eliminate any null mappings, mappings that attempt to remap - # the backspace key, or identity mappings + # the backspace key, or mappings that would become identity + # mappings after clearing the high bit table = {source: target for source, target in raw.items() if target and ord(source) != 0x7f and ord(target) != 0x7f - and ord(source) != ord(target)} + and ord(source) & ~BiosKeyMapping.KEY_PSEUDO != ord(target)} # Recursively delete any mappings that would produce # unreachable alphanumerics (e.g. the "il" keymap, which maps # away the whole lower-case alphabet) @@ -281,13 +298,17 @@ class KeyRemapping: """C variable name""" return re.sub(r'\W', '_', self.name) + "_mapping" - @staticmethod - def ascii_name(char: str) -> str: + @classmethod + def ascii_name(cls, char: str) -> str: """ASCII character name""" if char == '\\': name = "'\\\\'" elif char == '\'': name = "'\\\''" + elif ord(char) & BiosKeyMapping.KEY_PSEUDO: + name = "Pseudo-%s" % cls.ascii_name( + chr(ord(char) & ~BiosKeyMapping.KEY_PSEUDO) + ) elif char.isprintable(): name = "'%s'" % char elif ord(char) <= 0x1a: -- cgit v1.2.3-55-g7522 From 871dd236d4aff66e871c25addcf522fe75a4ccd7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 14 Feb 2022 13:22:48 +0000 Subject: [console] Allow for named keyboard mappings Separate the concept of a keyboard mapping from a list of remapped keys, to allow for the possibility of supporting multiple keyboard mappings at runtime. Signed-off-by: Michael Brown --- src/core/keymap.c | 14 ++-- src/hci/keymap/keymap_al.c | 11 ++- src/hci/keymap/keymap_az.c | 11 ++- src/hci/keymap/keymap_by.c | 11 ++- src/hci/keymap/keymap_cf.c | 11 ++- src/hci/keymap/keymap_cz.c | 11 ++- src/hci/keymap/keymap_de.c | 11 ++- src/hci/keymap/keymap_dk.c | 11 ++- src/hci/keymap/keymap_es.c | 11 ++- src/hci/keymap/keymap_et.c | 11 ++- src/hci/keymap/keymap_fi.c | 11 ++- src/hci/keymap/keymap_fr.c | 11 ++- src/hci/keymap/keymap_gr.c | 11 ++- src/hci/keymap/keymap_hu.c | 11 ++- src/hci/keymap/keymap_il.c | 11 ++- src/hci/keymap/keymap_it.c | 11 ++- src/hci/keymap/keymap_lt.c | 11 ++- src/hci/keymap/keymap_mk.c | 11 ++- src/hci/keymap/keymap_mt.c | 11 ++- src/hci/keymap/keymap_nl.c | 11 ++- src/hci/keymap/keymap_no-latin1.c | 11 ++- src/hci/keymap/keymap_no.c | 11 ++- src/hci/keymap/keymap_pl.c | 11 ++- src/hci/keymap/keymap_pt.c | 11 ++- src/hci/keymap/keymap_ro.c | 11 ++- src/hci/keymap/keymap_ru.c | 11 ++- src/hci/keymap/keymap_sg.c | 11 ++- src/hci/keymap/keymap_sr-latin.c | 11 ++- src/hci/keymap/keymap_ua.c | 11 ++- src/hci/keymap/keymap_uk.c | 11 ++- src/hci/keymap/keymap_us.c | 11 ++- src/include/ipxe/keymap.h | 19 +++++- src/util/genkeymap.py | 140 +++++++++++++++++++++----------------- 33 files changed, 373 insertions(+), 130 deletions(-) (limited to 'src/util') diff --git a/src/core/keymap.c b/src/core/keymap.c index 5054e4769..c0953967a 100644 --- a/src/core/keymap.c +++ b/src/core/keymap.c @@ -31,6 +31,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * */ +/** Default keyboard mapping */ +static TABLE_START ( keymap_start, KEYMAP ); + +/** Current keyboard mapping */ +static struct keymap *keymap = keymap_start; + /** * Remap a key * @@ -38,12 +44,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret character Mapped character */ unsigned int key_remap ( unsigned int character ) { - struct key_mapping *mapping; + struct keymap_key *key; /* Remap via table */ - for_each_table_entry ( mapping, KEYMAP ) { - if ( mapping->from == character ) { - character = mapping->to; + for ( key = keymap->basic ; key->from ; key++ ) { + if ( key->from == character ) { + character = key->to; break; } } diff --git a/src/hci/keymap/keymap_al.c b/src/hci/keymap/keymap_al.c index 6b4663489..a3df385a9 100644 --- a/src/hci/keymap/keymap_al.c +++ b/src/hci/keymap/keymap_al.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "al" keyboard mapping */ -struct key_mapping al_mapping[] __keymap = { +/** "al" basic remapping */ +static struct keymap_key al_basic[] = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ { 0x1c, 0x1d }, /* 0x1c => 0x1d */ @@ -32,4 +32,11 @@ struct key_mapping al_mapping[] __keymap = { { 0x7e, 0x7c }, /* '~' => '|' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "al" keyboard map */ +struct keymap al_keymap __keymap = { + .name = "al", + .basic = al_basic, }; diff --git a/src/hci/keymap/keymap_az.c b/src/hci/keymap/keymap_az.c index 91a243460..7b382ca8b 100644 --- a/src/hci/keymap/keymap_az.c +++ b/src/hci/keymap/keymap_az.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "az" keyboard mapping */ -struct key_mapping az_mapping[] __keymap = { +/** "az" basic remapping */ +static struct keymap_key az_basic[] = { { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x24, 0x3b }, /* '$' => ';' */ { 0x26, 0x3f }, /* '&' => '?' */ @@ -23,4 +23,11 @@ struct key_mapping az_mapping[] __keymap = { { 0x7c, 0x2f }, /* '|' => '/' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "az" keyboard map */ +struct keymap az_keymap __keymap = { + .name = "az", + .basic = az_basic, }; diff --git a/src/hci/keymap/keymap_by.c b/src/hci/keymap/keymap_by.c index 43fb746bf..4127609e3 100644 --- a/src/hci/keymap/keymap_by.c +++ b/src/hci/keymap/keymap_by.c @@ -10,8 +10,15 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "by" keyboard mapping */ -struct key_mapping by_mapping[] __keymap = { +/** "by" basic remapping */ +static struct keymap_key by_basic[] = { { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "by" keyboard map */ +struct keymap by_keymap __keymap = { + .name = "by", + .basic = by_basic, }; diff --git a/src/hci/keymap/keymap_cf.c b/src/hci/keymap/keymap_cf.c index d7e63b9b1..0bbe89659 100644 --- a/src/hci/keymap/keymap_cf.c +++ b/src/hci/keymap/keymap_cf.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "cf" keyboard mapping */ -struct key_mapping cf_mapping[] __keymap = { +/** "cf" basic remapping */ +static struct keymap_key cf_basic[] = { { 0x23, 0x2f }, /* '#' => '/' */ { 0x3c, 0x27 }, /* '<' => '\'' */ { 0x3e, 0x2e }, /* '>' => '.' */ @@ -21,4 +21,11 @@ struct key_mapping cf_mapping[] __keymap = { { 0x60, 0x23 }, /* '`' => '#' */ { 0x7c, 0x3e }, /* '|' => '>' */ { 0x7e, 0x7c }, /* '~' => '|' */ + { 0, 0 } +}; + +/** "cf" keyboard map */ +struct keymap cf_keymap __keymap = { + .name = "cf", + .basic = cf_basic, }; diff --git a/src/hci/keymap/keymap_cz.c b/src/hci/keymap/keymap_cz.c index 2b4a21592..8655d5b68 100644 --- a/src/hci/keymap/keymap_cz.c +++ b/src/hci/keymap/keymap_cz.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "cz" keyboard mapping */ -struct key_mapping cz_mapping[] __keymap = { +/** "cz" basic remapping */ +static struct keymap_key cz_basic[] = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ { 0x1f, 0x1c }, /* 0x1f => 0x1c */ @@ -43,4 +43,11 @@ struct key_mapping cz_mapping[] __keymap = { { 0x7b, 0x2f }, /* '{' => '/' */ { 0x7c, 0x27 }, /* '|' => '\'' */ { 0x7d, 0x28 }, /* '}' => '(' */ + { 0, 0 } +}; + +/** "cz" keyboard map */ +struct keymap cz_keymap __keymap = { + .name = "cz", + .basic = cz_basic, }; diff --git a/src/hci/keymap/keymap_de.c b/src/hci/keymap/keymap_de.c index 85574d487..4d23c2e60 100644 --- a/src/hci/keymap/keymap_de.c +++ b/src/hci/keymap/keymap_de.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "de" keyboard mapping */ -struct key_mapping de_mapping[] __keymap = { +/** "de" basic remapping */ +static struct keymap_key de_basic[] = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ { 0x1c, 0x23 }, /* 0x1c => '#' */ @@ -38,4 +38,11 @@ struct key_mapping de_mapping[] __keymap = { { 0x7d, 0x2a }, /* '}' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "de" keyboard map */ +struct keymap de_keymap __keymap = { + .name = "de", + .basic = de_basic, }; diff --git a/src/hci/keymap/keymap_dk.c b/src/hci/keymap/keymap_dk.c index 4e1d5a739..100246bf5 100644 --- a/src/hci/keymap/keymap_dk.c +++ b/src/hci/keymap/keymap_dk.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "dk" keyboard mapping */ -struct key_mapping dk_mapping[] __keymap = { +/** "dk" basic remapping */ +static struct keymap_key dk_basic[] = { { 0x1c, 0x27 }, /* 0x1c => '\'' */ { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ @@ -30,4 +30,11 @@ struct key_mapping dk_mapping[] __keymap = { { 0x7c, 0x2a }, /* '|' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "dk" keyboard map */ +struct keymap dk_keymap __keymap = { + .name = "dk", + .basic = dk_basic, }; diff --git a/src/hci/keymap/keymap_es.c b/src/hci/keymap/keymap_es.c index 91327ea51..2f4b86c47 100644 --- a/src/hci/keymap/keymap_es.c +++ b/src/hci/keymap/keymap_es.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "es" keyboard mapping */ -struct key_mapping es_mapping[] __keymap = { +/** "es" basic remapping */ +static struct keymap_key es_basic[] = { { 0x1c, 0x1d }, /* 0x1c => 0x1d */ { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ @@ -30,4 +30,11 @@ struct key_mapping es_mapping[] __keymap = { { 0x7d, 0x2a }, /* '}' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "es" keyboard map */ +struct keymap es_keymap __keymap = { + .name = "es", + .basic = es_basic, }; diff --git a/src/hci/keymap/keymap_et.c b/src/hci/keymap/keymap_et.c index 493ec93d4..a8bf46ebc 100644 --- a/src/hci/keymap/keymap_et.c +++ b/src/hci/keymap/keymap_et.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "et" keyboard mapping */ -struct key_mapping et_mapping[] __keymap = { +/** "et" basic remapping */ +static struct keymap_key et_basic[] = { { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ @@ -28,4 +28,11 @@ struct key_mapping et_mapping[] __keymap = { { 0x7c, 0x2a }, /* '|' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "et" keyboard map */ +struct keymap et_keymap __keymap = { + .name = "et", + .basic = et_basic, }; diff --git a/src/hci/keymap/keymap_fi.c b/src/hci/keymap/keymap_fi.c index 18f48d47e..eb75eb4dc 100644 --- a/src/hci/keymap/keymap_fi.c +++ b/src/hci/keymap/keymap_fi.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "fi" keyboard mapping */ -struct key_mapping fi_mapping[] __keymap = { +/** "fi" basic remapping */ +static struct keymap_key fi_basic[] = { { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ @@ -28,4 +28,11 @@ struct key_mapping fi_mapping[] __keymap = { { 0x7c, 0x2a }, /* '|' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "fi" keyboard map */ +struct keymap fi_keymap __keymap = { + .name = "fi", + .basic = fi_basic, }; diff --git a/src/hci/keymap/keymap_fr.c b/src/hci/keymap/keymap_fr.c index 808cd7945..523254ee5 100644 --- a/src/hci/keymap/keymap_fr.c +++ b/src/hci/keymap/keymap_fr.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "fr" keyboard mapping */ -struct key_mapping fr_mapping[] __keymap = { +/** "fr" basic remapping */ +static struct keymap_key fr_basic[] = { { 0x01, 0x11 }, /* Ctrl-A => Ctrl-Q */ { 0x11, 0x01 }, /* Ctrl-Q => Ctrl-A */ { 0x17, 0x1a }, /* Ctrl-W => Ctrl-Z */ @@ -59,4 +59,11 @@ struct key_mapping fr_mapping[] __keymap = { { 0x7a, 0x77 }, /* 'z' => 'w' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "fr" keyboard map */ +struct keymap fr_keymap __keymap = { + .name = "fr", + .basic = fr_basic, }; diff --git a/src/hci/keymap/keymap_gr.c b/src/hci/keymap/keymap_gr.c index b48142e5e..16a2a7032 100644 --- a/src/hci/keymap/keymap_gr.c +++ b/src/hci/keymap/keymap_gr.c @@ -10,8 +10,15 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "gr" keyboard mapping */ -struct key_mapping gr_mapping[] __keymap = { +/** "gr" basic remapping */ +static struct keymap_key gr_basic[] = { { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "gr" keyboard map */ +struct keymap gr_keymap __keymap = { + .name = "gr", + .basic = gr_basic, }; diff --git a/src/hci/keymap/keymap_hu.c b/src/hci/keymap/keymap_hu.c index a2eadbc62..5e407161f 100644 --- a/src/hci/keymap/keymap_hu.c +++ b/src/hci/keymap/keymap_hu.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "hu" keyboard mapping */ -struct key_mapping hu_mapping[] __keymap = { +/** "hu" basic remapping */ +static struct keymap_key hu_basic[] = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ { 0x1e, 0x36 }, /* 0x1e => '6' */ @@ -32,4 +32,11 @@ struct key_mapping hu_mapping[] __keymap = { { 0x60, 0x30 }, /* '`' => '0' */ { 0x79, 0x7a }, /* 'y' => 'z' */ { 0x7a, 0x79 }, /* 'z' => 'y' */ + { 0, 0 } +}; + +/** "hu" keyboard map */ +struct keymap hu_keymap __keymap = { + .name = "hu", + .basic = hu_basic, }; diff --git a/src/hci/keymap/keymap_il.c b/src/hci/keymap/keymap_il.c index 78e7fa970..de5e639ca 100644 --- a/src/hci/keymap/keymap_il.c +++ b/src/hci/keymap/keymap_il.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "il" keyboard mapping */ -struct key_mapping il_mapping[] __keymap = { +/** "il" basic remapping */ +static struct keymap_key il_basic[] = { { 0x1d, 0x1b }, /* 0x1d => 0x1b */ { 0x27, 0x2c }, /* '\'' => ',' */ { 0x28, 0x29 }, /* '(' => ')' */ @@ -26,4 +26,11 @@ struct key_mapping il_mapping[] __keymap = { { 0x7d, 0x7b }, /* '}' => '{' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "il" keyboard map */ +struct keymap il_keymap __keymap = { + .name = "il", + .basic = il_basic, }; diff --git a/src/hci/keymap/keymap_it.c b/src/hci/keymap/keymap_it.c index 5a8e2b38d..a4921020a 100644 --- a/src/hci/keymap/keymap_it.c +++ b/src/hci/keymap/keymap_it.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "it" keyboard mapping */ -struct key_mapping it_mapping[] __keymap = { +/** "it" basic remapping */ +static struct keymap_key it_basic[] = { { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ @@ -32,4 +32,11 @@ struct key_mapping it_mapping[] __keymap = { { 0x7e, 0x7c }, /* '~' => '|' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "it" keyboard map */ +struct keymap it_keymap __keymap = { + .name = "it", + .basic = it_basic, }; diff --git a/src/hci/keymap/keymap_lt.c b/src/hci/keymap/keymap_lt.c index 3e99d8c6c..333241d21 100644 --- a/src/hci/keymap/keymap_lt.c +++ b/src/hci/keymap/keymap_lt.c @@ -10,6 +10,13 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "lt" keyboard mapping */ -struct key_mapping lt_mapping[] __keymap = { +/** "lt" basic remapping */ +static struct keymap_key lt_basic[] = { + { 0, 0 } +}; + +/** "lt" keyboard map */ +struct keymap lt_keymap __keymap = { + .name = "lt", + .basic = lt_basic, }; diff --git a/src/hci/keymap/keymap_mk.c b/src/hci/keymap/keymap_mk.c index 9f2cff78b..1656fb99c 100644 --- a/src/hci/keymap/keymap_mk.c +++ b/src/hci/keymap/keymap_mk.c @@ -10,8 +10,15 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "mk" keyboard mapping */ -struct key_mapping mk_mapping[] __keymap = { +/** "mk" basic remapping */ +static struct keymap_key mk_basic[] = { { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "mk" keyboard map */ +struct keymap mk_keymap __keymap = { + .name = "mk", + .basic = mk_basic, }; diff --git a/src/hci/keymap/keymap_mt.c b/src/hci/keymap/keymap_mt.c index dfca2ff66..ebff8506f 100644 --- a/src/hci/keymap/keymap_mt.c +++ b/src/hci/keymap/keymap_mt.c @@ -10,11 +10,18 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "mt" keyboard mapping */ -struct key_mapping mt_mapping[] __keymap = { +/** "mt" basic remapping */ +static struct keymap_key mt_basic[] = { { 0x1c, 0x1e }, /* 0x1c => 0x1e */ { 0x22, 0x40 }, /* '"' => '@' */ { 0x40, 0x22 }, /* '@' => '"' */ { 0x5c, 0x23 }, /* '\\' => '#' */ { 0x7c, 0x7e }, /* '|' => '~' */ + { 0, 0 } +}; + +/** "mt" keyboard map */ +struct keymap mt_keymap __keymap = { + .name = "mt", + .basic = mt_basic, }; diff --git a/src/hci/keymap/keymap_nl.c b/src/hci/keymap/keymap_nl.c index d248fc8ae..2172e045f 100644 --- a/src/hci/keymap/keymap_nl.c +++ b/src/hci/keymap/keymap_nl.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "nl" keyboard mapping */ -struct key_mapping nl_mapping[] __keymap = { +/** "nl" basic remapping */ +static struct keymap_key nl_basic[] = { { 0x1c, 0x3c }, /* 0x1c => '<' */ { 0x1d, 0x1c }, /* 0x1d => 0x1c */ { 0x1e, 0x36 }, /* 0x1e => '6' */ @@ -35,4 +35,11 @@ struct key_mapping nl_mapping[] __keymap = { { 0x7d, 0x7c }, /* '}' => '|' */ { 0xdc, 0x5d }, /* Pseudo-'\\' => ']' */ { 0xfc, 0x5b }, /* Pseudo-'|' => '[' */ + { 0, 0 } +}; + +/** "nl" keyboard map */ +struct keymap nl_keymap __keymap = { + .name = "nl", + .basic = nl_basic, }; diff --git a/src/hci/keymap/keymap_no-latin1.c b/src/hci/keymap/keymap_no-latin1.c index d5a721a90..65f30beae 100644 --- a/src/hci/keymap/keymap_no-latin1.c +++ b/src/hci/keymap/keymap_no-latin1.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "no-latin1" keyboard mapping */ -struct key_mapping no_latin1_mapping[] __keymap = { +/** "no-latin1" basic remapping */ +static struct keymap_key no_latin1_basic[] = { { 0x1d, 0x1e }, /* 0x1d => 0x1e */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ @@ -34,4 +34,11 @@ struct key_mapping no_latin1_mapping[] __keymap = { { 0x7d, 0x5e }, /* '}' => '^' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "no-latin1" keyboard map */ +struct keymap no_latin1_keymap __keymap = { + .name = "no-latin1", + .basic = no_latin1_basic, }; diff --git a/src/hci/keymap/keymap_no.c b/src/hci/keymap/keymap_no.c index b6190da4a..d3d06bce3 100644 --- a/src/hci/keymap/keymap_no.c +++ b/src/hci/keymap/keymap_no.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "no" keyboard mapping */ -struct key_mapping no_mapping[] __keymap = { +/** "no" basic remapping */ +static struct keymap_key no_basic[] = { { 0x1c, 0x27 }, /* 0x1c => '\'' */ { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ @@ -32,4 +32,11 @@ struct key_mapping no_mapping[] __keymap = { { 0x7c, 0x2a }, /* '|' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "no" keyboard map */ +struct keymap no_keymap __keymap = { + .name = "no", + .basic = no_basic, }; diff --git a/src/hci/keymap/keymap_pl.c b/src/hci/keymap/keymap_pl.c index 224fbde28..a23c01f2c 100644 --- a/src/hci/keymap/keymap_pl.c +++ b/src/hci/keymap/keymap_pl.c @@ -10,8 +10,15 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "pl" keyboard mapping */ -struct key_mapping pl_mapping[] __keymap = { +/** "pl" basic remapping */ +static struct keymap_key pl_basic[] = { { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "pl" keyboard map */ +struct keymap pl_keymap __keymap = { + .name = "pl", + .basic = pl_basic, }; diff --git a/src/hci/keymap/keymap_pt.c b/src/hci/keymap/keymap_pt.c index 6d850fee8..c065fd76f 100644 --- a/src/hci/keymap/keymap_pt.c +++ b/src/hci/keymap/keymap_pt.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "pt" keyboard mapping */ -struct key_mapping pt_mapping[] __keymap = { +/** "pt" basic remapping */ +static struct keymap_key pt_basic[] = { { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ @@ -31,4 +31,11 @@ struct key_mapping pt_mapping[] __keymap = { { 0x7e, 0x7c }, /* '~' => '|' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "pt" keyboard map */ +struct keymap pt_keymap __keymap = { + .name = "pt", + .basic = pt_basic, }; diff --git a/src/hci/keymap/keymap_ro.c b/src/hci/keymap/keymap_ro.c index 0eef7d534..334cf6080 100644 --- a/src/hci/keymap/keymap_ro.c +++ b/src/hci/keymap/keymap_ro.c @@ -10,6 +10,13 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "ro" keyboard mapping */ -struct key_mapping ro_mapping[] __keymap = { +/** "ro" basic remapping */ +static struct keymap_key ro_basic[] = { + { 0, 0 } +}; + +/** "ro" keyboard map */ +struct keymap ro_keymap __keymap = { + .name = "ro", + .basic = ro_basic, }; diff --git a/src/hci/keymap/keymap_ru.c b/src/hci/keymap/keymap_ru.c index f7611c30a..a08b115ed 100644 --- a/src/hci/keymap/keymap_ru.c +++ b/src/hci/keymap/keymap_ru.c @@ -10,9 +10,16 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "ru" keyboard mapping */ -struct key_mapping ru_mapping[] __keymap = { +/** "ru" basic remapping */ +static struct keymap_key ru_basic[] = { { 0x0d, 0x0a }, /* Ctrl-M => Ctrl-J */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "ru" keyboard map */ +struct keymap ru_keymap __keymap = { + .name = "ru", + .basic = ru_basic, }; diff --git a/src/hci/keymap/keymap_sg.c b/src/hci/keymap/keymap_sg.c index 9a515c745..152c5d631 100644 --- a/src/hci/keymap/keymap_sg.c +++ b/src/hci/keymap/keymap_sg.c @@ -10,8 +10,8 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "sg" keyboard mapping */ -struct key_mapping sg_mapping[] __keymap = { +/** "sg" basic remapping */ +static struct keymap_key sg_basic[] = { { 0x19, 0x1a }, /* Ctrl-Y => Ctrl-Z */ { 0x1a, 0x19 }, /* Ctrl-Z => Ctrl-Y */ { 0x21, 0x2b }, /* '!' => '+' */ @@ -40,4 +40,11 @@ struct key_mapping sg_mapping[] __keymap = { { 0x7d, 0x21 }, /* '}' => '!' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "sg" keyboard map */ +struct keymap sg_keymap __keymap = { + .name = "sg", + .basic = sg_basic, }; diff --git a/src/hci/keymap/keymap_sr-latin.c b/src/hci/keymap/keymap_sr-latin.c index 1d4588733..ec5efdc89 100644 --- a/src/hci/keymap/keymap_sr-latin.c +++ b/src/hci/keymap/keymap_sr-latin.c @@ -10,8 +10,15 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "sr-latin" keyboard mapping */ -struct key_mapping sr_latin_mapping[] __keymap = { +/** "sr-latin" basic remapping */ +static struct keymap_key sr_latin_basic[] = { { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "sr-latin" keyboard map */ +struct keymap sr_latin_keymap __keymap = { + .name = "sr-latin", + .basic = sr_latin_basic, }; diff --git a/src/hci/keymap/keymap_ua.c b/src/hci/keymap/keymap_ua.c index 50f2e184d..b4199cdad 100644 --- a/src/hci/keymap/keymap_ua.c +++ b/src/hci/keymap/keymap_ua.c @@ -10,8 +10,15 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "ua" keyboard mapping */ -struct key_mapping ua_mapping[] __keymap = { +/** "ua" basic remapping */ +static struct keymap_key ua_basic[] = { { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ + { 0, 0 } +}; + +/** "ua" keyboard map */ +struct keymap ua_keymap __keymap = { + .name = "ua", + .basic = ua_basic, }; diff --git a/src/hci/keymap/keymap_uk.c b/src/hci/keymap/keymap_uk.c index 6550d8ee5..156b42dff 100644 --- a/src/hci/keymap/keymap_uk.c +++ b/src/hci/keymap/keymap_uk.c @@ -10,10 +10,17 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "uk" keyboard mapping */ -struct key_mapping uk_mapping[] __keymap = { +/** "uk" basic remapping */ +static struct keymap_key uk_basic[] = { { 0x22, 0x40 }, /* '"' => '@' */ { 0x40, 0x22 }, /* '@' => '"' */ { 0x5c, 0x23 }, /* '\\' => '#' */ { 0x7c, 0x7e }, /* '|' => '~' */ + { 0, 0 } +}; + +/** "uk" keyboard map */ +struct keymap uk_keymap __keymap = { + .name = "uk", + .basic = uk_basic, }; diff --git a/src/hci/keymap/keymap_us.c b/src/hci/keymap/keymap_us.c index 73d01a30a..5d78f80a2 100644 --- a/src/hci/keymap/keymap_us.c +++ b/src/hci/keymap/keymap_us.c @@ -10,6 +10,13 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); #include -/** "us" keyboard mapping */ -struct key_mapping us_mapping[] __keymap = { +/** "us" basic remapping */ +static struct keymap_key us_basic[] = { + { 0, 0 } +}; + +/** "us" keyboard map */ +struct keymap us_keymap __keymap = { + .name = "us", + .basic = us_basic, }; diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h index 93c9e7314..a64ab9cd4 100644 --- a/src/include/ipxe/keymap.h +++ b/src/include/ipxe/keymap.h @@ -13,16 +13,29 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -/** A keyboard mapping */ -struct key_mapping { +/** A remapped key + * + * Represents a mapping from an ASCII character (as interpreted from a + * keyboard scancode by the US-only keyboard driver provided by the + * BIOS) to the appropriate ASCII value for the keyboard layout. + */ +struct keymap_key { /** Character read from keyboard */ uint8_t from; /** Character to be used instead */ uint8_t to; } __attribute__ (( packed )); +/** A keyboard mapping */ +struct keymap { + /** Name */ + const char *name; + /** Basic remapping table (zero-terminated) */ + struct keymap_key *basic; +}; + /** Keyboard mapping table */ -#define KEYMAP __table ( struct key_mapping, "keymap" ) +#define KEYMAP __table ( struct keymap, "keymap" ) /** Define a keyboard mapping */ #define __keymap __table_entry ( KEYMAP, 01 ) diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index 081e314cc..d38552eb4 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -79,7 +79,7 @@ class KeyModifiers(Flag): return 3 + bin(self.value).count('1') -@dataclass +@dataclass(frozen=True) class Key: """A single key definition""" @@ -120,8 +120,8 @@ class Key: return None -class KeyMapping(UserDict[KeyModifiers, Sequence[Key]]): - """A keyboard mapping""" +class KeyLayout(UserDict[KeyModifiers, Sequence[Key]]): + """A keyboard layout""" BKEYMAP_MAGIC: ClassVar[bytes] = b'bkeymap' """Magic signature for output produced by 'loadkeys -b'""" @@ -163,16 +163,16 @@ class KeyMapping(UserDict[KeyModifiers, Sequence[Key]]): @property def unshifted(self): - """Basic unshifted key mapping""" + """Basic unshifted keyboard layout""" return self[KeyModifiers.NONE] @property def shifted(self): - """Basic shifted key mapping""" + """Basic shifted keyboard layout""" return self[KeyModifiers.SHIFT] @classmethod - def load(cls, name: str) -> KeyMapping: + def load(cls, name: str) -> KeyLayout: """Load keymap using 'loadkeys -b'""" bkeymap = subprocess.check_output(["loadkeys", "-u", "-b", name]) if not bkeymap.startswith(cls.BKEYMAP_MAGIC): @@ -181,21 +181,21 @@ class KeyMapping(UserDict[KeyModifiers, Sequence[Key]]): included = bkeymap[:cls.MAX_NR_KEYMAPS] if len(included) != cls.MAX_NR_KEYMAPS: raise ValueError("Invalid bkeymap inclusion list") - keymaps = bkeymap[cls.MAX_NR_KEYMAPS:] + bkeymap = bkeymap[cls.MAX_NR_KEYMAPS:] keys = {} for modifiers in map(KeyModifiers, range(cls.MAX_NR_KEYMAPS)): if included[modifiers.value]: fmt = Struct('<%dH' % cls.NR_KEYS) - keymap = keymaps[:fmt.size] - if len(keymap) != fmt.size: + bkeylist = bkeymap[:fmt.size] + if len(bkeylist) != fmt.size: raise ValueError("Invalid bkeymap map %#x" % modifiers.value) keys[modifiers] = [ Key(modifiers=modifiers, keycode=keycode, keysym=keysym) - for keycode, keysym in enumerate(fmt.unpack(keymap)) + for keycode, keysym in enumerate(fmt.unpack(bkeylist)) ] - keymaps = keymaps[len(keymap):] - if keymaps: + bkeymap = bkeymap[len(bkeylist):] + if bkeymap: raise ValueError("Trailing bkeymap data") for modifiers, fixups in cls.FIXUPS.get(name, {}).items(): for keycode, keysym in fixups: @@ -218,8 +218,8 @@ class KeyMapping(UserDict[KeyModifiers, Sequence[Key]]): } -class BiosKeyMapping(KeyMapping): - """Keyboard mapping as used by the BIOS +class BiosKeyLayout(KeyLayout): + """Keyboard layout as used by the BIOS To allow for remappings of the somewhat interesting key 86, we arrange for our keyboard drivers to generate this key as "\\|" @@ -247,22 +247,56 @@ class BiosKeyMapping(KeyMapping): return inverse +class KeymapKeys(UserDict[str, str]): + """An ASCII character remapping""" + + @classmethod + def ascii_name(cls, char: str) -> str: + """ASCII character name""" + if char == '\\': + name = "'\\\\'" + elif char == '\'': + name = "'\\\''" + elif ord(char) & BiosKeyLayout.KEY_PSEUDO: + name = "Pseudo-%s" % cls.ascii_name( + chr(ord(char) & ~BiosKeyLayout.KEY_PSEUDO) + ) + elif char.isprintable(): + name = "'%s'" % char + elif ord(char) <= 0x1a: + name = "Ctrl-%c" % (ord(char) + 0x40) + else: + name = "0x%02x" % ord(char) + return name + + @property + def code(self): + """Generated source code for C array""" + return '{\n' + ''.join( + '\t{ 0x%02x, 0x%02x },\t/* %s => %s */\n' % ( + ord(source), ord(target), + self.ascii_name(source), self.ascii_name(target) + ) + for source, target in self.items() + ) + '\t{ 0, 0 }\n}' + + @dataclass -class KeyRemapping: - """A keyboard remapping""" +class Keymap: + """An iPXE keyboard mapping""" name: str """Mapping name""" - source: KeyMapping - """Source keyboard mapping""" + source: KeyLayout + """Source keyboard layout""" - target: KeyMapping - """Target keyboard mapping""" + target: KeyLayout + """Target keyboard layout""" @property - def ascii(self) -> MutableMapping[str, str]: - """Remapped ASCII key table""" + def basic(self) -> KeymapKeys: + """Basic remapping table""" # Construct raw mapping from source ASCII to target ASCII raw = {source: self.target[key.modifiers][key.keycode].ascii for source, key in self.source.inverse.items()} @@ -273,7 +307,7 @@ class KeyRemapping: if target and ord(source) != 0x7f and ord(target) != 0x7f - and ord(source) & ~BiosKeyMapping.KEY_PSEUDO != ord(target)} + and ord(source) & ~BiosKeyLayout.KEY_PSEUDO != ord(target)} # Recursively delete any mappings that would produce # unreachable alphanumerics (e.g. the "il" keymap, which maps # away the whole lower-case alphabet) @@ -291,35 +325,17 @@ class KeyRemapping: if digits not in (shifted, unshifted): raise ValueError("Inconsistent numeric remapping %s / %s" % (unshifted, shifted)) - return dict(sorted(table.items())) + return KeymapKeys(dict(sorted(table.items()))) - @property - def cname(self) -> str: + def cname(self, suffix: str) -> str: """C variable name""" - return re.sub(r'\W', '_', self.name) + "_mapping" - - @classmethod - def ascii_name(cls, char: str) -> str: - """ASCII character name""" - if char == '\\': - name = "'\\\\'" - elif char == '\'': - name = "'\\\''" - elif ord(char) & BiosKeyMapping.KEY_PSEUDO: - name = "Pseudo-%s" % cls.ascii_name( - chr(ord(char) & ~BiosKeyMapping.KEY_PSEUDO) - ) - elif char.isprintable(): - name = "'%s'" % char - elif ord(char) <= 0x1a: - name = "Ctrl-%c" % (ord(char) + 0x40) - else: - name = "0x%02x" % ord(char) - return name + return re.sub(r'\W', '_', (self.name + '_' + suffix)) @property def code(self) -> str: """Generated source code""" + keymap_name = self.cname("keymap") + basic_name = self.cname("basic") code = textwrap.dedent(f""" /** @file * @@ -333,17 +349,15 @@ class KeyRemapping: #include - /** "{self.name}" keyboard mapping */ - struct key_mapping {self.cname}[] __keymap = {{ - """).lstrip() + ''.join( - '\t{ 0x%02x, 0x%02x },\t/* %s => %s */\n' % ( - ord(source), ord(target), - self.ascii_name(source), self.ascii_name(target) - ) - for source, target in self.ascii.items() - ) + textwrap.dedent(""" - }; - """).strip() + /** "{self.name}" basic remapping */ + static struct keymap_key {basic_name}[] = %s; + + /** "{self.name}" keyboard map */ + struct keymap {keymap_name} __keymap = {{ + \t.name = "{self.name}", + \t.basic = {basic_name}, + }}; + """).strip() % self.basic.code return code @@ -356,12 +370,12 @@ if __name__ == '__main__': parser.add_argument('layout', help="Target keyboard layout") args = parser.parse_args() - # Load source and target keymaps - source = BiosKeyMapping.load('us') - target = KeyMapping.load(args.layout) + # Load source and target keyboard layouts + source = BiosKeyLayout.load('us') + target = KeyLayout.load(args.layout) - # Construct remapping - remap = KeyRemapping(name=args.layout, source=source, target=target) + # Construct keyboard mapping + keymap = Keymap(name=args.layout, source=source, target=target) # Output generated code - print(remap.code) + print(keymap.code) -- cgit v1.2.3-55-g7522 From e1cedbc0d4fdb0e16818f6b722f4873a50780761 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 14 Feb 2022 13:45:59 +0000 Subject: [console] Support AltGr to access ASCII characters via remapping Several keyboard layouts define ASCII characters as accessible only via the AltGr modifier. Add support for this modifier to ensure that all ASCII characters are accessible. Experiments suggest that the BIOS console is likely to fail to generate ASCII characters when the AltGr key is pressed. Work around this limitation by accepting LShift+RShift (which will definitely produce an ASCII character) as a synonym for AltGr. Signed-off-by: Michael Brown --- src/arch/x86/include/bios.h | 4 +++ src/arch/x86/interface/pcbios/bios_console.c | 12 +++++++++ src/core/keymap.c | 5 +++- src/drivers/usb/usbkbd.c | 2 ++ src/hci/keymap/keymap_al.c | 8 ++++++ src/hci/keymap/keymap_az.c | 7 +++++ src/hci/keymap/keymap_by.c | 6 +++++ src/hci/keymap/keymap_cf.c | 9 +++++++ src/hci/keymap/keymap_cz.c | 26 ++++++++++++++++++ src/hci/keymap/keymap_de.c | 11 ++++++++ src/hci/keymap/keymap_dk.c | 9 +++++++ src/hci/keymap/keymap_es.c | 11 ++++++++ src/hci/keymap/keymap_et.c | 10 +++++++ src/hci/keymap/keymap_fi.c | 9 +++++++ src/hci/keymap/keymap_fr.c | 12 +++++++++ src/hci/keymap/keymap_gr.c | 6 +++++ src/hci/keymap/keymap_hu.c | 17 ++++++++++++ src/hci/keymap/keymap_il.c | 6 +++++ src/hci/keymap/keymap_it.c | 12 +++++++++ src/hci/keymap/keymap_lt.c | 6 +++++ src/hci/keymap/keymap_mk.c | 6 +++++ src/hci/keymap/keymap_mt.c | 7 +++++ src/hci/keymap/keymap_nl.c | 8 ++++++ src/hci/keymap/keymap_no-latin1.c | 10 +++++++ src/hci/keymap/keymap_no.c | 8 ++++++ src/hci/keymap/keymap_pl.c | 6 +++++ src/hci/keymap/keymap_pt.c | 10 +++++++ src/hci/keymap/keymap_ro.c | 6 +++++ src/hci/keymap/keymap_ru.c | 6 +++++ src/hci/keymap/keymap_sg.c | 10 +++++++ src/hci/keymap/keymap_sr-latin.c | 6 +++++ src/hci/keymap/keymap_ua.c | 6 +++++ src/hci/keymap/keymap_uk.c | 6 +++++ src/hci/keymap/keymap_us.c | 6 +++++ src/include/ipxe/keymap.h | 5 ++++ src/interface/efi/efi_console.c | 3 +++ src/util/genkeymap.py | 40 +++++++++++++++++++++++++--- 37 files changed, 332 insertions(+), 5 deletions(-) (limited to 'src/util') diff --git a/src/arch/x86/include/bios.h b/src/arch/x86/include/bios.h index 3ba8264ec..6391a4958 100644 --- a/src/arch/x86/include/bios.h +++ b/src/arch/x86/include/bios.h @@ -7,6 +7,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define BDA_EBDA 0x000e #define BDA_EQUIPMENT_WORD 0x0010 #define BDA_KB0 0x0017 +#define BDA_KB0_RSHIFT 0x01 +#define BDA_KB0_LSHIFT 0x02 #define BDA_KB0_CTRL 0x04 #define BDA_KB0_CAPSLOCK 0x040 #define BDA_FBMS 0x0013 @@ -16,5 +18,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define BDA_REBOOT_WARM 0x1234 #define BDA_NUM_DRIVES 0x0075 #define BDA_CHAR_HEIGHT 0x0085 +#define BDA_KB2 0x0096 +#define BDA_KB2_RALT 0x08 #endif /* BIOS_H */ diff --git a/src/arch/x86/interface/pcbios/bios_console.c b/src/arch/x86/interface/pcbios/bios_console.c index 2664ac8a5..0220c8564 100644 --- a/src/arch/x86/interface/pcbios/bios_console.c +++ b/src/arch/x86/interface/pcbios/bios_console.c @@ -362,6 +362,7 @@ static const char * bios_ansi_seq ( unsigned int scancode ) { static int bios_getchar ( void ) { uint16_t keypress; uint8_t kb0; + uint8_t kb2; unsigned int scancode; unsigned int character; const char *ansi_seq; @@ -387,6 +388,7 @@ static int bios_getchar ( void ) { scancode = ( keypress >> 8 ); character = ( keypress & 0xff ); get_real ( kb0, BDA_SEG, BDA_KB0 ); + get_real ( kb2, BDA_SEG, BDA_KB2 ); /* If it's a normal character, map (if applicable) and return it */ if ( character && ( character < 0x80 ) ) { @@ -405,6 +407,16 @@ static int bios_getchar ( void ) { character |= KEYMAP_CTRL; if ( kb0 & BDA_KB0_CAPSLOCK ) character |= KEYMAP_CAPSLOCK_REDO; + if ( kb2 & BDA_KB2_RALT ) + character |= KEYMAP_ALTGR; + + /* Treat LShift+RShift as AltGr since many BIOSes will + * not return ASCII characters when AltGr is pressed. + */ + if ( ( kb0 & ( BDA_KB0_LSHIFT | BDA_KB0_RSHIFT ) ) == + ( BDA_KB0_LSHIFT | BDA_KB0_RSHIFT ) ) { + character |= KEYMAP_ALTGR; + } /* Map and return */ return key_remap ( character ); diff --git a/src/core/keymap.c b/src/core/keymap.c index a5209bc20..3fa85f74e 100644 --- a/src/core/keymap.c +++ b/src/core/keymap.c @@ -65,8 +65,11 @@ unsigned int key_remap ( unsigned int character ) { if ( ( character & KEYMAP_CAPSLOCK_UNDO ) && isalpha ( mapped ) ) mapped ^= CASE_TOGGLE; + /* Select remapping table */ + key = ( ( character & KEYMAP_ALTGR ) ? keymap->altgr : keymap->basic ); + /* Remap via table */ - for ( key = keymap->basic ; key->from ; key++ ) { + for ( ; key->from ; key++ ) { if ( mapped == key->from ) { mapped = key->to; break; diff --git a/src/drivers/usb/usbkbd.c b/src/drivers/usb/usbkbd.c index 516667b25..b284e584f 100644 --- a/src/drivers/usb/usbkbd.c +++ b/src/drivers/usb/usbkbd.c @@ -132,6 +132,8 @@ static unsigned int usbkbd_map ( unsigned int keycode, unsigned int modifiers, /* Apply modifiers */ if ( modifiers & USBKBD_CTRL ) key |= KEYMAP_CTRL; + if ( modifiers & USBKBD_ALT_RIGHT ) + key |= KEYMAP_ALTGR; if ( leds & USBKBD_LED_CAPS_LOCK ) key |= KEYMAP_CAPSLOCK; diff --git a/src/hci/keymap/keymap_al.c b/src/hci/keymap/keymap_al.c index a3df385a9..b68b98878 100644 --- a/src/hci/keymap/keymap_al.c +++ b/src/hci/keymap/keymap_al.c @@ -35,8 +35,16 @@ static struct keymap_key al_basic[] = { { 0, 0 } }; +/** "al" AltGr remapping */ +static struct keymap_key al_altgr[] = { + { 0x31, 0x7e }, /* '1' => '~' */ + { 0x37, 0x60 }, /* '7' => '`' */ + { 0, 0 } +}; + /** "al" keyboard map */ struct keymap al_keymap __keymap = { .name = "al", .basic = al_basic, + .altgr = al_altgr, }; diff --git a/src/hci/keymap/keymap_az.c b/src/hci/keymap/keymap_az.c index 7b382ca8b..03087e01e 100644 --- a/src/hci/keymap/keymap_az.c +++ b/src/hci/keymap/keymap_az.c @@ -26,8 +26,15 @@ static struct keymap_key az_basic[] = { { 0, 0 } }; +/** "az" AltGr remapping */ +static struct keymap_key az_altgr[] = { + { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ + { 0, 0 } +}; + /** "az" keyboard map */ struct keymap az_keymap __keymap = { .name = "az", .basic = az_basic, + .altgr = az_altgr, }; diff --git a/src/hci/keymap/keymap_by.c b/src/hci/keymap/keymap_by.c index 4127609e3..9af6c966d 100644 --- a/src/hci/keymap/keymap_by.c +++ b/src/hci/keymap/keymap_by.c @@ -17,8 +17,14 @@ static struct keymap_key by_basic[] = { { 0, 0 } }; +/** "by" AltGr remapping */ +static struct keymap_key by_altgr[] = { + { 0, 0 } +}; + /** "by" keyboard map */ struct keymap by_keymap __keymap = { .name = "by", .basic = by_basic, + .altgr = by_altgr, }; diff --git a/src/hci/keymap/keymap_cf.c b/src/hci/keymap/keymap_cf.c index 0bbe89659..09242ee6f 100644 --- a/src/hci/keymap/keymap_cf.c +++ b/src/hci/keymap/keymap_cf.c @@ -24,8 +24,17 @@ static struct keymap_key cf_basic[] = { { 0, 0 } }; +/** "cf" AltGr remapping */ +static struct keymap_key cf_altgr[] = { + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x3b, 0x7e }, /* ';' => '~' */ + { 0x60, 0x5c }, /* '`' => '\\' */ + { 0, 0 } +}; + /** "cf" keyboard map */ struct keymap cf_keymap __keymap = { .name = "cf", .basic = cf_basic, + .altgr = cf_altgr, }; diff --git a/src/hci/keymap/keymap_cz.c b/src/hci/keymap/keymap_cz.c index 8655d5b68..cce686d9a 100644 --- a/src/hci/keymap/keymap_cz.c +++ b/src/hci/keymap/keymap_cz.c @@ -46,8 +46,34 @@ static struct keymap_key cz_basic[] = { { 0, 0 } }; +/** "cz" AltGr remapping */ +static struct keymap_key cz_altgr[] = { + { 0x2c, 0x3c }, /* ',' => '<' */ + { 0x2e, 0x3e }, /* '.' => '>' */ + { 0x2f, 0x2a }, /* '/' => '*' */ + { 0x30, 0x7d }, /* '0' => '}' */ + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x33, 0x23 }, /* '3' => '#' */ + { 0x34, 0x24 }, /* '4' => '$' */ + { 0x36, 0x5e }, /* '6' => '^' */ + { 0x37, 0x26 }, /* '7' => '&' */ + { 0x38, 0x2a }, /* '8' => '*' */ + { 0x39, 0x7b }, /* '9' => '{' */ + { 0x3b, 0x24 }, /* ';' => '$' */ + { 0x62, 0x7b }, /* 'b' => '{' */ + { 0x63, 0x26 }, /* 'c' => '&' */ + { 0x67, 0x5d }, /* 'g' => ']' */ + { 0x68, 0x60 }, /* 'h' => '`' */ + { 0x6d, 0x5e }, /* 'm' => '^' */ + { 0x6e, 0x7d }, /* 'n' => '}' */ + { 0x76, 0x40 }, /* 'v' => '@' */ + { 0x78, 0x23 }, /* 'x' => '#' */ + { 0, 0 } +}; + /** "cz" keyboard map */ struct keymap cz_keymap __keymap = { .name = "cz", .basic = cz_basic, + .altgr = cz_altgr, }; diff --git a/src/hci/keymap/keymap_de.c b/src/hci/keymap/keymap_de.c index 4d23c2e60..4a889a242 100644 --- a/src/hci/keymap/keymap_de.c +++ b/src/hci/keymap/keymap_de.c @@ -41,8 +41,19 @@ static struct keymap_key de_basic[] = { { 0, 0 } }; +/** "de" AltGr remapping */ +static struct keymap_key de_altgr[] = { + { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0x30, 0x7d }, /* '0' => '}' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x71, 0x40 }, /* 'q' => '@' */ + { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ + { 0, 0 } +}; + /** "de" keyboard map */ struct keymap de_keymap __keymap = { .name = "de", .basic = de_basic, + .altgr = de_altgr, }; diff --git a/src/hci/keymap/keymap_dk.c b/src/hci/keymap/keymap_dk.c index 100246bf5..4d40743b1 100644 --- a/src/hci/keymap/keymap_dk.c +++ b/src/hci/keymap/keymap_dk.c @@ -33,8 +33,17 @@ static struct keymap_key dk_basic[] = { { 0, 0 } }; +/** "dk" AltGr remapping */ +static struct keymap_key dk_altgr[] = { + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x3d, 0x7c }, /* '=' => '|' */ + { 0x71, 0x40 }, /* 'q' => '@' */ + { 0, 0 } +}; + /** "dk" keyboard map */ struct keymap dk_keymap __keymap = { .name = "dk", .basic = dk_basic, + .altgr = dk_altgr, }; diff --git a/src/hci/keymap/keymap_es.c b/src/hci/keymap/keymap_es.c index 2f4b86c47..397e2cbaa 100644 --- a/src/hci/keymap/keymap_es.c +++ b/src/hci/keymap/keymap_es.c @@ -33,8 +33,19 @@ static struct keymap_key es_basic[] = { { 0, 0 } }; +/** "es" AltGr remapping */ +static struct keymap_key es_altgr[] = { + { 0x30, 0x7d }, /* '0' => '}' */ + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x5c, 0x7d }, /* '\\' => '}' */ + { 0x71, 0x40 }, /* 'q' => '@' */ + { 0, 0 } +}; + /** "es" keyboard map */ struct keymap es_keymap __keymap = { .name = "es", .basic = es_basic, + .altgr = es_altgr, }; diff --git a/src/hci/keymap/keymap_et.c b/src/hci/keymap/keymap_et.c index a8bf46ebc..4120dbed9 100644 --- a/src/hci/keymap/keymap_et.c +++ b/src/hci/keymap/keymap_et.c @@ -31,8 +31,18 @@ static struct keymap_key et_basic[] = { { 0, 0 } }; +/** "et" AltGr remapping */ +static struct keymap_key et_altgr[] = { + { 0x27, 0x5e }, /* '\'' => '^' */ + { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0x32, 0x40 }, /* '2' => '@' */ + { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ + { 0, 0 } +}; + /** "et" keyboard map */ struct keymap et_keymap __keymap = { .name = "et", .basic = et_basic, + .altgr = et_altgr, }; diff --git a/src/hci/keymap/keymap_fi.c b/src/hci/keymap/keymap_fi.c index eb75eb4dc..978121a88 100644 --- a/src/hci/keymap/keymap_fi.c +++ b/src/hci/keymap/keymap_fi.c @@ -31,8 +31,17 @@ static struct keymap_key fi_basic[] = { { 0, 0 } }; +/** "fi" AltGr remapping */ +static struct keymap_key fi_altgr[] = { + { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0x32, 0x40 }, /* '2' => '@' */ + { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ + { 0, 0 } +}; + /** "fi" keyboard map */ struct keymap fi_keymap __keymap = { .name = "fi", .basic = fi_basic, + .altgr = fi_altgr, }; diff --git a/src/hci/keymap/keymap_fr.c b/src/hci/keymap/keymap_fr.c index 523254ee5..c0a959f0d 100644 --- a/src/hci/keymap/keymap_fr.c +++ b/src/hci/keymap/keymap_fr.c @@ -62,8 +62,20 @@ static struct keymap_key fr_basic[] = { { 0, 0 } }; +/** "fr" AltGr remapping */ +static struct keymap_key fr_altgr[] = { + { 0x2d, 0x5d }, /* '-' => ']' */ + { 0x30, 0x40 }, /* '0' => '@' */ + { 0x33, 0x23 }, /* '3' => '#' */ + { 0x38, 0x5c }, /* '8' => '\\' */ + { 0x39, 0x5e }, /* '9' => '^' */ + { 0x61, 0x40 }, /* 'a' => '@' */ + { 0, 0 } +}; + /** "fr" keyboard map */ struct keymap fr_keymap __keymap = { .name = "fr", .basic = fr_basic, + .altgr = fr_altgr, }; diff --git a/src/hci/keymap/keymap_gr.c b/src/hci/keymap/keymap_gr.c index 16a2a7032..4826c26c2 100644 --- a/src/hci/keymap/keymap_gr.c +++ b/src/hci/keymap/keymap_gr.c @@ -17,8 +17,14 @@ static struct keymap_key gr_basic[] = { { 0, 0 } }; +/** "gr" AltGr remapping */ +static struct keymap_key gr_altgr[] = { + { 0, 0 } +}; + /** "gr" keyboard map */ struct keymap gr_keymap __keymap = { .name = "gr", .basic = gr_basic, + .altgr = gr_altgr, }; diff --git a/src/hci/keymap/keymap_hu.c b/src/hci/keymap/keymap_hu.c index 5e407161f..64e27dda6 100644 --- a/src/hci/keymap/keymap_hu.c +++ b/src/hci/keymap/keymap_hu.c @@ -35,8 +35,25 @@ static struct keymap_key hu_basic[] = { { 0, 0 } }; +/** "hu" AltGr remapping */ +static struct keymap_key hu_altgr[] = { + { 0x2e, 0x3e }, /* '.' => '>' */ + { 0x2f, 0x2a }, /* '/' => '*' */ + { 0x33, 0x5e }, /* '3' => '^' */ + { 0x37, 0x60 }, /* '7' => '`' */ + { 0x3b, 0x24 }, /* ';' => '$' */ + { 0x63, 0x26 }, /* 'c' => '&' */ + { 0x6d, 0x3c }, /* 'm' => '<' */ + { 0x76, 0x40 }, /* 'v' => '@' */ + { 0x78, 0x23 }, /* 'x' => '#' */ + { 0x7a, 0x3e }, /* 'z' => '>' */ + { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0, 0 } +}; + /** "hu" keyboard map */ struct keymap hu_keymap __keymap = { .name = "hu", .basic = hu_basic, + .altgr = hu_altgr, }; diff --git a/src/hci/keymap/keymap_il.c b/src/hci/keymap/keymap_il.c index de5e639ca..e3061fa54 100644 --- a/src/hci/keymap/keymap_il.c +++ b/src/hci/keymap/keymap_il.c @@ -29,8 +29,14 @@ static struct keymap_key il_basic[] = { { 0, 0 } }; +/** "il" AltGr remapping */ +static struct keymap_key il_altgr[] = { + { 0, 0 } +}; + /** "il" keyboard map */ struct keymap il_keymap __keymap = { .name = "il", .basic = il_basic, + .altgr = il_altgr, }; diff --git a/src/hci/keymap/keymap_it.c b/src/hci/keymap/keymap_it.c index a4921020a..f67bbadcb 100644 --- a/src/hci/keymap/keymap_it.c +++ b/src/hci/keymap/keymap_it.c @@ -35,8 +35,20 @@ static struct keymap_key it_basic[] = { { 0, 0 } }; +/** "it" AltGr remapping */ +static struct keymap_key it_altgr[] = { + { 0x2d, 0x60 }, /* '-' => '`' */ + { 0x30, 0x7d }, /* '0' => '}' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x3b, 0x40 }, /* ';' => '@' */ + { 0x3d, 0x7e }, /* '=' => '~' */ + { 0x71, 0x40 }, /* 'q' => '@' */ + { 0, 0 } +}; + /** "it" keyboard map */ struct keymap it_keymap __keymap = { .name = "it", .basic = it_basic, + .altgr = it_altgr, }; diff --git a/src/hci/keymap/keymap_lt.c b/src/hci/keymap/keymap_lt.c index 333241d21..5d6ee5a8c 100644 --- a/src/hci/keymap/keymap_lt.c +++ b/src/hci/keymap/keymap_lt.c @@ -15,8 +15,14 @@ static struct keymap_key lt_basic[] = { { 0, 0 } }; +/** "lt" AltGr remapping */ +static struct keymap_key lt_altgr[] = { + { 0, 0 } +}; + /** "lt" keyboard map */ struct keymap lt_keymap __keymap = { .name = "lt", .basic = lt_basic, + .altgr = lt_altgr, }; diff --git a/src/hci/keymap/keymap_mk.c b/src/hci/keymap/keymap_mk.c index 1656fb99c..4b90ef799 100644 --- a/src/hci/keymap/keymap_mk.c +++ b/src/hci/keymap/keymap_mk.c @@ -17,8 +17,14 @@ static struct keymap_key mk_basic[] = { { 0, 0 } }; +/** "mk" AltGr remapping */ +static struct keymap_key mk_altgr[] = { + { 0, 0 } +}; + /** "mk" keyboard map */ struct keymap mk_keymap __keymap = { .name = "mk", .basic = mk_basic, + .altgr = mk_altgr, }; diff --git a/src/hci/keymap/keymap_mt.c b/src/hci/keymap/keymap_mt.c index ebff8506f..f5baf6907 100644 --- a/src/hci/keymap/keymap_mt.c +++ b/src/hci/keymap/keymap_mt.c @@ -20,8 +20,15 @@ static struct keymap_key mt_basic[] = { { 0, 0 } }; +/** "mt" AltGr remapping */ +static struct keymap_key mt_altgr[] = { + { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0, 0 } +}; + /** "mt" keyboard map */ struct keymap mt_keymap __keymap = { .name = "mt", .basic = mt_basic, + .altgr = mt_altgr, }; diff --git a/src/hci/keymap/keymap_nl.c b/src/hci/keymap/keymap_nl.c index 2172e045f..bbee4cbdf 100644 --- a/src/hci/keymap/keymap_nl.c +++ b/src/hci/keymap/keymap_nl.c @@ -38,8 +38,16 @@ static struct keymap_key nl_basic[] = { { 0, 0 } }; +/** "nl" AltGr remapping */ +static struct keymap_key nl_altgr[] = { + { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0x39, 0x7d }, /* '9' => '}' */ + { 0, 0 } +}; + /** "nl" keyboard map */ struct keymap nl_keymap __keymap = { .name = "nl", .basic = nl_basic, + .altgr = nl_altgr, }; diff --git a/src/hci/keymap/keymap_no-latin1.c b/src/hci/keymap/keymap_no-latin1.c index 65f30beae..63fe85548 100644 --- a/src/hci/keymap/keymap_no-latin1.c +++ b/src/hci/keymap/keymap_no-latin1.c @@ -37,8 +37,18 @@ static struct keymap_key no_latin1_basic[] = { { 0, 0 } }; +/** "no-latin1" AltGr remapping */ +static struct keymap_key no_latin1_altgr[] = { + { 0x30, 0x7d }, /* '0' => '}' */ + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x5b, 0x7d }, /* '[' => '}' */ + { 0, 0 } +}; + /** "no-latin1" keyboard map */ struct keymap no_latin1_keymap __keymap = { .name = "no-latin1", .basic = no_latin1_basic, + .altgr = no_latin1_altgr, }; diff --git a/src/hci/keymap/keymap_no.c b/src/hci/keymap/keymap_no.c index d3d06bce3..95a95428b 100644 --- a/src/hci/keymap/keymap_no.c +++ b/src/hci/keymap/keymap_no.c @@ -35,8 +35,16 @@ static struct keymap_key no_basic[] = { { 0, 0 } }; +/** "no" AltGr remapping */ +static struct keymap_key no_altgr[] = { + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x71, 0x40 }, /* 'q' => '@' */ + { 0, 0 } +}; + /** "no" keyboard map */ struct keymap no_keymap __keymap = { .name = "no", .basic = no_basic, + .altgr = no_altgr, }; diff --git a/src/hci/keymap/keymap_pl.c b/src/hci/keymap/keymap_pl.c index a23c01f2c..a76181fbc 100644 --- a/src/hci/keymap/keymap_pl.c +++ b/src/hci/keymap/keymap_pl.c @@ -17,8 +17,14 @@ static struct keymap_key pl_basic[] = { { 0, 0 } }; +/** "pl" AltGr remapping */ +static struct keymap_key pl_altgr[] = { + { 0, 0 } +}; + /** "pl" keyboard map */ struct keymap pl_keymap __keymap = { .name = "pl", .basic = pl_basic, + .altgr = pl_altgr, }; diff --git a/src/hci/keymap/keymap_pt.c b/src/hci/keymap/keymap_pt.c index c065fd76f..99ba52e4b 100644 --- a/src/hci/keymap/keymap_pt.c +++ b/src/hci/keymap/keymap_pt.c @@ -34,8 +34,18 @@ static struct keymap_key pt_basic[] = { { 0, 0 } }; +/** "pt" AltGr remapping */ +static struct keymap_key pt_altgr[] = { + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ + { 0x71, 0x40 }, /* 'q' => '@' */ + { 0, 0 } +}; + /** "pt" keyboard map */ struct keymap pt_keymap __keymap = { .name = "pt", .basic = pt_basic, + .altgr = pt_altgr, }; diff --git a/src/hci/keymap/keymap_ro.c b/src/hci/keymap/keymap_ro.c index 334cf6080..620450001 100644 --- a/src/hci/keymap/keymap_ro.c +++ b/src/hci/keymap/keymap_ro.c @@ -15,8 +15,14 @@ static struct keymap_key ro_basic[] = { { 0, 0 } }; +/** "ro" AltGr remapping */ +static struct keymap_key ro_altgr[] = { + { 0, 0 } +}; + /** "ro" keyboard map */ struct keymap ro_keymap __keymap = { .name = "ro", .basic = ro_basic, + .altgr = ro_altgr, }; diff --git a/src/hci/keymap/keymap_ru.c b/src/hci/keymap/keymap_ru.c index a08b115ed..2aafcf9bd 100644 --- a/src/hci/keymap/keymap_ru.c +++ b/src/hci/keymap/keymap_ru.c @@ -18,8 +18,14 @@ static struct keymap_key ru_basic[] = { { 0, 0 } }; +/** "ru" AltGr remapping */ +static struct keymap_key ru_altgr[] = { + { 0, 0 } +}; + /** "ru" keyboard map */ struct keymap ru_keymap __keymap = { .name = "ru", .basic = ru_basic, + .altgr = ru_altgr, }; diff --git a/src/hci/keymap/keymap_sg.c b/src/hci/keymap/keymap_sg.c index 152c5d631..9a6db9cb4 100644 --- a/src/hci/keymap/keymap_sg.c +++ b/src/hci/keymap/keymap_sg.c @@ -43,8 +43,18 @@ static struct keymap_key sg_basic[] = { { 0, 0 } }; +/** "sg" AltGr remapping */ +static struct keymap_key sg_altgr[] = { + { 0x32, 0x40 }, /* '2' => '@' */ + { 0x33, 0x23 }, /* '3' => '#' */ + { 0x37, 0x7c }, /* '7' => '|' */ + { 0x5c, 0x7d }, /* '\\' => '}' */ + { 0, 0 } +}; + /** "sg" keyboard map */ struct keymap sg_keymap __keymap = { .name = "sg", .basic = sg_basic, + .altgr = sg_altgr, }; diff --git a/src/hci/keymap/keymap_sr-latin.c b/src/hci/keymap/keymap_sr-latin.c index ec5efdc89..7e55714a2 100644 --- a/src/hci/keymap/keymap_sr-latin.c +++ b/src/hci/keymap/keymap_sr-latin.c @@ -17,8 +17,14 @@ static struct keymap_key sr_latin_basic[] = { { 0, 0 } }; +/** "sr-latin" AltGr remapping */ +static struct keymap_key sr_latin_altgr[] = { + { 0, 0 } +}; + /** "sr-latin" keyboard map */ struct keymap sr_latin_keymap __keymap = { .name = "sr-latin", .basic = sr_latin_basic, + .altgr = sr_latin_altgr, }; diff --git a/src/hci/keymap/keymap_ua.c b/src/hci/keymap/keymap_ua.c index b4199cdad..44e82cb2d 100644 --- a/src/hci/keymap/keymap_ua.c +++ b/src/hci/keymap/keymap_ua.c @@ -17,8 +17,14 @@ static struct keymap_key ua_basic[] = { { 0, 0 } }; +/** "ua" AltGr remapping */ +static struct keymap_key ua_altgr[] = { + { 0, 0 } +}; + /** "ua" keyboard map */ struct keymap ua_keymap __keymap = { .name = "ua", .basic = ua_basic, + .altgr = ua_altgr, }; diff --git a/src/hci/keymap/keymap_uk.c b/src/hci/keymap/keymap_uk.c index 156b42dff..28cf7aac4 100644 --- a/src/hci/keymap/keymap_uk.c +++ b/src/hci/keymap/keymap_uk.c @@ -19,8 +19,14 @@ static struct keymap_key uk_basic[] = { { 0, 0 } }; +/** "uk" AltGr remapping */ +static struct keymap_key uk_altgr[] = { + { 0, 0 } +}; + /** "uk" keyboard map */ struct keymap uk_keymap __keymap = { .name = "uk", .basic = uk_basic, + .altgr = uk_altgr, }; diff --git a/src/hci/keymap/keymap_us.c b/src/hci/keymap/keymap_us.c index 5d78f80a2..6432474e2 100644 --- a/src/hci/keymap/keymap_us.c +++ b/src/hci/keymap/keymap_us.c @@ -15,8 +15,14 @@ static struct keymap_key us_basic[] = { { 0, 0 } }; +/** "us" AltGr remapping */ +static struct keymap_key us_altgr[] = { + { 0, 0 } +}; + /** "us" keyboard map */ struct keymap us_keymap __keymap = { .name = "us", .basic = us_basic, + .altgr = us_altgr, }; diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h index 3da25190b..72b6961ef 100644 --- a/src/include/ipxe/keymap.h +++ b/src/include/ipxe/keymap.h @@ -32,6 +32,8 @@ struct keymap { const char *name; /** Basic remapping table (zero-terminated) */ struct keymap_key *basic; + /** AltGr remapping table (zero-terminated) */ + struct keymap_key *altgr; }; /** Keyboard mapping table */ @@ -64,6 +66,9 @@ struct keymap { /** Undo and redo CapsLock key flags */ #define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO ) +/** AltGr key flag */ +#define KEYMAP_ALTGR 0x0800 + extern unsigned int key_remap ( unsigned int character ); #endif /* _IPXE_KEYMAP_H */ diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 9adce4a9b..fc1500afb 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -334,6 +334,9 @@ static int efi_getchar ( void ) { EFI_RIGHT_CONTROL_PRESSED ) ) { character |= KEYMAP_CTRL; } + if ( shift & EFI_RIGHT_ALT_PRESSED ) { + character |= KEYMAP_ALTGR; + } } /* Apply toggle state */ diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index d38552eb4..ff5ff0a87 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -171,6 +171,11 @@ class KeyLayout(UserDict[KeyModifiers, Sequence[Key]]): """Basic shifted keyboard layout""" return self[KeyModifiers.SHIFT] + @property + def altgr(self): + """AltGr keyboard layout""" + return self.get(KeyModifiers.ALTGR, self.unshifted) + @classmethod def load(cls, name: str) -> KeyLayout: """Load keymap using 'loadkeys -b'""" @@ -278,6 +283,7 @@ class KeymapKeys(UserDict[str, str]): self.ascii_name(source), self.ascii_name(target) ) for source, target in self.items() + if ord(source) & ~BiosKeyLayout.KEY_PSEUDO != ord(target) ) + '\t{ 0, 0 }\n}' @@ -301,13 +307,12 @@ class Keymap: raw = {source: self.target[key.modifiers][key.keycode].ascii for source, key in self.source.inverse.items()} # Eliminate any null mappings, mappings that attempt to remap - # the backspace key, or mappings that would become identity - # mappings after clearing the high bit + # the backspace key, or identity mappings table = {source: target for source, target in raw.items() if target and ord(source) != 0x7f and ord(target) != 0x7f - and ord(source) & ~BiosKeyLayout.KEY_PSEUDO != ord(target)} + and source != target} # Recursively delete any mappings that would produce # unreachable alphanumerics (e.g. the "il" keymap, which maps # away the whole lower-case alphabet) @@ -327,6 +332,28 @@ class Keymap: (unshifted, shifted)) return KeymapKeys(dict(sorted(table.items()))) + @property + def altgr(self) -> KeymapKeys: + """AltGr remapping table""" + # Construct raw mapping from source ASCII to target ASCII + raw = {source: self.target.altgr[key.keycode].ascii + for source, key in self.source.inverse.items() + if key.modifiers == KeyModifiers.NONE} + # Identify printable keys that are unreachable via the basic map + basic = self.basic + unmapped = set(x for x in basic.keys() + if x.isascii() and x.isprintable()) + remapped = set(basic.values()) + unreachable = unmapped - remapped + # Eliminate any null mappings, mappings for unprintable + # characters, or mappings for characters that are reachable + # via the basic map + table = {source: target for source, target in raw.items() + if source.isprintable() + and target + and target in unreachable} + return KeymapKeys(dict(sorted(table.items()))) + def cname(self, suffix: str) -> str: """C variable name""" return re.sub(r'\W', '_', (self.name + '_' + suffix)) @@ -336,6 +363,7 @@ class Keymap: """Generated source code""" keymap_name = self.cname("keymap") basic_name = self.cname("basic") + altgr_name = self.cname("altgr") code = textwrap.dedent(f""" /** @file * @@ -352,12 +380,16 @@ class Keymap: /** "{self.name}" basic remapping */ static struct keymap_key {basic_name}[] = %s; + /** "{self.name}" AltGr remapping */ + static struct keymap_key {altgr_name}[] = %s; + /** "{self.name}" keyboard map */ struct keymap {keymap_name} __keymap = {{ \t.name = "{self.name}", \t.basic = {basic_name}, + \t.altgr = {altgr_name}, }}; - """).strip() % self.basic.code + """).strip() % (self.basic.code, self.altgr.code) return code -- cgit v1.2.3-55-g7522 From c7d78192919bfa62fde33650e1506e902816eec3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Feb 2022 11:28:57 +0000 Subject: [console] Treat dead keys as producing their ASCII equivalents Treat dead keys in target keymaps as producing the closest equivalent ASCII character, since many of these characters are otherwise unrepresented on the keyboard. Signed-off-by: Michael Brown --- src/hci/keymap/keymap_al.c | 2 ++ src/hci/keymap/keymap_cf.c | 5 +++++ src/hci/keymap/keymap_cz.c | 6 +++--- src/hci/keymap/keymap_de.c | 2 ++ src/hci/keymap/keymap_dk.c | 3 +++ src/hci/keymap/keymap_es.c | 5 +++++ src/hci/keymap/keymap_et.c | 3 ++- src/hci/keymap/keymap_fi.c | 3 +++ src/hci/keymap/keymap_fr.c | 3 ++- src/hci/keymap/keymap_hu.c | 1 + src/hci/keymap/keymap_it.c | 1 + src/hci/keymap/keymap_nl.c | 4 ++++ src/hci/keymap/keymap_no.c | 3 +++ src/hci/keymap/keymap_pt.c | 5 +++++ src/util/genkeymap.py | 22 ++++++++++++++++++++-- 15 files changed, 61 insertions(+), 7 deletions(-) (limited to 'src/util') diff --git a/src/hci/keymap/keymap_al.c b/src/hci/keymap/keymap_al.c index b68b98878..4d279171f 100644 --- a/src/hci/keymap/keymap_al.c +++ b/src/hci/keymap/keymap_al.c @@ -37,7 +37,9 @@ static struct keymap_key al_basic[] = { /** "al" AltGr remapping */ static struct keymap_key al_altgr[] = { + { 0x30, 0x7e }, /* '0' => '~' */ { 0x31, 0x7e }, /* '1' => '~' */ + { 0x34, 0x7e }, /* '4' => '~' */ { 0x37, 0x60 }, /* '7' => '`' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_cf.c b/src/hci/keymap/keymap_cf.c index 09242ee6f..434e3383c 100644 --- a/src/hci/keymap/keymap_cf.c +++ b/src/hci/keymap/keymap_cf.c @@ -12,13 +12,17 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "cf" basic remapping */ static struct keymap_key cf_basic[] = { + { 0x22, 0x60 }, /* '"' => '`' */ { 0x23, 0x2f }, /* '#' => '/' */ + { 0x27, 0x60 }, /* '\'' => '`' */ { 0x3c, 0x27 }, /* '<' => '\'' */ { 0x3e, 0x2e }, /* '>' => '.' */ { 0x40, 0x22 }, /* '@' => '"' */ + { 0x5b, 0x5e }, /* '[' => '^' */ { 0x5c, 0x3c }, /* '\\' => '<' */ { 0x5e, 0x3f }, /* '^' => '?' */ { 0x60, 0x23 }, /* '`' => '#' */ + { 0x7b, 0x5e }, /* '{' => '^' */ { 0x7c, 0x3e }, /* '|' => '>' */ { 0x7e, 0x7c }, /* '~' => '|' */ { 0, 0 } @@ -26,6 +30,7 @@ static struct keymap_key cf_basic[] = { /** "cf" AltGr remapping */ static struct keymap_key cf_altgr[] = { + { 0x27, 0x7b }, /* '\'' => '{' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x3b, 0x7e }, /* ';' => '~' */ { 0x60, 0x5c }, /* '`' => '\\' */ diff --git a/src/hci/keymap/keymap_cz.c b/src/hci/keymap/keymap_cz.c index cce686d9a..fb072b117 100644 --- a/src/hci/keymap/keymap_cz.c +++ b/src/hci/keymap/keymap_cz.c @@ -24,6 +24,7 @@ static struct keymap_key cz_basic[] = { { 0x28, 0x39 }, /* '(' => '9' */ { 0x29, 0x30 }, /* ')' => '0' */ { 0x2a, 0x38 }, /* '*' => '8' */ + { 0x2b, 0x5e }, /* '+' => '^' */ { 0x2d, 0x3d }, /* '-' => '=' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x31, 0x2b }, /* '1' => '+' */ @@ -43,6 +44,7 @@ static struct keymap_key cz_basic[] = { { 0x7b, 0x2f }, /* '{' => '/' */ { 0x7c, 0x27 }, /* '|' => '\'' */ { 0x7d, 0x28 }, /* '}' => '(' */ + { 0x7e, 0x60 }, /* '~' => '`' */ { 0, 0 } }; @@ -55,16 +57,14 @@ static struct keymap_key cz_altgr[] = { { 0x32, 0x40 }, /* '2' => '@' */ { 0x33, 0x23 }, /* '3' => '#' */ { 0x34, 0x24 }, /* '4' => '$' */ - { 0x36, 0x5e }, /* '6' => '^' */ { 0x37, 0x26 }, /* '7' => '&' */ { 0x38, 0x2a }, /* '8' => '*' */ { 0x39, 0x7b }, /* '9' => '{' */ { 0x3b, 0x24 }, /* ';' => '$' */ + { 0x61, 0x7e }, /* 'a' => '~' */ { 0x62, 0x7b }, /* 'b' => '{' */ { 0x63, 0x26 }, /* 'c' => '&' */ { 0x67, 0x5d }, /* 'g' => ']' */ - { 0x68, 0x60 }, /* 'h' => '`' */ - { 0x6d, 0x5e }, /* 'm' => '^' */ { 0x6e, 0x7d }, /* 'n' => '}' */ { 0x76, 0x40 }, /* 'v' => '@' */ { 0x78, 0x23 }, /* 'x' => '#' */ diff --git a/src/hci/keymap/keymap_de.c b/src/hci/keymap/keymap_de.c index 4a889a242..bbd39520f 100644 --- a/src/hci/keymap/keymap_de.c +++ b/src/hci/keymap/keymap_de.c @@ -21,6 +21,7 @@ static struct keymap_key de_basic[] = { { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ + { 0x2b, 0x60 }, /* '+' => '`' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3c, 0x3b }, /* '<' => ';' */ { 0x3e, 0x3a }, /* '>' => ':' */ @@ -32,6 +33,7 @@ static struct keymap_key de_basic[] = { { 0x5d, 0x2b }, /* ']' => '+' */ { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ + { 0x60, 0x5e }, /* '`' => '^' */ { 0x79, 0x7a }, /* 'y' => 'z' */ { 0x7a, 0x79 }, /* 'z' => 'y' */ { 0x7c, 0x27 }, /* '|' => '\'' */ diff --git a/src/hci/keymap/keymap_dk.c b/src/hci/keymap/keymap_dk.c index 4d40743b1..6d2e60aca 100644 --- a/src/hci/keymap/keymap_dk.c +++ b/src/hci/keymap/keymap_dk.c @@ -18,6 +18,7 @@ static struct keymap_key dk_basic[] = { { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ + { 0x2b, 0x60 }, /* '+' => '`' */ { 0x2d, 0x2b }, /* '-' => '+' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3c, 0x3b }, /* '<' => ';' */ @@ -28,6 +29,7 @@ static struct keymap_key dk_basic[] = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7c, 0x2a }, /* '|' => '*' */ + { 0x7d, 0x5e }, /* '}' => '^' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ { 0, 0 } @@ -35,6 +37,7 @@ static struct keymap_key dk_basic[] = { /** "dk" AltGr remapping */ static struct keymap_key dk_altgr[] = { + { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x3d, 0x7c }, /* '=' => '|' */ { 0x71, 0x40 }, /* 'q' => '@' */ diff --git a/src/hci/keymap/keymap_es.c b/src/hci/keymap/keymap_es.c index 397e2cbaa..614ca7b8b 100644 --- a/src/hci/keymap/keymap_es.c +++ b/src/hci/keymap/keymap_es.c @@ -24,9 +24,11 @@ static struct keymap_key es_basic[] = { { 0x3e, 0x3a }, /* '>' => ':' */ { 0x3f, 0x5f }, /* '?' => '_' */ { 0x40, 0x22 }, /* '@' => '"' */ + { 0x5b, 0x60 }, /* '[' => '`' */ { 0x5d, 0x2b }, /* ']' => '+' */ { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ + { 0x7b, 0x5e }, /* '{' => '^' */ { 0x7d, 0x2a }, /* '}' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ @@ -35,8 +37,11 @@ static struct keymap_key es_basic[] = { /** "es" AltGr remapping */ static struct keymap_key es_altgr[] = { + { 0x27, 0x7b }, /* '\'' => '{' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ { 0x5c, 0x7d }, /* '\\' => '}' */ { 0x71, 0x40 }, /* 'q' => '@' */ diff --git a/src/hci/keymap/keymap_et.c b/src/hci/keymap/keymap_et.c index 4120dbed9..f3eb02eab 100644 --- a/src/hci/keymap/keymap_et.c +++ b/src/hci/keymap/keymap_et.c @@ -16,6 +16,7 @@ static struct keymap_key et_basic[] = { { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ + { 0x2b, 0x60 }, /* '+' => '`' */ { 0x2d, 0x2b }, /* '-' => '+' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3c, 0x3b }, /* '<' => ';' */ @@ -25,6 +26,7 @@ static struct keymap_key et_basic[] = { { 0x5c, 0x27 }, /* '\\' => '\'' */ { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ + { 0x60, 0x5e }, /* '`' => '^' */ { 0x7c, 0x2a }, /* '|' => '*' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ @@ -33,7 +35,6 @@ static struct keymap_key et_basic[] = { /** "et" AltGr remapping */ static struct keymap_key et_altgr[] = { - { 0x27, 0x5e }, /* '\'' => '^' */ { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ diff --git a/src/hci/keymap/keymap_fi.c b/src/hci/keymap/keymap_fi.c index 978121a88..622f06252 100644 --- a/src/hci/keymap/keymap_fi.c +++ b/src/hci/keymap/keymap_fi.c @@ -16,6 +16,7 @@ static struct keymap_key fi_basic[] = { { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ + { 0x2b, 0x60 }, /* '+' => '`' */ { 0x2d, 0x2b }, /* '-' => '+' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3c, 0x3b }, /* '<' => ';' */ @@ -26,6 +27,7 @@ static struct keymap_key fi_basic[] = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x7c, 0x2a }, /* '|' => '*' */ + { 0x7d, 0x5e }, /* '}' => '^' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ { 0, 0 } @@ -34,6 +36,7 @@ static struct keymap_key fi_basic[] = { /** "fi" AltGr remapping */ static struct keymap_key fi_altgr[] = { { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } diff --git a/src/hci/keymap/keymap_fr.c b/src/hci/keymap/keymap_fr.c index c0a959f0d..c002bf95a 100644 --- a/src/hci/keymap/keymap_fr.c +++ b/src/hci/keymap/keymap_fr.c @@ -49,6 +49,7 @@ static struct keymap_key fr_basic[] = { { 0x51, 0x41 }, /* 'Q' => 'A' */ { 0x57, 0x5a }, /* 'W' => 'Z' */ { 0x5a, 0x57 }, /* 'Z' => 'W' */ + { 0x5b, 0x5e }, /* '[' => '^' */ { 0x5c, 0x2a }, /* '\\' => '*' */ { 0x5d, 0x24 }, /* ']' => '$' */ { 0x5e, 0x36 }, /* '^' => '6' */ @@ -67,8 +68,8 @@ static struct keymap_key fr_altgr[] = { { 0x2d, 0x5d }, /* '-' => ']' */ { 0x30, 0x40 }, /* '0' => '@' */ { 0x33, 0x23 }, /* '3' => '#' */ + { 0x35, 0x5b }, /* '5' => '[' */ { 0x38, 0x5c }, /* '8' => '\\' */ - { 0x39, 0x5e }, /* '9' => '^' */ { 0x61, 0x40 }, /* 'a' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_hu.c b/src/hci/keymap/keymap_hu.c index 64e27dda6..8f2d70aac 100644 --- a/src/hci/keymap/keymap_hu.c +++ b/src/hci/keymap/keymap_hu.c @@ -39,6 +39,7 @@ static struct keymap_key hu_basic[] = { static struct keymap_key hu_altgr[] = { { 0x2e, 0x3e }, /* '.' => '>' */ { 0x2f, 0x2a }, /* '/' => '*' */ + { 0x32, 0x5e }, /* '2' => '^' */ { 0x33, 0x5e }, /* '3' => '^' */ { 0x37, 0x60 }, /* '7' => '`' */ { 0x3b, 0x24 }, /* ';' => '$' */ diff --git a/src/hci/keymap/keymap_it.c b/src/hci/keymap/keymap_it.c index f67bbadcb..a55dafe6a 100644 --- a/src/hci/keymap/keymap_it.c +++ b/src/hci/keymap/keymap_it.c @@ -42,6 +42,7 @@ static struct keymap_key it_altgr[] = { { 0x39, 0x5d }, /* '9' => ']' */ { 0x3b, 0x40 }, /* ';' => '@' */ { 0x3d, 0x7e }, /* '=' => '~' */ + { 0x5c, 0x60 }, /* '\\' => '`' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_nl.c b/src/hci/keymap/keymap_nl.c index bbee4cbdf..8038d4d37 100644 --- a/src/hci/keymap/keymap_nl.c +++ b/src/hci/keymap/keymap_nl.c @@ -15,10 +15,12 @@ static struct keymap_key nl_basic[] = { { 0x1c, 0x3c }, /* 0x1c => '<' */ { 0x1d, 0x1c }, /* 0x1d => 0x1c */ { 0x1e, 0x36 }, /* 0x1e => '6' */ + { 0x22, 0x60 }, /* '"' => '`' */ { 0x26, 0x5f }, /* '&' => '_' */ { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x27 }, /* ')' => '\'' */ { 0x2a, 0x28 }, /* '*' => '(' */ + { 0x2b, 0x7e }, /* '+' => '~' */ { 0x2d, 0x2f }, /* '-' => '/' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3b, 0x2b }, /* ';' => '+' */ @@ -31,6 +33,7 @@ static struct keymap_key nl_basic[] = { { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x60, 0x40 }, /* '`' => '@' */ + { 0x7b, 0x5e }, /* '{' => '^' */ { 0x7c, 0x3e }, /* '|' => '>' */ { 0x7d, 0x7c }, /* '}' => '|' */ { 0xdc, 0x5d }, /* Pseudo-'\\' => ']' */ @@ -41,6 +44,7 @@ static struct keymap_key nl_basic[] = { /** "nl" AltGr remapping */ static struct keymap_key nl_altgr[] = { { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0x38, 0x7b }, /* '8' => '{' */ { 0x39, 0x7d }, /* '9' => '}' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_no.c b/src/hci/keymap/keymap_no.c index 95a95428b..4b2f7268e 100644 --- a/src/hci/keymap/keymap_no.c +++ b/src/hci/keymap/keymap_no.c @@ -18,6 +18,7 @@ static struct keymap_key no_basic[] = { { 0x28, 0x29 }, /* '(' => ')' */ { 0x29, 0x3d }, /* ')' => '=' */ { 0x2a, 0x28 }, /* '*' => '(' */ + { 0x2b, 0x60 }, /* '+' => '`' */ { 0x2d, 0x2b }, /* '-' => '+' */ { 0x2f, 0x2d }, /* '/' => '-' */ { 0x3c, 0x3b }, /* '<' => ';' */ @@ -30,6 +31,7 @@ static struct keymap_key no_basic[] = { { 0x5f, 0x3f }, /* '_' => '?' */ { 0x60, 0x7c }, /* '`' => '|' */ { 0x7c, 0x2a }, /* '|' => '*' */ + { 0x7d, 0x5e }, /* '}' => '^' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ { 0, 0 } @@ -37,6 +39,7 @@ static struct keymap_key no_basic[] = { /** "no" AltGr remapping */ static struct keymap_key no_altgr[] = { + { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } diff --git a/src/hci/keymap/keymap_pt.c b/src/hci/keymap/keymap_pt.c index 99ba52e4b..f294e9563 100644 --- a/src/hci/keymap/keymap_pt.c +++ b/src/hci/keymap/keymap_pt.c @@ -12,6 +12,7 @@ FILE_LICENCE ( PUBLIC_DOMAIN ); /** "pt" basic remapping */ static struct keymap_key pt_basic[] = { + { 0x1c, 0x7e }, /* 0x1c => '~' */ { 0x1e, 0x36 }, /* 0x1e => '6' */ { 0x26, 0x2f }, /* '&' => '/' */ { 0x28, 0x29 }, /* '(' => ')' */ @@ -24,10 +25,13 @@ static struct keymap_key pt_basic[] = { { 0x3f, 0x5f }, /* '?' => '_' */ { 0x40, 0x22 }, /* '@' => '"' */ { 0x5b, 0x2b }, /* '[' => '+' */ + { 0x5c, 0x7e }, /* '\\' => '~' */ { 0x5e, 0x26 }, /* '^' => '&' */ { 0x5f, 0x3f }, /* '_' => '?' */ { 0x60, 0x5c }, /* '`' => '\\' */ { 0x7b, 0x2a }, /* '{' => '*' */ + { 0x7c, 0x5e }, /* '|' => '^' */ + { 0x7d, 0x60 }, /* '}' => '`' */ { 0x7e, 0x7c }, /* '~' => '|' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ @@ -36,6 +40,7 @@ static struct keymap_key pt_basic[] = { /** "pt" AltGr remapping */ static struct keymap_key pt_altgr[] = { + { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index ff5ff0a87..42ccee175 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -54,6 +54,14 @@ class KeyType(IntEnum): UNKNOWN = 0xf0 +class DeadKey(IntEnum): + """Dead keys""" + + GRAVE = 0 + CIRCUMFLEX = 2 + TILDE = 3 + + class KeyModifiers(Flag): """Key modifiers""" @@ -96,6 +104,13 @@ class Key: KeyType.LETTER} """Key types with direct ASCII values""" + DEAD_KEYS: ClassVar[Mapping[int, str]] = { + DeadKey.GRAVE: '`', + DeadKey.CIRCUMFLEX: '^', + DeadKey.TILDE: '~', + } + """Dead key replacement ASCII values""" + @property def keytype(self) -> Optional[KeyType]: """Key type""" @@ -112,11 +127,14 @@ class Key: @property def ascii(self) -> Optional[str]: """ASCII character""" - if self.keytype in self.ASCII_TYPES: - value = self.value + keytype = self.keytype + value = self.value + if keytype in self.ASCII_TYPES: char = chr(value) if value and char.isascii(): return char + if keytype == KeyType.DEAD: + return self.DEAD_KEYS.get(value) return None -- cgit v1.2.3-55-g7522 From 164db2cc630932a91119b1aee5fa299d17716819 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Feb 2022 11:43:08 +0000 Subject: [console] Fix unreachable characters in "il" keymap Signed-off-by: Michael Brown --- src/hci/keymap/keymap_il.c | 1 + src/util/genkeymap.py | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src/util') diff --git a/src/hci/keymap/keymap_il.c b/src/hci/keymap/keymap_il.c index e3061fa54..95e33a0bd 100644 --- a/src/hci/keymap/keymap_il.c +++ b/src/hci/keymap/keymap_il.c @@ -31,6 +31,7 @@ static struct keymap_key il_basic[] = { /** "il" AltGr remapping */ static struct keymap_key il_altgr[] = { + { 0x5c, 0x60 }, /* '\\' => '`' */ { 0, 0 } }; diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index 42ccee175..5f87a89d2 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -176,6 +176,12 @@ class KeyLayout(UserDict[KeyModifiers, Sequence[Key]]): # Treat Ctrl-Backspace as producing Backspace rather than Ctrl-H KeyModifiers.CTRL: [(KEY_BACKSPACE, 0x7f)], }, + 'il': { + # Redefine some otherwise unreachable ASCII characters + # using the closest available approximation + KeyModifiers.ALTGR: [(0x28, ord('\'')), (0x2b, ord('`')), + (0x35, ord('/'))], + }, } """Fixups for erroneous keymappings produced by 'loadkeys -b'""" -- cgit v1.2.3-55-g7522 From a7a79ab12b1ba7b3873fccaa4778443c1577ad8e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Feb 2022 11:45:17 +0000 Subject: [console] Fix unreachable characters in "mt" keymap Signed-off-by: Michael Brown --- src/hci/keymap/keymap_mt.c | 1 - src/util/genkeymap.py | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/hci/keymap/keymap_mt.c b/src/hci/keymap/keymap_mt.c index f5baf6907..0a9a110b0 100644 --- a/src/hci/keymap/keymap_mt.c +++ b/src/hci/keymap/keymap_mt.c @@ -22,7 +22,6 @@ static struct keymap_key mt_basic[] = { /** "mt" AltGr remapping */ static struct keymap_key mt_altgr[] = { - { 0x2d, 0x5c }, /* '-' => '\\' */ { 0, 0 } }; diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index 5f87a89d2..e471cd31a 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -182,6 +182,11 @@ class KeyLayout(UserDict[KeyModifiers, Sequence[Key]]): KeyModifiers.ALTGR: [(0x28, ord('\'')), (0x2b, ord('`')), (0x35, ord('/'))], }, + 'mt': { + # Redefine erroneous key 86 as generating "\\|" + KeyModifiers.NONE: [(KEY_NON_US, ord('\\'))], + KeyModifiers.SHIFT: [(KEY_NON_US, ord('|'))], + }, } """Fixups for erroneous keymappings produced by 'loadkeys -b'""" -- cgit v1.2.3-55-g7522 From 510f9de0a23d3a64654669e1a08ad7fdba5f270b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Feb 2022 11:51:37 +0000 Subject: [console] Ensure that all ASCII characters are reachable in all keymaps Signed-off-by: Michael Brown --- src/util/genkeymap.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/util') diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index e471cd31a..8df949612 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -381,6 +381,12 @@ class Keymap: if source.isprintable() and target and target in unreachable} + # Check that all characters are now reachable + unreachable -= set(table.values()) + if unreachable: + raise ValueError("Unreachable characters: %s" % ', '.join( + KeymapKeys.ascii_name(x) for x in sorted(unreachable) + )) return KeymapKeys(dict(sorted(table.items()))) def cname(self, suffix: str) -> str: -- cgit v1.2.3-55-g7522 From 419b2e71da689ded944c3789c87b7ae3646c7a7c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 15 Feb 2022 16:41:19 +0000 Subject: [console] Fix definition of unreachability for remapped keys The AltGr remapping table is constructed to include only keys that are not reachable after applying the basic remapping table. The logic currently fails to include keys that are omitted entirely from the basic remapping table since they would map to a non-ASCII character. Fix this logic by allowing the remapping tables to include null mappings, which are then elided only at the point of constructing the C code fragment. Reported-by: Christian Nilsson Signed-off-by: Michael Brown --- src/hci/keymap/keymap_al.c | 5 +++++ src/hci/keymap/keymap_cf.c | 1 + src/hci/keymap/keymap_cz.c | 8 +++++++ src/hci/keymap/keymap_de.c | 5 +++++ src/hci/keymap/keymap_dk.c | 7 ++++++ src/hci/keymap/keymap_es.c | 13 +++++++++++ src/hci/keymap/keymap_et.c | 10 +++++++++ src/hci/keymap/keymap_fi.c | 6 +++++ src/hci/keymap/keymap_fr.c | 6 +++++ src/hci/keymap/keymap_hu.c | 18 +++++++++++++++ src/hci/keymap/keymap_it.c | 6 +++++ src/hci/keymap/keymap_lt.c | 4 ++++ src/hci/keymap/keymap_mt.c | 5 +++++ src/hci/keymap/keymap_no-latin1.c | 5 +++++ src/hci/keymap/keymap_no.c | 7 ++++++ src/hci/keymap/keymap_pt.c | 1 + src/hci/keymap/keymap_se.c | 5 +++++ src/hci/keymap/keymap_sg.c | 2 ++ src/util/genkeymap.py | 46 +++++++++++++++++++-------------------- 19 files changed, 137 insertions(+), 23 deletions(-) (limited to 'src/util') diff --git a/src/hci/keymap/keymap_al.c b/src/hci/keymap/keymap_al.c index 4d279171f..6e14395a5 100644 --- a/src/hci/keymap/keymap_al.c +++ b/src/hci/keymap/keymap_al.c @@ -37,10 +37,15 @@ static struct keymap_key al_basic[] = { /** "al" AltGr remapping */ static struct keymap_key al_altgr[] = { + { 0x21, 0x7e }, /* '!' => '~' */ + { 0x26, 0x60 }, /* '&' => '`' */ { 0x30, 0x7e }, /* '0' => '~' */ { 0x31, 0x7e }, /* '1' => '~' */ { 0x34, 0x7e }, /* '4' => '~' */ { 0x37, 0x60 }, /* '7' => '`' */ + { 0x3a, 0x7e }, /* ':' => '~' */ + { 0x56, 0x60 }, /* 'V' => '`' */ + { 0x7c, 0x7e }, /* '|' => '~' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_cf.c b/src/hci/keymap/keymap_cf.c index 434e3383c..55bbfc1a4 100644 --- a/src/hci/keymap/keymap_cf.c +++ b/src/hci/keymap/keymap_cf.c @@ -33,6 +33,7 @@ static struct keymap_key cf_altgr[] = { { 0x27, 0x7b }, /* '\'' => '{' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x3b, 0x7e }, /* ';' => '~' */ + { 0x5c, 0x7d }, /* '\\' => '}' */ { 0x60, 0x5c }, /* '`' => '\\' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_cz.c b/src/hci/keymap/keymap_cz.c index fb072b117..08e9638e1 100644 --- a/src/hci/keymap/keymap_cz.c +++ b/src/hci/keymap/keymap_cz.c @@ -50,6 +50,9 @@ static struct keymap_key cz_basic[] = { /** "cz" AltGr remapping */ static struct keymap_key cz_altgr[] = { + { 0x21, 0x7e }, /* '!' => '~' */ + { 0x24, 0x7e }, /* '$' => '~' */ + { 0x29, 0x7e }, /* ')' => '~' */ { 0x2c, 0x3c }, /* ',' => '<' */ { 0x2e, 0x3e }, /* '.' => '>' */ { 0x2f, 0x2a }, /* '/' => '*' */ @@ -60,10 +63,15 @@ static struct keymap_key cz_altgr[] = { { 0x37, 0x26 }, /* '7' => '&' */ { 0x38, 0x2a }, /* '8' => '*' */ { 0x39, 0x7b }, /* '9' => '{' */ + { 0x3a, 0x7e }, /* ':' => '~' */ { 0x3b, 0x24 }, /* ';' => '$' */ + { 0x4b, 0x26 }, /* 'K' => '&' */ + { 0x58, 0x3e }, /* 'X' => '>' */ + { 0x5a, 0x3c }, /* 'Z' => '<' */ { 0x61, 0x7e }, /* 'a' => '~' */ { 0x62, 0x7b }, /* 'b' => '{' */ { 0x63, 0x26 }, /* 'c' => '&' */ + { 0x66, 0x5b }, /* 'f' => '[' */ { 0x67, 0x5d }, /* 'g' => ']' */ { 0x6e, 0x7d }, /* 'n' => '}' */ { 0x76, 0x40 }, /* 'v' => '@' */ diff --git a/src/hci/keymap/keymap_de.c b/src/hci/keymap/keymap_de.c index bbd39520f..ca5e4a9a9 100644 --- a/src/hci/keymap/keymap_de.c +++ b/src/hci/keymap/keymap_de.c @@ -47,8 +47,13 @@ static struct keymap_key de_basic[] = { static struct keymap_key de_altgr[] = { { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ + { 0x3b, 0x7e }, /* ';' => '~' */ + { 0x5d, 0x7e }, /* ']' => '~' */ { 0x71, 0x40 }, /* 'q' => '@' */ + { 0x7c, 0x7e }, /* '|' => '~' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_dk.c b/src/hci/keymap/keymap_dk.c index 6d2e60aca..5b229024a 100644 --- a/src/hci/keymap/keymap_dk.c +++ b/src/hci/keymap/keymap_dk.c @@ -39,7 +39,14 @@ static struct keymap_key dk_basic[] = { static struct keymap_key dk_altgr[] = { { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x34, 0x24 }, /* '4' => '$' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x3a, 0x7e }, /* ':' => '~' */ { 0x3d, 0x7c }, /* '=' => '|' */ + { 0x5c, 0x7e }, /* '\\' => '~' */ + { 0x5d, 0x7e }, /* ']' => '~' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_es.c b/src/hci/keymap/keymap_es.c index 614ca7b8b..93d87f2a0 100644 --- a/src/hci/keymap/keymap_es.c +++ b/src/hci/keymap/keymap_es.c @@ -37,14 +37,27 @@ static struct keymap_key es_basic[] = { /** "es" AltGr remapping */ static struct keymap_key es_altgr[] = { + { 0x22, 0x7b }, /* '"' => '{' */ { 0x27, 0x7b }, /* '\'' => '{' */ + { 0x2b, 0x7e }, /* '+' => '~' */ + { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ + { 0x31, 0x7c }, /* '1' => '|' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x33, 0x23 }, /* '3' => '#' */ + { 0x34, 0x7e }, /* '4' => '~' */ { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ + { 0x3a, 0x7e }, /* ':' => '~' */ + { 0x3b, 0x7e }, /* ';' => '~' */ + { 0x3d, 0x7e }, /* '=' => '~' */ { 0x5c, 0x7d }, /* '\\' => '}' */ + { 0x60, 0x5c }, /* '`' => '\\' */ { 0x71, 0x40 }, /* 'q' => '@' */ + { 0x7c, 0x7e }, /* '|' => '~' */ + { 0x7e, 0x5c }, /* '~' => '\\' */ + { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_et.c b/src/hci/keymap/keymap_et.c index f3eb02eab..4d763266f 100644 --- a/src/hci/keymap/keymap_et.c +++ b/src/hci/keymap/keymap_et.c @@ -35,8 +35,18 @@ static struct keymap_key et_basic[] = { /** "et" AltGr remapping */ static struct keymap_key et_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x2d, 0x5c }, /* '-' => '\\' */ + { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x34, 0x24 }, /* '4' => '$' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x5f, 0x5c }, /* '_' => '\\' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_fi.c b/src/hci/keymap/keymap_fi.c index 622f06252..ac69813e8 100644 --- a/src/hci/keymap/keymap_fi.c +++ b/src/hci/keymap/keymap_fi.c @@ -38,6 +38,12 @@ static struct keymap_key fi_altgr[] = { { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x34, 0x24 }, /* '4' => '$' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x49, 0x7c }, /* 'I' => '|' */ + { 0x5d, 0x7e }, /* ']' => '~' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_fr.c b/src/hci/keymap/keymap_fr.c index c002bf95a..ad797f876 100644 --- a/src/hci/keymap/keymap_fr.c +++ b/src/hci/keymap/keymap_fr.c @@ -68,9 +68,15 @@ static struct keymap_key fr_altgr[] = { { 0x2d, 0x5d }, /* '-' => ']' */ { 0x30, 0x40 }, /* '0' => '@' */ { 0x33, 0x23 }, /* '3' => '#' */ + { 0x34, 0x7b }, /* '4' => '{' */ { 0x35, 0x5b }, /* '5' => '[' */ + { 0x36, 0x7c }, /* '6' => '|' */ + { 0x37, 0x60 }, /* '7' => '`' */ { 0x38, 0x5c }, /* '8' => '\\' */ + { 0x3d, 0x7d }, /* '=' => '}' */ + { 0x5c, 0x60 }, /* '\\' => '`' */ { 0x61, 0x40 }, /* 'a' => '@' */ + { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_hu.c b/src/hci/keymap/keymap_hu.c index 8f2d70aac..d64baaebf 100644 --- a/src/hci/keymap/keymap_hu.c +++ b/src/hci/keymap/keymap_hu.c @@ -37,18 +37,36 @@ static struct keymap_key hu_basic[] = { /** "hu" AltGr remapping */ static struct keymap_key hu_altgr[] = { + { 0x21, 0x7e }, /* '!' => '~' */ + { 0x23, 0x5e }, /* '#' => '^' */ + { 0x26, 0x60 }, /* '&' => '`' */ + { 0x2c, 0x3b }, /* ',' => ';' */ { 0x2e, 0x3e }, /* '.' => '>' */ { 0x2f, 0x2a }, /* '/' => '*' */ + { 0x30, 0x7e }, /* '0' => '~' */ + { 0x31, 0x7e }, /* '1' => '~' */ { 0x32, 0x5e }, /* '2' => '^' */ { 0x33, 0x5e }, /* '3' => '^' */ + { 0x34, 0x7e }, /* '4' => '~' */ { 0x37, 0x60 }, /* '7' => '`' */ { 0x3b, 0x24 }, /* ';' => '$' */ + { 0x4b, 0x26 }, /* 'K' => '&' */ + { 0x58, 0x3e }, /* 'X' => '>' */ + { 0x5a, 0x3c }, /* 'Z' => '<' */ + { 0x62, 0x7b }, /* 'b' => '{' */ { 0x63, 0x26 }, /* 'c' => '&' */ + { 0x66, 0x5b }, /* 'f' => '[' */ + { 0x67, 0x5d }, /* 'g' => ']' */ { 0x6d, 0x3c }, /* 'm' => '<' */ + { 0x6e, 0x7d }, /* 'n' => '}' */ + { 0x71, 0x5c }, /* 'q' => '\\' */ { 0x76, 0x40 }, /* 'v' => '@' */ + { 0x77, 0x7c }, /* 'w' => '|' */ { 0x78, 0x23 }, /* 'x' => '#' */ { 0x7a, 0x3e }, /* 'z' => '>' */ + { 0x7c, 0x7e }, /* '|' => '~' */ { 0xdc, 0x3c }, /* Pseudo-'\\' => '<' */ + { 0xfc, 0x3e }, /* Pseudo-'|' => '>' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_it.c b/src/hci/keymap/keymap_it.c index a55dafe6a..2511bb791 100644 --- a/src/hci/keymap/keymap_it.c +++ b/src/hci/keymap/keymap_it.c @@ -37,13 +37,19 @@ static struct keymap_key it_basic[] = { /** "it" AltGr remapping */ static struct keymap_key it_altgr[] = { + { 0x23, 0x7e }, /* '#' => '~' */ + { 0x27, 0x23 }, /* '\'' => '#' */ { 0x2d, 0x60 }, /* '-' => '`' */ { 0x30, 0x7d }, /* '0' => '}' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ { 0x3b, 0x40 }, /* ';' => '@' */ { 0x3d, 0x7e }, /* '=' => '~' */ + { 0x40, 0x7e }, /* '@' => '~' */ { 0x5c, 0x60 }, /* '\\' => '`' */ { 0x71, 0x40 }, /* 'q' => '@' */ + { 0x7c, 0x7e }, /* '|' => '~' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_lt.c b/src/hci/keymap/keymap_lt.c index 5d6ee5a8c..a237b1d62 100644 --- a/src/hci/keymap/keymap_lt.c +++ b/src/hci/keymap/keymap_lt.c @@ -17,6 +17,10 @@ static struct keymap_key lt_basic[] = { /** "lt" AltGr remapping */ static struct keymap_key lt_altgr[] = { + { 0x22, 0x5e }, /* '"' => '^' */ + { 0x27, 0x5e }, /* '\'' => '^' */ + { 0x4b, 0x26 }, /* 'K' => '&' */ + { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_mt.c b/src/hci/keymap/keymap_mt.c index 0a9a110b0..a95c5b4e8 100644 --- a/src/hci/keymap/keymap_mt.c +++ b/src/hci/keymap/keymap_mt.c @@ -22,6 +22,11 @@ static struct keymap_key mt_basic[] = { /** "mt" AltGr remapping */ static struct keymap_key mt_altgr[] = { + { 0x30, 0x7d }, /* '0' => '}' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x5c, 0x60 }, /* '\\' => '`' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_no-latin1.c b/src/hci/keymap/keymap_no-latin1.c index 63fe85548..1f4cc38d3 100644 --- a/src/hci/keymap/keymap_no-latin1.c +++ b/src/hci/keymap/keymap_no-latin1.c @@ -39,10 +39,15 @@ static struct keymap_key no_latin1_basic[] = { /** "no-latin1" AltGr remapping */ static struct keymap_key no_latin1_altgr[] = { + { 0x22, 0x5b }, /* '"' => '[' */ + { 0x27, 0x7b }, /* '\'' => '{' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ { 0x5b, 0x7d }, /* '[' => '}' */ + { 0x7b, 0x5d }, /* '{' => ']' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_no.c b/src/hci/keymap/keymap_no.c index 4b2f7268e..239e3aea5 100644 --- a/src/hci/keymap/keymap_no.c +++ b/src/hci/keymap/keymap_no.c @@ -41,6 +41,13 @@ static struct keymap_key no_basic[] = { static struct keymap_key no_altgr[] = { { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x34, 0x24 }, /* '4' => '$' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x3a, 0x7e }, /* ':' => '~' */ + { 0x5c, 0x7e }, /* '\\' => '~' */ + { 0x5d, 0x7e }, /* ']' => '~' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_pt.c b/src/hci/keymap/keymap_pt.c index f294e9563..75bf565ce 100644 --- a/src/hci/keymap/keymap_pt.c +++ b/src/hci/keymap/keymap_pt.c @@ -44,6 +44,7 @@ static struct keymap_key pt_altgr[] = { { 0x32, 0x40 }, /* '2' => '@' */ { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ + { 0x39, 0x5d }, /* '9' => ']' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_se.c b/src/hci/keymap/keymap_se.c index 6ca990444..9c6cf64a4 100644 --- a/src/hci/keymap/keymap_se.c +++ b/src/hci/keymap/keymap_se.c @@ -40,6 +40,11 @@ static struct keymap_key se_altgr[] = { { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x34, 0x24 }, /* '4' => '$' */ + { 0x37, 0x7b }, /* '7' => '{' */ + { 0x38, 0x5b }, /* '8' => '[' */ + { 0x39, 0x5d }, /* '9' => ']' */ + { 0x5d, 0x7e }, /* ']' => '~' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } diff --git a/src/hci/keymap/keymap_sg.c b/src/hci/keymap/keymap_sg.c index 9a6db9cb4..2afe59c61 100644 --- a/src/hci/keymap/keymap_sg.c +++ b/src/hci/keymap/keymap_sg.c @@ -45,9 +45,11 @@ static struct keymap_key sg_basic[] = { /** "sg" AltGr remapping */ static struct keymap_key sg_altgr[] = { + { 0x27, 0x7b }, /* '\'' => '{' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x33, 0x23 }, /* '3' => '#' */ { 0x37, 0x7c }, /* '7' => '|' */ + { 0x3d, 0x7e }, /* '=' => '~' */ { 0x5c, 0x7d }, /* '\\' => '}' */ { 0, 0 } }; diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index 8df949612..632f71eda 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -33,6 +33,10 @@ import textwrap from typing import ClassVar, Optional +BACKSPACE = chr(0x7f) +"""Backspace character""" + + class KeyType(IntEnum): """Key types""" @@ -174,7 +178,7 @@ class KeyLayout(UserDict[KeyModifiers, Sequence[Key]]): KeyModifiers.NONE: [(KEY_NON_US, ord('\\'))], KeyModifiers.SHIFT: [(KEY_NON_US, ord('|'))], # Treat Ctrl-Backspace as producing Backspace rather than Ctrl-H - KeyModifiers.CTRL: [(KEY_BACKSPACE, 0x7f)], + KeyModifiers.CTRL: [(KEY_BACKSPACE, ord(BACKSPACE))], }, 'il': { # Redefine some otherwise unreachable ASCII characters @@ -200,11 +204,6 @@ class KeyLayout(UserDict[KeyModifiers, Sequence[Key]]): """Basic shifted keyboard layout""" return self[KeyModifiers.SHIFT] - @property - def altgr(self): - """AltGr keyboard layout""" - return self.get(KeyModifiers.ALTGR, self.unshifted) - @classmethod def load(cls, name: str) -> KeyLayout: """Load keymap using 'loadkeys -b'""" @@ -281,7 +280,7 @@ class BiosKeyLayout(KeyLayout): return inverse -class KeymapKeys(UserDict[str, str]): +class KeymapKeys(UserDict[str, Optional[str]]): """An ASCII character remapping""" @classmethod @@ -312,7 +311,8 @@ class KeymapKeys(UserDict[str, str]): self.ascii_name(source), self.ascii_name(target) ) for source, target in self.items() - if ord(source) & ~BiosKeyLayout.KEY_PSEUDO != ord(target) + if target + and ord(source) & ~BiosKeyLayout.KEY_PSEUDO != ord(target) ) + '\t{ 0, 0 }\n}' @@ -335,13 +335,12 @@ class Keymap: # Construct raw mapping from source ASCII to target ASCII raw = {source: self.target[key.modifiers][key.keycode].ascii for source, key in self.source.inverse.items()} - # Eliminate any null mappings, mappings that attempt to remap - # the backspace key, or identity mappings + # Eliminate any identity mappings, or mappings that attempt to + # remap the backspace key table = {source: target for source, target in raw.items() - if target - and ord(source) != 0x7f - and ord(target) != 0x7f - and source != target} + if source != target + and source != BACKSPACE + and target != BACKSPACE} # Recursively delete any mappings that would produce # unreachable alphanumerics (e.g. the "il" keymap, which maps # away the whole lower-case alphabet) @@ -354,8 +353,8 @@ class Keymap: # Sanity check: ensure that all numerics are reachable using # the same shift state digits = '1234567890' - unshifted = ''.join(table.get(x, x) for x in '1234567890') - shifted = ''.join(table.get(x, x) for x in '!@#$%^&*()') + unshifted = ''.join(table.get(x) or x for x in '1234567890') + shifted = ''.join(table.get(x) or x for x in '!@#$%^&*()') if digits not in (shifted, unshifted): raise ValueError("Inconsistent numeric remapping %s / %s" % (unshifted, shifted)) @@ -365,21 +364,22 @@ class Keymap: def altgr(self) -> KeymapKeys: """AltGr remapping table""" # Construct raw mapping from source ASCII to target ASCII - raw = {source: self.target.altgr[key.keycode].ascii - for source, key in self.source.inverse.items() - if key.modifiers == KeyModifiers.NONE} + raw = { + source: + self.target.get((key.modifiers | KeyModifiers.ALTGR), + self.target[key.modifiers])[key.keycode].ascii + for source, key in self.source.inverse.items() + } # Identify printable keys that are unreachable via the basic map basic = self.basic unmapped = set(x for x in basic.keys() if x.isascii() and x.isprintable()) remapped = set(basic.values()) unreachable = unmapped - remapped - # Eliminate any null mappings, mappings for unprintable - # characters, or mappings for characters that are reachable - # via the basic map + # Eliminate any mappings for unprintable characters, or + # mappings for characters that are reachable via the basic map table = {source: target for source, target in raw.items() if source.isprintable() - and target and target in unreachable} # Check that all characters are now reachable unreachable -= set(table.values()) -- cgit v1.2.3-55-g7522 From 11e17991d0729fd17ab06d94ec67a8ca48032af4 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 16 Feb 2022 00:11:33 +0000 Subject: [console] Ensure that US keyboard map appears at start of linker table Signed-off-by: Michael Brown --- src/hci/keymap/keymap_us.c | 2 +- src/include/ipxe/keymap.h | 5 ++++- src/util/genkeymap.py | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/util') diff --git a/src/hci/keymap/keymap_us.c b/src/hci/keymap/keymap_us.c index 6432474e2..b8e604a48 100644 --- a/src/hci/keymap/keymap_us.c +++ b/src/hci/keymap/keymap_us.c @@ -21,7 +21,7 @@ static struct keymap_key us_altgr[] = { }; /** "us" keyboard map */ -struct keymap us_keymap __keymap = { +struct keymap us_keymap __keymap_default = { .name = "us", .basic = us_basic, .altgr = us_altgr, diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h index 72b6961ef..392d3ab8f 100644 --- a/src/include/ipxe/keymap.h +++ b/src/include/ipxe/keymap.h @@ -39,8 +39,11 @@ struct keymap { /** Keyboard mapping table */ #define KEYMAP __table ( struct keymap, "keymap" ) +/** Define a default keyboard mapping */ +#define __keymap_default __table_entry ( KEYMAP, 01 ) + /** Define a keyboard mapping */ -#define __keymap __table_entry ( KEYMAP, 01 ) +#define __keymap __table_entry ( KEYMAP, 02 ) /** Mappable character mask */ #define KEYMAP_MASK 0xff diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index 632f71eda..9fd987477 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -399,6 +399,7 @@ class Keymap: keymap_name = self.cname("keymap") basic_name = self.cname("basic") altgr_name = self.cname("altgr") + attribute = "__keymap_default" if self.name == "us" else "__keymap" code = textwrap.dedent(f""" /** @file * @@ -419,7 +420,7 @@ class Keymap: static struct keymap_key {altgr_name}[] = %s; /** "{self.name}" keyboard map */ - struct keymap {keymap_name} __keymap = {{ + struct keymap {keymap_name} {attribute} = {{ \t.name = "{self.name}", \t.basic = {basic_name}, \t.altgr = {altgr_name}, -- cgit v1.2.3-55-g7522 From bc5c612f756b11c08e5e1eaeee3c1fd91252534d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 16 Feb 2022 15:19:35 +0000 Subject: [console] Include mappings for AltGr-Shift- The BIOS console's interpretation of LShift+RShift as equivalent to AltGr requires the shifted ASCII characters to be present in the AltGr mapping table, to allow AltGr-Shift- to be interpreted in the same way as AltGr-. For keyboard layouts that have different ASCII characters for AltGr- and AltGr-Shift-, this will potentially leave the character for AltGr- inaccessible via the BIOS console if the BIOS requires the use of the LShift+RShift workaround. This theoretically affects the numeric keys in the Lithuanian ("lt") keyboard layout (where the numerals are accessed via AltGr- and punctuation characters via AltGr-Shift-), but the simple workaround for that keyboard layout is to avoid using AltGr and Shift entirely since the unmodified numeric keys are not remapped anyway. Signed-off-by: Michael Brown --- src/hci/keymap/keymap_al.c | 1 + src/hci/keymap/keymap_cf.c | 6 ++++++ src/hci/keymap/keymap_cz.c | 9 +++++++++ src/hci/keymap/keymap_de.c | 8 ++++++++ src/hci/keymap/keymap_dk.c | 8 ++++++++ src/hci/keymap/keymap_es.c | 8 ++++++++ src/hci/keymap/keymap_fi.c | 4 ++++ src/hci/keymap/keymap_fr.c | 8 ++++++++ src/hci/keymap/keymap_hu.c | 13 +++++++++++++ src/hci/keymap/keymap_il.c | 5 +++++ src/hci/keymap/keymap_it.c | 8 ++++++++ src/hci/keymap/keymap_lt.c | 1 + src/hci/keymap/keymap_mt.c | 5 +++++ src/hci/keymap/keymap_nl.c | 1 + src/hci/keymap/keymap_no-latin1.c | 4 ++++ src/hci/keymap/keymap_no.c | 6 ++++++ src/hci/keymap/keymap_pt.c | 5 +++++ src/hci/keymap/keymap_se.c | 6 ++++++ src/hci/keymap/keymap_sg.c | 7 +++++++ src/util/genkeymap.py | 8 +++++--- 20 files changed, 118 insertions(+), 3 deletions(-) (limited to 'src/util') diff --git a/src/hci/keymap/keymap_al.c b/src/hci/keymap/keymap_al.c index 6e14395a5..ad4792b9b 100644 --- a/src/hci/keymap/keymap_al.c +++ b/src/hci/keymap/keymap_al.c @@ -39,6 +39,7 @@ static struct keymap_key al_basic[] = { static struct keymap_key al_altgr[] = { { 0x21, 0x7e }, /* '!' => '~' */ { 0x26, 0x60 }, /* '&' => '`' */ + { 0x29, 0x7e }, /* ')' => '~' */ { 0x30, 0x7e }, /* '0' => '~' */ { 0x31, 0x7e }, /* '1' => '~' */ { 0x34, 0x7e }, /* '4' => '~' */ diff --git a/src/hci/keymap/keymap_cf.c b/src/hci/keymap/keymap_cf.c index 55bbfc1a4..7ecfc4448 100644 --- a/src/hci/keymap/keymap_cf.c +++ b/src/hci/keymap/keymap_cf.c @@ -30,11 +30,17 @@ static struct keymap_key cf_basic[] = { /** "cf" AltGr remapping */ static struct keymap_key cf_altgr[] = { + { 0x22, 0x7b }, /* '"' => '{' */ { 0x27, 0x7b }, /* '\'' => '{' */ { 0x32, 0x40 }, /* '2' => '@' */ + { 0x3a, 0x7e }, /* ':' => '~' */ { 0x3b, 0x7e }, /* ';' => '~' */ { 0x5c, 0x7d }, /* '\\' => '}' */ { 0x60, 0x5c }, /* '`' => '\\' */ + { 0x7b, 0x5b }, /* '{' => '[' */ + { 0x7c, 0x7d }, /* '|' => '}' */ + { 0x7d, 0x5d }, /* '}' => ']' */ + { 0x7e, 0x5c }, /* '~' => '\\' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_cz.c b/src/hci/keymap/keymap_cz.c index 08e9638e1..dd793a8d0 100644 --- a/src/hci/keymap/keymap_cz.c +++ b/src/hci/keymap/keymap_cz.c @@ -52,6 +52,7 @@ static struct keymap_key cz_basic[] = { static struct keymap_key cz_altgr[] = { { 0x21, 0x7e }, /* '!' => '~' */ { 0x24, 0x7e }, /* '$' => '~' */ + { 0x28, 0x7b }, /* '(' => '{' */ { 0x29, 0x7e }, /* ')' => '~' */ { 0x2c, 0x3c }, /* ',' => '<' */ { 0x2e, 0x3e }, /* '.' => '>' */ @@ -65,7 +66,13 @@ static struct keymap_key cz_altgr[] = { { 0x39, 0x7b }, /* '9' => '{' */ { 0x3a, 0x7e }, /* ':' => '~' */ { 0x3b, 0x24 }, /* ';' => '$' */ + { 0x41, 0x7e }, /* 'A' => '~' */ + { 0x42, 0x7b }, /* 'B' => '{' */ + { 0x43, 0x26 }, /* 'C' => '&' */ + { 0x46, 0x5b }, /* 'F' => '[' */ + { 0x47, 0x5d }, /* 'G' => ']' */ { 0x4b, 0x26 }, /* 'K' => '&' */ + { 0x56, 0x40 }, /* 'V' => '@' */ { 0x58, 0x3e }, /* 'X' => '>' */ { 0x5a, 0x3c }, /* 'Z' => '<' */ { 0x61, 0x7e }, /* 'a' => '~' */ @@ -76,6 +83,8 @@ static struct keymap_key cz_altgr[] = { { 0x6e, 0x7d }, /* 'n' => '}' */ { 0x76, 0x40 }, /* 'v' => '@' */ { 0x78, 0x23 }, /* 'x' => '#' */ + { 0x7b, 0x5b }, /* '{' => '[' */ + { 0x7d, 0x5d }, /* '}' => ']' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_de.c b/src/hci/keymap/keymap_de.c index ca5e4a9a9..fb1136dc7 100644 --- a/src/hci/keymap/keymap_de.c +++ b/src/hci/keymap/keymap_de.c @@ -45,15 +45,23 @@ static struct keymap_key de_basic[] = { /** "de" AltGr remapping */ static struct keymap_key de_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ + { 0x3a, 0x7e }, /* ':' => '~' */ { 0x3b, 0x7e }, /* ';' => '~' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x5d, 0x7e }, /* ']' => '~' */ + { 0x5f, 0x5c }, /* '_' => '\\' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0x7c, 0x7e }, /* '|' => '~' */ + { 0x7d, 0x7e }, /* '}' => '~' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_dk.c b/src/hci/keymap/keymap_dk.c index 5b229024a..45cdeb25d 100644 --- a/src/hci/keymap/keymap_dk.c +++ b/src/hci/keymap/keymap_dk.c @@ -37,6 +37,11 @@ static struct keymap_key dk_basic[] = { /** "dk" AltGr remapping */ static struct keymap_key dk_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ + { 0x2b, 0x7c }, /* '+' => '|' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x34, 0x24 }, /* '4' => '$' */ @@ -45,9 +50,12 @@ static struct keymap_key dk_altgr[] = { { 0x39, 0x5d }, /* '9' => ']' */ { 0x3a, 0x7e }, /* ':' => '~' */ { 0x3d, 0x7c }, /* '=' => '|' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x5c, 0x7e }, /* '\\' => '~' */ { 0x5d, 0x7e }, /* ']' => '~' */ { 0x71, 0x40 }, /* 'q' => '@' */ + { 0x7c, 0x7e }, /* '|' => '~' */ + { 0xfc, 0x5c }, /* Pseudo-'|' => '\\' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_es.c b/src/hci/keymap/keymap_es.c index 93d87f2a0..c1c55b348 100644 --- a/src/hci/keymap/keymap_es.c +++ b/src/hci/keymap/keymap_es.c @@ -37,8 +37,13 @@ static struct keymap_key es_basic[] = { /** "es" AltGr remapping */ static struct keymap_key es_altgr[] = { + { 0x21, 0x7c }, /* '!' => '|' */ { 0x22, 0x7b }, /* '"' => '{' */ + { 0x26, 0x7b }, /* '&' => '{' */ { 0x27, 0x7b }, /* '\'' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x2b, 0x7e }, /* '+' => '~' */ { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ @@ -52,9 +57,12 @@ static struct keymap_key es_altgr[] = { { 0x3a, 0x7e }, /* ':' => '~' */ { 0x3b, 0x7e }, /* ';' => '~' */ { 0x3d, 0x7e }, /* '=' => '~' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x5c, 0x7d }, /* '\\' => '}' */ + { 0x5f, 0x5c }, /* '_' => '\\' */ { 0x60, 0x5c }, /* '`' => '\\' */ { 0x71, 0x40 }, /* 'q' => '@' */ + { 0x7b, 0x5b }, /* '{' => '[' */ { 0x7c, 0x7e }, /* '|' => '~' */ { 0x7e, 0x5c }, /* '~' => '\\' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ diff --git a/src/hci/keymap/keymap_fi.c b/src/hci/keymap/keymap_fi.c index ac69813e8..8bcd0c393 100644 --- a/src/hci/keymap/keymap_fi.c +++ b/src/hci/keymap/keymap_fi.c @@ -35,6 +35,8 @@ static struct keymap_key fi_basic[] = { /** "fi" AltGr remapping */ static struct keymap_key fi_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x29, 0x7d }, /* ')' => '}' */ { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ @@ -44,6 +46,8 @@ static struct keymap_key fi_altgr[] = { { 0x39, 0x5d }, /* '9' => ']' */ { 0x49, 0x7c }, /* 'I' => '|' */ { 0x5d, 0x7e }, /* ']' => '~' */ + { 0x5f, 0x5c }, /* '_' => '\\' */ + { 0x7d, 0x7e }, /* '}' => '~' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_fr.c b/src/hci/keymap/keymap_fr.c index ad797f876..23a0837fb 100644 --- a/src/hci/keymap/keymap_fr.c +++ b/src/hci/keymap/keymap_fr.c @@ -65,6 +65,11 @@ static struct keymap_key fr_basic[] = { /** "fr" AltGr remapping */ static struct keymap_key fr_altgr[] = { + { 0x25, 0x5b }, /* '%' => '[' */ + { 0x26, 0x60 }, /* '&' => '`' */ + { 0x29, 0x40 }, /* ')' => '@' */ + { 0x2a, 0x5c }, /* '*' => '\\' */ + { 0x2b, 0x7d }, /* '+' => '}' */ { 0x2d, 0x5d }, /* '-' => ']' */ { 0x30, 0x40 }, /* '0' => '@' */ { 0x33, 0x23 }, /* '3' => '#' */ @@ -74,7 +79,10 @@ static struct keymap_key fr_altgr[] = { { 0x37, 0x60 }, /* '7' => '`' */ { 0x38, 0x5c }, /* '8' => '\\' */ { 0x3d, 0x7d }, /* '=' => '}' */ + { 0x41, 0x40 }, /* 'A' => '@' */ { 0x5c, 0x60 }, /* '\\' => '`' */ + { 0x5e, 0x7c }, /* '^' => '|' */ + { 0x5f, 0x5d }, /* '_' => ']' */ { 0x61, 0x40 }, /* 'a' => '@' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } diff --git a/src/hci/keymap/keymap_hu.c b/src/hci/keymap/keymap_hu.c index d64baaebf..771671408 100644 --- a/src/hci/keymap/keymap_hu.c +++ b/src/hci/keymap/keymap_hu.c @@ -39,7 +39,9 @@ static struct keymap_key hu_basic[] = { static struct keymap_key hu_altgr[] = { { 0x21, 0x7e }, /* '!' => '~' */ { 0x23, 0x5e }, /* '#' => '^' */ + { 0x24, 0x7e }, /* '$' => '~' */ { 0x26, 0x60 }, /* '&' => '`' */ + { 0x29, 0x7e }, /* ')' => '~' */ { 0x2c, 0x3b }, /* ',' => ';' */ { 0x2e, 0x3e }, /* '.' => '>' */ { 0x2f, 0x2a }, /* '/' => '*' */ @@ -49,8 +51,19 @@ static struct keymap_key hu_altgr[] = { { 0x33, 0x5e }, /* '3' => '^' */ { 0x34, 0x7e }, /* '4' => '~' */ { 0x37, 0x60 }, /* '7' => '`' */ + { 0x3a, 0x24 }, /* ':' => '$' */ { 0x3b, 0x24 }, /* ';' => '$' */ + { 0x3c, 0x3b }, /* '<' => ';' */ + { 0x40, 0x5e }, /* '@' => '^' */ + { 0x42, 0x7b }, /* 'B' => '{' */ + { 0x43, 0x26 }, /* 'C' => '&' */ + { 0x46, 0x5b }, /* 'F' => '[' */ + { 0x47, 0x5d }, /* 'G' => ']' */ { 0x4b, 0x26 }, /* 'K' => '&' */ + { 0x4d, 0x3c }, /* 'M' => '<' */ + { 0x51, 0x5c }, /* 'Q' => '\\' */ + { 0x56, 0x40 }, /* 'V' => '@' */ + { 0x57, 0x7c }, /* 'W' => '|' */ { 0x58, 0x3e }, /* 'X' => '>' */ { 0x5a, 0x3c }, /* 'Z' => '<' */ { 0x62, 0x7b }, /* 'b' => '{' */ diff --git a/src/hci/keymap/keymap_il.c b/src/hci/keymap/keymap_il.c index 95e33a0bd..b11e7ce71 100644 --- a/src/hci/keymap/keymap_il.c +++ b/src/hci/keymap/keymap_il.c @@ -31,7 +31,12 @@ static struct keymap_key il_basic[] = { /** "il" AltGr remapping */ static struct keymap_key il_altgr[] = { + { 0x22, 0x27 }, /* '"' => '\'' */ + { 0x3f, 0x2f }, /* '?' => '/' */ { 0x5c, 0x60 }, /* '\\' => '`' */ + { 0x71, 0x2f }, /* 'q' => '/' */ + { 0x77, 0x27 }, /* 'w' => '\'' */ + { 0x7c, 0x60 }, /* '|' => '`' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_it.c b/src/hci/keymap/keymap_it.c index 2511bb791..bb14ae1bd 100644 --- a/src/hci/keymap/keymap_it.c +++ b/src/hci/keymap/keymap_it.c @@ -37,17 +37,25 @@ static struct keymap_key it_basic[] = { /** "it" AltGr remapping */ static struct keymap_key it_altgr[] = { + { 0x22, 0x23 }, /* '"' => '#' */ { 0x23, 0x7e }, /* '#' => '~' */ + { 0x26, 0x7b }, /* '&' => '{' */ { 0x27, 0x23 }, /* '\'' => '#' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x2d, 0x60 }, /* '-' => '`' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ + { 0x3a, 0x40 }, /* ':' => '@' */ { 0x3b, 0x40 }, /* ';' => '@' */ { 0x3d, 0x7e }, /* '=' => '~' */ { 0x40, 0x7e }, /* '@' => '~' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x5c, 0x60 }, /* '\\' => '`' */ + { 0x5f, 0x60 }, /* '_' => '`' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0x7c, 0x7e }, /* '|' => '~' */ { 0, 0 } diff --git a/src/hci/keymap/keymap_lt.c b/src/hci/keymap/keymap_lt.c index a237b1d62..f8e60a5c5 100644 --- a/src/hci/keymap/keymap_lt.c +++ b/src/hci/keymap/keymap_lt.c @@ -20,6 +20,7 @@ static struct keymap_key lt_altgr[] = { { 0x22, 0x5e }, /* '"' => '^' */ { 0x27, 0x5e }, /* '\'' => '^' */ { 0x4b, 0x26 }, /* 'K' => '&' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_mt.c b/src/hci/keymap/keymap_mt.c index a95c5b4e8..0997bfe93 100644 --- a/src/hci/keymap/keymap_mt.c +++ b/src/hci/keymap/keymap_mt.c @@ -22,11 +22,16 @@ static struct keymap_key mt_basic[] = { /** "mt" AltGr remapping */ static struct keymap_key mt_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ { 0x5c, 0x60 }, /* '\\' => '`' */ + { 0x7e, 0x60 }, /* '~' => '`' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_nl.c b/src/hci/keymap/keymap_nl.c index 8038d4d37..97c7e8b5d 100644 --- a/src/hci/keymap/keymap_nl.c +++ b/src/hci/keymap/keymap_nl.c @@ -46,6 +46,7 @@ static struct keymap_key nl_altgr[] = { { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x38, 0x7b }, /* '8' => '{' */ { 0x39, 0x7d }, /* '9' => '}' */ + { 0x5f, 0x5c }, /* '_' => '\\' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_no-latin1.c b/src/hci/keymap/keymap_no-latin1.c index 1f4cc38d3..80df84889 100644 --- a/src/hci/keymap/keymap_no-latin1.c +++ b/src/hci/keymap/keymap_no-latin1.c @@ -40,7 +40,11 @@ static struct keymap_key no_latin1_basic[] = { /** "no-latin1" AltGr remapping */ static struct keymap_key no_latin1_altgr[] = { { 0x22, 0x5b }, /* '"' => '[' */ + { 0x26, 0x7b }, /* '&' => '{' */ { 0x27, 0x7b }, /* '\'' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x37, 0x7b }, /* '7' => '{' */ diff --git a/src/hci/keymap/keymap_no.c b/src/hci/keymap/keymap_no.c index 239e3aea5..0a624c3ab 100644 --- a/src/hci/keymap/keymap_no.c +++ b/src/hci/keymap/keymap_no.c @@ -39,6 +39,10 @@ static struct keymap_key no_basic[] = { /** "no" AltGr remapping */ static struct keymap_key no_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x34, 0x24 }, /* '4' => '$' */ @@ -46,9 +50,11 @@ static struct keymap_key no_altgr[] = { { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ { 0x3a, 0x7e }, /* ':' => '~' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x5c, 0x7e }, /* '\\' => '~' */ { 0x5d, 0x7e }, /* ']' => '~' */ { 0x71, 0x40 }, /* 'q' => '@' */ + { 0x7c, 0x7e }, /* '|' => '~' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_pt.c b/src/hci/keymap/keymap_pt.c index 75bf565ce..3133c1561 100644 --- a/src/hci/keymap/keymap_pt.c +++ b/src/hci/keymap/keymap_pt.c @@ -40,11 +40,16 @@ static struct keymap_key pt_basic[] = { /** "pt" AltGr remapping */ static struct keymap_key pt_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0, 0 } }; diff --git a/src/hci/keymap/keymap_se.c b/src/hci/keymap/keymap_se.c index 9c6cf64a4..2bac96985 100644 --- a/src/hci/keymap/keymap_se.c +++ b/src/hci/keymap/keymap_se.c @@ -37,6 +37,10 @@ static struct keymap_key se_basic[] = { /** "se" AltGr remapping */ static struct keymap_key se_altgr[] = { + { 0x26, 0x7b }, /* '&' => '{' */ + { 0x28, 0x5d }, /* '(' => ']' */ + { 0x29, 0x7d }, /* ')' => '}' */ + { 0x2a, 0x5b }, /* '*' => '[' */ { 0x2d, 0x5c }, /* '-' => '\\' */ { 0x30, 0x7d }, /* '0' => '}' */ { 0x32, 0x40 }, /* '2' => '@' */ @@ -44,7 +48,9 @@ static struct keymap_key se_altgr[] = { { 0x37, 0x7b }, /* '7' => '{' */ { 0x38, 0x5b }, /* '8' => '[' */ { 0x39, 0x5d }, /* '9' => ']' */ + { 0x51, 0x40 }, /* 'Q' => '@' */ { 0x5d, 0x7e }, /* ']' => '~' */ + { 0x5f, 0x5c }, /* '_' => '\\' */ { 0x71, 0x40 }, /* 'q' => '@' */ { 0xdc, 0x7c }, /* Pseudo-'\\' => '|' */ { 0, 0 } diff --git a/src/hci/keymap/keymap_sg.c b/src/hci/keymap/keymap_sg.c index 2afe59c61..c4200099a 100644 --- a/src/hci/keymap/keymap_sg.c +++ b/src/hci/keymap/keymap_sg.c @@ -45,12 +45,19 @@ static struct keymap_key sg_basic[] = { /** "sg" AltGr remapping */ static struct keymap_key sg_altgr[] = { + { 0x22, 0x7b }, /* '"' => '{' */ + { 0x26, 0x7c }, /* '&' => '|' */ { 0x27, 0x7b }, /* '\'' => '{' */ + { 0x2b, 0x7e }, /* '+' => '~' */ { 0x32, 0x40 }, /* '2' => '@' */ { 0x33, 0x23 }, /* '3' => '#' */ { 0x37, 0x7c }, /* '7' => '|' */ { 0x3d, 0x7e }, /* '=' => '~' */ { 0x5c, 0x7d }, /* '\\' => '}' */ + { 0x7b, 0x5b }, /* '{' => '[' */ + { 0x7c, 0x7d }, /* '|' => '}' */ + { 0x7d, 0x5d }, /* '}' => ']' */ + { 0xfc, 0x5c }, /* Pseudo-'|' => '\\' */ { 0, 0 } }; diff --git a/src/util/genkeymap.py b/src/util/genkeymap.py index 9fd987477..b70ce5f72 100755 --- a/src/util/genkeymap.py +++ b/src/util/genkeymap.py @@ -365,9 +365,11 @@ class Keymap: """AltGr remapping table""" # Construct raw mapping from source ASCII to target ASCII raw = { - source: - self.target.get((key.modifiers | KeyModifiers.ALTGR), - self.target[key.modifiers])[key.keycode].ascii + source: next((self.target[x][key.keycode].ascii + for x in (key.modifiers | KeyModifiers.ALTGR, + KeyModifiers.ALTGR, key.modifiers) + if x in self.target + and self.target[x][key.keycode].ascii), None) for source, key in self.source.inverse.items() } # Identify printable keys that are unreachable via the basic map -- cgit v1.2.3-55-g7522