00001 // ===================================================================================== 00002 // Filename: InputContext.cpp 00003 // Description: 00004 // Created: 02/15/2007 08:47:46 PM EST 00005 // Revision: none 00006 // Compiler: gcc 3.4.6 00007 // 00008 // Author: John P. Feltz 00009 // Email: jfeltz@gmail.com 00010 // License: Copyright (c) 2006-2007, John P. Feltz 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of the GNU General Public License as 00013 // published by the Free Software Foundation, version 2 of the 00014 // License. 00015 // This program is distributed in the hope that it will be 00016 // useful, but WITHOUT ANY WARRANTY; without even the implied 00017 // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00018 // PURPOSE. 00019 // See the GNU General Public License version 2 for more details. 00020 // 00021 // ===================================================================================== 00022 00023 #include <System.h> 00024 00025 #include <InputSequencer.h> 00026 #include <InputNode.h> 00027 #include <InputContext.h> 00028 00029 namespace cmil { 00030 bool defaultContext::addCombo(const Ev& event) { 00031 std::ostringstream seq_add_ss; 00032 seq_add_ss << "addCombo( sequence ) : deferring to sequencer->addCombo()."; 00033 log_debug(seq_add_ss.str()); 00034 log_debug(""); 00035 00036 if(!m_sequencer->addCombo(event)) { 00037 log_error("addCombo( sequence ) : sequence found invalid by sequencer, not adding."); 00038 return false; 00039 } 00040 00041 return true; 00042 } 00043 00044 //This adds an input-action sequence. 00045 bool defaultContext::addNormal(const Ev& event) { 00046 std::ostringstream seq_add_ss; 00047 seq_add_ss << "addNormal( sequence ) : deferring to sequencer->addNormal."; 00048 log_debug(seq_add_ss.str()); 00049 00050 if(!m_sequencer->addNormal(event)) { 00051 log_error("addNormal( sequence ) : sequence found invalid by sequencer, not adding."); 00052 return false; 00053 } 00054 00055 return true; 00056 } 00057 00058 void defaultContext::captureNormal( ModAction* action ) { 00059 m_sequencer->captureNormal(action); 00060 } 00061 00062 Ev::Sequence* defaultContext::getCaptured() const { 00063 return m_sequencer->getCaptured(); 00064 } 00065 00066 bool defaultContext::removeNormal(const Ev& event) { 00067 std::ostringstream seq_remove_ss; 00068 seq_remove_ss << "removeNormal( sequence ) : deferring to sequencer->removeNormal."; 00069 log_debug(seq_remove_ss.str()); 00070 00071 if(!m_sequencer->removeNormal(event)) { 00072 log_error("removeNormal( sequence ) : sequence found invalid by sequencer, not removeing."); 00073 return false; 00074 } 00075 00076 return true; 00077 } 00078 00079 std::string defaultContext::getName() const { 00080 return "defaultContext"; 00081 } 00082 00083 void defaultContext::update(const InputData& input) { 00084 m_sequencer->handle(input); 00085 } 00086 00087 void defaultContext::update(const ModData& input) { 00088 m_sequencer->handle(input); 00089 } 00090 }