#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]
Help me with this DI code...
I have no idea why it's not working...
look
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
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
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
Popular Topics
Advertisement