Archived

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

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

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

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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites