00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(_XRB_INPUTSTATE_HPP_)
00012 #define _XRB_INPUTSTATE_HPP_
00013
00014 #include "xrb.hpp"
00015
00016 #include <list>
00017 #include <map>
00018 #include <string>
00019
00020 #include "xrb_key.hpp"
00021 #include "xrb_eventhandler.hpp"
00022
00023 namespace Xrb
00024 {
00025
00031 class InputState : public EventHandler
00032 {
00033 public:
00034
00035 InputState ();
00036 ~InputState ();
00037
00038 Key const *GetKey (Key::Code code) const;
00039 Key const *GetKey (std::string const &name) const;
00040 bool IsValidKeyCode (Key::Code code) const;
00041 bool IsValidKeyName (std::string const &name) const;
00042 Key::Code KeyCode (std::string const &name) const;
00043 std::string const &KeyName (Key::Code code) const;
00044 bool IsKeyPressed (Key::Code const code) const;
00045 bool IsKeyPressed (std::string const &name) const;
00046 bool IsEitherAltKeyPressed () const;
00047 bool IsEitherControlKeyPressed () const;
00048 bool IsEitherShiftKeyPressed () const;
00049 inline bool IsCapsLockOn () const { return m_is_caps_lock_on; }
00050 inline bool IsNumLockOn () const { return m_is_num_lock_on; }
00051 inline bool IsScrollLockOn () const { return m_is_scroll_lock_on; }
00052 Key::Modifier Modifier () const;
00053
00054
00055 void ResetPressed ();
00056
00057 protected:
00058
00059
00060 virtual bool HandleEvent (Event const *e);
00061 void InitKeyMaps ();
00062
00063 private:
00064
00065
00066 typedef std::map<Key::Code, Key *> KeyCodeMap;
00067
00068 typedef std::map<std::string, Key *> KeyNameMap;
00069
00073 KeyCodeMap m_keycode_map;
00078 KeyNameMap m_keyname_map;
00081 bool m_is_caps_lock_on;
00084 bool m_is_num_lock_on;
00087 bool m_is_scroll_lock_on;
00088 };
00089
00090 }
00091
00092 #endif // !defined(_XRB_INPUTSTATE_HPP_)
00093