Help on my little game

Started by
10 comments, last by BrandonisMaster 15 years, 5 months ago
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
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]
Also, DirectX SDK contain Direct Input samples, check them too.
Its about the mouse device pointer is NULL.

I uploaded it somewhere else: http://rapidshare.com/files/163690745/paddlegame.rar.html

Thanks,

Brandon
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?
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
we're not here to debug your code.
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.
I don't want you to debug my code, I have already done that -.- All that I want is someone to look at that code and see what is wrong with the device.

Regards,

Brandon
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.

This topic is closed to new replies.

Advertisement