Mercurial > audlegacy-plugins
changeset 2406:dff5709d36bf
Reimplement using a GTK+ widget.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Mon, 18 Feb 2008 01:46:46 -0600 |
parents | 4f1dd5b277f6 |
children | d722ca89f7bf |
files | src/projectm-1.0/COPYING src/projectm-1.0/ConfigFile.cxx src/projectm-1.0/ConfigFile.h src/projectm-1.0/Makefile src/projectm-1.0/gtk_projectm_impl.cxx src/projectm-1.0/gtk_projectm_impl.h src/projectm-1.0/main.c src/projectm-1.0/main.cxx src/projectm-1.0/main_visplugin.c src/projectm-1.0/sdltoprojectM.h |
diffstat | 10 files changed, 354 insertions(+), 1266 deletions(-) [+] |
line wrap: on
line diff
--- a/src/projectm-1.0/COPYING Mon Feb 18 00:33:11 2008 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License.
--- a/src/projectm-1.0/ConfigFile.cxx Mon Feb 18 00:33:11 2008 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -// ConfigFile.cpp - -#include "ConfigFile.h" - -using std::string; - -ConfigFile::ConfigFile( string filename, string delimiter, - string comment, string sentry ) - : myDelimiter(delimiter), myComment(comment), mySentry(sentry) -{ - // Construct a ConfigFile, getting keys and values from given file - - std::ifstream in( filename.c_str() ); - - if( !in ) throw file_not_found( filename ); - - in >> (*this); -} - - -ConfigFile::ConfigFile() - : myDelimiter( string(1,'=') ), myComment( string(1,'#') ) -{ - // Construct a ConfigFile without a file; empty -} - - -void ConfigFile::remove( const string& key ) -{ - // Remove key and its value - myContents.erase( myContents.find( key ) ); - return; -} - - -bool ConfigFile::keyExists( const string& key ) const -{ - // Indicate whether key is found - mapci p = myContents.find( key ); - return ( p != myContents.end() ); -} - - -/* static */ -void ConfigFile::trim( string& s ) -{ - // Remove leading and trailing whitespace - static const char whitespace[] = " \n\t\v\r\f"; - s.erase( 0, s.find_first_not_of(whitespace) ); - s.erase( s.find_last_not_of(whitespace) + 1U ); -} - - -std::ostream& operator<<( std::ostream& os, const ConfigFile& cf ) -{ - // Save a ConfigFile to os - for( ConfigFile::mapci p = cf.myContents.begin(); - p != cf.myContents.end(); - ++p ) - { - os << p->first << " " << cf.myDelimiter << " "; - os << p->second << std::endl; - } - return os; -} - - -std::istream& operator>>( std::istream& is, ConfigFile& cf ) -{ - // Load a ConfigFile from is - // Read in keys and values, keeping internal whitespace - typedef string::size_type pos; - const string& delim = cf.myDelimiter; // separator - const string& comm = cf.myComment; // comment - const string& sentry = cf.mySentry; // end of file sentry - const pos skip = delim.length(); // length of separator - - string nextline = ""; // might need to read ahead to see where value ends - - while( is || nextline.length() > 0 ) - { - // Read an entire line at a time - string line; - if( nextline.length() > 0 ) - { - line = nextline; // we read ahead; use it now - nextline = ""; - } - else - { - std::getline( is, line ); - } - - // Ignore comments - line = line.substr( 0, line.find(comm) ); - - // Check for end of file sentry - if( sentry != "" && line.find(sentry) != string::npos ) return is; - - // Parse the line if it contains a delimiter - pos delimPos = line.find( delim ); - if( delimPos < string::npos ) - { - // Extract the key - string key = line.substr( 0, delimPos ); - line.replace( 0, delimPos+skip, "" ); - - // See if value continues on the next line - // Stop at blank line, next line with a key, end of stream, - // or end of file sentry - bool terminate = false; - while( !terminate && is ) - { - std::getline( is, nextline ); - terminate = true; - - string nlcopy = nextline; - ConfigFile::trim(nlcopy); - if( nlcopy == "" ) continue; - - nextline = nextline.substr( 0, nextline.find(comm) ); - if( nextline.find(delim) != string::npos ) - continue; - if( sentry != "" && nextline.find(sentry) != string::npos ) - continue; - - nlcopy = nextline; - ConfigFile::trim(nlcopy); - if( nlcopy != "" ) line += "\n"; - line += nextline; - terminate = false; - } - - // Store key and value - ConfigFile::trim(key); - ConfigFile::trim(line); - cf.myContents[key] = line; // overwrites if key is repeated - } - } - - return is; -}
--- a/src/projectm-1.0/ConfigFile.h Mon Feb 18 00:33:11 2008 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,253 +0,0 @@ -// ConfigFile.h -// Class for reading named values from configuration files -// Richard J. Wagner v2.1 24 May 2004 wagnerr@umich.edu - -// Copyright (c) 2004 Richard J. Wagner -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. - -// Typical usage -// ------------- -// -// Given a configuration file "settings.inp": -// atoms = 25 -// length = 8.0 # nanometers -// name = Reece Surcher -// -// Named values are read in various ways, with or without default values: -// ConfigFile config( "settings.inp" ); -// int atoms = config.read<int>( "atoms" ); -// double length = config.read( "length", 10.0 ); -// string author, title; -// config.readInto( author, "name" ); -// config.readInto( title, "title", string("Untitled") ); -// -// See file example.cpp for more examples. - -#ifndef CONFIGFILE_H -#define CONFIGFILE_H - -#include <string> -#include <map> -#include <iostream> -#include <fstream> -#include <sstream> - -using std::string; - -class ConfigFile { -// Data -protected: - string myDelimiter; // separator between key and value - string myComment; // separator between value and comments - string mySentry; // optional string to signal end of file - std::map<string,string> myContents; // extracted keys and values - - typedef std::map<string,string>::iterator mapi; - typedef std::map<string,string>::const_iterator mapci; - -// Methods -public: - ConfigFile( string filename, - string delimiter = "=", - string comment = "#", - string sentry = "EndConfigFile" ); - ConfigFile(); - - // Search for key and read value or optional default value - template<class T> T read( const string& key ) const; // call as read<T> - template<class T> T read( const string& key, const T& value ) const; - template<class T> bool readInto( T& var, const string& key ) const; - template<class T> - bool readInto( T& var, const string& key, const T& value ) const; - - // Modify keys and values - template<class T> void add( string key, const T& value ); - void remove( const string& key ); - - // Check whether key exists in configuration - bool keyExists( const string& key ) const; - - // Check or change configuration syntax - string getDelimiter() const { return myDelimiter; } - string getComment() const { return myComment; } - string getSentry() const { return mySentry; } - string setDelimiter( const string& s ) - { string old = myDelimiter; myDelimiter = s; return old; } - string setComment( const string& s ) - { string old = myComment; myComment = s; return old; } - - // Write or read configuration - friend std::ostream& operator<<( std::ostream& os, const ConfigFile& cf ); - friend std::istream& operator>>( std::istream& is, ConfigFile& cf ); - -protected: - template<class T> static string T_as_string( const T& t ); - template<class T> static T string_as_T( const string& s ); - static void trim( string& s ); - - -// Exception types -public: - struct file_not_found { - string filename; - file_not_found( const string& filename_ = string() ) - : filename(filename_) {} }; - struct key_not_found { // thrown only by T read(key) variant of read() - string key; - key_not_found( const string& key_ = string() ) - : key(key_) {} }; -}; - - -/* static */ -template<class T> -string ConfigFile::T_as_string( const T& t ) -{ - // Convert from a T to a string - // Type T must support << operator - std::ostringstream ost; - ost << t; - return ost.str(); -} - - -/* static */ -template<class T> -T ConfigFile::string_as_T( const string& s ) -{ - // Convert from a string to a T - // Type T must support >> operator - T t; - std::istringstream ist(s); - ist >> t; - return t; -} - - -/* static */ -template<> -inline string ConfigFile::string_as_T<string>( const string& s ) -{ - // Convert from a string to a string - // In other words, do nothing - return s; -} - - -/* static */ -template<> -inline bool ConfigFile::string_as_T<bool>( const string& s ) -{ - // Convert from a string to a bool - // Interpret "false", "F", "no", "n", "0" as false - // Interpret "true", "T", "yes", "y", "1", "-1", or anything else as true - bool b = true; - string sup = s; - for( string::iterator p = sup.begin(); p != sup.end(); ++p ) - *p = toupper(*p); // make string all caps - if( sup==string("FALSE") || sup==string("F") || - sup==string("NO") || sup==string("N") || - sup==string("0") || sup==string("NONE") ) - b = false; - return b; -} - - -template<class T> -T ConfigFile::read( const string& key ) const -{ - // Read the value corresponding to key - mapci p = myContents.find(key); - if( p == myContents.end() ) throw key_not_found(key); - return string_as_T<T>( p->second ); -} - - -template<class T> -T ConfigFile::read( const string& key, const T& value ) const -{ - // Return the value corresponding to key or given default value - // if key is not found - mapci p = myContents.find(key); - if( p == myContents.end() ) return value; - return string_as_T<T>( p->second ); -} - - -template<class T> -bool ConfigFile::readInto( T& var, const string& key ) const -{ - // Get the value corresponding to key and store in var - // Return true if key is found - // Otherwise leave var untouched - mapci p = myContents.find(key); - bool found = ( p != myContents.end() ); - if( found ) var = string_as_T<T>( p->second ); - return found; -} - - -template<class T> -bool ConfigFile::readInto( T& var, const string& key, const T& value ) const -{ - // Get the value corresponding to key and store in var - // Return true if key is found - // Otherwise set var to given default - mapci p = myContents.find(key); - bool found = ( p != myContents.end() ); - if( found ) - var = string_as_T<T>( p->second ); - else - var = value; - return found; -} - - -template<class T> -void ConfigFile::add( string key, const T& value ) -{ - // Add a key with given value - string v = T_as_string( value ); - trim(key); - trim(v); - myContents[key] = v; - return; -} - -#endif // CONFIGFILE_H - -// Release notes: -// v1.0 21 May 1999 -// + First release -// + Template read() access only through non-member readConfigFile() -// + ConfigurationFileBool is only built-in helper class -// -// v2.0 3 May 2002 -// + Shortened name from ConfigurationFile to ConfigFile -// + Implemented template member functions -// + Changed default comment separator from % to # -// + Enabled reading of multiple-line values -// -// v2.1 24 May 2004 -// + Made template specializations inline to avoid compiler-dependent linkage -// + Allowed comments within multiple-line values -// + Enabled blank line termination for multiple-line values -// + Added optional sentry to detect end of configuration file -// + Rewrote messy trimWhitespace() function as elegant trim()
--- a/src/projectm-1.0/Makefile Mon Feb 18 00:33:11 2008 -0600 +++ b/src/projectm-1.0/Makefile Mon Feb 18 01:46:46 2008 -0600 @@ -1,8 +1,7 @@ PLUGIN = projectm-1.0${PLUGIN_SUFFIX} -SRCS = main.cxx \ - ConfigFile.cxx \ - main_visplugin.c +SRCS = gtk_projectm_impl.cxx \ + main.c include ../../buildsys.mk include ../../extra.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/gtk_projectm_impl.cxx Mon Feb 18 01:46:46 2008 -0600 @@ -0,0 +1,263 @@ +/* + * gtk_projectm_impl.cxx: GTK+ ProjectM Implementation. + * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> + * Portions copyright (c) 2004-2006 Peter Sperl + * + * This program is free software; you may distribute it under the terms + * of the GNU General Public License; version 2. + */ + +#include <stdio.h> +#include <string.h> +#include <string> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <gtk/gtk.h> +#include <gtk/gtkgl.h> + +#include "gtk_projectm_impl.h" + +#include <math.h> + +#include <libprojectM/projectM.hpp> + +#include <GL/gl.h> +#define CONFIG_FILE "/share/projectM/config.inp" + +// Forward declarations +static std::string read_config(); + +int SDLThreadWrapper(void *); +void handle_playback_trigger(void *, void *); + +static void _gtk_projectm_realize_impl(GtkWidget *widget, gpointer data); +static gboolean _gtk_projectm_redraw_impl(GtkWidget *widget); +static gboolean _gtk_projectm_expose_impl(GtkWidget *widget, GdkEventExpose *event, gpointer data); +static gboolean _gtk_projectm_configure_impl(GtkWidget *widget, GdkEventConfigure *event, gpointer data); + +struct _GtkProjectMPrivate { + projectM *pm; + GdkGLConfig *glconfig; + GtkWidget *drawing_area; + gint idle_id; + GTimer *timer; + gint frames; +}; + +extern "C" GtkWidget * +gtk_projectm_new(void) +{ + struct _GtkProjectMPrivate *priv = g_slice_new0(struct _GtkProjectMPrivate); + + gtk_gl_init(NULL, NULL); + + priv->glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE)); + if (!priv->glconfig) + return NULL; + + priv->drawing_area = gtk_drawing_area_new(); + gtk_widget_set_size_request(priv->drawing_area, 512, 512); + gtk_widget_set_gl_capability(priv->drawing_area, priv->glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); + gtk_widget_add_events(priv->drawing_area, GDK_VISIBILITY_NOTIFY_MASK); + + g_signal_connect_after(G_OBJECT(priv->drawing_area), "realize", + G_CALLBACK(_gtk_projectm_realize_impl), priv); + g_signal_connect(G_OBJECT(priv->drawing_area), "expose_event", + G_CALLBACK(_gtk_projectm_expose_impl), priv); + + priv->timer = g_timer_new(); + priv->frames = 0; + + g_object_set_data(G_OBJECT(priv->drawing_area), "GtkProjectMPrivate", priv); + + return priv->drawing_area; +} + +extern "C" void +gtk_projectm_add_pcm_data(GtkWidget *widget, gint16 pcm_data[2][512]) +{ + struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) g_object_get_data(G_OBJECT(widget), "GtkProjectMPrivate"); + + g_return_if_fail(priv != NULL); + g_return_if_fail(priv->pm != NULL); + + priv->pm->pcm->addPCM16(pcm_data); +} + +static void +_gtk_projectm_realize_impl(GtkWidget *widget, gpointer data) +{ + GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); + GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); + struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) data; + + if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) + return; + + std::string configFile = read_config(); + priv->pm = new projectM(configFile); + priv->pm->projectM_resetGL(widget->allocation.width, widget->allocation.height); + + gdk_gl_drawable_swap_buffers(gldrawable); + gdk_gl_drawable_gl_end(gldrawable); + + g_signal_connect(G_OBJECT(widget), "configure_event", + G_CALLBACK(_gtk_projectm_configure_impl), NULL); + + priv->idle_id = g_timeout_add (1000 / 30, + (GSourceFunc) _gtk_projectm_redraw_impl, + priv->drawing_area); +} + +static gboolean +_gtk_projectm_configure_impl(GtkWidget *widget, GdkEventConfigure *event, gpointer data) +{ + GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); + GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); + struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) data; + + if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) + return FALSE; + + priv->pm->projectM_resetGL(widget->allocation.width, widget->allocation.height); + + gdk_gl_drawable_swap_buffers(gldrawable); + gdk_gl_drawable_gl_end(gldrawable); + + return TRUE; +} + +static gboolean +_gtk_projectm_expose_impl(GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); + GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); + struct _GtkProjectMPrivate *priv = (struct _GtkProjectMPrivate *) data; + + if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) + return FALSE; + + priv->pm->renderFrame(); + priv->frames++; + + gdk_gl_drawable_swap_buffers(gldrawable); + gdk_gl_drawable_gl_end(gldrawable); + + gdouble seconds = g_timer_elapsed (priv->timer, NULL); + if (seconds >= 5.0) + { + gdouble fps = priv->frames / seconds; + g_print ("%d frames in %6.3f seconds = %6.3f FPS\n", priv->frames, seconds, fps); + g_timer_reset (priv->timer); + priv->frames = 0; + } + + return TRUE; +} + +static gboolean +_gtk_projectm_redraw_impl(GtkWidget *widget) +{ + gdk_window_invalidate_rect(widget->window, &widget->allocation, FALSE); + + return TRUE; +} + +/******************************************************************************** + * XXX: This code is from projectM and still needs to be rewritten! * + ********************************************************************************/ +static std::string read_config() +{ + +// int n; + + char num[512]; + FILE *in; + FILE *out; + + char *home; + char projectM_home[1024]; + char projectM_config[1024]; + + strcpy(projectM_config, PROJECTM_PREFIX); + strcpy(projectM_config + strlen(PROJECTM_PREFIX), CONFIG_FILE); + projectM_config[strlen(PROJECTM_PREFIX) + strlen(CONFIG_FILE)] = '\0'; + //printf("dir:%s \n",projectM_config); + home = getenv("HOME"); + strcpy(projectM_home, home); + strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); + projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; + + + if ((in = fopen(projectM_home, "r")) != 0) + { + //printf("reading ~/.projectM/config.inp \n"); + fclose(in); + return std::string(projectM_home); + } + else + { + printf("trying to create ~/.projectM/config.inp \n"); + + strcpy(projectM_home, home); + strcpy(projectM_home + strlen(home), "/.projectM"); + projectM_home[strlen(home) + strlen("/.projectM")] = '\0'; + mkdir(projectM_home, 0755); + + strcpy(projectM_home, home); + strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); + projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; + + if ((out = fopen(projectM_home, "w")) != 0) + { + + if ((in = fopen(projectM_config, "r")) != 0) + { + + while (fgets(num, 80, in) != NULL) + { + fputs(num, out); + } + fclose(in); + fclose(out); + + + if ((in = fopen(projectM_home, "r")) != 0) + { + printf("created ~/.projectM/config.inp successfully\n"); + fclose(in); + return std::string(projectM_home); + } + else + { + printf("This shouldn't happen, using implementation defualts\n"); + abort(); + } + } + else + { + printf("Cannot find projectM default config, using implementation defaults\n"); + abort(); + } + } + else + { + printf("Cannot create ~/.projectM/config.inp, using default config file\n"); + if ((in = fopen(projectM_config, "r")) != 0) + { + printf("Successfully opened default config file\n"); + fclose(in); + return std::string(projectM_config); + } + else + { + printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); + abort(); + } + } + + } + + abort(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/gtk_projectm_impl.h Mon Feb 18 01:46:46 2008 -0600 @@ -0,0 +1,24 @@ +/* + * gtk_projectm_impl.h: GTK+ ProjectM Implementation. + * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> + * Portions copyright (c) 2004-2006 Peter Sperl + * + * This program is free software; you may distribute it under the terms + * of the GNU General Public License; version 2. + */ + +#include <stdio.h> +#include <string.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <gtk/gtk.h> +#include <gtk/gtkgl.h> + +G_BEGIN_DECLS + +GtkWidget *gtk_projectm_new(void); +void gtk_projectm_add_pcm_data(GtkWidget *widget, gint16 pcm_data[2][512]); + +G_END_DECLS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/projectm-1.0/main.c Mon Feb 18 01:46:46 2008 -0600 @@ -0,0 +1,65 @@ +/* + * main.cxx: plugin glue to libprojectm + * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> + * Portions copyright (c) 2004-2006 Peter Sperl + * + * This program is free software; you may distribute it under the terms + * of the GNU General Public License; version 2. + */ + +#include <audacious/plugin.h> + +#include "gtk_projectm_impl.h" + +GtkWidget *projectm = NULL; +GtkWidget *window = NULL; + +void +projectM_init(void) +{ + GtkWidget *vbox; + + if (window) + return; + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), "ProjectM"); + gtk_container_set_reallocate_redraws(GTK_CONTAINER(window), TRUE); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), vbox); + gtk_widget_show(vbox); + + projectm = gtk_projectm_new(); + gtk_box_pack_start(GTK_BOX(vbox), projectm, TRUE, TRUE, 0); + gtk_widget_show(projectm); + + gtk_widget_show(window); +} + +void +projectM_cleanup(void) +{ + +} + +void +projectM_render_pcm(gint16 pcm_data[2][512]) +{ + g_return_if_fail(projectm != NULL); + + gtk_projectm_add_pcm_data(projectm, pcm_data); +} + +VisPlugin projectM_vtable = { + .description = "projectM", + .num_pcm_chs_wanted = 2, + .init = projectM_init, + .cleanup = projectM_cleanup, + .render_pcm = projectM_render_pcm, +}; + +VisPlugin *projectM_vplist[] = { &projectM_vtable, NULL }; + +DECLARE_PLUGIN(projectm, NULL, NULL, NULL, NULL, NULL, NULL, + projectM_vplist, NULL);
--- a/src/projectm-1.0/main.cxx Mon Feb 18 00:33:11 2008 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,362 +0,0 @@ -/* - * main.cxx: plugin glue to libprojectm - * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> - * Portions copyright (c) 2004-2006 Peter Sperl - * - * This program is free software; you may distribute it under the terms - * of the GNU General Public License; version 2. - */ - -#include <stdio.h> -#include <string.h> -#include <string> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <gtk/gtk.h> -#include <gtk/gtkgl.h> - -extern "C" -{ -#include <audacious/util.h> -#include <audacious/plugin.h> -#include <audacious/playlist.h> -#include <audacious/auddrct.h> -} - -#include <math.h> -#include "ConfigFile.h" - -#include <libprojectM/projectM.hpp> - -#include <GL/gl.h> -#define CONFIG_FILE "/share/projectM/config.inp" - -// Forward declarations -extern "C" void projectM_xmms_init(void); -extern "C" void projectM_cleanup(void); -extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]); -extern "C" int worker_func(void *); -std::string read_config(); - -extern "C" VisPlugin projectM_vtable; - -int SDLThreadWrapper(void *); -void handle_playback_trigger(void *, void *); - -static void -projectM_draw_init(GtkWidget *widget, - void *data); - -static gboolean -projectM_idle_func(GtkWidget *widget); - -static gboolean -projectM_draw_impl(GtkWidget *widget, - GdkEventExpose *event, - gpointer data); - -static gboolean -projectM_reconfigure(GtkWidget *widget, - GdkEventConfigure *event, - gpointer data); - -class projectMPlugin -{ - public: - projectM *pm; - - GdkGLConfig *glconfig; - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *drawing_area; - gboolean is_sync; - gboolean error; - gint idle_id; - GTimer *timer; - gint frames; - - projectMPlugin() - { - gtk_gl_init(NULL, NULL); - - this->pm = NULL; - - this->glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE)); - if (!this->glconfig) - { - this->error++; - return; - } - - this->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(this->window), "ProjectM"); - gtk_container_set_reallocate_redraws(GTK_CONTAINER(this->window), TRUE); - - this->vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(this->window), this->vbox); - gtk_widget_show(this->vbox); - - this->drawing_area = gtk_drawing_area_new(); - gtk_widget_set_size_request(this->drawing_area, 512, 512); - gtk_widget_set_gl_capability(this->drawing_area, this->glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); - gtk_widget_add_events(this->drawing_area, GDK_VISIBILITY_NOTIFY_MASK); - gtk_box_pack_start(GTK_BOX(this->vbox), this->drawing_area, TRUE, TRUE, 0); - - g_signal_connect_after(G_OBJECT(this->drawing_area), "realize", - G_CALLBACK(projectM_draw_init), NULL); - g_signal_connect(G_OBJECT(this->drawing_area), "expose_event", - G_CALLBACK(projectM_draw_impl), NULL); - - this->timer = g_timer_new(); - this->frames = 0; - } - - ~projectMPlugin() - { - delete this->pm; - this->pm = 0; - - aud_hook_dissociate("playback begin", handle_playback_trigger); - } - - void initUI(void) - { - gtk_widget_show(this->drawing_area); - gtk_widget_show(this->window); - - this->idle_id = g_timeout_add (1000 / 30, - (GSourceFunc) projectM_idle_func, - this->drawing_area); - - /* XXX */ - aud_hook_associate("playback begin", handle_playback_trigger, NULL); - } - - void addPCMData(gint16 pcm_data[2][512]) - { - if (this->pm) - this->pm->pcm->addPCM16(pcm_data); - } - - void triggerPlaybackBegin(PlaylistEntry *entry) - { - std::string title(entry->title); - - if (this->pm) - this->pm->projectM_setTitle(title); - } -}; - -/* glue to implementation section */ -projectMPlugin *thePlugin = 0; - -static void -projectM_draw_init(GtkWidget *widget, - void *data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - - if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) - return; - - std::string configFile = read_config(); - thePlugin->pm = new projectM(configFile); - thePlugin->pm->projectM_resetGL(widget->allocation.width, widget->allocation.height); - - gdk_gl_drawable_swap_buffers(gldrawable); - gdk_gl_drawable_gl_end(gldrawable); - - g_signal_connect(G_OBJECT(widget), "configure_event", - G_CALLBACK(projectM_reconfigure), NULL); -} - -static gboolean -projectM_reconfigure(GtkWidget *widget, - GdkEventConfigure *event, - gpointer data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - - if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) - return FALSE; - - thePlugin->pm->projectM_resetGL(widget->allocation.width, widget->allocation.height); - - gdk_gl_drawable_swap_buffers(gldrawable); - gdk_gl_drawable_gl_end(gldrawable); - - return TRUE; -} - -static gboolean -projectM_draw_impl(GtkWidget *widget, - GdkEventExpose *event, - gpointer data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context(widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); - - if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext)) - return FALSE; - - thePlugin->pm->renderFrame(); - thePlugin->frames++; - - gdk_gl_drawable_swap_buffers(gldrawable); - gdk_gl_drawable_gl_end(gldrawable); - - gdouble seconds = g_timer_elapsed (thePlugin->timer, NULL); - if (seconds >= 5.0) - { - gdouble fps = thePlugin->frames / seconds; - g_print ("%d frames in %6.3f seconds = %6.3f FPS\n", thePlugin->frames, seconds, fps); - g_timer_reset (thePlugin->timer); - thePlugin->frames = 0; - } - - return TRUE; -} - -static gboolean -projectM_idle_func(GtkWidget *widget) -{ - gdk_window_invalidate_rect(widget->window, &widget->allocation, FALSE); - - return TRUE; -} - -void handle_playback_trigger(gpointer plentry_p, gpointer unused) -{ - PlaylistEntry *entry = reinterpret_cast<PlaylistEntry *>(plentry_p); - - if (!thePlugin) - return; - - thePlugin->triggerPlaybackBegin(entry); -} - -extern "C" void projectM_xmms_init(void) -{ - if (thePlugin) - return; - - thePlugin = new projectMPlugin; - thePlugin->initUI(); -} - -extern "C" void projectM_cleanup(void) -{ - if (!thePlugin) - return; - - delete thePlugin; -} - -extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]) -{ - if (!thePlugin) - return; - - thePlugin->addPCMData(pcm_data); -} - -/******************************************************************************** - * XXX: This code is from projectM and still needs to be rewritten! * - ********************************************************************************/ -std::string read_config() -{ - -// int n; - - char num[512]; - FILE *in; - FILE *out; - - char *home; - char projectM_home[1024]; - char projectM_config[1024]; - - strcpy(projectM_config, PROJECTM_PREFIX); - strcpy(projectM_config + strlen(PROJECTM_PREFIX), CONFIG_FILE); - projectM_config[strlen(PROJECTM_PREFIX) + strlen(CONFIG_FILE)] = '\0'; - //printf("dir:%s \n",projectM_config); - home = getenv("HOME"); - strcpy(projectM_home, home); - strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); - projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; - - - if ((in = fopen(projectM_home, "r")) != 0) - { - //printf("reading ~/.projectM/config.inp \n"); - fclose(in); - return std::string(projectM_home); - } - else - { - printf("trying to create ~/.projectM/config.inp \n"); - - strcpy(projectM_home, home); - strcpy(projectM_home + strlen(home), "/.projectM"); - projectM_home[strlen(home) + strlen("/.projectM")] = '\0'; - mkdir(projectM_home, 0755); - - strcpy(projectM_home, home); - strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); - projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; - - if ((out = fopen(projectM_home, "w")) != 0) - { - - if ((in = fopen(projectM_config, "r")) != 0) - { - - while (fgets(num, 80, in) != NULL) - { - fputs(num, out); - } - fclose(in); - fclose(out); - - - if ((in = fopen(projectM_home, "r")) != 0) - { - printf("created ~/.projectM/config.inp successfully\n"); - fclose(in); - return std::string(projectM_home); - } - else - { - printf("This shouldn't happen, using implementation defualts\n"); - abort(); - } - } - else - { - printf("Cannot find projectM default config, using implementation defaults\n"); - abort(); - } - } - else - { - printf("Cannot create ~/.projectM/config.inp, using default config file\n"); - if ((in = fopen(projectM_config, "r")) != 0) - { - printf("Successfully opened default config file\n"); - fclose(in); - return std::string(projectM_config); - } - else - { - printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); - abort(); - } - } - - } - - abort(); -}
--- a/src/projectm-1.0/main_visplugin.c Mon Feb 18 00:33:11 2008 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#include <audacious/plugin.h> - -extern void projectM_xmms_init(void); -extern void projectM_cleanup(void); -extern void projectM_render_pcm(gint16 pcm_data[2][512]); - -VisPlugin projectM_vtable = { - .description = "projectM v1.0", - .num_pcm_chs_wanted = 2, - .init = projectM_xmms_init, - .cleanup = projectM_cleanup, - .render_pcm = projectM_render_pcm, -}; - -VisPlugin *projectM_vplist[] = { &projectM_vtable, NULL }; - -DECLARE_PLUGIN(projectm, NULL, NULL, NULL, NULL, NULL, NULL, - projectM_vplist, NULL);
--- a/src/projectm-1.0/sdltoprojectM.h Mon Feb 18 00:33:11 2008 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -/** - * $Id: sdltoprojectM.h,v 1.1.1.1 2005/12/23 18:42:00 psperl Exp $ - * - * Translates SDL -> projectM variables - * - * $Log: sdltoprojectM.h,v $ - * Revision 1.1.1.1 2005/12/23 18:42:00 psperl - * Initial Import - * - * Revision 1.1 2004/10/08 00:35:28 cvs - * Moved and imported - * - * Revision 1.1.1.1 2004/10/04 12:56:00 cvs - * Imported - * - */ - -#ifndef _SDLTOPROJECTM_H -#define _SDLTOPROJECTM_H - -#include "libprojectM/event.h" -#ifdef WIN32 -#include <SDL.h> -#else -#include <SDL/SDL.h> -#endif - -projectMEvent sdl2pmEvent( SDL_Event event ) { \ - - switch ( event.type ) { \ - case SDL_VIDEORESIZE: - return PROJECTM_VIDEORESIZE; \ - case SDL_KEYUP: \ - return PROJECTM_KEYUP; \ - case SDL_KEYDOWN: \ - return PROJECTM_KEYDOWN; \ - case SDL_QUIT: \ - return PROJECTM_VIDEOQUIT; \ - default: - return PROJECTM_KEYUP; \ - } \ - } \ - -projectMKeycode sdl2pmKeycode( SDLKey keysym ) { \ - switch ( keysym ) { \ - case SDLK_F1: \ - return PROJECTM_K_F1; \ - case SDLK_F2: \ - return PROJECTM_K_F2; \ - case SDLK_F3: \ - return PROJECTM_K_F3; \ - case SDLK_F4: \ - return PROJECTM_K_F4; \ - case SDLK_F5: \ - return PROJECTM_K_F5; \ - case SDLK_F6: \ - return PROJECTM_K_F6; \ - case SDLK_F7: \ - return PROJECTM_K_F7; \ - case SDLK_F8: \ - return PROJECTM_K_F8; \ - case SDLK_F9: \ - return PROJECTM_K_F9; \ - case SDLK_F10: \ - return PROJECTM_K_F10; \ - case SDLK_F11: \ - return PROJECTM_K_F11; \ - case SDLK_F12: \ - return PROJECTM_K_F12; \ - case SDLK_ESCAPE: \ - return PROJECTM_K_ESCAPE; - case SDLK_a: - return PROJECTM_K_a; - case SDLK_b: - return PROJECTM_K_b; - case SDLK_c: - return PROJECTM_K_c; - case SDLK_d: - return PROJECTM_K_d; - case SDLK_e: - return PROJECTM_K_e; - case SDLK_f: - return PROJECTM_K_f; - case SDLK_g: - return PROJECTM_K_g; - case SDLK_h: - return PROJECTM_K_h; - case SDLK_i: - return PROJECTM_K_i; - case SDLK_j: - return PROJECTM_K_j; - case SDLK_k: - return PROJECTM_K_k; - case SDLK_l: - return PROJECTM_K_l; - case SDLK_m: - return PROJECTM_K_m; - case SDLK_n: - return PROJECTM_K_n; - case SDLK_o: - return PROJECTM_K_o; - case SDLK_p: - return PROJECTM_K_p; - case SDLK_q: - return PROJECTM_K_q; - case SDLK_r: - return PROJECTM_K_r; - case SDLK_s: - return PROJECTM_K_s; - case SDLK_t: - return PROJECTM_K_t; - case SDLK_u: - return PROJECTM_K_u; - case SDLK_v: - return PROJECTM_K_v; - case SDLK_w: - return PROJECTM_K_w; - case SDLK_x: - return PROJECTM_K_x; - case SDLK_y: - return PROJECTM_K_y; - case SDLK_z: - return PROJECTM_K_z; - case SDLK_UP: - return PROJECTM_K_UP; - case SDLK_RETURN: - return PROJECTM_K_RETURN; - case SDLK_RIGHT: - return PROJECTM_K_RIGHT; - case SDLK_LEFT: - return PROJECTM_K_LEFT; - case SDLK_DOWN: - return PROJECTM_K_DOWN; - case SDLK_PAGEUP: - return PROJECTM_K_PAGEUP; - case SDLK_PAGEDOWN: - return PROJECTM_K_PAGEDOWN; - - default: \ - return PROJECTM_K_NONE; \ - } \ - } \ - -projectMModifier sdl2pmModifier( SDLMod mod ) { \ - return PROJECTM_KMOD_LSHIFT; \ - } \ - -#endif /** _SDLTOPROJECTM_H */