Changeset 3285 for code/branches/core4/src/core/input/InputHandler.h
- Timestamp:
- Jul 13, 2009, 6:41:58 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/input/InputHandler.h
r3274 r3285 41 41 namespace orxonox 42 42 { 43 namespace ButtonEvent 44 { 45 //! Helper enum to deploy events with the help of templates 46 enum Value 47 { 48 Press, 49 Release, 50 Hold 51 }; 52 53 //! Enables function overloading with integer values 54 template <ButtonEvent::Value Event> 55 struct EnumToType { }; 56 typedef EnumToType<Press> TPress; 57 typedef EnumToType<Release> TRelease; 58 typedef EnumToType<Hold> THold; 59 } 60 61 namespace KeyboardModifier 62 { 63 //! Keyboard modifiers (shift, ctrl and alt) 64 enum Enum 65 { 66 Shift = 0x0000001, 67 Ctrl = 0x0000010, 68 Alt = 0x0000100 69 }; 70 } 71 72 //! Event argument for key events 73 class _CoreExport KeyEvent 74 { 75 public: 76 KeyEvent(const OIS::KeyEvent& evt) 77 : key_(static_cast<KeyCode::ByEnum>(evt.key)) 78 , text_(evt.text) 79 , modifiers_(0) 80 { } 81 bool operator==(const KeyEvent& rhs) const 82 { return rhs.key_ == key_; } 83 bool operator!=(const KeyEvent& rhs) const 84 { return rhs.key_ != key_; } 85 void setModifiers(int modifiers) 86 { modifiers_ = modifiers; } 87 88 bool isModifierDown(KeyboardModifier::Enum modifier) const 89 { return static_cast<KeyboardModifier::Enum>(modifier & modifiers_); } 90 KeyCode::ByEnum getKeyCode() const 91 { return key_; } 92 unsigned int getText() const { return text_; } 93 94 private: 95 KeyCode::ByEnum key_; 96 unsigned int text_; 97 int modifiers_; 98 }; 99 43 100 /** 44 101 @brief
Note: See TracChangeset
for help on using the changeset viewer.