Help me with this DI code...

Started by
2 comments, last by Ilankt 20 years, 7 months ago
I have no idea why it's not working... look

#include "MainCore.h"

bool cKeyboard::Create(HWND hWnd,HINSTANCE hInst)
{
	if (FAILED(DirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&DI,NULL)))
		return (FALSE);
	if(FAILED(DI->CreateDevice(GUID_SysKeyboard,&DIDevice,NULL)))
		return (FALSE);
	DIDevice->SetDataFormat(&c_dfDIKeyboard);
	DIDevice->SetCooperativeLevel(hWnd,DISCL_FOREGROUND | DISCL_NONEXCLUSIVE | DISCL_NOWINKEY);
	if (FAILED(DIDevice->Acquire()))
		return (FALSE);
	return (TRUE);
}

bool cKeyboard::Read(void)
{
	if(FAILED(DIDevice->GetDeviceState(sizeof(buffer),(LPVOID)&buffer)))
		return (FALSE);
	return (TRUE);

}

bool cKeyboard::KeyPressed(BYTE k)
{
	#define KEYDOWN(name, key) (name[key] & 0x80) 
	if (KEYDOWN(buffer,k))
		return (TRUE);
	return (FALSE);
}
the problem is that i want to do something like this: if Keyboard.Keypressed(VK_ESCAPE)) //do code but it dosent work... i changed it alot cause it dosent worked before, but still dosent working... [edited by - ilankt on September 1, 2003 3:06:54 PM]
How appropriate, you fight like a cow!
Advertisement
Lo,

I think it is because you are using VK_ESCAPE instead of DIK_ESCAPE. All the defines for the DirectInput Keys are proceeded with a DIK.

I could be wrong, but give it a try.

Hope it helped...

Coin
DUHH!!!
STUPID ME!!!
THANKS!
lol
How appropriate, you fight like a cow!
btw, get rid of that define (KEYDOWN)...its so incredibly useless. Just use a comment above the if statement so you know what its doing.

This topic is closed to new replies.

Advertisement