InputLayer.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:2k
- /*******************************************************************
- * Advanced 3D Game Programming using DirectX 7.0
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Title: InputLayer.h
- * Desc: Manages DirectInput
- * Currently only has support for keyboard/mouse
- * copyright (c) 1999 by Adrian Perez
- * See license.txt for modification and distribution information
- ******************************************************************/
- #ifndef _INPUTLAYER_H
- #define _INPUTLAYER_H
- #include <dinput.h>
- #include "Keyboard.h"
- #include "Mouse.h"
- class cInputLayer
- {
- cKeyboard* m_pKeyboard;
- cMouse* m_pMouse;
- // The DI7 object
- LPDIRECTINPUT8 m_pDI;
-
- static cInputLayer* m_pGlobalILayer;
- cInputLayer(
- HINSTANCE hInst,
- HWND hWnd,
- bool bExclusive,
- bool bUseKeyboard = true,
- bool bUseMouse = true );
- public:
- static void Destroy();
- virtual ~cInputLayer();
- cKeyboard* GetKeyboard()
- {
- return m_pKeyboard;
- }
- cMouse* GetMouse()
- {
- return m_pMouse;
- }
- void UpdateDevices();
- static cInputLayer* GetInput()
- {
- return m_pGlobalILayer;
- }
- LPDIRECTINPUT8 GetDInput()
- {
- return m_pDI;
- }
- void SetFocus(); // called when the app gains focus
- void KillFocus(); // called when the app must release focus
- static void Create(
- HINSTANCE hInst,
- HWND hWnd,
- bool bExclusive,
- bool bUseKeyboard = true,
- bool bUseMouse = true )
- {
- // everything is taken care of in the constructor
- new cInputLayer(
- hInst,
- hWnd,
- bExclusive,
- bUseKeyboard,
- bUseMouse );
- }
- };
- inline cInputLayer* Input()
- {
- return cInputLayer::GetInput();
- }
- #endif //_INPUTLAYER_H