Sirikata
|
00001 /* Sirikata libproxyobject -- Ogre Graphics Plugin 00002 * InputResponse.hpp 00003 * 00004 * Copyright (c) 2009, Ewen Cheslack-Postava 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are 00009 * met: 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in 00014 * the documentation and/or other materials provided with the 00015 * distribution. 00016 * * Neither the name of Sirikata nor the names of its contributors may 00017 * be used to endorse or promote products derived from this software 00018 * without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00021 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00022 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00023 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00024 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00026 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 */ 00032 00033 #ifndef _SIRIKATA_INPUT_RESPONSES_HPP_ 00034 #define _SIRIKATA_INPUT_RESPONSES_HPP_ 00035 00036 #include <sirikata/core/util/Platform.hpp> 00037 #include "InputBindingEvent.hpp" 00038 00039 namespace Sirikata { 00040 namespace SimpleCamera { 00041 00046 class InputResponse { 00047 public: 00048 virtual ~InputResponse(); 00049 00051 virtual void invoke(InputBindingEvent& evt); 00052 00053 typedef std::vector<InputBindingEvent> InputEventDescriptorList; 00058 virtual InputEventDescriptorList getInputEvents(const InputBindingEvent& descriptor) const = 0; 00059 00060 protected: 00061 virtual void defaultAction() {} 00062 }; 00063 00064 class SimpleInputResponse : public InputResponse { 00065 public: 00066 typedef std::tr1::function<void(void)> ResponseCallback; 00067 00068 SimpleInputResponse(ResponseCallback cb); 00069 00070 virtual InputEventDescriptorList getInputEvents(const InputBindingEvent& descriptor) const; 00071 protected: 00072 virtual void defaultAction(); 00073 00074 private: 00075 ResponseCallback mCallback; 00076 }; 00077 00078 class FloatToggleInputResponse : public InputResponse { 00079 public: 00080 typedef std::tr1::function<void(float)> ResponseCallback; 00081 00082 FloatToggleInputResponse(ResponseCallback cb, float onval, float offval); 00083 00084 virtual void invoke(InputBindingEvent& evt); 00085 00086 virtual InputEventDescriptorList getInputEvents(const InputBindingEvent& descriptor) const; 00087 private: 00088 ResponseCallback mCallback; 00089 float mOnValue; 00090 float mOffValue; 00091 }; 00092 00093 class Vector2fInputResponse : public InputResponse { 00094 public: 00095 typedef std::tr1::function<void(Vector2f)> ResponseCallback; 00096 00097 Vector2fInputResponse(ResponseCallback cb); 00098 00099 virtual void invoke(InputBindingEvent& evt); 00100 00101 virtual InputEventDescriptorList getInputEvents(const InputBindingEvent& descriptor) const; 00102 private: 00103 ResponseCallback mCallback; 00104 }; 00105 00106 class AxisInputResponse : public InputResponse { 00107 public: 00108 typedef std::tr1::function<void(float)> ResponseCallback; 00109 00110 AxisInputResponse(ResponseCallback cb); 00111 00112 virtual void invoke(InputBindingEvent& evt); 00113 00114 virtual InputEventDescriptorList getInputEvents(const InputBindingEvent& descriptor) const; 00115 private: 00116 ResponseCallback mCallback; 00117 }; 00118 00119 } // namespace SimpleCamera 00120 } // namespace Sirikata 00121 00122 #endif //_SIRIKATA_INPUT_RESPONSES_HPP_