From 190de48acc3e09cba1d39042031fb7c7318687c7 Mon Sep 17 00:00:00 2001 From: simigern Date: Sun, 21 May 2006 13:07:24 +0000 Subject: [PATCH 1/1] P-Keys are F-Keys+ALT --- snom.pl | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/snom.pl b/snom.pl index be082e5..43ea498 100755 --- a/snom.pl +++ b/snom.pl @@ -1,5 +1,5 @@ #!/bin/sh -#$Id: snom.pl,v 1.5 2006-05-21 12:42:40 simigern Exp $ +#$Id: snom.pl,v 1.6 2006-05-21 13:07:24 simigern Exp $ PATH=/opt/csw/bin:/opt/local/bin:/usr/bin:/bin exec perl -w -x "$0" "$@" @@ -272,20 +272,17 @@ sub KBDInput my ($widget, $event) = @_; my $keyval = $event->keyval; - foreach my $i (1, 2, 3, 4, 5, 6, 7, 8, 9, 0) { - if ($keyval == $Gtk2::Gdk::Keysyms{$i} || $keyval == $Gtk2::Gdk::Keysyms{"KP_${i}"}) { - snom_key($i); - return TRUE; - } - } - foreach my $i ('F1', 'F2', 'F3', 'F4') { - if ($keyval == $Gtk2::Gdk::Keysyms{$i}) { + for (my $i=1; $i<10; $i++) { + if ($keyval == $Gtk2::Gdk::Keysyms{$i} || $keyval == $Gtk2::Gdk::Keysyms{"KP_${i}"}) { snom_key($i); return TRUE; } } + if ($keyval == $Gtk2::Gdk::Keysyms{asterisk}) {snom_key('*'); return TRUE;} + if ($keyval == $Gtk2::Gdk::Keysyms{KP_Multiply}) {snom_key('*'); return TRUE;} + if ($keyval == $Gtk2::Gdk::Keysyms{numbersign}) {snom_key('#'); return TRUE;} if ($keyval == $Gtk2::Gdk::Keysyms{Return}) {snom_key("ENTER"); return TRUE;} if ($keyval == $Gtk2::Gdk::Keysyms{KP_Enter}) {snom_key("ENTER"); return TRUE;} if ($keyval == $Gtk2::Gdk::Keysyms{Escape}) {snom_key("CANCEL"); return TRUE;} @@ -297,7 +294,34 @@ sub KBDInput if ($keyval == $Gtk2::Gdk::Keysyms{KP_Up}) {snom_key("UP"); return TRUE;} if ($keyval == $Gtk2::Gdk::Keysyms{Down}) {snom_key("DOWN"); return TRUE;} if ($keyval == $Gtk2::Gdk::Keysyms{KP_Down}) {snom_key("DOWN"); return TRUE;} - return TRUE; + + if (!$event->state) { + for (my $i=1; $i<5; $i++) { + if ($keyval == $Gtk2::Gdk::Keysyms{"F${i}"}) { + snom_key("F${i}"); + return TRUE; + } + } + } else { + if ($event->state eq 'mod1-mask') { + for (my $i=1; $i<13; $i++) { + if ($keyval == $Gtk2::Gdk::Keysyms{"F${i}"}) { + snom_key("P${i}"); + return TRUE; + } + } + } + } + + print "Unhandled: Modifier: ".$event->state.", Key: "; + foreach my $key (keys(%Gtk2::Gdk::Keysyms)) { + if ($keyval == $Gtk2::Gdk::Keysyms{$key}) { + print "${key}\n"; + return TRUE; + } + } + print "ERR\n"; + return FALSE; } ### Callback function to close the window -- 2.39.5