Jump to content
  • Advertisement

Archived

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

johnnyBravo

DLL Direct Input (LPDIRECTINPUT8) giving access violation

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

Hi, i wasnt sure whether to put this in the dx forum or this forum, with my DirectInput DLL, i keep getting an access violation when I try to access a variable. eg Input * i ... if(i->getDevice()==NULL) or if (i->lp_DI==NULL) heres my dll header:
#ifdef AINPUT_EXPORTS
#define AINPUT_API __declspec(dllexport)
#else
#define AINPUT_API __declspec(dllimport)
#endif

#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>

class AINPUT_API Input {
private:
	static Input * reference;
	Input();
	~Input();

public:
	LPDIRECTINPUT8 lp_DI;
	static Input * getInstance();
	LPDIRECTINPUT8 getDevice();
};

heres my dll source:
#include "ainput.h"
Input * Input::reference;

Input::Input()
{
	DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION, 
						IID_IDirectInput8, (void**)&lp_DI,NULL);
}

Input::~Input()
{
	if( lp_DI != NULL ) 
	{
		lp_DI->Release();
		lp_DI=NULL;
	}
}

Input * Input::getInstance()
{
	if(reference==NULL)
		reference = new Input();

	return reference;
}		
	
LPDIRECTINPUT8	Input::getDevice()
{
	return lp_DI;
}	
and this is just what dx stuff is in my links
quote:
dxguid.lib dinput8.lib
thanks, just let me know if i am not being clear enough

Share this post


Link to post
Share on other sites
Advertisement
If I had to guess, I''d say the problem was the i was null, which means that you aren''t creating an Input object properly. How are you initializing i?

Share this post


Link to post
Share on other sites
I initiliase ''i'' like so:

Input * i;

then in the winmain i call it, as its a singleton
Input::getInstance();

then to use its device i would call i->getDevice()

,i think its quite strange that i would get such an error.

Share this post


Link to post
Share on other sites
But do you ever have a line like:

i = Input::getInstance(); ?

If you don''t assign i a value, it''s not going to magically fill itself.

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!