Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2009, 5:31:02 PM (15 years ago)
Author:
rgrieder
Message:

Merged all remaining revisions from core4 back to the trunk.

Location:
code/trunk
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/input/InputPrereqs.h

    r3276 r3327  
    3030@file
    3131@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.
    3334*/
    3435
     
    5253        const unsigned int numberOfKeys = 0xEE; // 238
    5354
    54         // note: KeyCode comments were directly copied from OISKeyboard.h
     55        //! Key codes as enumeration
    5556        enum ByEnum
    5657        {
     
    202203        };
    203204       
    204         // Names as string. Has no real linkage!
     205        //! Key codes as strings
    205206        const char* const ByString[] =
    206207        {
     
    307308        const unsigned int numberOfButtons = 8;
    308309
     310        //! Mouse button codes as enumeration
    309311        enum ByEnum
    310312        {
     
    319321        };
    320322
    321         // Names as string. Has no real linkage!
     323        // Mouse button codes as strings
    322324        const char* const ByString[] =
    323325        {
     
    337339        const unsigned int numberOfAxes = 2;
    338340
     341        // Mouse axis codes as enumeration
    339342        enum ByEnum
    340343        {
     
    343346        };
    344347
    345         // Names as string. Has no real linkage!
     348        // Mouse axis codes as strings
    346349        const char* const ByString[] =
    347350        {
     
    356359        const unsigned int numberOfButtons = 64;
    357360
     361        // Joy stick button codes as enumeration
    358362        enum ByEnum
    359363        {
     
    380384        };
    381385
    382         // Names as string. Has no real linkage!
     386        // Joy stick button codes as strings
    383387        const char* const ByString[] =
    384388        {
     
    406410        const unsigned int numberOfAxes = 24;
    407411
     412        // Joy stick axis codes as enumeration
    408413        enum ByEnum
    409414        {
     
    416421        };
    417422
    418         // Names as string. Has no real linkage!
     423        // Joy stick axis codes as strings
    419424        const char* const ByString[] =
    420425        {
     
    435440    namespace InputDeviceEnumerator
    436441    {
     442        //! Used to access the devices in an array
    437443        enum Value
    438444        {
     
    442448        };
    443449    }
    444 
    445     namespace ButtonEvent
    446     {
    447         enum Value
    448         {
    449             Press,
    450             Release,
    451             Hold
    452         };
    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 KeyboardModifier
    463     {
    464         enum Enum
    465         {
    466             Shift = 0x0000001,
    467             Ctrl  = 0x0000010,
    468             Alt   = 0x0000100
    469         };
    470     }
    471 
    472     class _CoreExport KeyEvent
    473     {
    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) const
    481             { return rhs.key_ == key_; }
    482         bool operator!=(const KeyEvent& rhs) const
    483             { return rhs.key_ != key_; }
    484         void setModifiers(int modifiers)
    485             { modifiers_ = modifiers; }
    486 
    487         bool isModifierDown(KeyboardModifier::Enum modifier) const
    488             { return static_cast<KeyboardModifier::Enum>(modifier & modifiers_); }
    489         KeyCode::ByEnum getKeyCode() const
    490             { 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 traits
    502     //-----------------------------------------------------------------------
    503 
    504     struct KeyboardTraits
    505     {
    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 MouseTraits
    514     {
    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 JoyStickTraits
    523     {
    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 enum
    532     namespace InputDeviceNames
    533     {
    534         const char* const values[] = { "", "Keyboard", "Mouse", "JoyStick" };
    535     }
    536450}
    537451
Note: See TracChangeset for help on using the changeset viewer.