🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
All sorts of other things can cause what look like input problems. For instance, I was using BltFast in windowed mode and because I wasn't properly waiting for my Blits to finish, they were being queued which lead to the input looking like it had a 2 second delay.
- Splat
The best way to deal with the problem is to implement buffered input, it works perfectly, and is relatively easy to set up. There is an article on GDNet somewhere about DirectX buffered input, look for it, even though it's for directx 3, it explains how to do it very well.
This way you can get messages from all of the devices in sequential order (using the macro DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2)).
Of course if you want to be able to have a key repeat a down message during a long keypress you would need to add some additional code to your game loop.
Just my two pence.
------------------
Where's my Golden Fleece?
I have my main game loop, and in it I get the state of all keys with DI. Now, when I check them, it goes way too fast.
Sometimes when you hit "left" once, you go left 4-5 positions, just because the keypress is too slow (I think).
I've tried slowing this down with some timer code, but that isn't what it is supposed to be, since now there is like a delay sortof-feel on the keys.
Does anyone know what I might do to correct this problem?
m_ButtonsClk[0] = (!m_Buttons[0] && (mouseState.rgbButtons[0]&0x80));
m_ButtonsClk[1] = (!m_Buttons[1] && (mouseState.rgbButtons[1]&0x80));
m_ButtonsClk[2] = (!m_Buttons[2] && (mouseState.rgbButtons[2]&0x80));
m_ButtonsClk[3] = (!m_Buttons[3] && (mouseState.rgbButtons[3]&0x80));
m_ButtonsClk[4] = (!m_Buttons[4] && (mouseState.rgbButtons[4]&0x80));
m_ButtonsClk[5] = (!m_Buttons[5] && (mouseState.rgbButtons[5]&0x80));
m_ButtonsClk[6] = (!m_Buttons[6] && (mouseState.rgbButtons[6]&0x80));
m_Buttons[0] = (mouseState.rgbButtons[0] & 0x80 );
m_Buttons[1] = (mouseState.rgbButtons[1] & 0x80 );
m_Buttons[2] = (mouseState.rgbButtons[2] & 0x80 );
m_Buttons[3] = (mouseState.rgbButtons[3] & 0x80 );
m_Buttons[4] = (mouseState.rgbButtons[4] & 0x80 );
m_Buttons[5] = (mouseState.rgbButtons[5] & 0x80 );
m_Buttons[6] = (mouseState.rgbButtons[6] & 0x80 );
where mouseState is the updated DIMOUSESTATE, m_Buttons tells whether the key is down(pressed or being held down), and m_ButtonsClk tells whether or not the button was pressed (and not being held down). This seems to work well for everything that I have done. Hope this helps.