userInput.h

Go to the documentation of this file.
00001 #ifndef USER_INPUT_H
00002 #define USER_INPUT_H
00003 
00013 #include "typeUtils.h"
00014 #include <SDL.h>
00015 #include <vector>
00016 #include <list>
00017 
00018 
00022 class UserInput {
00023   friend class SDL_Video;
00024   friend class ButtonComponent;
00025   friend class MenuComponent;
00026   friend class ComboBoxComponent;
00027   friend class TextInputComponent;
00028   friend class OptionComponent;
00029   friend class CheckBoxComponent;
00030 
00031 public:
00032   typedef std::vector<char> keys_t; 
00033   typedef std::vector<int> sdl_keys_t; 
00034   typedef std::list<SDLKey> now_keys_t; 
00039   class userInput_t {
00040   public:
00041     bool quit;                  
00042     bool left_released;         
00043     bool left_clicked;          
00044     int wheel_moved;            
00045     VXV::Grid mpos;             
00046     bool mouse_moved;           
00047     int mxx;                    
00048     int myy;                    
00049     keys_t keys;                
00050     sdl_keys_t sdl_keys;        
00051     now_keys_t now_keys;        
00052     bool tab_pressed;           
00053     bool ctrl_pressed;          
00054     bool alt_pressed;           
00056     userInput_t(void)
00057       : quit(false), left_released(false), left_clicked(false),
00058         wheel_moved(0) {}
00059     ~userInput_t(void) {}
00060 
00066     bool isPressed(char ch) const;
00067 
00073     bool isPressedCode(int code) const;
00074 
00080     bool nowPressedCode(int code) const;
00081   };
00082 
00083 private:
00084   // システム
00085   bool toggle_fullscreen;
00086 
00087   // マウス
00088   VXV::Grid mpos;
00089   bool left_release;
00090   keys_t keys_sys;
00091   sdl_keys_t sdl_keys_sys;
00092   typedef std::vector<SDLMod> sdl_mods_t;
00093   sdl_mods_t sdl_mods_sys;
00094 
00095   static UserInput* obj;
00096   static userInput_t state;
00097   void internal_stateClear(void);
00098   void internal_update(void);
00099   static void stateClear(void);
00100   void keyupHandler(SDL_KeyboardEvent& key_event);
00101   void keydownHandler(SDL_KeyboardEvent& key_event);
00102   void mousebuttonHandler(SDL_MouseButtonEvent& button_event);
00103   UserInput(void);
00104 
00105 public:
00106   ~UserInput(void);
00107 
00113   static UserInput& getObject(void);
00114 
00120   static userInput_t getInputed(void);
00121 };
00122 
00123 #endif /* !USER_INPUT_H */
00124 

Generated on Mon Apr 13 22:52:01 2009 by  doxygen 1.5.7.1