Original Post
Im having a small problem with getting usefull data from the keyboard. Basically i have initialised Direct Input and the keyboard. The code below shows the routine to collect the data from keyboard and I have created a message box to output the corresponding key identifier when pressed. Examples of this data is "0xc8" or "0x01" obviously depending on the key that is pressed.
My question is how do I compare this data stored in strElement(e.g. If(strElement == "0xc8") This is what i want to do but there is a problem with data types.
Any help greatly appreciated.
HRESULT KeyboardInput(HWND hDlg)
{
HRESULT hr;
TCHAR strElement[10];
BYTE diks[256]; // DirectInput keyboard state buffer
int i;
if( NULL == lpDIDEVICE8 )
return S_OK;
ZeroMemory( &diks, sizeof(diks) );
hr = lpDIDEVICE8->GetDeviceState( sizeof(diks), &diks );
for( i = 0; i < 256; i++ )
{
if( diks & 0x80 )
{
wsprintf( strElement, TEXT("0x%02x "), i );
MessageBox(hDlg, strElement,"Key Pressed",MB_OK);
}
}
return S_OK;
}