Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kasooi

I'm having problems with dsound and dinput

This topic is 5547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here are my errors: C:\WINDOWS\TEMP\cc9Qmagb.o: In function `DSound_Init(void)'': //c/windows/desktop/source/game/gptemp.cpp:418: undefined reference to `DirectSoundCreate@12'' C:\WINDOWS\TEMP\ccDhE3fb.o: In function `DI_Init_Joystick(int, int, int, int)'': //C/windows/desktop/source/game/Gpdumb2.cpp:1134: undefined reference to `c_dfDIJoystick'' C:\WINDOWS\TEMP\ccDhE3fb.o: In function `DI_Init_Mouse(void)'': //C/windows/desktop/source/game/Gpdumb2.cpp:1190: undefined reference to `c_dfDIMouse'' C:\WINDOWS\TEMP\ccDhE3fb.o: In function `DI_Init_Keyboard(void)'': //C/windows/desktop/source/game/Gpdumb2.cpp:1218: undefined reference to `c_dfDIKeyboard'' First thing I would like to say is that I have everything linked fine. Here is what I''m linking: -fvtable-thunks -lobjc C:\DEV-C++\Lib\libddraw.a -lobjc C:\DEV-C++\Lib\libdinput.a -lobjc C:\DEV-C++\Lib\libdsound.a -lobjc C:\windows\desktop\source\game\Gpdumb1.cpp -lobjc C:\windows\desktop\source\game\Gpdumb2.cpp -lobjc C:\DEV-C++\Lib\libwinmm.a -lobjc C:\DEV-C++\Lib\libdxguid.a For the last 3 Here are the blocks in order:
int DI_Init_Joystick(int min_x, int max_x, int min_y, int max_y)
{
// this function initializes the joystick, it allows you to set
// the minimum and maximum x-y ranges 

// first find the fucking GUID of your particular joystick
lpdi->EnumDevices(DIDEVTYPE_JOYSTICK, 
                  DI_Enum_Joysticks, 
                  &joystickGUID, 
                  DIEDFL_ATTACHEDONLY); 

if (lpdi->CreateDevice(joystickGUID, &lpdijoy, NULL)!=DI_OK)
   return(0);

// now that we have created the joystick device we need to
// obtain a new more advanced interface called 
// IDIRECTINPUTDEVICE2, this needs to be done using the low level
// COM method queryinterface(), unfortunetely createdevice
// still gives a 1.0 version interface, so we to do this manually

lpdijoy->QueryInterface(IID_IDirectInputDevice2, 
                        (void **) &lpdijoy2); 

// release the version 1.0 interface since we have converted
// it to 2.0
lpdijoy->Release();

// set cooperation level
if (lpdijoy2->SetCooperativeLevel(main_window_handle, 
	                 DISCL_NONEXCLUSIVE | DISCL_BACKGROUND)!=DI_OK)
   return(0);

// set data format
if (lpdijoy2->SetDataFormat(&c_dfDIJoystick)!=DI_OK)
   return(0);

// set the range of the joystick
DIPROPRANGE joy_axis_range;

// first x axis
joy_axis_range.lMin = min_x;
joy_axis_range.lMax = max_x;

joy_axis_range.diph.dwSize       = sizeof(DIPROPRANGE); 
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); 
joy_axis_range.diph.dwObj        = DIJOFS_X;
joy_axis_range.diph.dwHow        = DIPH_BYOFFSET;

lpdijoy2->SetProperty(DIPROP_RANGE,&joy_axis_range.diph);

// now y-axis
joy_axis_range.lMin = min_y;
joy_axis_range.lMax = max_y;

joy_axis_range.diph.dwSize       = sizeof(DIPROPRANGE); 
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); 
joy_axis_range.diph.dwObj        = DIJOFS_Y;
joy_axis_range.diph.dwHow        = DIPH_BYOFFSET;

lpdijoy2->SetProperty(DIPROP_RANGE,&joy_axis_range.diph);

// acquire the joystick
if (lpdijoy2->Acquire()!=DI_OK)
   return(0);

// set found flag
joystick_found = 1;

// return success
return(1);

} // end DI_Init_Joystick 
int DI_Init_Mouse(void)
{
// this function intializes the mouse

// create a mouse device 
if (lpdi->CreateDevice(GUID_SysMouse, &lpdimouse, NULL)!=DI_OK)
   return(0);

// set cooperation level
if (lpdimouse->SetCooperativeLevel(main_window_handle, 
                       DISCL_NONEXCLUSIVE | DISCL_BACKGROUND)!=DI_OK)
   return(0);

// set data format
if (lpdimouse->SetDataFormat(&c_dfDIMouse)!=DI_OK)
   return(0);

// acquire the mouse
if (lpdimouse->Acquire()!=DI_OK)
   return(0);

// return success
return(1);

} // end DI_Init_Mouse 
int DI_Init_Keyboard(void)
{
// this function initializes the keyboard device

// create the keyboard device  
if (lpdi->CreateDevice(GUID_SysKeyboard, &lpdikey, NULL)!=DI_OK)
   return(0);

// set cooperation level
if (lpdikey->SetCooperativeLevel(main_window_handle, 
                 DISCL_NONEXCLUSIVE | DISCL_BACKGROUND)!=DI_OK)
    return(0);

// set data format
if (lpdikey->SetDataFormat(&c_dfDIKeyboard)!=DI_OK)
   return(0);

// acquire the keyboard
if (lpdikey->Acquire()!=DI_OK)
   return(0);

// return success
return(1);

} // end DI_Init_Keyboard 
I''m using Dev C++ 4.01(since the newer versions are too confusing and give me 3 times as much errors). I also have all the .h''s included too.... Nothing just wants to work properly...

Share this post


Link to post
Share on other sites
Advertisement
Too much code to go through, just make sure you are including what you need, especially mmsystem.h and mmsystem.lib, you can use dinput or just GetAsynchKeyState macro if you just need key input

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

Taught myself DirectSound a few months ago, wrote a demo with the bare minimum you need using dsutil.cpp | .h

DirectSoundDemo.cpp EXE

Couldn''t be easier, no parsing of the wav files needed since I''m using dsutil functions for loading sound buffers.

Phil P

Share this post


Link to post
Share on other sites
quote:
Original post by PhilVaz
Too much code to go through, just make sure you are including what you need, especially mmsystem.h and mmsystem.lib, you can use dinput or just GetAsynchKeyState macro if you just need key input

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

Taught myself DirectSound a few months ago, wrote a demo with the bare minimum you need using dsutil.cpp | .h

DirectSoundDemo.cpp EXE

Couldn't be easier, no parsing of the wav files needed since I'm using dsutil functions for loading sound buffers.

Phil P


Thanks for the sound thing.

But the thing is, I know about those keyboard functions.
But I want to use the mouse with my program.

I mean, sure, I could live without the mouse. But it would be nice to get the hang of making a game that uses it. I'm pretty much just trying to get good at all the features of DirectX.

I was trying out the sound thing and it didn't work. I don't got DirectSoundDemo.h and dsutil.h and dsutil.cpp

[edited by - kasooi on August 15, 2003 12:49:24 AM]

Share this post


Link to post
Share on other sites
<< But I want to use the mouse with my program. >>

You can read the mouse without dinput. You can include it inside your WinProc as follows (this is from a Breakout game I made that uses the mouse to the move the paddle)

case WM_MOUSEMOVE:
{
xoldmouse = xmouse;
xmouse = (int)LOWORD(lparam);
}

Then inside my MovePaddle function I have

int xold = xpaddle; // save old (previous) position of paddle

if (xoldmouse != xmouse) xpaddle = xmouse;

<< I mean, sure, I could live without the mouse. But it would be nice to get the hang of making a game that uses it. >>

There you go, you can check for mouse movement without DirectX. But its good to learn dinput anyway.

<< I was trying out the sound thing and it didn''t work. I don''t got DirectSoundDemo.h and dsutil.h and dsutil.cpp >>

It obviously won''t compile without the .h plus you need the WAV sounds and a resource .rc file. The .h is just the WAV with the sound files. Here is dsutil.cpp .h for the simple to use DSLoadSoundBuffer functions

dsutil.cpp dsutil.h

Phil P

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!