Skip to main content
GameDev.net gamedev.net
🔒 Locked

Input Core problems

Started by Wargrave Apr 14, 2006 at 2:50 PM 5 replies 1.7k views
Original Post
Wargrave
Wargrave
Hello, I'm having great difficulties with the following code. Can anyone explain what I'm doing wrong?

class cInput;
class cInputDevice;

class cInput  
{
  protected:
      HWND           m_hWnd;
      IDirectInput8 *m_pDI;

  public:
    cInput();
    ~cInput();

    IDirectInput8 *GetDirectInputCOM();
    HWND           GethWnd();
    
    BOOL Init(HWND hWnd, HINSTANCE hInst);
    BOOL Shutdown();
};

class cInputDevice
{
  public:
    cInput               *m_Input;

    short                 m_Type;
    IDirectInputDevice8  *m_pDIDevice;

    BOOL                  m_Windowed;

    char                  m_State[256];
    DIMOUSESTATE         *m_MouseState;
    DIJOYSTATE           *m_JoystickState;

    BOOL                  m_Locks[256];

    long                  m_XPos, m_YPos;
      
    static BOOL FAR PASCAL EnumJoysticks(LPCDIDEVICEINSTANCE pdInst, LPVOID pvRef);

  public:
    cInputDevice();
    ~cInputDevice();

    IDirectInputDevice8 *DeviceCOM();

    // Generic functions - all devices
    BOOL Create(cInput *Input, short Type, BOOL Windowed = TRUE);
    BOOL Free();

    BOOL Clear();
    BOOL Read();
    BOOL Acquire(BOOL Active = TRUE);

    BOOL GetLock(char Num);
    BOOL SetLock(char Num, BOOL State = TRUE);

    long GetXPos();
    BOOL SetXPos(long XPos);
    long GetYPos();
    BOOL SetYPos(long YPos);
    long GetXDelta();
    long GetYDelta();

    // Keyboard specific functions
    BOOL  GetKeyState(char Num);
    BOOL  SetKeyState(char Num, BOOL State);
    BOOL  GetPureKeyState(char Num);
    short GetKeypress(long TimeOut = 0);
    long  GetNumKeyPresses();
    long  GetNumPureKeyPresses();

    // Mouse/Joystick specific functions
    BOOL  GetButtonState(char Num);
    BOOL  SetButtonState(char Num, BOOL State);
    BOOL  GetPureButtonState(char Num);
    long  GetNumButtonPresses();
    long  GetNumPureButtonPresses();
};

#endif
c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(197) : error C2143: syntax error : missing ';' before '*' c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(197) : error C2501: 'cInput::IDirectInput8' : missing storage-class or type specifiers c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(197) : error C2501: 'cInput::m_pDI' : missing storage-class or type specifiers c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(203) : error C2143: syntax error : missing ';' before '*' c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(203) : error C2501: 'cInput::IDirectInput8' : missing storage-class or type specifiers c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(203) : error C2501: 'cInput::GetDirectInputCOM' : missing storage-class or type specifiers c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(203) : warning C4183: 'GetDirectInputCOM': missing return type; assumed to be a member function returning 'int' c:\Documents and Settings\Eddie\Skrivbord\4APR\Core_Input.h(216) : error C2143: syntax error : missing ';' before '*' Thanks Wargrave
Drew_Benton
Drew_Benton
Ah, using the Programming RPG's With DirectX input are you. All you need to do is put a #include at the top of the header file and it should compile. What's happening now is you are using DirectX specific code and without the header file, it's not being delcared, so your program doesn't know they exist. If you run into later troubles with key presses and such, take a look at this thread.
Wargrave
Wargrave
I included #include and instead I got a different kind of errors. I looked at the thread that I was referred to and I don't think that it could explain the errors. I might be wrong though.

Compiling...Core_Input.cppc:\program\microsoft directx sdk (february 2006)\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800Linking...Core_Input.obj : error LNK2019: unresolved external symbol _DirectInput8Create@20 referenced in function "public: int __thiscall cInput::Init(struct HWND__ *,struct HINSTANCE__ *)" (?Init@cInput@@QAEHPAUHWND__@@PAUHINSTANCE__@@@Z)Core_Input.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8ACore_Input.obj : error LNK2001: unresolved external symbol _c_dfDIJoystickCore_Input.obj : error LNK2001: unresolved external symbol _c_dfDIMouseCore_Input.obj : error LNK2001: unresolved external symbol _GUID_SysMouseCore_Input.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboardCore_Input.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboardDebug/EggCore.exe : fatal error LNK1120: 7 unresolved externals


Thanks
Wargrave
jflanglois
jflanglois
Add dinput8.lib and dxguid.lib to your linker input setting (Project->Properties->Configuration Properties->Linker->Input->Additional Dependencies).

Also, to remove the warning, add #define DIRECTINPUT_VERSION 0x0800 before you #include .


jfl.
Wargrave
Wargrave
The Input Core worked perfectly.

// Core includes//#include "Core_System.h"//#include "Core_Graphics.h"#include "Core_Input.h"//#include "Core_Sound.h"//#include "Core_Network.h"


But then, when I was trying to build the Sound Core, I got 102 INPUT errors although the Input Core worked perfectly 5 minutes before.

// Core includes//#include "Core_System.h"//#include "Core_Graphics.h"//#include "Core_Input.h"#include "Core_Sound.h"//#include "Core_Network.h"


Then I tested both cores at the same time. I got 37 errors.

// Core includes//#include "Core_System.h"//#include "Core_Graphics.h"#include "Core_Input.h"#include "Core_Sound.h"//#include "Core_Network.h"


c:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(41) : error C2143: syntax error : missing ';' before '*'c:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(41) : error C2501: 'cSound::IDirectMusicPerformance8' : missing storage-class or type specifiersc:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(41) : error C2501: 'cSound::m_pDMPerformance' : missing storage-class or type specifiersc:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(42) : error C2143: syntax error : missing ';' before '*'c:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(42) : error C2501: 'cSound::IDirectMusicLoader8' : missing storage-class or type specifiersc:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(42) : error C2501: 'cSound::m_pDMLoader' : missing storage-class or type specifiersc:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(49) : error C2143: syntax error : missing ';' before '*'c:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(49) : error C2501: 'cSound::IDirectMusicPerformance8' : missing storage-class or type specifiersc:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(49) : error C2501: 'cSound::GetPerformanceCOM' : missing storage-class or type specifiersc:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\13APR\EggCoreExe\Core_Sound.h(49) : warning C4183: 'GetPerformanceCOM': missing return type; assumed to be a member function returning 'int'


class cSound{  protected:    // Sound system related    HWND                      m_hWnd;    // Master volume level    long                      m_Volume;    // Playback format settings    long                      m_Frequency;        // Music and sound objects    IDirectMusicPerformance8 *m_pDMPerformance;    IDirectMusicLoader8      *m_pDMLoader;  public:    cSound();    ~cSound();


I really don't have a clue about what is wrong.

Thanks
Wargrave

[Edited by - Wargrave on April 15, 2006 8:46:54 PM]
jflanglois
jflanglois
Exactly the same thing is wrong here as it was for input. Please read the error messages and MSDN

For instance, at the bottom of MSDN: IDirectMusicLoader8 you will have a list of requirements for that interface.


jfl.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.