diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-07-25 10:17:40 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-25 10:17:40 -0500 |
commit | 6e32e06498782f98db57bbb05baa6fc4ba3d76be (patch) | |
tree | dd7d93ab39212df2d4232abb3c78b7d145953764 /apps/plugins/lua/rbdefines_helper.pl | |
parent | 3834094172480a0c64c91a20544c0a6f81c646c2 (diff) |
lua add sound_current, consolidate sound_ functions
add defines for sound functions
SOUND_VOLUME, SOUND_BALANCE, SOUND_CHANNELS, SOUND_STEREO_WIDTH ...
defines depend on target
require "sound_defines" to add them to rb.sound_settings[]
consolidates:
sound_set, sound_current, sound_default, sound_min, sound_max,
sound_unit, sound_pitch, sound_val2phys to a single function
rb.sound("name", setting, [value])
require "sound.lua" for old functionality
Change-Id: Ice695218aa433f4fcbb48fbd6b8a9bf29c994110
Diffstat (limited to 'apps/plugins/lua/rbdefines_helper.pl')
-rwxr-xr-x | apps/plugins/lua/rbdefines_helper.pl | 98 |
1 files changed, 70 insertions, 28 deletions
diff --git a/apps/plugins/lua/rbdefines_helper.pl b/apps/plugins/lua/rbdefines_helper.pl index ba15346a8a..b55609077d 100755 --- a/apps/plugins/lua/rbdefines_helper.pl +++ b/apps/plugins/lua/rbdefines_helper.pl @@ -20,28 +20,46 @@ #rockbox to lua define generator, add names of constants to the array to include -my @rockbox_defines = ( - '^HZ$', - '^LCD_(DEPTH|HEIGHT|WIDTH)$', - '^MODEL_NAME$', - '^SCREEN_MAIN$', - '^LCD_DEFAULT_(FG|BG)$', - '^LCD_REMOTE_(DEPTH|HEIGHT|WIDTH)$', - '^LCD_.+(BRIGHT|DARK)COLOR', - '^SCREEN_REMOTE$', - '^FONT_SYSFIXED$', - '^FONT_UI$', - '^PLAYBACK_EVENT_.*', - '^PLAYLIST_(INSERT|PREPEND|REPLACE)', - '^TOUCHSCREEN_(POINT|BUTTON)$', - '^SYS_CHARGER_(DIS|)CONNECTED$', - '^SYS_(TIMEOUT|POWEROFF)$', - '^SYS_USB_(DIS|)CONNECTED$', - '^HOME_DIR$', - '^PLUGIN_DIR$', - '^PLUGIN(_APPS_|_GAMES_|_)DATA_DIR$', - '^ROCKBOX_DIR$', - '^VIEWERS_DATA_DIR$'); +if ($#ARGV + 1 != 1) { + warn "no definition type defined"; + exit; +} + +my $def_type = $ARGV[0]; +#warn "$def_type\n"; +my $lua_table; +my @rockbox_defines; + +if ($def_type eq "rb_defines") { + $lua_table = "rb"; + @rockbox_defines = ( + '^HZ$', + '^LCD_(DEPTH|HEIGHT|WIDTH)$', + '^MODEL_NAME$', + '^SCREEN_MAIN$', + '^LCD_DEFAULT_(FG|BG)$', + '^LCD_REMOTE_(DEPTH|HEIGHT|WIDTH)$', + '^LCD_.+(BRIGHT|DARK)COLOR', + '^SCREEN_REMOTE$', + '^FONT_SYSFIXED$', + '^FONT_UI$', + '^PLAYBACK_EVENT_.*', + '^PLAYLIST_(INSERT|PREPEND|REPLACE)', + '^TOUCHSCREEN_(POINT|BUTTON)$', + '^SYS_CHARGER_(DIS|)CONNECTED$', + '^SYS_(TIMEOUT|POWEROFF)$', + '^SYS_USB_(DIS|)CONNECTED$', + '^HOME_DIR$', + '^PLUGIN_DIR$', + '^PLUGIN(_APPS_|_GAMES_|_)DATA_DIR$', + '^ROCKBOX_DIR$', + '^VIEWERS_DATA_DIR$'); +} +elsif ($def_type eq "sound_defines") { + $lua_table = "rb.sound_settings"; + @rockbox_defines = ( + '^(?!.*LAST_SETTING)SOUND_'); +} my @captured_defines; my @names_seen; @@ -115,7 +133,12 @@ while(my $line = <STDIN>) else { next; } do_enum($line) } - + elsif($line =~ /^enum.*{[^;]+};.*/) #enum { + { + next if($line =~ /enum\s*__.*/); #don't add reserved + next if(do_enum($line)); + + } } #warn "total defines: ".scalar @all_defines; #warn "captured defines: ".scalar @captured_defines; @@ -123,17 +146,18 @@ while(my $line = <STDIN>) my @sorted_defines = sort { @$a{'name'} cmp @$b{'name'} } @captured_defines; printf "int main(void)\n{\n"; -printf "\tprintf(\"--[[Autogenerated rockbox constants]]\\n\\n\");"; +printf "\tprintf(\"--[[Autogenerated rockbox constants]]\\n\\n\");\n\n"; +printf "\tprintf(\"%s = %s or {}\\n\");\n", $lua_table, $lua_table; # Print the C array foreach my $define (@sorted_defines) { if(@$define{'value'} =~ /^0[xX][0-9a-fA-F]+$/) #hex number { - printf "\tprintf(\"rb[\\\"%%s\\\"] = 0x%%x\\n\", stringify(%s), %s);\n", @$define{'name'}, @$define{'name'}; + printf "\tprintf(\"%s[\\\"%%s\\\"] = 0x%%x\\n\", stringify(%s), %s);\n", $lua_table, @$define{'name'}, @$define{'name'}; } elsif(@$define{'value'} =~ /^[0-9]+$/) #number { - printf "\tprintf(\"rb[\\\"%%s\\\"] = %%d\\n\", stringify(%s), %s);\n", @$define{'name'}, @$define{'name'}; + printf "\tprintf(\"%s[\\\"%%s\\\"] = %%d\\n\", stringify(%s), %s);\n", $lua_table, @$define{'name'}, @$define{'name'}; } else #might be a string but we don't know since the macro isn't expanded far enough { @@ -167,11 +191,11 @@ foreach my $define (@sorted_defines) if ($var =~$quot_regex) #has a quote it is a string { #guard with empty literals "" so gcc throws an error if it isn't a string - printf "\tprintf(\"rb[\\\"%%s\\\"] = \\\"%%s\\\"\\n\", stringify(%s), \"\" %s \"\");\n", @$define{'name'}, @$define{'name'}; + printf "\tprintf(\"%s[\\\"%%s\\\"] = \\\"%%s\\\"\\n\", stringify(%s), \"\" %s \"\");\n", $lua_table, @$define{'name'}, @$define{'name'}; } elsif ($var =~$num_regex) #it must be a number { - printf "\tprintf(\"rb[\\\"%%s\\\"] = %%d\\n\", stringify(%s), %s);\n", @$define{'name'}, @$define{'name'}; + printf "\tprintf(\"%s[\\\"%%s\\\"] = %%d\\n\", stringify(%s), %s);\n", $lua_table, @$define{'name'}, @$define{'name'}; } else { warn "Skipping ".@$define{'name'}." indeterminate macro type\n"; } } @@ -186,6 +210,23 @@ EOF sub do_enum { my ($line) = @_; + if($line =~ /.*enum.*{(.*)};.*/) #single line enums + { + print $line; + $value = "0"; #enums are always integers + my $enum = $1; + $enum =~ s/\s+//g;; + my @values = split(',', $enum); + + foreach my $name(@values) { + if(grep($name =~ $_, @rockbox_defines)) + { + push(@names_seen, $name); + push(@captured_defines, {'name' => $name, 'value' => $value}); + } + } + return 1; + } while($line = <STDIN>) { @@ -209,4 +250,5 @@ sub do_enum { } } + return 0; } |