#!/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" "$@"
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;}
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