Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

DirectInput Keyboard Problem

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

Hi guys, I really don't understand why this is happening, it used to work fine (on VC6 but I'm using VS2005 now): #define KEYDOWN(name,key) ((name)[(key)] & 0x80) int Heartbeat() { char keyboard_buffer[256]; if(FAILED(g_keyboard->GetDeviceState(sizeof(keyboard_buffer),(LPVOID)&keyboard_buffer))){ return 1; } my_trigger=FALSE; if(KEYDOWN(keyboard_buffer,DIK_UP)){ my_trigger=TRUE; } return 0; } Everything is fine at first, when I press the up key the trigger is TRUE, but from then on it's always TRUE, as if the key is still depressed (when it isn't). Any ideas ? *** edit *** I added this and now it works: if(FAILED(result)){ result=g_keyboard->Acquire(); while(result == DIERR_INPUTLOST) result=g_keyboard->Acquire(); return 0; } *** For a fullscreen game what should I set the cooperation level to ? Thanks. [Edited by - Endemoniada on April 22, 2007 9:07:28 PM]

Share this post


Link to post
Share on other sites
Advertisement
I set my cooperation level as background and nonexclusive, that way you wont have troubles when your window loses focus. You can just check if the window is in focus before you do anything with the input.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!