Changeset 3285 for code/branches/core4/src/core/input/InputPrereqs.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/InputPrereqs.h
r3274 r3285 442 442 }; 443 443 } 444 445 namespace ButtonEvent446 {447 enum Value448 {449 Press,450 Release,451 Hold452 };453 454 template <ButtonEvent::Value Event>455 struct EnumToType { };456 typedef EnumToType<Press> TPress;457 typedef EnumToType<Release> TRelease;458 typedef EnumToType<Hold> THold;459 }460 461 462 namespace KeyboardModifier463 {464 enum Enum465 {466 Shift = 0x0000001,467 Ctrl = 0x0000010,468 Alt = 0x0000100469 };470 }471 472 class _CoreExport KeyEvent473 {474 public:475 KeyEvent(const OIS::KeyEvent& evt)476 : key_(static_cast<KeyCode::ByEnum>(evt.key))477 , text_(evt.text)478 , modifiers_(0)479 { }480 bool operator==(const KeyEvent& rhs) const481 { return rhs.key_ == key_; }482 bool operator!=(const KeyEvent& rhs) const483 { return rhs.key_ != key_; }484 void setModifiers(int modifiers)485 { modifiers_ = modifiers; }486 487 bool isModifierDown(KeyboardModifier::Enum modifier) const488 { return static_cast<KeyboardModifier::Enum>(modifier & modifiers_); }489 KeyCode::ByEnum getKeyCode() const490 { return key_; }491 unsigned int getText() const { return text_; }492 493 private:494 KeyCode::ByEnum key_;495 unsigned int text_;496 int modifiers_;497 };498 499 500 //-----------------------------------------------------------------------501 // Device type traits502 //-----------------------------------------------------------------------503 504 struct KeyboardTraits505 {506 typedef Keyboard DeviceClass;507 typedef OIS::Keyboard OISDeviceClass;508 typedef KeyEvent ButtonType;509 typedef KeyEvent& ButtonTypeParam;510 static const OIS::Type OISDeviceValue = OIS::OISKeyboard;511 };512 513 struct MouseTraits514 {515 typedef Mouse DeviceClass;516 typedef OIS::Mouse OISDeviceClass;517 typedef MouseButtonCode::ByEnum ButtonType;518 typedef MouseButtonCode::ByEnum ButtonTypeParam;519 static const OIS::Type OISDeviceValue = OIS::OISMouse;520 };521 522 struct JoyStickTraits523 {524 typedef JoyStick DeviceClass;525 typedef OIS::JoyStick OISDeviceClass;526 typedef JoyStickButtonCode::ByEnum ButtonType;527 typedef JoyStickButtonCode::ByEnum ButtonTypeParam;528 static const OIS::Type OISDeviceValue = OIS::OISJoyStick;529 };530 531 // Note: Entries correspond to OIS::Type enum532 namespace InputDeviceNames533 {534 const char* const values[] = { "", "Keyboard", "Mouse", "JoyStick" };535 }536 444 } 537 445
Note: See TracChangeset
for help on using the changeset viewer.