Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problem with Direct Input

Started by Blackstream Jul 7, 2005 at 7:40 PM 1 replies 850+ views
Original Post
Blackstream
Blackstream
I doubt anyone will know what's going on, but I'm trying to get input with direct input. I get most keys just fine. Letter keys, function keys, whatever. But whenever I try to get the arrow keys, they are either considered always on, or always off, no matter what I press. It's really really weird.

I use this code to update my key array

if(FAILED(result = keyboard->GetDeviceState(256 * sizeof(char), (LPVOID)keys))) {
  if(FAILED(result = Acquire())) {
    return result;
  }

  if(FAILED(result = keyboard->GetDeviceState(256 * sizeof(char), (LPVOID keys))) {
    return result;
  }
}

And I use this code to check to see if a key is pressed
if(keys[key] & 0x80)
  return true;
else
  return false;

Where key would equal DIK_DOWN
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Blackstream
Blackstream
Still investigating the problem... it seems ALL my keys above a certain number don't work... like DIK_F12 and higher (by higher, I mean the actual value that dinput.h assigns to that macro) just do not work.
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Blackstream
Blackstream
And I solved my problem with that revelation a few seconds later when I realized I should use unsigned char instead of char for passing the key code to the function that checks to see if my key is pressed or not. In other words, anything above like 128 decimal got turned into a negative.

Stupid little silly bugs. It's funny how one keyword (or lackof) can have you scratching your head for hours.
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.