核动力机器人代码---input class based on glfw

 #ifndef G_INPUT_INPUT_HPP #define G_INPUT_INPUT_HPP #if _MSC_VER > 1000 #pragma once #endif #ifndef _g_lib_ //#error please define g lib #endif #include <memory> #include <boost/utility.hpp> #include <gl/glfw.h> #include "gsingleton.hpp" using namespace g::design_pattern; namespace g { namespace input { class KeyBoard : public boost::noncopyable { public: KeyBoard(); ~KeyBoard(); public: static void GLFWCALL check_key_board(int key, int action); int get_pressed_key(); private: KeyBoard& operator = (const KeyBoard &kb); private: static int key_code; }; //前向引用鼠标属性 struct MouseStatus; class Mouse : public boost::noncopyable { public: Mouse(); ~Mouse(); public: //mouse pos static void GLFWCALL check_mouse_pos(int xpos, int ypos); //mouse button static void GLFWCALL check_mouse_button(int button, int action); //mouse wheel static void GLFWCALL functionname(int pos); MouseStatus get_mouse_status(); private: Mouse& operator = (const Mouse &mouse); private: static MouseStatus mouse_status; } ; //input system... //not inluded joystick...:) //singleton ... class InputSys { public: static std::auto_ptr<KeyBoard> key_ptr; static std::auto_ptr<Mouse> mouse_ptr; private: DEFINE_SINGLETON_CLASS(InputSys); private: InputSys(); InputSys(const InputSys &input); InputSys operator = (const InputSys &input); ~InputSys(); }; typedef g::design_pattern::Singleton<InputSys> InputSyatemManger; } } #endif

 

看了glfw之后,顺便写下这个。

没测试 不知对不对。

另外明天回家,9天后再来成都  -_-! 88

 

 

注释:说局题外话,单态描述起来简单,但是实现起来并不好做的。。。。

核动力机器人。。。

你可能感兴趣的:(struct,Class,input,action,button,keyboard)