📄 inputlayer.h
字号:
/*******************************************************************
* 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -