summaryrefslogtreecommitdiffstats
path: root/perl-install/install/share/kmap2bkmap
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-04-25 12:26:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-04-25 12:26:16 +0000
commit126777bc019a54afb4ec51299f2cf9d2841698aa (patch)
tree97f76e571902ead55ba138f1156a4b4f00b9b779 /perl-install/install/share/kmap2bkmap
parentf1f67448efc714873378dfeb8279fae68054a90a (diff)
downloaddrakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.gz
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.bz2
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.xz
drakx-126777bc019a54afb4ec51299f2cf9d2841698aa.zip
re-sync after the big svn loss
Diffstat (limited to 'perl-install/install/share/kmap2bkmap')
-rwxr-xr-xperl-install/install/share/kmap2bkmap39
1 files changed, 39 insertions, 0 deletions
diff --git a/perl-install/install/share/kmap2bkmap b/perl-install/install/share/kmap2bkmap
new file mode 100755
index 000000000..58505dda0
--- /dev/null
+++ b/perl-install/install/share/kmap2bkmap
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+use lib "..";
+use c;
+
+my $KMAP_MAGIC = 0x8B39C07F;
+
+BEGIN { @ARGV == 1 or die "usage: kmap2bkmap <keymap>\n" }
+
+# load unicode keymap
+my $unimap = "$ARGV[0]" . ".uni";
+system("sudo loadkeys $unimap") == 0 or die;
+open F, "dumpkeys -n -f |";
+<F> =~ /^keymaps\s+(.*)/ or die;
+foreach (split ',', $1) {
+ my @l = /(\d+)-(\d+)/;
+ my ($i, $j) = @l ? @l : ($_,$_);
+ $keymaps[$_] = 1 foreach $i .. $j;
+}
+
+print pack("I", $KMAP_MAGIC);
+print map { pack "i", $keymaps[$_] || 0 } 0 .. c::MAX_NR_KEYMAPS()-1;
+
+foreach (<F>) {
+ s/\+0x/0x/g;
+ my ($keycode, $key, undef, @l) = split;
+ $keycode eq 'keycode' or next;
+ my $i = 0;
+ $L[$i++][$key] = hex $_ foreach @l;
+}
+close F or die "dumpkeys failed";
+
+foreach (@L) {
+ foreach my $i (0 .. c::NR_KEYS()-1) {
+ print pack "s", defined $_->[$i] ? $_->[$i] : 0x200;
+ }
+}
+
+exit 0;