MPMA Framework 0.4
Unified.h
Go to the documentation of this file.
00001 
00002 //Luke Lenhart, 2008-2011
00003 //See /docs/License.txt for details on how this code may be used.
00004 
00005 #pragma once
00006 
00007 #include "../base/Setup.h"
00008 
00009 #ifdef MPMA_COMPILE_INPUT
00010 
00011 #include "../base/Types.h"
00012 
00013 #include <string>
00014 #include <vector>
00015 
00017 namespace INPUT
00018 {
00019     //Note that all input relies on the window being set up first.
00020 
00022     enum DeviceType
00023     {
00024         KEYBOARD_DEVICE=1,
00025         MOUSE_DEVICE,
00026         GAME_DEVICE
00027     };
00028 
00029     // -- buttons
00030 
00032     struct UnifiedButton
00033     {
00035 
00036         DeviceType Type;
00037         //Data specific to the device for this button.  The application should not try to interpret this value.
00038         union
00039         {
00040             nuint *DataPtr;
00041             nuint Data;
00042         };
00043 
00044         //ctor
00045         inline UnifiedButton(DeviceType type, nuint data)
00046         {
00047             Type=type;
00048             Data=data;
00049         }
00050 
00051         //ctor
00052         inline UnifiedButton(DeviceType type, nuint *dataPtr)
00053         {
00054             Type=type;
00055             DataPtr=dataPtr;
00056         }
00057 
00058         inline bool operator==(const UnifiedButton &o) const 
00059                 { return Type==o.Type && Data==o.Data; }
00060         inline bool operator!=(const UnifiedButton &o) const 
00061                 { return !(*this==o); }
00062 
00064         bool IsPressed() const;
00065 
00067         const std::string& GetFriendlyName() const;
00068 
00070         const std::string GetPersistentIdentifier() const;
00071     };
00072 
00073 
00075     const std::vector<UnifiedButton*>& GetCurrentlyPressedButtons();
00076 
00078     const std::vector<UnifiedButton*>& GetNewlyPressedButtons();
00079 
00081     UnifiedButton* FindUnifiedButton(const std::string &persistentIdendifier);
00082 
00083     namespace MOUSE
00084     {
00086         UnifiedButton* GetUnifiedButton(uint8 button);
00087     }
00088 
00089     namespace KEYBOARD
00090     {
00092         UnifiedButton* GetUnifiedButton(uint8 key);
00093     }
00094 
00095     namespace GAME
00096     {
00097         class Button;
00098 
00100         UnifiedButton* GetUnifiedButton(Button *button);
00101     }
00102 
00103     // -- axes
00104 
00106     extern bool KeyboardLettersActsAsAxis;
00107 
00109     extern bool KeyboardNumpadActsAsAxis;
00110 
00112     extern bool KeyboardArrowsActsAsAxis;
00113 
00115     struct UnifiedAxisSet
00116     {
00118         DeviceType Type;
00119 
00120         //An identifier for the axis.  The application should not try to interpret this value.
00121         union
00122         {
00123             nuint *DataPtr;
00124             nuint Data;
00125         };
00126 
00127         //ctor
00128         inline UnifiedAxisSet(DeviceType type, nuint data)
00129         {
00130             Type=type;
00131             Data=data;
00132         }
00133 
00134         //ctor
00135         inline UnifiedAxisSet(DeviceType type, nuint *dataPtr)
00136         {
00137             Type=type;
00138             DataPtr=dataPtr;
00139         }
00140 
00141         inline bool operator==(const UnifiedButton &o) const 
00142                 { return Type==o.Type && Data==o.Data; }
00143         inline bool operator!=(const UnifiedButton &o) const 
00144                 { return !(*this==o); }
00145 
00147         float GetXValue() const;
00148 
00150         float GetYValue() const;
00151 
00153         float GetZValue() const;
00154 
00156         const std::string GetFriendlyName() const;
00157 
00159         const std::string GetPersistentIdentifier() const;
00160     };
00161 
00162     namespace KEYBOARD
00163     {
00165         UnifiedAxisSet* GetUnifiedAxisSetArrows();
00166 
00168         UnifiedAxisSet* GetUnifiedAxisSetLetters();
00169 
00171         UnifiedAxisSet* GetUnifiedAxisSetNumpad();
00172     }
00173 
00174     namespace GAME
00175     {
00176         class AxisSet;
00177 
00179         UnifiedAxisSet* GetUnifiedAxisSet(AxisSet *axes);
00180     }
00181 
00183     const std::vector<UnifiedAxisSet*> GetNewlyPressedAxes();
00184 
00186     const std::vector<UnifiedAxisSet*> GetCurrentlyPressedAxes();
00187 
00189     UnifiedAxisSet* FindUnifiedAxisSet(const std::string &persistentIdendifier);
00190 }
00191 
00192 #endif //#ifdef MPMA_COMPILE_INPUT
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends