bdirectinput.h
来自「用VC++及DirectX实现的SuperMario小游戏」· C头文件 代码 · 共 58 行
H
58 行
/*
Author: Bear
This source is free to anybody.
If you have any problem with this or some advice to me, please:
mailto: heyang22118952.student@sina.com
or yang45249.student@sina.com
or you can contact me through my QQ: 261570581
Welcome to discuss game programming techniques with me :)
And I like to play games!
*/
#pragma once
#include "BHeader.h"
class BDLL_API BDirectInput
{
public:
BDirectInput(void);
~BDirectInput(void);
bool Initialize(HINSTANCE hInst, HWND hwnd);
void UnInitialize(void);
bool GetDeviceState(void);
private:
LPDIRECTINPUT8 lpdi;
LPDIRECTINPUTDEVICE8 lpdiKeyboard;
LPDIRECTINPUTDEVICE8 lpdiMouse;
UCHAR keyState[256];
DIMOUSESTATE mouseState;
public:
//these functions must be called after GetDeviceState been called.
//and you may call these functions only one time after every GetDeviceState call.
long BDirectInput::GetMouseDX(void)
{
return mouseState.lX;
}
long BDirectInput::GetMouseDY(void)
{
return mouseState.lY;
}
BOOL BDirectInput::KeyDown(int diKeyCode)
{
assert(diKeyCode >=0 && diKeyCode < 256);
return (keyState[diKeyCode] & 0x80);
}
BOOL BDirectInput::MouseDown(int mCode)
{
assert(mCode >=0 && mCode <=3);
return (mouseState.rgbButtons[mCode] & 0x80);
}
private:
bool initialized;
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?