www.pudn.com > GameEngine.rar > GameEngine_Input.h, change:2005-08-19,size:1678b


#ifndef GameEngine_Input_Include 
#define GameEngine_Input_Include 
 
#define ITEMS_NUM 10 
static LPDIRECTINPUT8 g_pIDirectInput=NULL; 
BOOL CALLBACK EnumJSCallback(LPCDIDEVICEINSTANCE,LPVOID); 
 
class CGameEngine_Input{ 
private: 
	bool m_bUseJoystick; 
	LPDIRECTINPUTDEVICE8 m_pKeyboardDevice;     //键盘设备 
	LPDIRECTINPUTDEVICE8 m_pMouseDevice;        //鼠标设备 
	LPDIRECTINPUTDEVICE8 m_pJoystickDevice;     //游戏杆设备 
	char m_KeyBuffer[256];                      //键盘的缓冲区(立即模式) 
	DIDEVICEOBJECTDATA m_MouseData[ITEMS_NUM];  //鼠标的缓冲区(缓冲模式) 
	DIJOYSTATE2 m_JoystickData;                 //游戏杆的缓冲区(立即模式)           
	long m_lMouseMoveX,m_lMouseMoveY;           //鼠标的X-Y轴总移动量 
public: 
	CGameEngine_Input(); 
	~CGameEngine_Input(); 
	bool CreateInput(HINSTANCE,HWND,int iMin=-100,int iMax=100,int iDeadZone=20,bool bUseJoystick=false);   
	bool ReadKeyboard(); 
	bool ReadMouse(); 
	bool ReadJoystick(); 
	inline bool IsKeyPressed(int key){return ((m_KeyBuffer[key] & 0x80)?true:false);}    //判断用户按键函数 
	inline long GetMouseMoveX(){return m_lMouseMoveX;}    
	inline long GetMouseMoveY(){return m_lMouseMoveY;} 
	bool IsLButtonPressed();            //判断鼠标左键按下 
	bool IsRButtonPressed();            //判断鼠标右键按下 
	bool IsMButtonPressed();            //判断鼠标中间滑轮按下 
	inline bool IsJSButtonPressed(int iButton){return ((m_JoystickData.rgbButtons[iButton] & 0x80)?true:false);}  //判断游戏杆按钮按下 
private: 
	bool CreateDirectInput(HINSTANCE); 
	bool CreateKeyboard(HWND); 
	bool CreateMouse(HWND); 
	bool CreateJoystick(HWND,int iMin,int iMax,int iDeadZone); 
	void InputRelease(); 
}; 
#endif