📄 ginput.h
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -