2006-05-11 17:15:40 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
2012-04-12 11:33:26 +00:00
|
|
|
# Updates http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h from upstream (X.org 7.x),
|
|
|
|
# from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
2006-05-11 17:15:40 +00:00
|
|
|
#
|
|
|
|
# Author : Simos Xenitellis <simos at gnome dot org>.
|
2013-01-18 16:25:45 +00:00
|
|
|
# Author : Bastien Nocera <hadess@hadess.net>
|
2007-05-30 13:23:40 +00:00
|
|
|
# Version : 1.2
|
2006-05-11 17:15:40 +00:00
|
|
|
#
|
2012-04-12 11:33:26 +00:00
|
|
|
# Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
|
|
|
# Input : http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
|
|
|
|
# Output : http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h
|
2006-05-11 17:15:40 +00:00
|
|
|
#
|
2007-05-30 13:23:40 +00:00
|
|
|
# Notes : It downloads keysymdef.h from the Internet, if not found locally,
|
2006-05-11 17:15:40 +00:00
|
|
|
# Notes : and creates an updated gdkkeysyms.h
|
2007-05-30 13:23:40 +00:00
|
|
|
# Notes : This version updates the source of gdkkeysyms.h from CVS to the GIT server.
|
2006-05-11 17:15:40 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
# Used for reading the keysymdef symbols.
|
|
|
|
my @keysymelements;
|
|
|
|
|
|
|
|
if ( ! -f "keysymdef.h" )
|
|
|
|
{
|
|
|
|
print "Trying to download keysymdef.h from\n";
|
2012-04-12 11:33:26 +00:00
|
|
|
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n";
|
|
|
|
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n"
|
|
|
|
unless system("wget -c -O keysymdef.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\"") == 0;
|
2006-05-11 17:15:40 +00:00
|
|
|
print " done.\n\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "We are using existing keysymdef.h found in this directory.\n";
|
2007-05-30 13:23:40 +00:00
|
|
|
print "It is assumed that you took care and it is a recent version\n";
|
2012-04-12 11:33:26 +00:00
|
|
|
print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h\n\n";
|
2006-05-11 17:15:40 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 17:01:43 +00:00
|
|
|
if ( ! -f "XF86keysym.h" )
|
|
|
|
{
|
|
|
|
print "Trying to download XF86keysym.h from\n";
|
2012-04-12 11:33:26 +00:00
|
|
|
print "http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n";
|
|
|
|
die "Unable to download keysymdef.h from http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n"
|
|
|
|
unless system("wget -c -O XF86keysym.h \"http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\"") == 0;
|
2009-09-09 17:01:43 +00:00
|
|
|
print " done.\n\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "We are using existing XF86keysym.h found in this directory.\n";
|
|
|
|
print "It is assumed that you took care and it is a recent version\n";
|
2012-04-12 11:33:26 +00:00
|
|
|
print "as found at http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h\n\n";
|
2009-09-09 17:01:43 +00:00
|
|
|
}
|
2006-05-11 17:15:40 +00:00
|
|
|
|
|
|
|
if ( -f "gdkkeysyms.h" )
|
|
|
|
{
|
|
|
|
print "There is already a gdkkeysyms.h file in this directory. We are not overwriting it.\n";
|
2007-05-30 13:23:40 +00:00
|
|
|
print "Please move it somewhere else in order to run this script.\n";
|
2006-05-11 17:15:40 +00:00
|
|
|
die "Exiting...\n\n";
|
|
|
|
}
|
|
|
|
|
2012-04-12 11:33:26 +00:00
|
|
|
# Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
2006-05-11 17:15:40 +00:00
|
|
|
die "Could not open file keysymdef.h: $!\n" unless open(IN_KEYSYMDEF, "<:utf8", "keysymdef.h");
|
|
|
|
|
|
|
|
# Output: gtk+/gdk/gdkkeysyms.h
|
|
|
|
die "Could not open file gdkkeysyms.h: $!\n" unless open(OUT_GDKKEYSYMS, ">:utf8", "gdkkeysyms.h");
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
# Output: gtk+/gdk/gdkkeysyms-compat.h
|
|
|
|
die "Could not open file gdkkeysyms-compat.h: $!\n" unless open(OUT_GDKKEYSYMS_COMPAT, ">:utf8", "gdkkeysyms-compat.h");
|
|
|
|
|
|
|
|
my $LICENSE_HEADER= <<EOF;
|
2008-07-01 22:57:50 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
2006-05-11 17:15:40 +00:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
2009-09-09 17:01:43 +00:00
|
|
|
* Copyright (C) 2005, 2006, 2007, 2009 GNOME Foundation
|
2006-05-11 17:15:40 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-05-11 17:15:40 +00:00
|
|
|
*/
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
print OUT_GDKKEYSYMS $LICENSE_HEADER;
|
|
|
|
print OUT_GDKKEYSYMS_COMPAT $LICENSE_HEADER;
|
|
|
|
|
|
|
|
print OUT_GDKKEYSYMS<<EOF;
|
|
|
|
|
2006-05-11 17:15:40 +00:00
|
|
|
/*
|
2012-04-12 11:33:26 +00:00
|
|
|
* File auto-generated from script http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms-update.pl
|
2006-05-11 17:15:40 +00:00
|
|
|
* using the input file
|
2012-04-12 11:33:26 +00:00
|
|
|
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h
|
2009-09-09 17:01:43 +00:00
|
|
|
* and
|
2012-04-12 11:33:26 +00:00
|
|
|
* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
|
2006-05-11 17:15:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2007-05-30 13:23:40 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2007. See the AUTHORS
|
2006-05-11 17:15:40 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GDK_KEYSYMS_H__
|
|
|
|
#define __GDK_KEYSYMS_H__
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
print OUT_GDKKEYSYMS_COMPAT<<EOF;
|
|
|
|
/*
|
|
|
|
* Compatibility version of gdkkeysyms.h.
|
|
|
|
*
|
|
|
|
* In GTK3, keysyms changed to have a KEY_ prefix. This is a compatibility header
|
|
|
|
* your application can include to gain access to the old names as well. Consider
|
|
|
|
* porting to the new names instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GDK_KEYSYMS_COMPAT_H__
|
|
|
|
#define __GDK_KEYSYMS_COMPAT_H__
|
|
|
|
|
|
|
|
EOF
|
2006-05-11 17:15:40 +00:00
|
|
|
|
|
|
|
while (<IN_KEYSYMDEF>)
|
|
|
|
{
|
|
|
|
next if ( ! /^#define / );
|
|
|
|
|
|
|
|
@keysymelements = split(/\s+/);
|
|
|
|
die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
|
|
|
|
|
|
|
|
$_ = $keysymelements[1];
|
|
|
|
die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ );
|
|
|
|
|
|
|
|
$_ = $keysymelements[2];
|
|
|
|
die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
my $element = $keysymelements[1];
|
|
|
|
my $binding = $element;
|
|
|
|
$binding =~ s/^XK_/GDK_KEY_/g;
|
|
|
|
my $compat_binding = $element;
|
|
|
|
$compat_binding =~ s/^XK_/GDK_/g;
|
2006-05-11 17:15:40 +00:00
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
|
|
|
|
printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
|
2006-05-11 17:15:40 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 17:01:43 +00:00
|
|
|
close IN_KEYSYMDEF;
|
|
|
|
|
2006-05-11 17:15:40 +00:00
|
|
|
#$gdksyms{"0"} = "0000";
|
|
|
|
|
2012-04-12 11:33:26 +00:00
|
|
|
# Source: http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h
|
2009-09-09 17:01:43 +00:00
|
|
|
die "Could not open file XF86keysym.h: $!\n" unless open(IN_XF86KEYSYM, "<:utf8", "XF86keysym.h");
|
|
|
|
|
|
|
|
while (<IN_XF86KEYSYM>)
|
|
|
|
{
|
|
|
|
next if ( ! /^#define / );
|
|
|
|
|
|
|
|
@keysymelements = split(/\s+/);
|
|
|
|
die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
|
|
|
|
|
|
|
|
$_ = $keysymelements[1];
|
|
|
|
die "Internal error, was expecting \"XF86XK_*\", found: $_\n" if ( ! /^XF86XK_/ );
|
|
|
|
|
|
|
|
# Work-around https://bugs.freedesktop.org/show_bug.cgi?id=11193
|
|
|
|
if ($_ eq "XF86XK_XF86BackForward") {
|
|
|
|
$keysymelements[1] = "XF86XK_AudioForward";
|
|
|
|
}
|
2009-09-10 09:15:10 +00:00
|
|
|
# XF86XK_Clear could end up a dupe of XK_Clear
|
|
|
|
# XF86XK_Select could end up a dupe of XK_Select
|
|
|
|
if ($_ eq "XF86XK_Clear") {
|
|
|
|
$keysymelements[1] = "XF86XK_WindowClear";
|
|
|
|
}
|
|
|
|
if ($_ eq "XF86XK_Select") {
|
|
|
|
$keysymelements[1] = "XF86XK_SelectButton";
|
|
|
|
}
|
2009-09-09 17:01:43 +00:00
|
|
|
|
|
|
|
# Ignore XF86XK_Q
|
|
|
|
next if ( $_ eq "XF86XK_Q");
|
2009-09-10 09:15:10 +00:00
|
|
|
# XF86XK_Calculater is misspelled, and a dupe
|
|
|
|
next if ( $_ eq "XF86XK_Calculater");
|
|
|
|
|
2009-09-09 17:01:43 +00:00
|
|
|
$_ = $keysymelements[2];
|
|
|
|
die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
my $element = $keysymelements[1];
|
|
|
|
my $binding = $element;
|
|
|
|
$binding =~ s/^XF86XK_/GDK_KEY_/g;
|
|
|
|
my $compat_binding = $element;
|
|
|
|
$compat_binding =~ s/^XF86XK_/GDK_/g;
|
2009-09-09 17:01:43 +00:00
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
printf OUT_GDKKEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
|
|
|
|
printf OUT_GDKKEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
|
2009-09-09 17:01:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
close IN_XF86KEYSYM;
|
2006-05-11 17:15:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
print OUT_GDKKEYSYMS<<EOF;
|
|
|
|
|
|
|
|
#endif /* __GDK_KEYSYMS_H__ */
|
|
|
|
EOF
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
print OUT_GDKKEYSYMS_COMPAT<<EOF;
|
|
|
|
|
|
|
|
#endif /* __GDK_KEYSYMS_COMPAT_H__ */
|
|
|
|
EOF
|
|
|
|
|
|
|
|
printf "We just finished converting keysymdef.h to gdkkeysyms.h and gdkkeysyms-compat.h\nThank you\n";
|