Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 13, 2009, 6:41:58 PM (15 years ago)
Author:
rgrieder
Message:

Shoved some code around to reduce contents of 'global' InputPrereqs.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/core/input/InputPrereqs.h

    r3274 r3285  
    442442        };
    443443    }
    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     }
    536444}
    537445
Note: See TracChangeset for help on using the changeset viewer.