Fix some greedy sed changes in imported code. Also provide a sys/types.h for compatib...
[kugel-rb.git] / apps / plugins / lua / button_helper.pl
blob7af3231b11bc71a800909647a42d70ad51f87450
1 #!/usr/bin/env perl
2 ############################################################################
3 # __________ __ ___.
4 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 # \/ \/ \/ \/ \/
9 # $Id$
11 # Copyright (C) 2009 by Maurus Cuelenaere
13 # All files in this archive are subject to the GNU General Public License.
14 # See the file COPYING in the source tree root for full license agreement.
16 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 # KIND, either express or implied.
19 ############################################################################
21 $svnrev = '$Revision$';
23 print <<EOF
24 #include <stdio.h>
25 #include <stdbool.h>
26 #include "button.h"
28 struct button
30 char* name;
31 unsigned long value;
34 static struct button buttons[] = {
35 EOF
38 while(my $line = <STDIN>)
40 chomp($line);
41 if($line =~ /^#define (BUTTON_[^\s]+) (.+)$/)
43 printf "{\"%s\", %s},\n", $1, $2;
47 print <<EOF
48 {"BUTTON_REL", BUTTON_REL},
49 {"BUTTON_REPEAT", BUTTON_REPEAT},
50 {"BUTTON_TOUCHSCREEN", BUTTON_TOUCHSCREEN},
53 int main(void)
55 unsigned int i;
56 printf("-- Don't change this file!\\n");
57 printf("-- It is automatically generated of button.h \%s\\n", "$svnrev");
58 printf("rb.buttons = {\\n");
59 for(i=0; i<sizeof(buttons)/sizeof(struct button); i++)
60 printf("\\t\%s = \%ld,\\n", buttons[i].name, buttons[i].value);
61 printf("}\\n");
63 return 0;
66 EOF