UI-KeyboardLayout
view release on metacpan or search on metacpan
lib/UI/KeyboardLayout.pm view on Meta::CPAN
if ($t =~ s/^KEYNAME_DEAD\n((?:(?:\s*[0-9a-f]{4,}\s+".*")?(?:\n|\Z))*)(?=(.*))/KEYNAMES_DEAD\n\n/mi) {
($dead, $next) = ($1,$2);
warn "Unknown keyword follows deadkey names descriptions in MSKLC map file: `$next'"
if length $next and not $next =~ /^(DEADKEY|KEYNAME|LIGATURE|COPYRIGHT|COMPANY|LOCALENAME|LOCALEID|VERSION|SHIFTSTATE|LAYOUT|ATTRIBUTES|KEYNAME_EXT|KEYNAME_DEAD|DESCRIPTIONS|LANGUAGENAMES|ENDKBD)$/i;
$dead =~ /\S/ or warn "EMPTY KEYNAME_DEAD section";
%d = map /^([0-9a-f]+)\s+"(.*)"\s*$/i, split /\n\s*/, $dead;
$d{lc $_} = $d{$_} for keys %d;
$self->{'[seen_knames]'} ||= {};
@{$self->{'[seen_knames]'}}{map {chr hex $_} keys %d} = values %d; # XXXX Overwrites older values
} elsif ($dead =~ /\S/) {
warn "no KEYNAME_DEAD section found" if 0;
}
\%o, \%d, $t; # %o - translation tables; %d - names; $t is what is left of input
}
sub massage_template ($$$) {
my ($self, $t, $r, %seen, %miss) = (shift, shift, shift);
my $keys = join '|', sort {length $b <=> length $a or $a cmp $b} keys %$r; # Prefer matching a longer key
$t =~ s/($keys)/ # warn "Plugging in `$1'";
$seen{$1}++, $r->{$1} /ge; # Can't use \b: see SORT_ORDER_ID_ LOCALE_ID
$seen{$_} or $miss{$_}++ for keys %$r;
warn "The following parts missing in the template: ", join ' ', sort keys %miss if %miss;
$t
}
# http://msdn.microsoft.com/en-us/library/dd373763
# http://msdn.microsoft.com/en-us/library/dd374060
my $template_win = <<'EO_TEMPLATE';
KBD DLLNAME "LAYOUTNAME"
COPYRIGHT "(c) COPYR_YEARS COMPANYNAME"
COMPANY "COMPANYNAME"
LOCALENAME "LOCALE_NAME"
LOCALEID "SORT_ORDER_ID_LOCALE_ID"
VERSION 1.0 // UI::KeyboardLayout version=UIKL_VERSION
MODIFIERS
SHIFTSTATE // With kbdutool the SHIFTSTATE should map to at least 2 columns, and map the Control key (= âhave 2 presentâ)
BITS_TEMPLATE
ATTRIBS
LAYOUT // an extra '@' at the end is a dead key
//SC VK_ Cap COL_HEADERS
// in this row â¸â¶ mean ârightâ: COL_HUMAN
//-- ---- ---- COL_EXPL
LAYOUT_KEYS
DO_LIGA
DEADKEYS
// KEYNAME KEYNAME_EXT KEYNAME_DEAD - used to map a Scancode to Key Name via GetKeyNameText(); null-terminated.
//
// If the name is not found in the first two tables,
// then it is deduced from the character/deadkey this key produces in the unshifted position (as MapVirtualKeyEx()).
// In particular, the special-case in the latter function covers VK_A to VK_Z!
//
// As a corollary, the third table needs only to contain dead keys in the unshifted positions, and only
// at positions not present in the first two tables.
KEYNAME // Mostly from type 4 keyboard, not producing a printable char, non-variable in types 1...6, Ctrl/etc are left versions
01 Esc
0e Backspace
0f Tab
1c Enter
1d Ctrl
2a Shift
36 "Right Shift"
37 "Num *"
38 Alt
39 Space
3a "Caps Lock"
3b F1
3c F2
3d F3
3e F4
3f F5
40 F6
41 F7
42 F8
43 F9
44 F10
45 Pause // VK_NUMLOCK
46 "Scroll Lock"
47 "Num 7" // VK_HOME (starts a block)
48 "Num 8" // ...
49 "Num 9" // ...
4a "Num -" // ...
4b "Num 4" // ...
4c "Num 5" // ...
4d "Num 6" // ...
4e "Num +" // ...
4f "Num 1" // ...
50 "Num 2" // ...
51 "Num 3" // ...
52 "Num 0" // VK_INSERT (ends a block)
53 "Num Del"
54 "Sys Req" // VK_SNAPSHOT ("Print Screen")
56 "Oem 102"
57 F11
58 F12
59 Clear
5a Wctrl
5b Finish
5c Jump // Was AX in older versions
5d EREOF
5e Backtab
5f Auto
62 Zoom
63 Help
64 F13 // These F-keys were wrong in MSKLC (VK-codes, not scancodes)
65 F14
66 F15
67 F16
68 F17
69 F18
6a F19
( run in 0.771 second using v1.01-cache-2.11-cpan-39bf76dae61 )