00001 #ifndef __C_DIRECT_INPUT_BASE_HPP 00002 #define __C_DIRECT_INPUT_BASE_HPP 00003 00004 //ver 2.0 00005 00006 //============================================================================ 00007 //DirectInputの基底クラス 00008 //GUIDの管理、Dinputオブジェクトの管理 00009 //============================================================================ 00010 class CDirectInputBase { 00011 private: 00012 // static std::list<DIDEVICEINSTANCE> g_lstDevInst; 00013 static std::list<GUID> g_lstUseDeviceGuid; 00014 protected: 00015 static LPDIRECTINPUT8 g_lpDInput; 00016 protected: 00017 //コールバック 00018 static BOOL CALLBACK EnumDeviceCallback(const DIDEVICEINSTANCE *lpDdi,LPVOID lpContext); 00019 // static BOOL CALLBACK EmunJoysticksCallback(const DIDEVICEINSTANCE *lpDdi,LPVOID lpContext); 00020 static BOOL CALLBACK EnumAxesCallback(LPCDIDEVICEOBJECTINSTANCE lpDdoi,LPVOID pvRef); 00021 00022 static int RemoveGuid(GUID guid); 00023 00024 // int GetDevInst(DIDEVICEINSTANCE *lpDdInst,TCHAR *szDeviceName); 00025 static VOID SetGuid(GUID guid){ g_lstUseDeviceGuid.push_back(guid); } 00026 static BOOL CheckDeviceGuid(GUID guid); 00027 public: 00028 virtual ‾CDirectInputBase(){;} 00029 00030 // virtual HRESULT DeviceCreate(const DIDEVICEINSTANCE *lpDdInst) = 0; 00031 virtual HRESULT DeviceAxes(LPCDIDEVICEOBJECTINSTANCE lpDdoi) = 0; 00032 // virtual DIDEVICEINSTANCE GetInstanceInfo() = 0; 00033 00034 //オブジェクトの初期化 00035 inline static HRESULT DIObjectInit(HINSTANCE hInst){ 00036 if(g_lpDInput == NULL) 00037 return DirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8,(LPVOID *)&g_lpDInput,NULL); 00038 return D3D_OK; 00039 } 00040 //オブジェクト開放 00041 inline static VOID DIObjectRelease(){ 00042 if(!g_lstUseDeviceGuid.empty()) 00043 g_lstUseDeviceGuid.clear(); 00044 SAFE_RELEASE(g_lpDInput); 00045 } 00046 00047 //デバイス情報の取得 00048 static VOID GetDeviceInstance(std::list<DIDEVICEINSTANCE> *lstInst,DWORD dwDevFilter,DWORD dwEnumFlag); 00049 /* 00050 //デバイス列挙 00051 inline static HRESULT EnumDevices(){ 00052 if(!g_lstDevInst.empty()) 00053 g_lstDevInst.clear(); 00054 return g_lpDInput->EnumDevices(DI8DEVCLASS_ALL,EnumDeviceCallback,(LPVOID)NULL,DIEDFL_ATTACHEDONLY); 00055 } 00056 //デバイスの名前取得 00057 // static int GetDeviceName(TCHAR *szDeviceName,DWORD dwDevType,UINT uIdx); 00058 //デバイスの数取得 00059 // static DWORD GetDeviceNum(DWORD dwCntDevType); 00060 // inline static DWORD GetDeviceNum(){ return (DWORD)g_lstDevInst.size(); } 00061 */ 00062 }; 00063 00064 #include "CDirectInput.hpp" 00065 00066 #endif