Package: clusterssh
Version: 4.00.11-2
Followup-For: Bug #364565

Okay, I really had enough of not being able to paste a minus..
so here's the fix. Please test: this code should prioritise 
shiftless keycodes against shifted ones. No implied or expressed
guarantees, however it Works For Me(Tm) and the logic looks sane now.

Using strings for modifiers is a fun way to do it, a numerical array
would make it dead simple but I'm kind of lazy to rewrite the whole
keyboard logic. 

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (2000, 'unstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-1-686-pae (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages clusterssh depends on:
ii  libx11-protocol-perl  0.56-2
ii  openssh-client        1:5.9p1-2
ii  perl-tk               1:804.029-1.2
ii  xterm                 276-2

clusterssh recommends no packages.

clusterssh suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/share/perl5/App/ClusterSSH.pm (from clusterssh 
package)
--- ClusterSSH.pm.orig	2012-04-05 12:04:19.596535136 +0200
+++ ClusterSSH.pm	2012-04-05 12:09:31.563032911 +0200
@@ -531,53 +531,48 @@
 
     logmsg( 1, "Loading keymaps and keycodes" );
 
-    foreach ( 0 .. $#keyboard ) {
-        if ( defined $keyboard[$_][3] ) {
-            if ( defined( $keycodetosym{ $keyboard[$_][3] } ) ) {
-                $keyboardmap{ $keycodetosym{ $keyboard[$_][3] } }
-                    = 'sa' . ( $_ + $min );
-            }
-            else {
-                logmsg( 2, "Unknown keycode ", $keyboard[$_][3] )
-                    if ( $keyboard[$_][3] != 0 );
-            }
-        }
-        if ( defined $keyboard[$_][2] ) {
-            if ( defined( $keycodetosym{ $keyboard[$_][2] } ) ) {
-                $keyboardmap{ $keycodetosym{ $keyboard[$_][2] } }
-                    = 'a' . ( $_ + $min );
-            }
-            else {
-                logmsg( 2, "Unknown keycode ", $keyboard[$_][2] )
-                    if ( $keyboard[$_][2] != 0 );
-            }
-        }
-        if ( defined $keyboard[$_][1] ) {
-            if ( defined( $keycodetosym{ $keyboard[$_][1] } ) ) {
-                $keyboardmap{ $keycodetosym{ $keyboard[$_][1] } }
-                    = 's' . ( $_ + $min );
-            }
-            else {
-                logmsg( 2, "Unknown keycode ", $keyboard[$_][1] )
-                    if ( $keyboard[$_][1] != 0 );
-            }
-        }
-        if ( defined $keyboard[$_][0] ) {
-            if ( defined( $keycodetosym{ $keyboard[$_][0] } ) ) {
-                $keyboardmap{ $keycodetosym{ $keyboard[$_][0] } }
-                    = 'n' . ( $_ + $min );
-            }
-            else {
-                logmsg( 2, "Unknown keycode ", $keyboard[$_][0] )
-                    if ( $keyboard[$_][0] != 0 );
-            }
-        }
-
-        # dont know these two key combs yet...
-        #$keyboardmap{ $keycodetosym { $keyboard[$_][4] } } = $_ + $min;
-        #$keyboardmap{ $keycodetosym { $keyboard[$_][5] } } = $_ + $min;
-    }
+	my %keyboard_modifier_priority = (
+		'sa' => 3,	# lowest
+		'a' => 2,
+		's' => 1,
+		'n' => 0,	# highest
+		);
+		
+	my %keyboard_stringlike_modifiers = reverse %keyboard_modifier_priority;	
+	
+	# try to associate $keyboard=X11->GetKeyboardMapping table with X11::Keysyms
+	foreach my $i ( 0 .. $#keyboard ) {
+		for my $modifier ( 0 .. 3 ) {
+			if( defined( $keycodetosym{ $keyboard[$i][$modifier] } ) ) {
+				# keyboard layout contains the keycode at $modifier level
+				if( defined( $keyboardmap{ $keycodetosym{ $keyboard[$i][$modifier] } } ) ) {
+					# we already have a mapping, let's see whether current one is better (lower shift state)
+					my ($mod_code,$key_code) = $keyboardmap{ $keycodetosym{ $keyboard[$i][$modifier] } } =~ /^(\D+)(\d+)$/;
+					# it is not easy to get around our own alien logic storing modifiers ;-)
+					if( $modifier < $keyboard_modifier_priority{$mod_code} ) {
+						# YES! current keycode have priority over old one (phew!)
+						$keyboardmap{ $keycodetosym{ $keyboard[$i][$modifier] } } =
+							$keyboard_stringlike_modifiers{$modifier} . ( $i + $min );
+					}
+				} else {
+					# we don't yet have a mapping... piece of cake!
+					$keyboardmap{ $keycodetosym{ $keyboard[$i][$modifier] } } =
+						$keyboard_stringlike_modifiers{$modifier} . ( $i + $min );
+				}
+			} else {
+				# we didn't get the code from X11::Keysyms
+				if( $keyboard[$i][$modifier] != 0 ) {
+					# ignore code=0
+					logmsg( 2, "Unknown keycode ", $keyboard[$i][$modifier] );
+				}
+			}
+		}
+	}
 
+    # dont know these two key combs yet...
+    #$keyboardmap{ $keycodetosym { $keyboard[$_][4] } } = $_ + $min;
+    #$keyboardmap{ $keycodetosym { $keyboard[$_][5] } } = $_ + $min;
+    
     #print "$_ => $keyboardmap{$_}\n" foreach(sort(keys(%keyboardmap)));
     #print "keysymtocode: $keysymtocode{o}\n";
     #die;

Reply via email to