Jump to content
  • Advertisement
Sign in to follow this  
BrandonisMaster

Help on my little game

This topic is 3533 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

I need some help on DirectInput. I just started a few days ago and I'm stuck. So, I uploaded the project file and I want someone to please look at it and find out what's wrong with it. Link: http://www.megaupload.com/?d=3SY1MBQ5 Thanks in advance, Brandon

Share this post


Link to post
Share on other sites
Advertisement
I'm sorry, but my intrenetz doesn't allow me to download files from megaupload.com.

What exactly about DirectInput do you need help on?

[Edited by - _fastcall on November 14, 2008 12:16:46 AM]

Share this post


Link to post
Share on other sites
I'm sorry, but my internets doesn't allow me to download files from rapidshare.

Quote:

Its about the mouse device pointer is NULL.


I'm going to go out on a limb and guess that you might not be creating the mouse device before you're using it.

Did you follow any DirectInput tutorials?

Share this post


Link to post
Share on other sites
Ok, here's where I narrowed it down to:

#include "dxinput.h"

#define BUTTON_DOWN(obj, button) (obj.rgbButtons[button] & 0x80)

LPDIRECTINPUT8 dinput;
LPDIRECTINPUTDEVICE8 dimouse;
LPDIRECTINPUTDEVICE8 dikeyboard;
LPDIRECTINPUTDEVICE8 dijoystick;
DIMOUSESTATE mouse_state;

char keys[256];

int Init_DirectInput(HWND hWnd)
{
HRESULT result = DirectInput8Create(
GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void **)&dinput,
NULL);

if(result != SUCCEEDED(result))
return 0;

result = dinput->CreateDevice(GUID_SysMouseEm2, &dimouse, NULL);
if(result != SUCCEEDED(result))
return 0;

result = dinput->CreateDevice(GUID_SysKeyboardEm2, &dikeyboard, NULL);
if(result != SUCCEEDED(result))
return 0;


return 1;
}

int Init_Mouse(HWND hWnd)
{
//help
HRESULT result = dimouse->SetDataFormat(&c_dfDIMouse);
if(result != SUCCEEDED(result))
return 0;

result = dimouse->SetCooperativeLevel(hWnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
if(result != SUCCEEDED(result))
return 0;

result = dimouse->Acquire();
if (result != SUCCEEDED(result))
return 0;

return 1;
}


The code that is messed up on debug is this line:

HRESULT result = dimouse->SetDataFormat(&c_dfDIMouse);


I created the device and everything. And I am using a DirectX game programming book to learn.

Thanks,

Brandon

Share this post


Link to post
Share on other sites
Quote:
Original post by BrandonisMaster
Its about the mouse device pointer is NULL.

Quote:
Original post by BrandonisMaster
I created the device and everything.


Then the mouse device pointer shouldn't be NULL.

Quote:
Original post by BrandonisMaster
And I am using a DirectX game programming book to learn.


Then refer to your book on how to use DirectInput.
Or, you could follow any of the DirectInput tutorials, and find the answers you're looking for.

Share this post


Link to post
Share on other sites
Quote:
Original post by BrandonisMaster
All that I want is someone to look at that code and see what is wrong with the device.


It's uninitialized/NULL, that's what's wrong with the mouse device pointer. Which would mean that the device hasn't been created.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!