Why does Direct Input (ver 8) doesn't accept Arrow Keys??

Started by
4 comments, last by glnefugio 21 years, 7 months ago
So, can anyone tell me why?? All other keys work but if I check if DIK_LEFT is pressed nothing happes but if i replace the DIK_LEFT with DIK_A or something the function works as i should, so whats the problem?? thanks in advance
Advertisement
ok they are the same,
i doupt about your structure that you use to
store key state data.
check it ( and its size ) and tell me.
what key board type your are using.
regards
piece of cake
I think it''s DIK_LEFTARROW, though they might be the same. Other than that, post some code so we can see what you''re doing to setup and get keystrokes.

tj963
tj963
I use de GetDeviceState function to set my keys arry.
thats the function:

if(FAILED(Keyboard->GetDeviceState(sizeof(keys),&keys)))
{
if(FAILED(Keyboard->Acquire()))
{
return false;
}

if(FAILED(Keyboard->GetDeviceState(sizeof(keys),&keys)))
{
return false;
}
}


the function keydown lokks like this:

return ((keys[key] & 0x80) ? true : false);


keys and key are both of the char type.

it works fine with all keys but the arrow keys!
I am also having the same problem but I think it is bacause of all the Windows dialog boxes
I am using (my arrow keys must be getting filtered by the message pump of one of those
dialog boxes). I have reverted back to using pure Windows API now.

_________________
Best regards,
Sherman Chin
www.Sherman3D.com
_________________ Best regards, Sherman Chin Director Sherman3D (Malaysia) Sdn Bhd www.Sherman3D.com www.AlphaKimori.com
The problem is you are using ''char'' as opposed to ''unsigned char'' for your key variable.

The char type is signed and therefore the top bit is used to determine the sign. Because DIK_LEFTARROW is 0xCB the top bit is being set and so the compiler thinks you are asking for a negative value. However, DI_A is 0x1E and the top bit is not set there so you are getting the value you are expecting.

The Windows message pump does not affect DirectInput in any way. DirectInput works at a lower level.

Cheers,
John


John Reynolds
Creative Asylum Ltd
www.creative-asylum.com
John ReynoldsCreative Asylum Ltdwww.creative-asylum.com

This topic is closed to new replies.

Advertisement