Archived

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

Ilankt

Help me with this DI code...

Recommended Posts

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]

Share this post


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

Share this post


Link to post
Share on other sites