What would cause this??

Started by
11 comments, last by DevLiquidKnight 20 years, 2 months ago
Its not even getting to that part because.. it errors before then.. so thats not an issue here.. Besides in that area I check to see if keyboard input was lost and if it is I re-aquire.

currently it goes like this WinMain -> Window Object -> CreateWindow -> Initialize game object sending window HWND and HINSTANCE -> Initialize DirectInput stuff -> Inlitialize Direct3D stuff -> back to window... -> Then if all goes correct it starts to render.. every frame

but its dieing at the initialize direct input stuff part...
I just put a breakpoint and walked into it.. it seems the HR result returned from trying to aquire keyboard returns with "access denied?" wtf?
here is my directinput class..

#include "DXInput.h"DXInput::DXInput(): m_method(0){}DXInput::~DXInput(){	DeInit();}/******************************************************************************* Un-Initialize Direct Input******************************************************************************/void WINAPI DXInput::DeInit(){	if(g_lpDI)	{		SAFE_RELEASE(g_lpDI);	}	if(g_lpDIDevice)	{		g_lpDIDevice->Unacquire();		SAFE_RELEASE(g_lpDIDevice);	}}/******************************************************************************* Process keys that are pressed******************************************************************************/void WINAPI DXInput::ProcessInput(CCamera *ptrCamera){	HRESULT	 hr;	hr=g_lpDIDevice->GetDeviceState(sizeof(buffer),(LPVOID)&buffer);	if (FAILED(hr))	{		if(hr == DIERR_INPUTLOST)		{			AquireKeyboard();		}		else if(hr == DIERR_INVALIDPARAM)		{			Error("DInput - GetDeviceState() returned : DIERR_INVALIDPARAM");		}		else if(hr == DIERR_NOTACQUIRED)		{			Error("DInput - GetDeviceState() returned : DIERR_NOTACQUIRED");		}		else if(hr == DIERR_NOTINITIALIZED)		{			Error("DInput - GetDeviceState() returned : DIERR_NOTINITIALIZED");		}		else		{			Error("DInput - GetDeviceState() returned : E_PENDING");		}	} 	if (KEYDOWN(buffer, DIK_RIGHT) || KEYDOWN(buffer, DIK_D) )// Straft right.	{		ptrCamera->move(CCamera::eRight);	}	if(KEYDOWN(buffer, DIK_LEFT) || KEYDOWN(buffer, DIK_A) )// Straft left. 	{		ptrCamera->move(CCamera::eLeft);	}	/*************************************************/	if (KEYDOWN(buffer, DIK_UP) || KEYDOWN(buffer, DIK_W) )		// Move forward. 	{		ptrCamera->move(CCamera::eForward);	}	if (KEYDOWN(buffer, DIK_DOWN) || KEYDOWN(buffer, DIK_S) ) // Move backwards	{ 		ptrCamera->move(CCamera::eBack);	}}/******************************************************************************* Aquire Keyboard If Keyboard Becomes Lost Ect...******************************************************************************/BOOL DXInput::AquireKeyboard(){	if(FAILED(g_lpDIDevice->Acquire()))	{		Error("Failed to aquire keyboard!");		return FALSE;	}	return TRUE;}/******************************************************************************* Create The Keyboard Device For DirectInput******************************************************************************/BOOL DXInput::CreateKeyboardDevice(HWND hWnd){	HRESULT hr=g_lpDI->CreateDevice(GUID_SysKeyboard, &g_lpDIDevice, NULL);	if ( FAILED(hr) )	{ 		Error("Failed to create keyboard device!");		return FALSE;	}	hr=g_lpDIDevice->SetDataFormat(&c_dfDIKeyboard);	if FAILED(hr)	{		Error("Failed to set data format!");		return FALSE;	}	hr=g_lpDIDevice->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);	if FAILED(hr)	{		Error("Failed to set cooperative level!");		return FALSE;	}	hr=g_lpDIDevice->Acquire();	if FAILED(hr)	{		Error("Failed to aquire keyboard!"); // this is where it dies.		return FALSE;	}	return TRUE;}void DXInput::Error(char *msg){	MessageBox(NULL,msg,"Error",MB_OK|MB_ICONERROR);	ExitProcess(1);}/******************************************************************************* Initilize DirectInput******************************************************************************/void WINAPI DXInput::InitializeInput(HWND hWnd, HINSTANCE hInst){	HRESULT	hr; 	m_hWnd=hWnd;	hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&g_lpDI,NULL); 	if FAILED(hr)	{ 		Error("DInput - Failed to inlialize DirectInput");	}	else	{		if(!CreateKeyboardDevice(hWnd))		{			Error("Failed to inlialize DirectInput device");		}	}}


[edited by - DevLiquidKnight on January 25, 2004 7:06:13 PM]

[edited by - DevLiquidKnight on January 25, 2004 7:27:18 PM]
Advertisement
How weird, your init code looks almost the same as mine - does something else have exclusive lock on the keyboard?

Reboot your PC and clear out the /Software/Microsoft/DirectInput registry tree.
ok i tried this..

g_lpDIDevice->SetCooperativeLevel(hWnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);


yet.. now it works this is really bazarr 0.0


it must be my keyboard type, or somthing?? I did buy this keyboard after I got the comp because my old one sucked... and i disliked the way the keys were put on it lol.... maybe this keyboard just sucks or somthing?


either way the keyboard input works *now trys to see if it works on freinds comps yet*

[edited by - DevLiquidKnight on January 25, 2004 7:37:25 PM]

This topic is closed to new replies.

Advertisement