cInputDevice.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:1k
- // CMAIN LIB - APPLICATION AND DIRECT WRAPPER
- //
- // Written by Mauricio Teichmann Ritter
- //
- // Copyright (C) 2002, Brazil. All rights reserved.
- //
- //
- // cInputDevice.h: interface for the cInputDevice class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_CINPUTDEVICE_H__00716BAA_8084_456C_91FB_03CCE67C3565__INCLUDED_)
- #define AFX_CINPUTDEVICE_H__00716BAA_8084_456C_91FB_03CCE67C3565__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "cApplication.h"
- class cInputDevice
- {
- private:
- static int m_iRefCount;
- protected:
- static LPDIRECTINPUT8 m_lpDI;
- public:
- cInputDevice();
- virtual ~cInputDevice();
- BOOL Create()
- {
- HRESULT hRet;
- if(!m_lpDI)
- {
- hRet = DirectInput8Create(GetMainApp()->GetInstHandle(), DIRECTINPUT_VERSION,
- IID_IDirectInput8, (void**)&m_lpDI, NULL);
- if FAILED(hRet)
- {
- // DirectInput not available
- return FALSE;
- }
- }
- m_iRefCount++;
- return TRUE;
- }
- void Destroy()
- {
- m_iRefCount--;
- if(m_iRefCount == 0)
- {
- if(m_lpDI != NULL){
- m_lpDI->Release();
- m_lpDI = NULL;
- }
- }
- }
- };
- #endif // !defined(AFX_CINPUTDEVICE_H__00716BAA_8084_456C_91FB_03CCE67C3565__INCLUDED_)