?? input.h
字號:
//--------------------------------------------------
// Desc: DirectInput8 Interface
// Date: 2006.8.8 /update
// Author: artsylee
//
// Copyright (C) 2006 artsylee
//
// Update: 2006.8.18 add CInputDevice class
// stInputInfo結構添加mouse是否移動信息(2006_11_15)
// 從MouseState中獲取鼠標移動信息(2007_3_26)
//--------------------------------------------------
#ifndef _INPUT_
#define _INPUT_
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
#define BUFFERSIZE 32
#define MAXKEY 256
#define MOUSEBUTTON 4
#define KEYDOWN(name, key) (name[key] & 0x80)
struct stInputInfo
{
POINT point; // point of mouse in window client
unsigned int KeyValue; // key value in buffered mode
unsigned int MouseValue; // mouse value in buffered mode
bool MouseMove; // 相對于上一幀mouse是否移動(2006_11_15).
};
//----------------------------------------
//----------------------------------------
// virtual input device
//----------------------------------------
//----------------------------------------
class ASE_DLL CInputDevice
{
public:
CInputDevice();
virtual ~CInputDevice();
virtual BOOL CreateDevice(HWND hWnd) = 0;
virtual void ReleaseDevice(void) = 0;
virtual HRESULT GetState(void) = 0;
virtual HRESULT GetData(void) = 0;
virtual bool IsKeyDown(unsigned char key) = 0;
virtual void SetBufferKey(unsigned int key, bool bKeyDown = true) = 0;
unsigned int GetBufferKey(void);
void ClearBufferKey(void);
protected:
LPDIRECTINPUTDEVICE8 m_lpDevice;
// Use unsigned int to hold key buffer data
unsigned int m_BufferData[BUFFERSIZE];
int m_BufferStart;
int m_BufferEnd;
};
//----------------------------------------
//----------------------------------------
// CKey class
//----------------------------------------
//----------------------------------------
class ASE_DLL CKey : public CInputDevice
{
public:
CKey();
virtual ~CKey();
public:
virtual BOOL CreateDevice(HWND hWnd);
virtual void ReleaseDevice(void);
virtual HRESULT GetState(void);
virtual HRESULT GetData(void);
virtual bool IsKeyDown(unsigned char key);
virtual void SetBufferKey(unsigned int key, bool bKeyDown = true);
// Set key down
private:
// Immediate Data
unsigned char m_KeyState[MAXKEY];
};
//----------------------------------------
//----------------------------------------
// CMouse class
//----------------------------------------
//----------------------------------------
#define LB_DOWN 1
#define RB_DOWN 2
#define MB_DOWN 4
#define LB_UP 8
#define RB_UP 16
#define MB_UP 32
enum BTN_MOUSE
{
LBUTTON = 0,
RBUTTON = 1,
MBUTTON = 2,
LRBUTTON = 3,
};
class ASE_DLL CMouse : public CInputDevice
{
public:
CMouse();
virtual ~CMouse();
public:
virtual BOOL CreateDevice(HWND hWnd);
virtual void ReleaseDevice(void);
virtual HRESULT GetState(void);
virtual HRESULT GetData(void);
virtual bool IsKeyDown(unsigned char mouse);
virtual void SetBufferKey(unsigned int key, bool bKeyDown = true);
void GetPointerOffset(long *x, long *y, long *z);
private:
// Immediate Data
long m_XPos;
long m_YPos;
long m_ZPos;
DWORD MouseButton[MOUSEBUTTON];
};
//----------------------------------------
//----------------------------------------
// CInput class
//----------------------------------------
//----------------------------------------
class ASE_DLL CInput
{
public:
CInput();
~CInput();
BOOL CreateInput(HWND hWnd);
void ReleaseInput(void);
CKey *GetKeyPtr(void) { return &m_Key; }
CMouse *GetMousePtr(void) { return &m_Mouse; }
BOOL UpdateBufferInput(stInputInfo *input);
private:
CKey m_Key;
CMouse m_Mouse;
HWND m_hWnd;
POINT m_OldPt;
};
#endif // _INPUT_
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -