首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

在学习中遇到一个有关问题,请大家帮忙看看,多谢高分求救

2012-03-06 
在学习中遇到一个问题,请大家帮忙看看,谢谢高分求救#ifndef__INPUT_SYSTEM_INCLUDED__#define__INPUT_SYST

在学习中遇到一个问题,请大家帮忙看看,谢谢高分求救
#ifndef   __INPUT_SYSTEM_INCLUDED__
#define   __INPUT_SYSTEM_INCLUDED__

#include   <dinput.h>

#define   IS_USEKEYBOARD     1
#define   IS_USEMOUSE           2
#define   IS_USEJOYSTICK     4

class   CKeyboard
{


public:
  CKeyboard(LPDIRECTINPUT8   pDI,   HWND   hwnd);//错误通不过
~CKeyboard();

    bool     KeyDown(int   key)   {   return   (m_keys[key]   &   0x80)   ?   true   :   false;   }
    bool     KeyUp(int   key)   {   return   (m_keys[key]   &   0x80)   ?   false   :   true;   }

    bool     Update();

    void     Clear()   {   ZeroMemory(m_keys,   256   *   sizeof(char));   }

    bool     Acquire();
    bool     Unacquire();
private:
  LPDIRECTINPUTDEVICE8     m_pDIDev;//错误

    char         m_keys[256];

};


class   CMouse
{
public:
    CMouse(LPDIRECTINPUT8   pDI,   HWND   hwnd,   bool   isExclusive   =   true);//错误
    ~CMouse();

    bool     ButtonDown(int   button)   {   return   (m_state.rgbButtons[button]   &   0x80)   ?   true   :   false;   }
    bool     ButtonUp(int   button)   {   return   (m_state.rgbButtons[button]   &   0x80)   ?   false   :   true;   }
    void     GetMovement(int   &dx,   int   &dy)   {   dx   =   m_state.lX;   dy   =   m_state.lY;   }

    bool     Update();

    bool     Acquire();
    bool     Unacquire();

private:
    LPDIRECTINPUTDEVICE8     m_pDIDev;//错误
    DIMOUSESTATE                     m_state;
};


class   CJoystick
{
public:
    CJoystick(LPDIRECTINPUT8   pDI,   HINSTANCE   appInstance);//错误
    ~CJoystick();

    bool     Update();

    bool     Acquire();
    bool     Unacquire();

private:
    LPDIRECTINPUTDEVICE8     m_pDIDev;//错误
};


class   CInputSystem
{
public:
CInputSystem()   {   }
~CInputSystem()   {   Shutdown();   }
    bool     Initialize(HWND   hwnd,   HINSTANCE   appInstance,   bool   isExclusive,   DWORD   flags   =   0);
    bool     Shutdown();

    void     AcquireAll();
    void     UnacquireAll();

    CKeyboard     *GetKeyboard()   {   return   m_pKeyboard;   }
    CMouse           *GetMouse()         {   return   m_pMouse;   }
    CJoystick     *GetJoystick()   {   return   m_pJoystick;   }



    bool     Update();

    bool     KeyDown(int   key)   {   return   (m_pKeyboard   &&   m_pKeyboard-> KeyDown(key));   }
    bool     KeyUp(int   key)   {   return   (m_pKeyboard   &&   m_pKeyboard-> KeyUp(key));   }

    bool     ButtonDown(int   button)   {   return   (m_pMouse   &&   m_pMouse-> ButtonDown(button));   }
    bool     ButtonUp(int   button)   {   return   (m_pMouse   &&   m_pMouse-> ButtonUp(button));   }
    void     GetMouseMovement(int   &dx,   int   &dy)   {   if   (m_pMouse)   m_pMouse-> GetMovement(dx,   dy);   }

private:
    CKeyboard     *m_pKeyboard;
    CMouse           *m_pMouse;
    CJoystick     *m_pJoystick;
   
    LPDIRECTINPUT8   m_pDI;//错误
};
请大家帮忙看看,错误的地方,怎么修改?非常感谢.


[解决办法]
头文件没加进来
[解决办法]
找到LPDIRECTINPUT8是在哪定义的
[解决办法]
Find 总会有个定义的
[解决办法]
你安装了Direct X SDK吗?如果是VC 6,默认带的是DX 5的,需要自己另外安装。
[解决办法]
把directx的include目录添加到vc的include路径了吗?

热点排行