Archived

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

DevLiquidKnight

What would cause this??

Recommended Posts

I made a small pre-game kinda.. like not finished but for some werid reason its not working on very many comps.. I've had my freinds try and check it by putting in a logging routine it logs EVERY freaking area... and yet when they execute the exe, the log files arent even made.. Ive tested it it works fine on my comp the files are made perfect all events logged.. for some weird reason, if i test it on my freinds comps, it is not even reaching the windows code of my game, it doesnt even LOG anything... which makes no sense to me at all... anyone got any idea what could maybe cause this I was thinking maybe it had to do with compiler settings I tried to make them as perfect as possible and yet it still doesn't work ? I just dont understand how it possibly could be quitting the app before it hits the windows code.. it logs when it hits the app... and it isnt even logging that! The even more weird part is it works on one of my freinds comps but not the others... I have the processor set to blended in the configuration settings its being compiled as a release build.. [edited by - DevLiquidKnight on January 25, 2004 2:07:34 AM]

Share this post


Link to post
Share on other sites
if you are running in 98 or ME, also know some flag combinations for creating the window that worked just find on your system dont work on XP or 2k systems, if it''s crashing before window creation and you have different operating systems, check that.

___________________
-Nicholas Anton
-raptor85.siigna.net

Share this post


Link to post
Share on other sites
Check all the return values of system calls + GetLastError() under Windows. Otherwise you''ll be throwing punches underwater guessing what the problem is.

I call AllocConsole() and FreeConsole() and log to console and file simultaneously.

Share this post


Link to post
Share on other sites
Ok, I think i may have found the problem but im not sure.. what it means... lol... dinput tries to aquire the device (keyboard) yet.. it does not return DIERR_INPUTLOST its returning...

DInput - GetDeviceState() returned : -2147024884

That number is a integer data type? any idea what it means ? 0.o

Share this post


Link to post
Share on other sites
I did a quick search on google and found this:

DIERR_NOTACQUIRED -2147024884
The operation cannot be performed unless the device is acquired.

Hope that helps =)


Later,
Lord Hen

"I am free of all prejudices. I hate everyone equally." - W. C. Fields

EDIT:
btw, doesnt directx have a way of inputting the error code, and outputting the string equivalent of it?
[edited by - Lord Hen on December 2, 2008 2:32:49 AM]

[edited by - Lord Hen on January 25, 2004 6:27:01 PM]

Share this post


Link to post
Share on other sites
hrm.... i shall look more into whats up with this... wonder why its failing...


anyone see anything wrong

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!");
return FALSE;
}


[edited by - DevLiquidKnight on January 25, 2004 6:45:46 PM]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites