00001 #ifndef GSGL_SCENEGRAPH_EVENT_MAP_H 00002 #define GSGL_SCENEGRAPH_EVENT_MAP_H 00003 00004 // 00005 // $Id: event_map.hpp 2 2008-03-01 20:58:50Z kulibali $ 00006 // 00007 // Copyright (c) 2008, The Periapsis Project. All rights reserved. 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are 00011 // met: 00012 // 00013 // * Redistributions of source code must retain the above copyright notice, 00014 // this list of conditions and the following disclaimer. 00015 // 00016 // * Redistributions in binary form must reproduce the above copyright 00017 // notice, this list of conditions and the following disclaimer in the 00018 // documentation and/or other materials provided with the distribution. 00019 // 00020 // * Neither the name of the The Periapsis Project nor the names of its 00021 // contributors may be used to endorse or promote products derived from 00022 // this software without specific prior written permission. 00023 // 00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00025 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 // 00036 00037 #include "scenegraph/scenegraph.hpp" 00038 00039 #include "data/singleton.hpp" 00040 #include "data/dictionary.hpp" 00041 00042 // forward declarations 00043 union SDL_Event; 00044 00045 namespace gsgl 00046 { 00047 00048 class string; 00049 00050 00051 namespace data 00052 { 00053 template <typename T> class list; 00054 class config_record; 00055 } // namespace data 00056 00057 00058 namespace scenegraph 00059 { 00060 class simulation; 00061 00062 00063 enum key_modifier { 00064 NO_MODIFIER = 0, 00065 CTRL_MODIFIER = 1 << 0, 00066 ALT_MODIFIER = 1 << 1, 00067 SHIFT_MODIFIER = 1 << 2 00068 }; 00069 00070 00071 /// Maps SDL events to internal game events. 00072 class SCENEGRAPH_API event_map 00073 : public scenegraph_object, public data::singleton<event_map> 00074 { 00075 // keys[sdl_keysim][modifier_bitmap] = scenegraph::event_code 00076 data::dictionary<data::dictionary< int, int >, int> key_events; 00077 00078 public: 00079 event_map(const string & fname); 00080 ~event_map(); 00081 00082 bool handle_event(const SDL_Event & e, scenegraph::simulation *sim); 00083 00084 private: 00085 void load_events(const string & fname); 00086 void load_keyboard_events(gsgl::data::config_record &); 00087 }; // class event_map 00088 00089 } // namespace scenegraph 00090 00091 } // namespace gsgl 00092 00093 #endif