• Advertisement

Archived

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

Help me with this DI code...

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

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
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

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement