ginput.h
来自「AABB碰撞检测,目前主流3D游戏必需,希望对大家有帮助」· C头文件 代码 · 共 62 行
H
62 行
#pragma once
#ifndef AFX_GINPUT_H_INCLUDED
#define AFX_GINPUT_H_INCLUDED
#include <dinput.h>
#include <dinputd.h>
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) if(p) {p->Release();p=NULL;}
#endif
#define MK_MIN 0x100
#define MK_LEFT 0x100 //>255
#define MK_RIGHT 0x101
#define MK_MID 0x102
class CGInput
{
LPDIRECTINPUT8 m_pDInput;
LPDIRECTINPUTDEVICE8 m_pDInputKB;
LPDIRECTINPUTDEVICE8 m_pDInputMouse;
char m_strKeyState[256];
DIMOUSESTATE m_MouseState;
char m_strKeyStateOld[256];
DIMOUSESTATE m_MouseStateOld;
public:
//初始化DirectInput
CGInput(HINSTANCE hInstance,HWND hWnd);
~CGInput(void);
//更新,读取状态
LRESULT Update(void);
LRESULT GetIsKeyDown(DWORD keycode)
{
if(keycode<MK_MIN)
return (0x80 & m_strKeyState[keycode]) |m_strKeyStateOld[keycode]>>4 ;
else
return (0x80 & m_MouseState.rgbButtons[keycode-MK_MIN])
|m_MouseStateOld.rgbButtons[keycode-MK_MIN]>>4;
};
LONG GetLX() {return m_MouseState.lX;};
LONG GetLY() {return m_MouseState.lY;};
LONG GetLZ() {return m_MouseState.lZ;};
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?