00001 #ifndef __C_DIRECT_INPUT_HPP 00002 #define __C_DIRECT_INPUT_HPP 00003 00004 #include "CDirectInputBase.hpp" 00005 00006 //ver 2.0 00007 00008 //キーイベント用関数ポインタ 00009 //typedef VOID (*CONTROL_EVENT)(DIDEVICEOBJECTDATA &DeviceObjData); 00010 00011 //class CDirectInputBase; 00012 00013 //============================================================================ 00014 //DirectInputの通常クラス 00015 //デバイスの状態を管理 00016 //============================================================================ 00017 class CDirectInput : public CDirectInputBase { 00018 private: 00019 LPDIRECTINPUTDEVICE8 m_lpDInputDevice;//デバイス 00020 DIDEVICEINSTANCE m_DiInst; 00021 DWORD m_dwBufferSize; 00022 protected: 00023 //インターフェイス設定コールバックから呼ばれる 00024 virtual HRESULT DeviceCondition(const DIDEVICEINSTANCE *lpDdInst); 00025 public: 00026 CDirectInput(); 00027 virtual ‾CDirectInput(){;} 00028 00029 //初期化 00030 HRESULT InitDevice(DIDEVICEINSTANCE DiDevInst,DWORD dwBufferSize,HWND hWindow,DWORD dwLevel); 00031 VOID Release(); 00032 00033 //デバイスの列挙コールバックから呼ばれる 00034 // HRESULT DeviceCreate(const DIDEVICEINSTANCE *lpDdInst); 00035 virtual HRESULT DeviceAxes(LPCDIDEVICEOBJECTINSTANCE lpDdoInst); 00036 00037 //制御許可 00038 inline HRESULT AcquireDevice(BOOL bAcquire){ 00039 if(this->m_lpDInputDevice) 00040 return (bAcquire) ? this->m_lpDInputDevice->Acquire() : this->m_lpDInputDevice->Unacquire(); 00041 return E_FAIL; 00042 } 00043 00044 //状態取得 00045 // HRESULT GetState(CONTROL_EVENT fnKey,DWORD dwItemNum,LPDIRECTINPUTDEVICE8 lpDIdevice); 00046 inline HRESULT GetState(BYTE byKeyState[]){ if(this->m_lpDInputDevice && !this->m_dwBufferSize) return this->m_lpDInputDevice->GetDeviceState(256,byKeyState); return E_FAIL; } 00047 inline HRESULT GetState(DIMOUSESTATE2 *dims){ if(this->m_lpDInputDevice && !this->m_dwBufferSize) return this->m_lpDInputDevice->GetDeviceState(sizeof(DIMOUSESTATE2),dims); return E_FAIL; } 00048 inline HRESULT GetState(DIJOYSTATE2 *dijs){ if(this->m_lpDInputDevice && !this->m_dwBufferSize){ this->m_lpDInputDevice->Poll(); return this->m_lpDInputDevice->GetDeviceState(sizeof(DIJOYSTATE2),dijs);} return E_FAIL; } 00049 HRESULT GetState(DIDEVICEOBJECTDATA *DiDevData,DWORD *dwItemNum); 00050 00051 //ゲッター 00052 inline DIDEVICEINSTANCE GetInstanceInfo(){ return this->m_DiInst; } 00053 inline HRESULT GetCaps(DIDEVCAPS *lpDevCaps){ lpDevCaps->dwSize = sizeof(DIDEVCAPS); return this->m_lpDInputDevice->GetCapabilities(lpDevCaps); } 00054 inline DWORD GetBufferSize(){ return this->m_dwBufferSize; } 00055 }; 00056 00057 #endif