Changeset 3327 for code/trunk/src/core/input/InputPrereqs.h
- Timestamp:
- Jul 19, 2009, 5:31:02 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core4 merged: 3269,3271-3275,3278,3285,3290-3294,3310
- Property svn:mergeinfo changed
-
code/trunk/src/core/input/InputPrereqs.h
r3276 r3327 30 30 @file 31 31 @brief 32 Declarations of various interface classes for the input management. 32 Declarations of all key/button/axis code enumeration and string literals 33 and an input device enumeration. 33 34 */ 34 35 … … 52 53 const unsigned int numberOfKeys = 0xEE; // 238 53 54 54 // note: KeyCode comments were directly copied from OISKeyboard.h55 //! Key codes as enumeration 55 56 enum ByEnum 56 57 { … … 202 203 }; 203 204 204 // Names as string. Has no real linkage!205 //! Key codes as strings 205 206 const char* const ByString[] = 206 207 { … … 307 308 const unsigned int numberOfButtons = 8; 308 309 310 //! Mouse button codes as enumeration 309 311 enum ByEnum 310 312 { … … 319 321 }; 320 322 321 // Names as string. Has no real linkage!323 // Mouse button codes as strings 322 324 const char* const ByString[] = 323 325 { … … 337 339 const unsigned int numberOfAxes = 2; 338 340 341 // Mouse axis codes as enumeration 339 342 enum ByEnum 340 343 { … … 343 346 }; 344 347 345 // Names as string. Has no real linkage!348 // Mouse axis codes as strings 346 349 const char* const ByString[] = 347 350 { … … 356 359 const unsigned int numberOfButtons = 64; 357 360 361 // Joy stick button codes as enumeration 358 362 enum ByEnum 359 363 { … … 380 384 }; 381 385 382 // Names as string. Has no real linkage!386 // Joy stick button codes as strings 383 387 const char* const ByString[] = 384 388 { … … 406 410 const unsigned int numberOfAxes = 24; 407 411 412 // Joy stick axis codes as enumeration 408 413 enum ByEnum 409 414 { … … 416 421 }; 417 422 418 // Names as string. Has no real linkage!423 // Joy stick axis codes as strings 419 424 const char* const ByString[] = 420 425 { … … 435 440 namespace InputDeviceEnumerator 436 441 { 442 //! Used to access the devices in an array 437 443 enum Value 438 444 { … … 442 448 }; 443 449 } 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 450 } 537 451
Note: See TracChangeset
for help on using the changeset viewer.