Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
binder.h
00001 /* 00002 Copyright (C) 2003, 04 by Mathew Sutcliffe <oktal@gmx.co.uk> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_UTIL_BINDER_H__ 00020 #define __CS_UTIL_BINDER_H__ 00021 00022 #include "csextern.h" 00023 #include "iutil/binder.h" 00024 #include "iutil/event.h" 00025 #include "iutil/eventh.h" 00026 #include "iutil/evdefs.h" 00027 #include "csutil/inputdef.h" 00028 #include "csutil/array.h" 00029 #include "csutil/hash.h" 00030 00052 class CS_CRYSTALSPACE_EXPORT csInputBinder : public iInputBinder 00053 { 00054 struct AxisCmd 00055 { 00056 unsigned cmd; 00057 int val, sens; 00058 bool wrap; 00059 AxisCmd (unsigned cmd0, int sens0) 00060 : cmd (cmd0), val (0), sens (sens0) {} 00061 }; 00062 typedef csHash<AxisCmd *, csInputDefinition> AxisHash; 00063 AxisHash axisHash; 00064 csArray<AxisCmd *> axisArray; 00065 00066 struct BtnCmd 00067 { 00068 unsigned cmd; 00069 bool down, toggle; 00070 BtnCmd (unsigned cmd0, bool toggle0) 00071 : cmd (cmd0), down (false), toggle (toggle0) {} 00072 }; 00073 typedef csHash<BtnCmd *, csInputDefinition> BtnHash; 00074 BtnHash btnHash; 00075 csArray<BtnCmd *> btnArray; 00076 00077 protected: 00078 bool HandleEvent (iEvent&); 00079 00080 public: 00081 SCF_DECLARE_IBASE; 00082 00087 csInputBinder (iBase *parent = 0, int btnSize = 127, int axisSize = 13); 00088 virtual ~csInputBinder (); 00089 00090 struct CS_CRYSTALSPACE_EXPORT eiEventHandler : public iEventHandler 00091 { 00092 SCF_DECLARE_EMBEDDED_IBASE (csInputBinder); 00093 bool HandleEvent (iEvent &ev) { return scfParent->HandleEvent (ev); } 00094 } scfiEventHandler; 00095 friend struct eiEventHandler; 00096 00097 virtual iEventHandler* QueryHandler () { return &scfiEventHandler; } 00098 00099 virtual int Axis (unsigned cmd); 00100 virtual bool Button (unsigned cmd); 00101 00102 virtual void BindButton (csInputDefinition const& def, unsigned int cmd, 00103 bool toggle = false); 00104 virtual void BindAxis (csInputDefinition const& def, unsigned int cmd, 00105 int sensitivity = 1); 00106 00107 virtual bool UnbindAxis (unsigned cmd); 00108 virtual bool UnbindButton (unsigned cmd); 00109 virtual void UnbindAll (); 00110 00111 virtual void LoadConfig (iConfigFile *, const char *subsection); 00112 virtual void SaveConfig (iConfigFile *, const char *subsection); 00113 }; 00114 00115 #endif // __CS_UTIL_BINDER_H__
Generated for Crystal Space by doxygen 1.4.4